diff options
author | Malfurious <m@lfurio.us> | 2023-07-02 08:37:48 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-07-02 08:37:48 -0400 |
commit | fae455643c4f9d22bff18df949ac773e10e97dee (patch) | |
tree | d0076566322b8eb8c9ae0472699b75e219737163 | |
parent | cb6993e4d31086411c1dd147ec820d37cbc2d01c (diff) | |
download | misplays-fae455643c4f9d22bff18df949ac773e10e97dee.tar.gz misplays-fae455643c4f9d22bff18df949ac773e10e97dee.zip |
Add main source file
Signed-off-by: Malfurious <m@lfurio.us>
-rw-r--r-- | misplays.c | 105 |
1 files changed, 105 insertions, 0 deletions
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 <stdlib.h> +#include <sys/syscall.h> +#include <unistd.h> + +#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; +} |