diff --git a/TODO b/TODO index 1763928a66..3a2846e10e 100644 --- a/TODO +++ b/TODO @@ -9,17 +9,32 @@ MAXPRIO ------- +* More userfriendly visual mode + - add for hex + - W will write a string + - _ -> write string does not obeys the cursor * rep+ret instruction (f3c3) should be identified as RET * p7 : 7bit encoding (sms) - variant for stego print? LSB, MSB, ... -* Make r_io happy with RList +* Kill kernel's list.h + r_anal.h + r_asm.h + r_crypto.h + r_parse.h + r_reg.h + r_syscall.h + r_util.h +* crackme mach0 happy with rbin +* bin_load should not be necessary! * add support for sockets in rarun2 * if no debugger supported, say so... r_io must ? -* valabind must support luvit and nodejs (-ffi) * check search multiple keywords and signatures * Fix iterators for r_macro (test only?) - search for antidebug/disasm tricks opcodes - allows to find interesting points to analyze +* get cparse ftw + +* use slices for r_list_iter primitives BUGS: * If [0-9] keybindings in visual point to same address use same reference diff --git a/libr/asm/asm.c b/libr/asm/asm.c index 8ad60fdfa6..9a40a9ff5e 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2011 nibble<.ds@gmail.com> */ +/* radare - LGPL - Copyright 2009-2012 nibble<.ds@gmail.com> */ #include @@ -8,8 +8,7 @@ #include #include "../config.h" -static RAsmPlugin *asm_static_plugins[] = - { R_ASM_STATIC_PLUGINS }; +static RAsmPlugin *asm_static_plugins[] = { R_ASM_STATIC_PLUGINS }; static int r_asm_pseudo_align(struct r_asm_op_t *op, char *input) { eprintf ("TODO: .align\n"); // Must add padding for labels and others.. but this is from RAsm, not RAsmOp diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 5167ec7b4e..19779570cf 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -150,8 +150,7 @@ static int cmd_print(void *data, const char *input) { r_cons_printf ("???\n"); } else r_cons_printf ("%s\n", asmop.buf_asm); } - if (tbs) - r_core_block_size (core, tbs); + if (tbs) r_core_block_size (core, tbs); return err; } case 'D': diff --git a/libr/core/file.c b/libr/core/file.c index 9b1c47ee8e..8383db13dd 100644 --- a/libr/core/file.c +++ b/libr/core/file.c @@ -129,7 +129,7 @@ R_API int r_core_bin_load(RCore *r, const char *file) { int va = r->io->va || r->io->debug; if (file == NULL) { - if (r->file == NULL) + if (!r->file || !r->file->filename) return R_FALSE; file = r->file->filename; } @@ -141,15 +141,13 @@ R_API int r_core_bin_load(RCore *r, const char *file) { eprintf ("NOTE: Use -a and -b to select sub binary in fat binary\n"); for (i=0; ibin->narch; i++) { r_bin_select_idx (r->bin, i); - if (r->bin->curarch.info == NULL) { - eprintf ("No extract info found.\n"); - } else { + if (r->bin->curarch.info) { eprintf (" $ r2 -a %s -b %d %s # 0x%08"PFMT64x"\n", r->bin->curarch.info->arch, r->bin->curarch.info->bits, r->bin->curarch.file, r->bin->curarch.offset); - } + } else eprintf ("No extract info found.\n"); } } r_bin_select (r->bin, r->assembler->cur->arch, r->assembler->bits, NULL);//"x86_32"); @@ -203,13 +201,17 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int mode, ut64 loa r_list_append (r->files, fh); // r_core_bin_load (r, fh->filename); - r_core_block_read (r, 0); cp = r_config_get (r->config, "cmd.open"); if (cp && *cp) r_core_cmd (r, cp, 0); r_config_set (r->config, "file.path", file); r_config_set_i (r->config, "zoom.to", loadaddr+fh->size); fh->map = r_io_map_add (r->io, fh->fd->fd, mode, 0, loadaddr, fh->size); + + //r_config_set_i (r->config, "io.va", 0); + r_core_block_read (r, 0); + //r_core_bin_load (r, NULL); // XXX: unnecessary call? + //r_core_block_read (r, 0); return fh; } diff --git a/libr/include/r_print.h b/libr/include/r_print.h index 4fdee83308..291aad1309 100644 --- a/libr/include/r_print.h +++ b/libr/include/r_print.h @@ -65,6 +65,10 @@ R_API int r_print_date_w32(struct r_print_t *p, const ut8 *buf, int len); R_API int r_print_date_unix(struct r_print_t *p, const ut8 *buf, int len); R_API void r_print_zoom(RPrint *p, void *user, RPrintZoomCallback cb, ut64 from, ut64 to, int len, int maxlen); R_API void r_print_progressbar(RPrint *pr, int pc, int _cols); + +// WIP +R_API int r_print_unpack7bit (const char *src, char *dest); +R_API int r_print_pack7bit (const char *src, char *dest); #endif #endif diff --git a/libr/lib/t/Makefile b/libr/lib/t/Makefile index 6be690baad..01dd0177dc 100644 --- a/libr/lib/t/Makefile +++ b/libr/lib/t/Makefile @@ -1,5 +1,7 @@ BINDEPS=r_lib r_util +include ../../config.mk + all: plugin.${EXT_SO} test-plugin${EXT_EXE} plugin.${EXT_SO}: diff --git a/libr/print/Makefile b/libr/print/Makefile index 0bfe943a40..53e31d44ed 100644 --- a/libr/print/Makefile +++ b/libr/print/Makefile @@ -1,5 +1,5 @@ NAME=r_print DEPS=r_cons r_util r_asm r_anal -OBJ=print.o format.o date.o disasm.o +OBJ=print.o format.o date.o disasm.o seven.o include ../rules.mk diff --git a/libr/print/format.c b/libr/print/format.c index 3fdcfe8a94..6afb956e09 100644 --- a/libr/print/format.c +++ b/libr/print/format.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2007-2011 pancake */ +/* radare - LGPL - Copyright 2007-2012 pancake */ #include "r_cons.h" #include "r_util.h" diff --git a/libr/print/seven.c b/libr/print/seven.c new file mode 100644 index 0000000000..88ae1e3fb1 --- /dev/null +++ b/libr/print/seven.c @@ -0,0 +1,62 @@ +/* radare - LGPL - Copyright 2012 pancake */ +#include + +// TODO: work in progress + +#if 0 +for(i=0; i> shift; + ch2 = src[(i+1)] & 0x7F; + ch2 = ch2 << (7-shift); + + ch1 = ch1 | ch2; + + j = strlen(dest); + sprintf (tmp, "%x", (ch1 >> 4)); + dest[j++] = tmp[0]; + sprintf (tmp, "%x", (ch1 & 0x0F)); + dest[j++] = tmp[0]; + dest[j++] = '\0'; + if (7 == ++shift) { + shift = 0; + i++; + } + } + return 0; +} + +R_API int r_print_unpack7bit (const char *src, char *dest) { + int i, j, shift = 0, len = strlen (src); + ut8 ch1, ch2 = '\0'; + char buf[8]; + + *dest = '\0'; + + for (i=0; i> shift)) << shift) | ch2; + dest[j++] = '\0'; + ch2 = ch1 >> (7-shift); + + shift++; + } + return 0; +} diff --git a/r2-bindings/node-ffi/Makefile b/r2-bindings/node-ffi/Makefile index e7f2366cc6..40c71bf74e 100644 --- a/r2-bindings/node-ffi/Makefile +++ b/r2-bindings/node-ffi/Makefile @@ -5,3 +5,13 @@ FORCE_SOEXT=1 SAVED=test.js test2.js include ../rules.mk + +npm: + rm -rf node_modules/r2 + mkdir -p node_modules/r2 + ${MAKE} + cp package.json node_modules/r2/ + cp r_core.js node_modules/r2/index.js + sed -e 's,./r_asm,r2,' test.js > node_modules/r2/test.js + sed -e 's,./r_asm,r2,' test2.js > node_modules/r2/test2.js + npm publish diff --git a/r2-bindings/node-ffi/package.json b/r2-bindings/node-ffi/package.json index cd2cab175b..243bc88f75 100644 --- a/r2-bindings/node-ffi/package.json +++ b/r2-bindings/node-ffi/package.json @@ -1,7 +1,7 @@ { "name": "radare2.js", "version": "0.0.1", "url": "http://www.radare.org", - "description": "automatic radare2 bindings for nodejs", + "description": "radare2 valabind-ffi bindings for nodejs", "dependencies": { "node-ffi": "0.5" }, diff --git a/r2-bindings/node-ffi/test2.js b/r2-bindings/node-ffi/test2.js index 72a508d173..ed64934489 100644 --- a/r2-bindings/node-ffi/test2.js +++ b/r2-bindings/node-ffi/test2.js @@ -2,14 +2,22 @@ var r2 = require ("./r_core") var c = new r2.RCore () var cons = new r2.RCons (c.cons) +var config = new r2.RConfig (c.config) var ret = c.file_open ("test2.js", false, 0); if (ret.pointer.address != 0) { - //console.log ("ret = ", ret); - c.bin_load ("test2.js"); // if not called it will not work XXX must fix - c.seek (0, true); - c.block_read (0); + //c.bin_load ("test.js"); + // c.seek (0, true); c.block_read (0); + //c.cmd0 ("S 0x00000000 0x00000000 0x00013b30 0x00013b30 ehdr rwx"); c.cmd0 ("o"); + c.cmd0 ("e io.va"); + cons.flush (); +console.log ("sections {"); + c.cmd0 ("om"); + c.cmd0 ("S"); + cons.flush (); +console.log ("}"); +c.block_read (0); c.cmd0 ("pD 8"); c.cmd0 ("? 33+4"); c.cmd0 ("x@0"); diff --git a/r2-bindings/vapi/r_config.vapi b/r2-bindings/vapi/r_config.vapi index 66f8efed25..73ed447395 100644 --- a/r2-bindings/vapi/r_config.vapi +++ b/r2-bindings/vapi/r_config.vapi @@ -3,6 +3,7 @@ namespace Radare { [Compact] [CCode (cprefix="r_config_", cname="RConfig", free_function="r_config_free")] public class RConfig { + public RConfig (); //TODO: public void setup_file(string file); public bool lock; public int last_notfound;