-
Notifications
You must be signed in to change notification settings - Fork 55
/
rappel.c
83 lines (72 loc) · 1.4 KB
/
rappel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <getopt.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include "common.h"
#include "exedir.h"
#include "pipe.h"
#include "ui.h"
// Defaults
struct options_t options = {
.start = 0x400000,
.verbose = 0,
.raw = 0,
.allregs = 0,
.savefile = NULL,
.rappel_dir = { 0 }
};
static
void _usage(
const char *argv0)
{
fprintf(stderr, "Usage: %s [options]\n"
"\t-h\t\tDisplay this help\n"
"\t-r\t\tTreat stdin as raw bytecode (useful for ascii shellcode)\n"
"\t-p\t\tPass signals to child process (will allow child to kill itself via SIGSEGV, others)\n"
"\t-s <filename>\tSave generated exe to <filename>\n"
"\t-x\t\tDisplay all registers (FP)\n"
"\t-v\t\tIncrease verbosity\n"
, argv0);
exit(EXIT_FAILURE);
}
static
void _parse_opts(
int argc,
char **argv) {
int c;
while ((c = getopt(argc, argv, "s:dhrpvx")) != -1)
switch (c) {
case 'h':
_usage(argv[0]);
break;
case 'd':
++options.dump;
break;
case 'r':
++options.raw;
break;
case 's':
options.savefile = optarg;
break;
case 'p':
++options.passsig;
break;
case 'v':
++options.verbose;
break;
case 'x':
++options.allregs;
break;
default:
exit(EXIT_FAILURE);
}
}
int main(int argc, char **argv) {
_parse_opts(argc, argv);
init_rappel_dir();
if (isatty(STDIN_FILENO))
interact(argv[0]);
else
pipe_mode();
return 0;
}