Implement 'cat' and 'cd' and do some fixes for 'di' code injection
This commit is contained in:
parent
c05c773431
commit
e5ce1cd5d4
|
@ -1010,7 +1010,6 @@ next:
|
|||
return ret;
|
||||
}
|
||||
next2:
|
||||
|
||||
/* sub commands */
|
||||
ptr = strchr (cmd, '`');
|
||||
if (ptr) {
|
||||
|
@ -1021,7 +1020,7 @@ next2:
|
|||
}
|
||||
ptr2 = strchr (ptr+1, '`');
|
||||
if (!ptr2) {
|
||||
eprintf ("parse: Missing '´' in expression.\n");
|
||||
eprintf ("parse: Missing backtick in expression.\n");
|
||||
return -1;
|
||||
} else {
|
||||
*ptr = '\0';
|
||||
|
|
|
@ -179,6 +179,15 @@ static int cmd_cmp(void *data, const char *input) {
|
|||
ut64 v64;
|
||||
|
||||
switch (*input) {
|
||||
case 'a':
|
||||
if (input[1]=='t' && input[2]==' ') {
|
||||
char *p = r_file_slurp (input+3, NULL);
|
||||
if (p) {
|
||||
r_cons_strcat (p);
|
||||
free (p);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
cmd_cmp_watcher (core, input+1);
|
||||
break;
|
||||
|
@ -323,7 +332,7 @@ static int cmd_cmp(void *data, const char *input) {
|
|||
" cw[us?] [...] Compare memory watchers\n");
|
||||
break;
|
||||
default:
|
||||
eprintf ("Usage: c[?cDdxfw] [argument]\n");
|
||||
eprintf ("Usage: c[?48cdDxfw] [argument]\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1107,12 +1107,26 @@ static int cmd_debug(void *data, const char *input) {
|
|||
break;
|
||||
case 'i':
|
||||
switch (input[1]) {
|
||||
case 'a':
|
||||
{
|
||||
RAsmCode *acode;
|
||||
r_asm_set_pc (core->assembler, core->offset);
|
||||
acode = r_asm_massemble (core->assembler, input+2);
|
||||
if (acode && *acode->buf_hex) {
|
||||
r_reg_arena_push (core->dbg->reg);
|
||||
r_debug_execute (core->dbg, acode->buf, acode->len, 0);
|
||||
r_reg_arena_pop (core->dbg->reg);
|
||||
r_asm_code_free (acode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
r_core_cmdf (core, "di `gs %s`", input+2);
|
||||
// XXX: last byte fails (ret) should not be generated
|
||||
r_core_cmdf (core, "dir `gs %s`", input+2);
|
||||
break;
|
||||
case 'r':
|
||||
r_reg_arena_push (core->dbg->reg);
|
||||
if (input[1]==' ') {
|
||||
if (input[2]==' ') {
|
||||
ut8 bytes[4096];
|
||||
int bytes_len = r_hex_str2bin (input+2, bytes);
|
||||
r_debug_execute (core->dbg, bytes, bytes_len, 0);
|
||||
|
@ -1127,10 +1141,11 @@ static int cmd_debug(void *data, const char *input) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
eprintf ("Usage: di[s] [arg| ...]\n");
|
||||
eprintf (" di 9090 ; inject two x86 nops\n");
|
||||
eprintf (" dir 9090 ; inject and restore state\n");
|
||||
eprintf (" dis write 1, 0x8048, 12 ; syscall injection\n");
|
||||
r_cons_printf ("Usage: di[asr] [arg| ...]\n"
|
||||
" di 9090 ; inject two x86 nops\n"
|
||||
" \"dia mov eax,6;mov ebx,0;int 0x80\" ; inject and restore state\n"
|
||||
" dir 9090 ; inject and restore state\n"
|
||||
" dis write 1, 0x8048, 12 ; syscall injection (see gs)\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -65,16 +65,16 @@ static int cmd_egg(void *data, const char *input) {
|
|||
if (input[1]=='?' || !input[1]) {
|
||||
eprintf ("Usage: gs [syscallname] [parameters]\n");
|
||||
} else {
|
||||
oa = strdup (input+2);
|
||||
p = strchr (oa+1, ' ');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
r_core_syscall (core, oa, p+1);
|
||||
} else {
|
||||
r_core_syscall (core, oa,"");
|
||||
}
|
||||
free (oa);
|
||||
oa = strdup (input+2);
|
||||
p = strchr (oa+1, ' ');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
r_core_syscall (core, oa, p+1);
|
||||
} else {
|
||||
r_core_syscall (core, oa, "");
|
||||
}
|
||||
free (oa);
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
r_egg_load (egg, input+2, 0);
|
||||
|
|
|
@ -1136,7 +1136,9 @@ R_API RBuffer *r_core_syscall (RCore *core, const char *name, const char *args)
|
|||
num = r_syscall_get_num (core->anal->syscall, name);
|
||||
snprintf (code, sizeof (code),
|
||||
"ptr@syscall(%d);\n"
|
||||
"main@global(0) { ptr(%s); }\n", num, args);
|
||||
"main@global(0) { ptr(%s);\n"
|
||||
":int3\n" /// XXX USE trap
|
||||
"}\n", num, args);
|
||||
r_egg_reset (core->egg);
|
||||
// TODO: setup arch/bits/os?
|
||||
r_egg_load (core->egg, code, 0);
|
||||
|
|
Loading…
Reference in New Issue