* Initial implementation of sys/farm

- add missing sys/gtk.sh
* Define TODO for 0.8.6
* Add URL attribute in dot graphs for 'ag' command
  - as requested by @hteso for bokken
* Empty graphs are now printing nothing to stdout
  - same as above
This commit is contained in:
pancake 2011-09-23 00:16:29 +02:00
parent 829a2bb69f
commit b60af6d878
14 changed files with 218 additions and 67 deletions

40
TODO
View File

@ -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<RList>()
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
====

View File

@ -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

View File

@ -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",

View File

@ -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);

13
sys/bindist.sh Normal file
View File

@ -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

18
sys/build.sh Executable file
View File

@ -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

21
sys/farm/CONFIG Normal file
View File

@ -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

12
sys/farm/check.sh Executable file
View File

@ -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" ]

6
sys/farm/daemon.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
cd `dirname $PWD/$0`
while : ; do
( ./check.sh ) && ./run.sh
sleep ${SLEEP}
done

15
sys/farm/prepare.sh Executable file
View File

@ -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

14
sys/farm/push.sh Executable file
View File

@ -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}

26
sys/farm/run.sh Executable file
View File

@ -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

18
sys/gtk.sh Normal file
View File

@ -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

View File

@ -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