mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 02:23:58 +00:00
Implement rafind2 -i to identify binaries
This commit is contained in:
parent
9bdce20d83
commit
78ec2d0340
@ -21,6 +21,7 @@ struct r_search_t *rs;
|
||||
static ut64 from = 0LL, to = -1;
|
||||
static char *mask = NULL;
|
||||
static int nonstop = 0;
|
||||
static bool identify = false;
|
||||
static int mode = R_SEARCH_STRING;
|
||||
static ut64 cur = 0;
|
||||
static ut8 *buf = NULL;
|
||||
@ -84,6 +85,7 @@ static int show_help(char *argv0, int line) {
|
||||
" -e [regex] search for regex matches (can be used multiple times)\n"
|
||||
" -f [from] start searching from address 'from'\n"
|
||||
" -h show this help\n"
|
||||
" -i identify filetype (r2 -qcpm file)\n"
|
||||
" -m magic search, file-type carver\n"
|
||||
" -M [str] set a binary mask to be applied on keywords\n"
|
||||
" -n do not stop on read errors\n"
|
||||
@ -106,6 +108,13 @@ static int rafind_open(char *file) {
|
||||
bool last = false;
|
||||
int ret;
|
||||
|
||||
if (identify) {
|
||||
char *cmd = r_str_newf ("r2 -e search.show=false -e search.count=1 -nqcpm '%s'", file);
|
||||
r_sandbox_system (cmd, 1);
|
||||
free (cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
io = r_io_new ();
|
||||
fd = r_io_open_nomap (io, file, R_IO_READ, 0);
|
||||
if (!fd) {
|
||||
@ -194,7 +203,7 @@ int main(int argc, char **argv) {
|
||||
int c;
|
||||
|
||||
keywords = r_list_new ();
|
||||
while ((c = getopt (argc, argv, "a:e:b:mM:s:S:x:Xzf:t:rnhvZ")) != -1) {
|
||||
while ((c = getopt (argc, argv, "a:ie:b:mM:s:S:x:Xzf:t:rnhvZ")) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
align = r_num_math (NULL, optarg);
|
||||
@ -202,6 +211,9 @@ int main(int argc, char **argv) {
|
||||
case 'r':
|
||||
rad = 1;
|
||||
break;
|
||||
case 'i':
|
||||
identify = true;
|
||||
break;
|
||||
case 'n':
|
||||
nonstop = 1;
|
||||
break;
|
||||
|
@ -5,7 +5,7 @@
|
||||
.Nd Advanced commandline hexadecimal editor
|
||||
.Sh SYNOPSIS
|
||||
.Nm rafind2
|
||||
.Op Fl zZXnrhv
|
||||
.Op Fl izZXnrhv
|
||||
.Op Fl b Ar size
|
||||
.Op Fl f Ar from
|
||||
.Op Fl t Ar to
|
||||
@ -29,6 +29,8 @@ Search for a specific wide string
|
||||
Search for a regular expression string matches
|
||||
.It Fl x Ar hex
|
||||
Search for an hexpair string
|
||||
.It Fl i
|
||||
Identify filetype (like file, uses r2 -qcpm)
|
||||
.It Fl m
|
||||
Carve for known file-types using the r_magic signatures
|
||||
.It Fl M Ar mask
|
||||
|
Loading…
Reference in New Issue
Block a user