bin.strpurge: added support for ranges (#9215)

This commit is contained in:
Khairul Azhar Kasmiran 2018-01-19 22:04:23 +08:00 committed by radare
parent 89c309a900
commit 9f258ebe1b
2 changed files with 15 additions and 2 deletions

View File

@ -206,12 +206,24 @@ R_API bool r_core_bin_strpurge(RCore *core, const char *str, ut64 refaddr) {
int splits = r_str_split (addrs, ',');
int i;
char *ptr;
ut64 addr;
char *range_sep;
ut64 addr, from, to;
for (i = 0, ptr = addrs; i < splits; i++, ptr += strlen (ptr) + 1) {
if (!strcmp (ptr, "true") && false_positive (str)) {
free (addrs);
return true;
}
range_sep = strchr (ptr, '-');
if (range_sep) {
*range_sep = 0;
from = r_num_get (NULL, ptr);
ptr = range_sep + 1;
to = r_num_get (NULL, ptr);
if (refaddr >= from && refaddr <= to) {
free (addrs);
return true;
}
}
addr = r_num_get (NULL, ptr);
if (addr != 0 || *ptr == '0') {
if (refaddr == addr) {

View File

@ -2391,7 +2391,8 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("bin.usextr", "true", &cb_usextr, "Use extract plugins when loading files");
SETCB ("bin.useldr", "true", &cb_useldr, "Use loader plugins when loading files");
SETCB ("bin.strpurge", "", &cb_strpurge, "Try to purge false positive strings (true: use the "
"false_positive() classifier in cbin.c, [,addr]*: specific string addresses to purge)");
"false_positive() classifier in cbin.c, [,addr]*: specific string addresses to purge, "
"[,addr1-addr2]*: purge all strings in the range addr1-addr2 inclusive)");
SETPREF ("bin.b64str", "false", "Try to debase64 the strings");
SETPREF ("bin.libs", "false", "Try to load libraries after loading main binary");
n = NODECB ("bin.strfilter", "", &cb_strfilter);