* Added 'pb' command to print in binary form

* Added 'ap' command to search and analyze function preludes
  - x86 only atm.. just as a PoC
This commit is contained in:
pancake 2011-02-12 12:54:26 +01:00
parent f950dcb33c
commit 13b4c2d9f1
6 changed files with 78 additions and 54 deletions

View File

@ -11,5 +11,6 @@ Contributors: (sorted by length)
- elektranox
- neuroflip
- rvalles
- capri_x
- graz
- pof

70
TODO
View File

@ -6,10 +6,9 @@
BINARY INFORMATION
==================
dwarf, pdb, def, lib
load symbols from .lib or .def (find signatures)
.def -> .idt
.lib -> ar2idt
- from file, from section, ...
- load symbols from .lib or .def (find signatures)
.def -> .idt , .lib -> ar2idt
UNDER DEVELOPMENT
=================
@ -17,9 +16,8 @@ UNDER DEVELOPMENT
- ./configure --without-valaswig # compile without generating cxx files
- build with swig/
Visual mode
Random stuff
-----------
* Add print support for bitfields (pb, pm b...)
* For each "call" or "push offset"+"ret" create a function.
- And, if deep code analysis is enabled:
- Search every possible function by searching typical prologs and put them in a queue.
@ -33,22 +31,26 @@ Visual mode
CPUID: Used to detect Virtual Machines and emulators.
// NOP args: NOP with arguments are typical antiemulation tricks.
SYSENTER: Direct system calls. Commonly, used as antiemulation tricks.
* implement aoe = anal op exec
- sync regs or what?
/a ??? deprecated analyze code? srsly?
* Search for wide strings /Z or so? /w maybe?
pancake
-------
* if console width > X place comments there (ash)
* Fix all that shitty r_io maps bugs
* Implement BLOCK in r_core_sysenv_begin|end ()
* comparisions doesnt works (RAnalCond)
* Fix iterators for r_macro (test only?)
* Add support for STATIC_PLUGINS in r_lang
- r_lang_define is implemented in lang.c, but requires the collaboration
of the plugins to properly setup the environment for the script execution.
- Add support for STATIC_PLUGINS in r_lang
- dlerror(/usr/lib/radare2/lang_perl.so): libperl.so: cannot open shared object file: No such file or directory
This issue is fixed by setting LD_LIBRARY_PATH...looks like dlopen ignores rpath
earada
------
* Add print support for bitfields (pm b...)
- r_bin_demangle (); // r_util maybe?
* _ZN7WebCore11CounterNode7recountERKNS_12AtomicStringE
- demangle c++ and objc names
@ -83,6 +85,23 @@ nibble
- do not allow to disassemble unaligned addresses (toggle)
- use 'jk' with bwdisasm to go up to previous opcode.
- r_asm can reduce cpu without disasm on fixed size ops archs.
* Display getsym() stuff in rabin2, not only legit syms
* Check if python plugin works from inside
- write tuto, how to call py code from shell or r2
* dmi command must read from memory if no file path provided
- rabin from memory ftw, to get libnames of dll, so..
* add support for sign/unsigned registers..or at least a way to cast them
* use r_anal_value everywhere
* diff code analysis
- diff two programs
1st level:
- check all functions EQUAL, DIFFERENT, REMOVED, ADDED
- check all symbols
- check all imports
- check all strings
2nd level:
- basic block level diffing (output in graph mode)
0.7 release
===========
@ -110,7 +129,6 @@ nibble
- allow to hook r_asm_disassemble and assemble with custom callbacks
- extend a disassembler with own instructions.
Assembler
---------
* Embed bits/arch/endian in a separated structure
@ -129,12 +147,6 @@ nibble
* Create radare2-testsuite project
- tests for ired, rax2, radare2, rabin2 ...
* Is RCore->block and blocksize a RBuf ? refactor!11
* Add support for STATIC_PLUGINS in r_lang
- r_lang_define is implemented in lang.c, but requires the collaboration
of the plugins to properly setup the environment for the script execution.
- Add support for STATIC_PLUGINS in r_lang
- dlerror(/usr/lib/radare2/lang_perl.so): libperl.so: cannot open shared object file: No such file or directory
This issue is fixed by setting LD_LIBRARY_PATH...looks like dlopen ignores rpath
Things to improve in r2
=======================
@ -157,7 +169,7 @@ Debugger
========
* stepover waits for one unknown event that cannot be stopped
* Implement list threads on ALL supported platforms (win,lin,osx)
* ALL threads must be stopped when a breakpoint is handled..
* All threads must be stopped when a breakpoint is handled..
* Add support for windbg+virtualkd
* Floating point registers
* MMX/XMM/DRX control
@ -181,30 +193,6 @@ pancake
- function signature comparsion if they dont match
r_anal_fcn_cmp (anal, f1, f2);
nibble
------
* Display getsym() stuff in rabin2, not only legit syms
* Check if python plugin works from inside
- write tuto, how to call py code from shell or r2
* dmi command must read from memory if no file path provided
- rabin from memory ftw
- to get libnames of dll, so..
* add support for sign/unsigned registers..or at least a way to cast them
* r_anal
- use r_anal_value everywhere
- x86im
- make x86_x86im the default backend for x86 analysis
* diff code analysis
- diff two programs
1st level:
- check all functions EQUAL, DIFFERENT, REMOVED, ADDED
- check all symbols
- check all imports
- check all strings
2nd level:
- basic block level diffing (output in graph mode)
Questions
=========
* Only use uppercase KMG for Kilo,Mega,Giga in r_num? - 'g' is for double

