Add r2 -z and r2 -zz: Fix the bin.strings and bin.rawstr logic.

This commit is contained in:
pancake 2014-09-08 23:29:01 +02:00
parent c9aaede4e4
commit 777b26fd6e
3 changed files with 31 additions and 13 deletions

View File

@ -97,7 +97,8 @@ static int main_help(int line) {
" -t load rabin2 info in thread\n" " -t load rabin2 info in thread\n"
#endif #endif
" -v, -V show radare2 version (-V show lib versions)\n" " -v, -V show radare2 version (-V show lib versions)\n"
" -w open file in write mode\n"); " -w open file in write mode\n"
" -z, -zz do not load strings or load them even in raw\n");
if (line==2) if (line==2)
printf ( printf (
"Scripts:\n" "Scripts:\n"
@ -171,6 +172,7 @@ int main(int argc, char **argv, char **envp) {
const char *prj = NULL; const char *prj = NULL;
//int threaded = R_FALSE; //int threaded = R_FALSE;
int debug = 0; int debug = 0;
int zflag = 0;
int do_analysis = 0; int do_analysis = 0;
int do_connect = 0; int do_connect = 0;
int fullfile = 0; int fullfile = 0;
@ -238,7 +240,7 @@ int main(int argc, char **argv, char **envp) {
argv++; argv++;
} else prefile = 0; } else prefile = 0;
while ((c = getopt (argc, argv, "0ACwfhm:e:nk:Ndqs:p:b:B:a:Lui:l:P:c:D:vVS" while ((c = getopt (argc, argv, "0ACwfhm:e:nk:Ndqs:p:b:B:a:Lui:l:P:c:D:vVSz"
#if USE_THREADS #if USE_THREADS
"t" "t"
#endif #endif
@ -253,6 +255,7 @@ int main(int argc, char **argv, char **envp) {
quiet = R_TRUE; quiet = R_TRUE;
break; break;
case 'a': asmarch = optarg; break; case 'a': asmarch = optarg; break;
case 'z': zflag++; break;
case 'A': case 'A':
do_analysis = R_TRUE; do_analysis = R_TRUE;
break; break;
@ -357,6 +360,15 @@ int main(int argc, char **argv, char **envp) {
return 0; return 0;
} }
switch (zflag) {
case 1:
r_config_set (r.config, "bin.strings", "false");
break;
case 2:
r_config_set (r.config, "bin.rawstr", "true");
break;
}
switch (va) { switch (va) {
case 0: case 0:
r_config_set_i (r.config, "io.va", 0); r_config_set_i (r.config, "io.va", 0);

View File

@ -116,12 +116,16 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
if (!(hasstr = r_config_get_i (r->config, "bin.strings"))) if (!(hasstr = r_config_get_i (r->config, "bin.strings")))
return 0; return 0;
if (!plugin) return 0; if (!plugin) return 0;
if (!plugin->info) { if (plugin->info && plugin->name) {
if (!rawstr) { if (!strcmp (plugin->name, "any")) {
eprintf ("WARN: Use '-e bin.rawstr=true' or 'rabin2 -zz'" if (!rawstr) {
" to find strings on unknown file types\n"); eprintf ("NOTE: Use '-e bin.rawstr=true' or 'r2 -zz' or '.!rabin2 -zz $FILE'"
return R_FALSE; " to find strings on unknown file types\n");
return R_FALSE;
}
} }
} }

View File

@ -263,9 +263,11 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 loadaddr, const char *f
} }
if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) { if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) {
treat_as_rawstr ++; if (r_config_get_i (r->config, "bin.rawstr")) {
if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) { treat_as_rawstr = R_TRUE;
return R_FALSE; if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) {
return R_FALSE;
}
} }
} }
@ -275,7 +277,7 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 loadaddr, const char *f
if ( plugin && strncmp (plugin->name, "any", 5)==0 ) { if ( plugin && strncmp (plugin->name, "any", 5)==0 ) {
// set use of raw strings // set use of raw strings
r_config_set_i (r->config, "io.va", 0); r_config_set_i (r->config, "io.va", 0);
r_config_set (r->config, "bin.rawstr", "true"); //\\ r_config_set (r->config, "bin.rawstr", "true");
// get bin.minstr // get bin.minstr
r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr"); r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr");
} else if (binfile) { } else if (binfile) {
@ -313,7 +315,7 @@ static int r_core_file_do_load_for_io_plugin (RCore *r, ut64 baseaddr, ut64 load
if ( plugin && strncmp (plugin->name, "any", 5)==0 ) { if ( plugin && strncmp (plugin->name, "any", 5)==0 ) {
// set use of raw strings // set use of raw strings
r_config_set_i (r->config, "io.va", 0); r_config_set_i (r->config, "io.va", 0);
r_config_set (r->config, "bin.rawstr", "true"); // r_config_set (r->config, "bin.rawstr", "true");
// get bin.minstr // get bin.minstr
r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr"); r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr");
} else if (binfile) { } else if (binfile) {
@ -448,7 +450,7 @@ R_API int r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
plugin = r_bin_file_cur_plugin (binfile); plugin = r_bin_file_cur_plugin (binfile);
if (plugin && plugin->name && !strncmp (plugin->name, "any", 3)) { if (plugin && plugin->name && !strncmp (plugin->name, "any", 3)) {
// set use of raw strings // set use of raw strings
r_config_set (r->config, "bin.rawstr", "true"); //r_config_set (r->config, "bin.rawstr", "true");
r_config_set_i (r->config, "io.va", 0); r_config_set_i (r->config, "io.va", 0);
// get bin.minstr // get bin.minstr
r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr"); r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr");