Proposal for the gi/ge commands (#9190)

This commit is contained in:
Andrea Sindoni 2018-01-14 09:21:02 +00:00 committed by radare
parent ddb5fd0575
commit 93f9fbb79b

View File

@ -6,15 +6,16 @@
static const char *help_msg_g[] = {
"Usage:", "g[wcilper] [arg]", "Go compile shellcodes",
"g", " ", "Compile the shellcode",
"g", " foo.r", "Compile r_egg source file",
"gw", "", "Compile and write",
"gc", " cmd=/bin/ls", "Set config option for shellcodes and encoders",
"gc", "", "List all config options",
"gl", "[?]", "List plugins (shellcodes, encoders)",
"gs", " name args", "Compile syscall name(args)",
"gi", " [type]", "Compile shellcode. like ragg2 -i (see gl or ragg2 -L)",
"gi", " [type]", "Define the shellcode type",
"gp", " padding", "Define padding for command",
"ge", " xor", "Specify an encoder",
"ge", " [encoder] [key]", "Specify an encoder and a key",
"gr", "", "Reset r_egg",
"EVAL VARS:", "", "asm.arch, asm.bits, asm.os",
NULL
@ -162,24 +163,45 @@ static int cmd_egg(void *data, const char *input) {
}
break;
case 'p': // "gp"
if (input[0] && input[2]) {
r_egg_padding (egg, input + 2);
if (input[1] == ' ') {
if (input[0] && input[2]) {
r_egg_option_set (egg, "egg.padding", input + 2);
}
} else {
eprintf ("Usage: gp [padding]\n");
}
// cmd_egg_option (egg, "egg.padding", input);
break;
case 'e': // "ge"
if (input[0] && input[2]) {
if (!r_egg_encode (egg, input + 2)) {
eprintf ("Invalid encoder '%s'\n", input + 2);
if (input[1] == ' ') {
const char *encoder = input + 2;
while (IS_WHITESPACE (*encoder) && *encoder) {
encoder++;
}
}
// cmd_egg_option (egg, "egg.encoder", input);
break;
case 'i': // "gi"
if (input[0] && input[2]) {
compileShellcode (egg, input + 2);
oa = strdup (encoder);
p = strchr (oa + 1, ' ');
if (p) {
*p = 0;
r_egg_option_set (egg, "key", p + 1);
r_egg_option_set (egg, "egg.encoder", oa);
} else {
eprintf ("Usage: ge [encoder] [key]\n");
}
free (oa);
} else {
eprintf ("Usage: gi [shellcode-type]");
eprintf ("Usage: ge [encoder] [key]\n");
}
break;
case 'i': // "gi"
if (input[1] == ' ') {
if (input[0] && input[2]) {
r_egg_option_set (egg, "egg.shellcode", input + 2);
} else {
eprintf ("Usage: gi [shellcode-type]\n");
}
} else {
eprintf ("Usage: gi [shellcode-type]\n");
}
break;
case 'l': // "gl"