View File

@ -1622,6 +1622,18 @@ static int cmd_print(void *data, const char *input) {
} else l = len;
switch (input[0]) {
case 'b':
{
char *buf;
int size = core->blocksize * 8;
buf = malloc (size);
if (buf) {
r_str_bits (buf, core->block, size, NULL);
r_cons_printf ("%s\n", buf);
free (buf);
} else eprintf ("ERROR: Cannot malloc %d bytes\n", size);
}
break;
case 'D':
case 'd':
if (input[1]=='f') {
@ -2458,6 +2470,18 @@ static int cmd_anal(void *data, const char *input) {
case 'a':
r_core_anal_all (core);
break;
case 'p':
{
// TODO: this is x86 only
// TODO: allow interruptible search
char *o = strdup (r_config_get (core->config, "search.prefix"));
r_config_set (core->config, "search.prefix", "pre.");
r_core_cmd0 (core, "fs preludes");
r_core_cmd0 (core, "./x 5589e5 && af @@ pre.");
r_config_set (core->config, "search.prefix", o);
free (o);
}
break;
default:
r_cons_printf (
"Usage: a[?obfrgtv]\n"
@ -2649,7 +2673,7 @@ static int cmd_write(void *data, const char *input) {
break;
case 'v':
{
ut64 off = r_num_math(core->num, input+1);
ut64 off = r_num_math (core->num, input+1);
r_io_set_fd (core->io, core->file->fd);
r_io_seek (core->io, core->offset, R_IO_SEEK_SET);
if (off&UT64_32U) {
@ -3148,7 +3172,7 @@ static int cmd_system(void *data, const char *input) {
static int cmd_open(void *data, const char *input) {
RCore *core = (RCore*)data;
RCoreFile *file;
ut64 addr, size;
ut64 addr;
char *ptr;
switch (*input) {

View File

@ -13,7 +13,7 @@ static void print_mem_help(RPrint *p) {
//" D - double (8 bytes)\n"
" f - float value\n"
" b - one byte \n"
" B - show 10 first bytes of buffer\n"
" B - show 10 first bytes of buffer\n" // B must be for binary ??
" i - %%i integer value (4 bytes)\n"
" w - word (16 bit hexa)\n"
" q - quadword (8 bytes)\n"

View File

@ -12,7 +12,7 @@ static const char *nullstr_c = "(null)";
R_API void r_str_subchr (char *s, int a, int b) {
while (*s) {
if(*s==a) {
if (*s==a) {
if (b) *s = b;
else strcpy (s, s+1);
}
@ -21,11 +21,21 @@ R_API void r_str_subchr (char *s, int a, int b) {
}
// TODO: do not use toupper.. must support modes to also append lowercase chars like in r1
// TODO: this functions needs some stabilization
R_API int r_str_bits (char *strout, const ut8 *buf, int len, const char *bitz) {
int i, j, *p = (int*)buf;
for (i=j=0; i<len && bitz[i]; i++) {
if (*p&(1<<i))
strout[j++] = toupper (bitz[i]);
int i, j;
if (bitz) {
for (i=j=0; i<len && (!bitz||bitz[i]); i++)
if (i>0 && (i%8)==0)
buf++;
if (*buf&(1<<i))
strout[j++] = toupper (bitz[i]);
} else {
for (i=j=0; i<len; i++) {
if (i>0 && (i%8)==0)
buf++;
strout[j++] = (*buf&(1<<(7-(i%8))))?'1':'0';
}
}
strout[j] = 0;
return j;
@ -640,7 +650,6 @@ R_API void r_str_argv_free(char **argv) {
free (argv);
}
#if 0
/* XXX this is necessary ??? */
// TODO: make it dynamic
@ -648,8 +657,7 @@ static int bprintf_init = 0;
static char bprintf_buf[4096];
// XXX overflow
R_API int r_bprintf(const char *fmt, ...)
{
R_API int r_bprintf(const char *fmt, ...) {
va_list ap;
if (bprintf_init==0)
*bprintf_buf = 0;
@ -659,8 +667,7 @@ R_API int r_bprintf(const char *fmt, ...)
return strlen(bprintf_buf);
}
R_API char *r_bprintf_get()
{
R_API char *r_bprintf_get() {
char *s;
if (bprintf_init==0)
*bprintf_buf = 0;

View File

@ -10,6 +10,10 @@ static void test(const char *str) {
}
int main () {
char buf[256];
int len = r_str_bits (buf, (const ut8*)"012345", 7*8, NULL);
printf ("%d: %s\n", len, buf);
test (" hello world ");
test ("hello world");
test ("hello \"world\"");