diff --git a/TODO b/TODO index ece27c22e8..7934c4d0f4 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,29 @@ | < V . | . V . < _/ .-' _/| () | |__\__|_|__|___/__|__|_\__\___/ |____(_)____/ +------8<-------------------8<--------------------8<-----------------8<---------- + +====[[ 0.8.6 ]]==== + +* shell encoder - get x86-64 one from twitter + - http://funoverip.net/2011/09/simple-shellcode-obfuscation/ +* enhace r_egg.. not usable til 0.9 +* rabin2 -z /dev/sda1 TAKES TOO LONG. opening r2 /tmp/fs is SLOW as shit. +* Add -f/-t in rahash2 to define ranges + - Add support for large files in rahash2 + - Do not use slurp (must work for big files too!) +* build farm + ====[[ 0.9 ]]==== +OSX +=== +* Proper support for MACH-O binaries + - rabin2 -f works? i think its used with '-a' + +Other stuff +=========== +* rax2 -k by default? * r_anal_find_fcn() is O(N). should be O(1) - var r = RHashTable() var l = r.add ("0x8048000-0x8049000", new RList ()) @@ -18,12 +39,8 @@ * Merge libr/db inside libr/util ? * Test r_search_delta() * Dupped javasm bin/asm -- must merge +* Implement differential distance signature search -------8<-------------------8<--------------------8<-----------------8<---------- - -====[[ 0.8.6 ]]==== - -* rax2 -k by default? * Rename r_hashtable -> r_ht - Make ht64.c include ht.c @@ -32,24 +49,11 @@ * Handle ^C as an alias for '.' command * search.kwidx must be search.lastidx or search.idx ? * add support for sockets in rarun2 -* shell encoder - get x86-64 one from twitter - - http://funoverip.net/2011/09/simple-shellcode-obfuscation/ * RBinCreate: - mach0 create for darwin-ppc - pe64 - plan9 bins -BOTTLENECKS: -============ -* rabin2 -z /dev/sda1 TAKES TOO LONG. opening r2 /tmp/fs is SLOW as shit. -* Add -f/-t in rahash2 to define ranges - - Add support for large files in rahash2 - - Do not use slurp (must work for big files too!) - -OSX -=== -* Proper support for MACH-O binaries - - rabin2 -f works? i think its used with '-a' TODO ==== diff --git a/configure.hook b/configure.hook index ac92c59f7e..f9748718d0 100755 --- a/configure.hook +++ b/configure.hook @@ -1,4 +1,11 @@ #!/bin/sh -[ plugins.def.cfg -nt ./plugins.cfg ] && rm -f plugins.cfg -[ ! -e plugins.cfg ] && ./configure-plugins $@ -r2-bindings/configure-langs $@ +case "$1" in +--version|--help) + : # nothing to do here + ;; +*) + [ plugins.def.cfg -nt ./plugins.cfg ] && rm -f plugins.cfg + [ ! -e plugins.cfg ] && ./configure-plugins $@ + r2-bindings/configure-langs $@ + ;; +esac diff --git a/libr/core/anal.c b/libr/core/anal.c index ddca92e317..752a5237f2 100644 --- a/libr/core/anal.c +++ b/libr/core/anal.c @@ -35,29 +35,29 @@ static char *r_core_anal_graph_label(RCore *core, struct r_anal_bb_t *bb, int op cmdstr = r_core_cmd_str (core, cmd); } if (cmdstr) { - if (!(str = malloc(strlen(cmdstr)*2))) + if (!(str = malloc (strlen(cmdstr)*2))) return NULL; - for(i=j=0;cmdstr[i];i++,j++) { - switch(cmdstr[i]) { + for(i=j=0; cmdstr[i]; i++,j++) { + switch (cmdstr[i]) { case 0x1b: /* skip ansi chars */ - for(i++;cmdstr[i]&&cmdstr[i]!='m'&&cmdstr[i]!='H'&&cmdstr[i]!='J';i++); + for (i++; cmdstr[i] && cmdstr[i]!='m' && cmdstr[i]!='H' && cmdstr[i]!='J'; i++); j--; break; case '"': - str[j]='\\'; - str[++j]='"'; + str[j] = '\\'; + str[++j] = '"'; break; case '\n': case '\r': - str[j]='\\'; - str[++j]='l'; + str[j] = '\\'; + str[++j] = 'l'; break; default: - str[j]=cmdstr[i]; + str[j] = cmdstr[i]; } } - str[j]='\0'; + str[j] = '\0'; free (cmdstr); } return str; @@ -82,13 +82,18 @@ static void r_core_anal_graph_nodes(RCore *core, RAnalFcn *fcn, int opts) { } if ((str = r_core_anal_graph_label (core, bbi, opts))) { if (opts & R_CORE_ANAL_GRAPHDIFF) { - r_cons_printf (" \"0x%08"PFMT64x"_0x%08"PFMT64x"\" [color=\"%s\", label=\"%s\"]\n", + r_cons_printf (" \"0x%08"PFMT64x"_0x%08"PFMT64x"\" [color=\"%s\"," + " label=\"%s\", URL=\"%s/0x%08"PFMT64x"\"]\n", fcn->addr, bbi->addr, - bbi->diff->type==R_ANAL_DIFF_TYPE_MATCH?"lightgray": - bbi->diff->type==R_ANAL_DIFF_TYPE_UNMATCH?"yellow":"red",str); + bbi->diff->type==R_ANAL_DIFF_TYPE_MATCH? "lightgray": + bbi->diff->type==R_ANAL_DIFF_TYPE_UNMATCH? "yellow": "red", str, + fcn->name, bbi->addr); } else { - r_cons_printf (" \"0x%08"PFMT64x"_0x%08"PFMT64x"\" [color=\"%s\", label=\"%s\"]\n", - fcn->addr, bbi->addr, bbi->traced?"yellow":"lightgray",str); + r_cons_printf (" \"0x%08"PFMT64x"_0x%08"PFMT64x"\" [" + "URL=\"%s/0x%08"PFMT64x"\" color=\"%s\", label=\"%s\"]\n", + fcn->addr, bbi->addr, + fcn->name, bbi->addr, + bbi->traced?"yellow":"lightgray", str); } r_cons_flush (); free (str); @@ -104,7 +109,7 @@ R_API int r_core_anal_bb(RCore *core, RAnalFcn *fcn, ut64 at, int head) { int ret = R_ANAL_RET_NEW, buflen, bblen = 0; int split = core->anal->split; - if (!(bb = r_anal_bb_new())) + if (!(bb = r_anal_bb_new ())) return R_FALSE; if (split) ret = r_anal_fcn_split_bb (fcn, bb, at); else r_list_foreach (fcn->bbs, iter, bbi) @@ -264,19 +269,23 @@ R_API int r_core_anal_fcn_clean(RCore *core, ut64 addr) { } R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv) { + int showhdr = 0; RListIter *iter, *iter2; RAnalRef *fcnr; RAnalFcn *fcni; - if (gv) r_cons_printf ("digraph code {\n" - "\tgraph [bgcolor=white];\n" - "\tnode [color=lightgray, style=filled shape=box" - " fontname=\"Courier\" fontsize=\"8\"];\n"); r_list_foreach (core->anal->fcns, iter, fcni) { if (addr != 0 && addr != fcni->addr) continue; if (!gv) r_cons_printf ("0x%08"PFMT64x"\n", fcni->addr); r_list_foreach (fcni->refs, iter2, fcnr) { + if (!showhdr) { + if (gv) r_cons_printf ("digraph code {\n" + "\tgraph [bgcolor=white];\n" + "\tnode [color=lightgray, style=filled shape=box" + " fontname=\"Courier\" fontsize=\"8\"];\n"); + showhdr = 1; + } // TODO: display only code or data refs? RFlagItem *flag = r_flag_get_i (core->flags, fcnr->addr); if (gv) r_cons_printf ("\t\"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" " @@ -287,7 +296,8 @@ R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv) { else r_cons_printf (" - 0x%08"PFMT64x" (%c)\n", fcnr->addr, fcnr->type); } } - r_cons_printf ("}\n"); + if (showhdr && gv) + r_cons_printf ("}\n"); } static void fcn_list_bbs(RAnalFcn *fcn) { @@ -319,7 +329,6 @@ static void fcn_list_bbs(RAnalFcn *fcn) { r_cons_flush (); } - R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad) { RAnalFcn *fcni; struct r_anal_ref_t *refi; @@ -397,10 +406,14 @@ R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad) { R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts) { RAnalFcn *fcni; RListIter *iter; - int reflines = r_config_get_i (core->config, "asm.lines"); - int bytes = r_config_get_i (core->config, "asm.bytes"); - int dwarf = r_config_get_i (core->config, "asm.dwarf"); + int reflines, bytes, dwarf; + if (r_list_empty (core->anal->fcns)) + return R_FALSE; + + reflines = r_config_get_i (core->config, "asm.lines"); + bytes = r_config_get_i (core->config, "asm.bytes"); + dwarf = r_config_get_i (core->config, "asm.dwarf"); r_config_set_i (core->config, "asm.lines", 0); r_config_set_i (core->config, "asm.bytes", 0); r_config_set_i (core->config, "asm.dwarf", 0); @@ -426,11 +439,8 @@ static int r_core_anal_followptr(RCore *core, ut64 at, ut64 ptr, ut64 ref, int c int wordsize, endian; if (ptr == ref) { - if (code) - r_cons_printf ("ar 0x%08"PFMT64x" 0x%08"PFMT64x"\n", - (ut64)ref, (ut64)at); - else r_cons_printf ("ard 0x%08"PFMT64x" 0x%08"PFMT64x"\n", - (ut64)ref, (ut64)at); + if (code) r_cons_printf ("ar 0x%08"PFMT64x" 0x%08"PFMT64x"\n", (ut64)ref, (ut64)at); + else r_cons_printf ("ard 0x%08"PFMT64x" 0x%08"PFMT64x"\n", (ut64)ref, (ut64)at); return R_TRUE; } if (depth < 1) @@ -512,8 +522,7 @@ R_API int r_core_anal_ref_list(RCore *core, int rad) { } r_list_foreach (core->anal->refs, iter2, refi) { - if (rad) - r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", + if (rad) r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", refi->type==R_ANAL_REF_TYPE_DATA?"d":"", refi->at, refi->addr); else r_cons_printf ("0x%08"PFMT64x" -> 0x%08"PFMT64x" (%c)\n", diff --git a/libr/include/r_anal.h b/libr/include/r_anal.h index 80da3033d1..d5c21a0405 100644 --- a/libr/include/r_anal.h +++ b/libr/include/r_anal.h @@ -429,6 +429,7 @@ R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op); R_API RAnalFcn *r_anal_fcn_new(); R_API RAnalFcn *r_anal_fcn_find(RAnal *anal, ut64 addr, int type); R_API RList *r_anal_fcn_list_new(); +R_API int r_anal_fcn_insert(RAnal *anal, RAnalFcn *fcn); R_API void r_anal_fcn_free(void *fcn); R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len, int reftype); diff --git a/sys/bindist.sh b/sys/bindist.sh new file mode 100644 index 0000000000..7fef444e2b --- /dev/null +++ b/sys/bindist.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# find root +cd `dirname $PWD/$0` ; cd .. + +D=prefix-install +P=`./configure --version|head -n 1|cut -d ' ' -f 1` +rm -rf $D +mkdir $D +make install DESTDIR=$D +cd $D +tar czvf ../$P-bin.tar.gz +rm -rf $D diff --git a/sys/build.sh b/sys/build.sh new file mode 100755 index 0000000000..8db653336d --- /dev/null +++ b/sys/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# 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 +fi +./configure --prefix=/usr && \ +make -j 4 diff --git a/sys/farm/CONFIG b/sys/farm/CONFIG new file mode 100644 index 0000000000..98b09fb23f --- /dev/null +++ b/sys/farm/CONFIG @@ -0,0 +1,21 @@ +# helpers +minutes() { echo $(($1*60)); } +hours() { echo $(($1*60*60)); } +days() { echo $(($1*60*60*24)); } +hhmm() { echo $((`hours $1`+`minutes $2`)); } + +# every 30 minutes +SLEEP=`hhmm 0 30` + +PACKAGE=radare2 +LOGDIR=log + +REMOTEDIR="" +[ -f ~/.r2farmrc ] && . ~/.r2farmrc + +TARGETS=" + build + bindist + mingw32 +" +# mingw64 maemo diff --git a/sys/farm/check.sh b/sys/farm/check.sh new file mode 100755 index 0000000000..4faa625da2 --- /dev/null +++ b/sys/farm/check.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +revision() { + echo `hg tip|head -n 1|cut -d : -f 2` +} + +cd `dirname $PWD/$0` ; cd .. +. ./farm/CONFIG +[ ! -f farm/last-revision ] && exit 1 +now=`revision` +old=`cat farm/last-revision` +[ "$now" = "$old" ] diff --git a/sys/farm/daemon.sh b/sys/farm/daemon.sh new file mode 100644 index 0000000000..fd5d7a2283 --- /dev/null +++ b/sys/farm/daemon.sh @@ -0,0 +1,6 @@ +#!/bin/sh +cd `dirname $PWD/$0` +while : ; do + ( ./check.sh ) && ./run.sh + sleep ${SLEEP} +done diff --git a/sys/farm/prepare.sh b/sys/farm/prepare.sh new file mode 100755 index 0000000000..d50a0e87b7 --- /dev/null +++ b/sys/farm/prepare.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# install all deps in order to setup the farm +PREPARE=" + vala + swig + valabind + python-deps + mingw32-deps + mingw64-deps +" + +cd `dirname $PWD/$0` ; cd .. +for a in ${PREPARE} ; do + ./${a}.sh +done diff --git a/sys/farm/push.sh b/sys/farm/push.sh new file mode 100755 index 0000000000..f2d1f083b6 --- /dev/null +++ b/sys/farm/push.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# find root +cd `dirname $PWD/$0` ; cd .. + +. ./farm/CONFIG + +if [ -z "${REMOTEDIR}" ]; then + echo "# You have to setup the REMOTEDIR var in your config var" + echo "echo 'REMOTEDIR=...' > ~/.r2farmrc" + exit 1 +fi + +rsync -avz farm/${LOGDIR}/* ${REMOTEDIR} diff --git a/sys/farm/run.sh b/sys/farm/run.sh new file mode 100755 index 0000000000..e7725fc1d7 --- /dev/null +++ b/sys/farm/run.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +cd `dirname $PWD/$0` ; cd .. +. ./farm/CONFIG + +revision() { + echo `hg tip|head -n 1|cut -d : -f 2` +} + +tstamp() { + date +%Y%m%d-%h +} + +logfile() { + echo "${LOGDIR}/${PACKAGE}-`tstamp`-`revision`-$1" +} + +mkdir -p farm/${LOGDIR} +for a in ${TARGETS} ; do + L=farm/`logfile $a` + echo "= $a" | tee $L.log + ./${a}.sh 2>&1 | tee -a $L.log + echo $? > $L.ret +done +echo $revision > farm/last-revision +exit 0 diff --git a/sys/gtk.sh b/sys/gtk.sh new file mode 100644 index 0000000000..0d82b3bd45 --- /dev/null +++ b/sys/gtk.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -x /usr/bin/pacman ]; then + sudo pacman -S gtk2 +elif [ -x /usr/bin/apt-get ]; then + sudo apt-get install gtk2-2.0-dev +elif [ -x /opt/local/bin/port ]; then + echo "Installing cairo.." + sudo port install cairo +quartz+no_x11 || exit 1 + echo "Installing pango.." + sudo port install pango +quartz+no_x11 || exit 1 + echo "Installing GTK2.." + sudo port install gtk2 +quartz+no_x11 || exit 1 +else + echo "Cannot install gtk :(" + exit 1 +fi +:> .gtk-done.sh diff --git a/sys/install.sh b/sys/install.sh index e23cc4371f..85993fdcf8 100755 --- a/sys/install.sh +++ b/sys/install.sh @@ -10,17 +10,4 @@ elif [ -d .git ]; then git pull fi -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 -fi -./configure --prefix=/usr && \ -make -j 4 && \ -sudo make symstall +./sys/build.sh && sudo make symstall