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 <dennis@hurricanelabs.com>
This commit is contained in:
Dennis Goodlett 2020-08-11 00:36:10 -04:00 committed by GitHub
parent a54f9363e4
commit ee133222fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 6 deletions

View File

@ -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);

45
man/rasign2.1 Normal file
View File

@ -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) ,

View File

@ -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=<<EOF
za spacename:sym.imp.puts n sym.imp.puts
EOF
RUN
NAME=rasign2 -f libc-v7.sig
FILE=
CMDS=!rasign2 -f bins/other/sigs/libc-v7.sig