#include #include #include #include "console.h" #include "helpers.h" static char *const SPLOITCMD[] = { "/bin/bash", "-c", "sploit <(echo 'io.interact()') cat", NULL }; static PANEL *left, *right; static struct console p1, p2; static int mode = 0; static void layout(void) { int w = COLS/2; reset_panel(left, LINES, w, 0, 0); reset_panel(right, LINES, COLS-w, 0, w); //reset_panel(left, 0, 0, 0, 0); //reset_panel(right, 0, 0, 0, 0); } static void dofork(struct console *cons) { if (fork() == 0) { console_configslave(cons); close_range(STDERR_FILENO+1, ~0U, CLOSE_RANGE_UNSHARE); execvp(SPLOITCMD[0], SPLOITCMD); exit(1); } } int main(void) { cursinit(); left = newpan(0, 0, 0, 0); right = newpan(0, 0, 0, 0); layout(); console_init(&p1); console_init(&p2); dofork(&p1); dofork(&p2); int quit = 0; while (!quit) { console_update(&p1, left); console_update(&p2, right); cursupdate(); int ch = getch(); if (mode == 0) { switch (ch) { case 'q': quit = 1; break; case KEY_RESIZE: layout(); break; case KEY_F(1): mode = 1; console_enter(&p1, left); break; case KEY_F(2): mode = 2; console_enter(&p2, right); break; } } else if (mode == 1) { switch (ch) { case KEY_RESIZE: layout(); break; case 0x1b: mode = 0; console_leave(&p1, left); break; case ERR: break; default: console_input(&p1, ch); break; } } else { switch (ch) { case KEY_RESIZE: layout(); break; case 0x1b: mode = 0; console_leave(&p2, right); break; case ERR: break; default: console_input(&p2, ch); break; } } } endwin(); return 0; }