From ee133222fe5b076983259dcbca734346755a43b2 Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Tue, 11 Aug 2020 00:36:10 -0400 Subject: [PATCH] Add zignature spaces to ##rasign2 (#17404) * Add zignature spaces to ##rasign2 * Update help information * Use space API instead of core Co-authored-by: Dennis Goodlett --- libr/main/rasign2.c | 21 ++++++++++++++------ man/rasign2.1 | 45 +++++++++++++++++++++++++++++++++++++++++++ test/db/tools/rasign2 | 9 +++++++++ 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 man/rasign2.1 diff --git a/libr/main/rasign2.c b/libr/main/rasign2.c index aa46601dcd..7adc59344e 100644 --- a/libr/main/rasign2.c +++ b/libr/main/rasign2.c @@ -5,13 +5,14 @@ static void rasign_show_help(void) { printf ("Usage: rasign2 [options] [file]\n" " -a [-a] add extra 'a' to analysis command\n" - " -o sigs.sdb add signatures to file, create if it does not exist\n" - " -r show output in radare commands\n" - " -j show signatures in json\n" - " -q quiet mode\n" " -f interpret the file as a FLIRT .sig file and dump signatures\n" - " -v show version information\n" " -h help menu\n" + " -j show signatures in json\n" + " -o sigs.sdb add signatures to file, create if it does not exist\n" + " -q quiet mode\n" + " -r show output in radare commands\n" + " -s signspace save all signatures under this signspace\n" + " -v show version information\n" "Examples:\n" " rasign2 -o libc.sdb libc.so.6\n"); } @@ -58,6 +59,7 @@ static void find_functions(RCore *core, size_t count) { R_API int r_main_rasign2(int argc, const char **argv) { const char *ofile = NULL; + const char *space = NULL; int c; size_t a_cnt = 0; bool rad = false; @@ -66,7 +68,7 @@ R_API int r_main_rasign2(int argc, const char **argv) { bool flirt = false; RGetopt opt; - r_getopt_init (&opt, argc, argv, "ao:rjqfvh"); + r_getopt_init (&opt, argc, argv, "afhjo:qrs:v"); while ((c = r_getopt_next (&opt)) != -1) { switch (c) { case 'a': @@ -75,6 +77,9 @@ R_API int r_main_rasign2(int argc, const char **argv) { case 'o': ofile = opt.arg; break; + case 's': + space = opt.arg; + break; case 'r': rad = true; break; @@ -139,6 +144,10 @@ R_API int r_main_rasign2(int argc, const char **argv) { r_config_set_i (core->config, "scr.color", COLOR_MODE_DISABLED); } + if (space) { + r_spaces_set (&core->anal->zign_spaces, space); + } + // run analysis to find functions find_functions (core, a_cnt); diff --git a/man/rasign2.1 b/man/rasign2.1 new file mode 100644 index 0000000000..6f6292e405 --- /dev/null +++ b/man/rasign2.1 @@ -0,0 +1,45 @@ +.Dd Aug 6, 2020 +.Dt RASIGN2 1 +.Sh NAME +.Nm RASIGN2 +.Nd radare2 zignature utility +.Sh SYNOPSIS +.Nm rasign2 +.Op Fl afhjqrv +.Op Fl s Ar space +.Op Fl o Ar outfile +.Ar file +.Sh DESCRIPTION +radiff2 implements many binary diffing algorithms for data and code. +.Pp +.Bl -tag -width Fl +.It Fl a +Analyze binary after loading it with RCore and use -AA to run aaaa instead of aaa. +.It Fl f +Interpret the input file as a flirt database and dump the signatures. +.It Fl h +Show usage help message. +.It Fl j +Show output in JSON. +.It Fl o Ar file.sdb +Add signatures to file, create if it does not exist. +.It Fl q +Enable quiet mode. +.It Fl r +Show output in radare commands. +.It Fl s Ar space +Add signatures save all signatures under this signspace. +.It Fl v +Show version information. +.El +.Sh SEE ALSO +.Pp +.Xr radare2(1) , +.Xr rafind2(1) , +.Xr rahash2(1) , +.Xr rabin2(1) , +.Xr rasm2(1) , +.Xr ragg2(1) , +.Xr rarun2(1) , +.Xr rax2(1) , +.Xr radiff2(1) , diff --git a/test/db/tools/rasign2 b/test/db/tools/rasign2 index c8eab56863..dce81fec5e 100644 --- a/test/db/tools/rasign2 +++ b/test/db/tools/rasign2 @@ -95,6 +95,15 @@ za main v b-32 b-24 b-40 b-36 b-16 EOF RUN + +NAME=rasign2 spaces check +FILE=- +CMDS=!!rasign2 -s spacename -ar bins/elf/hello_world~spacename:sym.imp.puts n sym.imp.puts +EXPECT=<