* added 'afi' to show info of functions

* afl is now less verbose
* Add /v2 /v4 /v8 and remove /q
* Rename /a to /r
* remove search.asmstr and use /a and /c
* Fail build of bindings if somethings goes wrong
* Add sys/static.sh
This commit is contained in:
pancake 2011-11-22 15:12:29 +01:00
parent 068be100ff
commit 85b952966c
7 changed files with 93 additions and 54 deletions

View File

@ -25,6 +25,7 @@ CHKLIB ewf
ARG_WITHOUT HAVE_EWF ewf disable EWF dependency ;
IFNOT HAVE_EWF { HAVE_LIB_EWF = 0 ; }
(( TODO must deprecate ))
CHKLIB gmp
ARG_WITHOUT HAVE_GMP gmp disable GMP dependency ;
IFNOT HAVE_GMP { HAVE_LIB_GMP = 0 ; }

View File

@ -41,6 +41,7 @@ R_API char* r_core_asm_search(RCore *core, const char *input, ut64 from, ut64 to
}
#define OPSZ 8
// TODO: add support for byte-per-byte opcode search
R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut64 to) {
RCoreAsmHit *hit;
RAsmOp op;
@ -67,9 +68,8 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
free (ptr);
return NULL;
}
for (tokcount=0;;tokcount++) {
if (tokcount==0) tok = (char*)strtok (ptr, ";");
else tok = (char*)strtok (NULL, ";");
for (tokcount=0; ; tokcount++) {
tok = strtok (tokcount? NULL: ptr, ",");
if (tok == NULL)
break;
tokens[tokcount] = r_str_trim_head_tail (tok);

View File

@ -2861,9 +2861,21 @@ static int cmd_anal(void *data, const char *input) {
free (ptr);
}
break;
case 'l':
case 'i':
r_core_anal_fcn_list (core, input+2, 0);
break;
case 'l':
{
RAnalFcn *fcn;
RListIter *iter;
r_list_foreach (core->anal->fcns, iter, fcn) {
int bbs = r_list_length (fcn->bbs);
r_cons_printf ("0x%08"PFMT64x" %6"PFMT64d" %3d %s\n",
fcn->addr, fcn->size, bbs, fcn->name);
}
}
break;
case '*':
r_core_anal_fcn_list (core, input+2, 1);
break;
@ -2960,7 +2972,8 @@ static int cmd_anal(void *data, const char *input) {
" af+ addr size name [type] [diff] ; Add function\n"
" afb fcnaddr addr size name [type] [diff] ; Add bb to function @ fcnaddr\n"
" af- [addr] ; Clean all function analysis data (or function at addr)\n"
" afl [fcn name] ; List functions\n"
" afl [fcn name] ; List functions (addr, size, bbs, name)\n"
" afi [fcn name] ; Show function(s) information (verbose afl)\n"
" afs [addr] [fcnsign] ; Get/set function signature at current address\n"
" af[aAv][?] [arg] ; Manipulate args, fastargs and variables in function\n"
" afc @ [addr] ; Calculate the Cyclomatic Complexity (starting at addr)\n"
@ -3711,6 +3724,7 @@ static int cmd_search(void *data, const char *input) {
int ignorecase = R_FALSE;
ut64 n64;
ut32 n32;
ut16 n16;
ut8 *buf;
mode = r_config_get (core->config, "search.in");
@ -3790,11 +3804,24 @@ static int cmd_search(void *data, const char *input) {
inverse = R_TRUE;
goto reread;
break;
case 'a':
case 'r':
if (input[1]==' ')
r_core_anal_search (core, from, to, r_num_math (core->num, input+2));
else r_core_anal_search (core, from, to, core->offset);
break;
case 'a': {
char *kwd;
if (!(kwd = r_core_asm_search (core, input+2, from, to)))
return R_FALSE;
r_search_reset (core->search, R_SEARCH_KEYWORD);
r_search_set_distance (core->search, (int)
r_config_get_i (core->config, "search.distance"));
r_search_kw_add (core->search,
r_search_keyword_new_hexmask (kwd, NULL));
r_search_begin (core->search);
free (kwd);
dosearch = R_TRUE;
} break;
case 'A':
dosearch = aes_search = R_TRUE;
break;
@ -3825,25 +3852,32 @@ static int cmd_search(void *data, const char *input) {
} else eprintf ("Invalid pattern size (must be >0)\n");
}
break;
case 'q':
r_search_reset (core->search, R_SEARCH_KEYWORD);
r_search_set_distance (core->search, (int)
r_config_get_i (core->config, "search.distance"));
n64 = (ut32)r_num_math (core->num, input+1);
// TODO: Add support for /v4 /v8 /v2
r_search_kw_add (core->search,
r_search_keyword_new ((const ut8*)&n64, 8, NULL, 0, NULL));
r_search_begin (core->search);
dosearch = R_TRUE;
break;
case 'v':
r_search_reset (core->search, R_SEARCH_KEYWORD);
r_search_set_distance (core->search, (int)
r_config_get_i (core->config, "search.distance"));
n32 = (ut32)r_num_math (core->num, input+1);
switch (input[1]) {
case '?':
eprintf ("Usage: /v[2|4|8] [value]\n");
return R_TRUE;
case '8':
n64 = r_num_math (core->num, input+2);
r_search_kw_add (core->search,
r_search_keyword_new ((const ut8*)&n64, 8, NULL, 0, NULL));
break;
case '2':
n16 = (ut16)r_num_math (core->num, input+2);
r_search_kw_add (core->search,
r_search_keyword_new ((const ut8*)&n16, 2, NULL, 0, NULL));
break;
default: // default size
case '4':
n32 = (ut32)r_num_math (core->num, input+1);
r_search_kw_add (core->search,
r_search_keyword_new ((const ut8*)&n32, 4, NULL, 0, NULL));
break;
}
// TODO: Add support for /v4 /v8 /v2
r_search_kw_add (core->search,
r_search_keyword_new ((const ut8*)&n32, 4, NULL, 0, NULL));
r_search_begin (core->search);
dosearch = R_TRUE;
break;
@ -3930,35 +3964,19 @@ static int cmd_search(void *data, const char *input) {
break;
case 'c': /* search asm */
{
/* TODO: Move to a separate function */
int asmstr = r_config_get_i (core->config, "search.asmstr");
if (asmstr) {
RCoreAsmHit *hit;
RListIter *iter;
int count = 0;
RList *hits;
if ((hits = r_core_asm_strsearch (core, input+2, from, to))) {
r_list_foreach (hits, iter, hit) {
r_cons_printf ("f %s_%i @ 0x%08"PFMT64x" # %i: %s\n",
searchprefix, count, hit->addr, hit->len, hit->code);
count++;
}
r_list_destroy (hits);
RCoreAsmHit *hit;
RListIter *iter;
int count = 0;
RList *hits;
if ((hits = r_core_asm_strsearch (core, input+2, from, to))) {
r_list_foreach (hits, iter, hit) {
r_cons_printf ("f %s_%i @ 0x%08"PFMT64x" # %i: %s\n",
searchprefix, count, hit->addr, hit->len, hit->code);
count++;
}
dosearch = 0;
} else {
char *kwd;
if (!(kwd = r_core_asm_search (core, input+2, from, to)))
return R_FALSE;
r_search_reset (core->search, R_SEARCH_KEYWORD);
r_search_set_distance (core->search, (int)
r_config_get_i (core->config, "search.distance"));
r_search_kw_add (core->search,
r_search_keyword_new_hexmask (kwd, NULL));
r_search_begin (core->search);
free (kwd);
dosearch = R_TRUE;
r_list_destroy (hits);
}
dosearch = 0;
}
break;
default:
@ -3973,12 +3991,12 @@ static int cmd_search(void *data, const char *input) {
" /d 101112 ; search for a deltified sequence of bytes\n"
" /!x 00 ; inverse hexa search (find first byte != 0x00)\n"
" /c jmp [esp] ; search for asm code (see search.asmstr)\n"
" /a jmp eax ; assemble opcode and search its bytes\n"
" /A ; search for AES expanded keys\n"
" /a sym.printf ; analyze code referencing an offset\n"
" /r sym.printf ; analyze opcode reference an offset\n"
" /m magicfile ; search for matching magic file (use blocksize)\n"
" /p patternsize ; search for pattern of given size\n"
" /v num ; look for a asm.bigendian 32bit value\n"
" /q num ; look for a asm.bigendian 64bit value\n"
" /v[?248] num ; look for a asm.bigendian 32bit value\n"
" // ; repeat last search\n"
" ./ hello ; search 'hello string' and import flags\n"
"Configuration:\n"

View File

@ -541,8 +541,6 @@ R_API int r_core_config_init(RCore *core) {
r_config_desc (cfg, "search.distance", "Search string distance");
r_config_set_i_cb (cfg, "search.align", 0, &config_searchalign_callback);
r_config_desc (cfg, "search.align", "Only catch aligned search hits");
r_config_set (cfg, "search.asmstr", "true");
r_config_desc (cfg, "search.asmstr", "Search string instead of assembly");
r_config_set_cb (cfg, "scr.html", "false", &config_scrhtml_callback);
r_config_desc (cfg, "scr.html", "If enabled disassembly use HTML syntax");
r_config_set_cb (cfg, "io.ffio", "true", &config_ioffio_callback);

View File

@ -19,7 +19,7 @@ echo "Build ${MOD} `pkg-config --libs ${MOD}`"
PYTHON_CONFIG=$(../python-config-wrapper -n)
export PYTHON_CONFIG
valabind-cc ${LNG} ${MOD} ${VALABINDFLAGS} \
exec valabind-cc ${LNG} ${MOD} ${VALABINDFLAGS} \
-I../../libr/include \
-x --vapidir=../vapi ../vapi/${MOD} \
`pkg-config --cflags --libs ${MOD}`

View File

@ -31,7 +31,7 @@ else
fi ; \
[ $$? = 0 ] && \
(cd .. && RELEASE=$(RELEASE) \
sh do-swig.sh ${LANG} `echo $@ | sed -e s,.${SOEXT},,`) ; \
sh do-swig.sh ${LANG} `echo $@ | sed -e s,.${SOEXT},,`) || exit 1 ; \
[ "${LANG}`uname`" = pythonDarwin ] && cp _${LIBPFX}$@ _`echo $@|sed -e s,.${SOEXT},.so,` ; \
true
endif

22
sys/static.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
MAKE=make
gmake --help >/dev/null 2>&1
[ $? = 0 ] && MAKE=gmake
# find root
cd `dirname $PWD/$0` ; cd ..
ccache --help > /dev/null 2>&1
if [ $? = 0 ]; then
[ -z "${CC}" ] && CC=gcc
CC="ccache ${CC}"
export CC
fi
# build
if [ -f config-user.mk ]; then
${MAKE} mrproper > /dev/null 2>&1
fi
./configure --prefix=/usr --with-nonpic --without-pic && \
${MAKE} -j 4