Add more fortunes and minor refactoring in core.c
This commit is contained in:
parent
30a75dc71c
commit
23a291b085
2 changed files with 59 additions and 54 deletions
11
doc/fortunes
11
doc/fortunes
|
|
@ -26,6 +26,7 @@ If you want to open the file in read-write mode use -w flag or -e cfg.write=true
|
|||
Print the contents of the current block with the 'p' command
|
||||
Command layout is: <repeat><command><bytes>@<offset>.\ For example: 3x20@0x33 will show 3 hexdumps of 20 bytes at 0x33
|
||||
Press 'c' in visual mode to toggle the cursor mode
|
||||
Press 'C' in visual mode to toggle colors
|
||||
You can "copy/paste" bytes using the cursor in visual mode 'c' and using the 'y' and 'Y' keys
|
||||
Move around the bytes with hjkl! Arrow keys are not portable and are less productive to use
|
||||
Seek at relative offsets with 's +<offset>' or 's -<offset>'
|
||||
|
|
@ -47,7 +48,6 @@ Use hasher to calculate hashes of portion blocks of a file
|
|||
Use zoom.byte=entropy and press 'z' in visual mode to zoom out to see the entropy of the whole file
|
||||
Use zoom.byte=printable in zoom mode (z key in visual mode) to find strings
|
||||
Set colors to your screen with 'e scr.color=true'
|
||||
Press 'C' in visual mode to toggle colors
|
||||
Trace the register changes when debugging with trace.cmtregs
|
||||
Move the comments to the right changing their margin with e asm.cmtmargin
|
||||
Execute a command on the visual prompt with cmd.vprompt
|
||||
|
|
@ -126,3 +126,12 @@ wait a moment..
|
|||
Don't do this.
|
||||
No such file or directory.
|
||||
Default scripting languages are NodeJS and Python.
|
||||
-bash: r2: command not found
|
||||
The unix-like reverse engineering framework
|
||||
To start the webserver type the following command: 'r2 -c=H /bin/ls'
|
||||
To enter into the visual mode type 'V' in the prompt and hit enter
|
||||
Press any key to continue...
|
||||
To disable those fortune messages: $ echo cfg.fortunes=false > ~/.radare2rc
|
||||
ilo ni li pona li pali e lipu. mi wile e ni: sina kama jo e musi
|
||||
Radare for FideOS, now with extra potato
|
||||
Your project name should contain an uppercase letter, 8 vowels, some numbers and the 5 first numbers of your private bitcoin key
|
||||
|
|
|
|||
102
libr/core/core.c
102
libr/core/core.c
|
|
@ -16,17 +16,17 @@ static int core_cmd_callback (void *user, const char *cmd) {
|
|||
|
||||
static ut64 getref (RCore *core, int n, char t, int type) {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
if (fcn) {
|
||||
RList *list = t=='r'? fcn->refs: fcn->xrefs;
|
||||
RListIter *iter;
|
||||
RAnalRef *r;
|
||||
int i=0;
|
||||
r_list_foreach (list, iter, r) {
|
||||
if (r->type == type) {
|
||||
if (i == n)
|
||||
return r->addr;
|
||||
i++;
|
||||
}
|
||||
RListIter *iter;
|
||||
RAnalRef *r;
|
||||
RList *list;
|
||||
int i=0;
|
||||
if (!fcn) return UT64_MAX;
|
||||
list = (t=='r')? fcn->refs: fcn->xrefs;
|
||||
r_list_foreach (list, iter, r) {
|
||||
if (r->type == type) {
|
||||
if (i == n)
|
||||
return r->addr;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return UT64_MAX;
|
||||
|
|
@ -35,10 +35,13 @@ static ut64 getref (RCore *core, int n, char t, int type) {
|
|||
static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
RCore *core = (RCore *)userptr; // XXX ?
|
||||
RAnalFunction *fcn;
|
||||
char *ptr, *bptr;
|
||||
RFlagItem *flag;
|
||||
RIOSection *s;
|
||||
RAnalOp op;
|
||||
ut64 ret = 0;
|
||||
*ok = 0;
|
||||
|
||||
if (ok) *ok = R_FALSE;
|
||||
if (*str=='[') {
|
||||
int refsz = (core->assembler->bits & R_SYS_BITS_64)? 8: 4;
|
||||
const char *p = strchr (str+5, ':');
|
||||
|
|
@ -62,30 +65,26 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
case 8: {
|
||||
ut64 num = 0;
|
||||
r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
|
||||
return num;
|
||||
}
|
||||
return num; }
|
||||
case 4: {
|
||||
ut32 num = 0;
|
||||
r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
|
||||
return num;
|
||||
}
|
||||
return num; }
|
||||
case 2: {
|
||||
ut16 num = 0;
|
||||
r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
|
||||
return num;
|
||||
}
|
||||
return num; }
|
||||
case 1: {
|
||||
ut8 num = 0;
|
||||
r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
|
||||
return num;
|
||||
}
|
||||
return num; }
|
||||
default:
|
||||
eprintf ("Invalid reference size: %d (%s)\n", refsz, str);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
if (str[0]=='$') {
|
||||
*ok = 1;
|
||||
if (ok) *ok = 1;
|
||||
// TODO: group analop-dependant vars after a char, so i can filter
|
||||
r_anal_op (core->anal, &op, core->offset,
|
||||
core->block, core->blocksize);
|
||||
|
|
@ -93,18 +92,16 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
case '.': // can use pc, sp, a0, a1, ...
|
||||
return r_debug_reg_get (core->dbg, str+2);
|
||||
case '{':
|
||||
{
|
||||
char *ptr, *bptr = strdup (str+2);
|
||||
ptr = strchr (bptr, '}');
|
||||
if (ptr != NULL) {
|
||||
ut64 ret;
|
||||
ptr[0]='\0';
|
||||
ret = r_config_get_i (core->config, bptr);
|
||||
free (bptr);
|
||||
return ret;
|
||||
}
|
||||
bptr = strdup (str+2);
|
||||
ptr = strchr (bptr, '}');
|
||||
if (ptr != NULL) {
|
||||
ut64 ret;
|
||||
ptr[0] = '\0';
|
||||
ret = r_config_get_i (core->config, bptr);
|
||||
free (bptr);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case 'e': return op.eob;
|
||||
case 'j': return op.jump;
|
||||
case 'f': return op.fail;
|
||||
|
|
@ -112,37 +109,36 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
case 'l': return op.length;
|
||||
case 'b': return core->blocksize;
|
||||
case 's': return core->file->size;
|
||||
case 'w': {
|
||||
int bits = r_config_get_i (core->config, "asm.bits");
|
||||
return bits/8;
|
||||
} break;
|
||||
case 'S': {
|
||||
RIOSection *s = r_io_section_get (core->io,
|
||||
r_io_section_vaddr_to_offset (core->io, core->offset));
|
||||
return s? (str[2]=='S'?s->size: s->offset): 0;
|
||||
}
|
||||
case 'w': return r_config_get_i (core->config, "asm.bits") / 8;
|
||||
case 'S':
|
||||
s = r_io_section_get (core->io,
|
||||
r_io_section_vaddr_to_offset (core->io,
|
||||
core->offset));
|
||||
return s? (str[2]=='S'? s->size: s->offset): 0;
|
||||
case '?': return core->num->value;
|
||||
case '$': return core->offset;
|
||||
case 'o': return core->io->off;
|
||||
case 'C': return getref (core, atoi (str+2), 'r', R_ANAL_REF_TYPE_CALL);
|
||||
case 'J': return getref (core, atoi (str+2), 'r', R_ANAL_REF_TYPE_CODE);
|
||||
case 'D': return getref (core, atoi (str+2), 'r', R_ANAL_REF_TYPE_DATA);
|
||||
case 'X': return getref (core, atoi (str+2), 'x', R_ANAL_REF_TYPE_CALL);
|
||||
case 'C': return getref (core, atoi (str+2), 'r',
|
||||
R_ANAL_REF_TYPE_CALL);
|
||||
case 'J': return getref (core, atoi (str+2), 'r',
|
||||
R_ANAL_REF_TYPE_CODE);
|
||||
case 'D': return getref (core, atoi (str+2), 'r',
|
||||
R_ANAL_REF_TYPE_DATA);
|
||||
case 'X': return getref (core, atoi (str+2), 'x',
|
||||
R_ANAL_REF_TYPE_CALL);
|
||||
case 'I':
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
if (fcn) return fcn->ninstr;
|
||||
return 0;
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
return fcn? fcn->ninstr: 0;
|
||||
case 'F':
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
if (fcn) return fcn->size;
|
||||
return 0;
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
return fcn? fcn->size: 0;
|
||||
}
|
||||
} else
|
||||
if (*str>'A') {
|
||||
if ((flag = r_flag_get (core->flags, str))) {
|
||||
ret = flag->offset;
|
||||
*ok = R_TRUE;
|
||||
} else *ok = ret = 0;
|
||||
if (ok) *ok = R_TRUE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue