From fae455643c4f9d22bff18df949ac773e10e97dee Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sun, 2 Jul 2023 08:37:48 -0400 Subject: Add main source file Signed-off-by: Malfurious --- misplays.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 misplays.c diff --git a/misplays.c b/misplays.c new file mode 100644 index 0000000..5eaca63 --- /dev/null +++ b/misplays.c @@ -0,0 +1,105 @@ +#include +#include +#include + +#include "console.h" +#include "curshelpers.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; +} -- cgit v1.2.3