Commit Graph

5129 Commits

Author SHA1 Message Date
pancake
026ccc7202 Add help for VV_ and VVF 2016-08-16 01:37:38 +02:00
pancake
2498a61ebe Fix #5524 - Add 'F' and '_' in graph 2016-08-16 01:32:44 +02:00
pancake
b5e57379cd Implement pxd8 and fix warnings 2016-08-16 01:14:02 +02:00
pancake
61b7f4af37 Fix #4195 - Remove r_cons dependency from r_flags 2016-08-16 00:59:31 +02:00
radare
93cb2941d3 Merge pull request #5527 from crorvick/cr/fix-backward-seek
Fix backward seek
2016-08-16 00:40:59 +02:00
Alexandru Caciulescu
bc5eff1a16 Fix false positives for LoadConst + optimize Nop pattern (#5515) 2016-08-16 00:40:17 +02:00
Chris Rorvick
9b47635f0c remove `next' param from r_core_block_read()
This was originally used to cause a seek to the next block prior to
reading such that successive calls to r_core_block_read() would progress
through memory one block at a time.  This was broken, though, by commit
452669d941 ("more cleanup in r_core_block_read") when when it used
`next' to directly calculate the offset rather than via a seek.

Only one call site remains that attempts to read the next block instead
of the current, and this probably was not even observable due to the
"hacky fix" added in commit 3bfa61946e ("Cleaner pvj, fix tinype load,
and honor 'ao N's").

The current of semantics of `next' appear to be broken and there is very
little dependence on it.  If the original behavior should be restored
anywhere, it would be much better to add a new function, or just do the
seek explicitly, rather than parameterizing r_core_block_read() on it.
2016-08-15 14:26:58 -05:00
Chris Rorvick
97cea63435 fix backwards seek
Commit 57b199789d ("Reread block after undo seek. Fixes dbg.status
issue") reads the *next* block into the buffer rather than the current.
This breaks backwards seeking as can be seen in the following example:

  $ r2 -N malloc://0x4000
  [0x00000000]> b 64
  [0x00000000]> wb 38
  [0x00000000]> s 64
  [0x00000040]> wb deadbeef
  [0x00000040]> s-32
  [0x00000020]> px
  - offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
  0x00000020  dead beef dead beef dead beef dead beef  ................
  0x00000030  dead beef dead beef dead beef dead beef  ................
  0x00000040  0000 0000 0000 0000 0000 0000 0000 0000  ................
  0x00000050  0000 0000 0000 0000 0000 0000 0000 0000  ................
  [0x00000020]> s+16
  [0x00000030]> px
  - offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
  0x00000030  3838 3838 3838 3838 3838 3838 3838 3838  8888888888888888
  0x00000040  dead beef dead beef dead beef dead beef  ................
  0x00000050  dead beef dead beef dead beef dead beef  ................
  0x00000060  dead beef dead beef dead beef dead beef  ................

The first block to a string of ASCII '8' bytes and the second to
0xdeadbeef.  We then seek backwards 32 bytes from our current 64 byte
offset but a dump at the resulting offset shows data from half way into
the second block (i.e., offset 0x60.)  Dumping again after seeking 16
bytes forward shows the expected last bit of the first block.  Clearly
the intent was to reread the current block, not the next block, after an
undo or backward seek.

NOTE: The above example will only work after applying the previous
commit as rereading the buffer when displaying the prompt hides this
bug.

Additionally, since the commit intended to reread the buffer only after
an undo seek, do not do this at all on a backward seek.
2016-08-15 14:00:39 -05:00
Pankaj Kataria
ad3034067e Added av command for listing virtual tables 2016-08-15 20:57:56 +02:00
pancake
f671097ea7 Fix #5526 - Save function local flags in projects 2016-08-15 20:47:46 +02:00
Chris Rorvick
486fd32949 remove hacky fix
Commit 3bfa61946e ("Cleaner pvj, fix tinype load, and honor 'ao N's
help") added a hack to reread the current block when printing the
prompt.  This has the drawback of causing scripts loaded via the `-i'
command line option to potentially behave differently than reading the
commands via stdin.  Remove the hack and fix the bugs.
2016-08-15 13:06:07 -05:00
Ahmed Mohamed Abd El-MAwgood
213c6f29d1 Fixing some aftm bugs and null dereferences (#5521) 2016-08-15 17:34:12 +02:00
Ahmed Mohamed Abd El-MAwgood
d0fb42aa46 Fixing Invalid address at var display (#5523) 2016-08-15 17:33:27 +02:00
Ahmed Mohamed Abd El-MAwgood
12dbe30cbb Fixing coverity CIDs (#5516)
fix CID 1361617
Resource leaks (RESOURCE_LEAK)
/libr/core/tp.c: 148 in stack_clean()
 Var iable "str" going out of scope leaks the storage it points to.

fix CID 1361612
Null pointer dereferences (NULL_RETURNS)
/libr/core/tp.c: 178 in r_anal_type_match()
Dereferencing a null pointer "op".

fix CID 1361611
/libr/anal/var.c: 112 in r_anal_var_retype()
/libr/anal/var.c: 125 in r_anal_var_retype()
Dereferencing a null pointer "fcn".

fix CID 1361610
Incorrect expression (IDENTICAL_BRANCHES)
/libr/core/cmd_anal.c: 1616 in __anal_reg_list()
Dereferencing null pointer "fcn".
2016-08-15 09:54:25 +02:00
Ahmed Mohamed Abd El-MAwgood
397790250c Update types databases 2016-08-15 08:50:46 +02:00
pancake
d001066eb4 Support longer wopD.. still not complete 2016-08-15 01:40:34 +02:00
pancake
e1b94b8343 Update sdb to fix an overflow in the base64 decoder 2016-08-15 01:02:05 +02:00
pancake
deb05ed383 Honor cfg.bigendian in wopO for debrujn patterns 2016-08-14 23:49:13 +02:00
Alexandru Caciulescu
2b35ce2ed4 Fix undeclared variable error (#5512)
Undeclared variable "i" at line 2215.
2016-08-14 23:24:32 +02:00
pancake
6c9af2e690 Fix #4841 - Restricted r2 shell thing 2016-08-14 19:55:54 +02:00
pancake
be220ec038 Fix VRR on windows issues 2016-08-14 19:29:59 +02:00
pancake
3654e5f33b Fix regression in reg.type=flg 2016-08-14 19:12:52 +02:00
pancake
6e478431dd Fix 4 warnings (unused stuff) in cmd_search_rop 2016-08-14 02:30:31 +02:00
pancake
f60597b2ee Fix ar 1 to honor RReg.Type.flg 2016-08-14 02:23:47 +02:00
Alexandru Caciulescu
e652a18469 Implement Arithmetic Pattern matching for ROP classification
* /R can now classify nop gadgets
* MovRegs and LoadConst pattern classification for /R
* Moved classification logic in separate file
* Adding Arithmetic Pattern classification for /R (work in progress)
2016-08-14 02:08:40 +02:00
Ahmed Mohamed Abd El-MAwgood
52da64becc Fix for function name decorators (oridinal, sym.blablabla) (#5488)
implemented function guess matched name which finds longest function name in sdb_types that is substring of the current function name
2016-08-14 02:07:43 +02:00
Ahmed Mohamed Abd El-MAwgood
4f413e7720 initial support for type matching (#5480)
Enabling stepping over
Basic (sym.imp.*) call catching routines
Fixing esil tracing bug and verbosity
Adding some apis for handling function prototypes and abstacting sbd queries
Fixing the double execusion bug in esil tracing
passing types into vars for `stack`
fixing trailing spaces
doing the regester branch
doing the stack_rev
2016-08-13 12:09:14 +02:00
Paul
52656941fe r_core_print_disasm_json fix (#5479)
* r_core_print_disasm_json fix
2016-08-10 21:10:00 +02:00
Álvaro Felipe Melchor
dc5673ec3a Fix regression with the arm/thumb changes (#5464)
Now we build a list of ranges (RAnalRange) based on anal hints to handle the
bits in a better way in the case of arm/thumb

Now instead of asm.bits that rules the whole binary we can define ranges with
anal hints
2016-08-10 18:49:44 +02:00
Alexandru Caciulescu
72e58c2e01 /R gadget classification patches for #5397 (#5448)
* /R can now classify nop gadgets
* MovRegs and LoadConst pattern classification for /R
* Moved classification logic in separate file
2016-08-09 17:24:25 +02:00
pancake
a2d9300d77 Fix #5339 - Projects now work with r2pipe 2016-08-09 12:53:34 +02:00
pancake
059ad1a51c Differentiate methods from functions in objc parser 2016-08-09 01:40:12 +02:00
Ahmed Mohamed Abd El-MAwgood
ad1565d9e4 few enhancements for afv FIX #5459 (#5461)
replacing afv[bsr]n  with afvn
replacing negative sign `n` with `_`
being consistent across the documentations (args + locals = vars)
refactoring code
2016-08-09 00:17:42 +02:00
@bezjaje
4e71ff36fe Honor endiannes and size too in reference values in disasm (#5469) 2016-08-08 23:40:56 +02:00
javierprtd
56636c8d09 Update dmh 2016-08-08 18:42:18 +02:00
pancake
b39fb26264 Add $Fb and $Fs to handle basicblock address and size 2016-08-08 13:32:23 +02:00
pancake
e8464e6d75 Honor endian in reference values in disasm 2016-08-08 11:35:03 +02:00
pancake
e866c76147 Fix #5432 - Implement pdrj 2016-08-08 11:07:05 +02:00
pancake
3fe30f5c35 Fix #5450 - Implement 'n' key in VV graph to rename function 2016-08-08 10:56:47 +02:00
pancake
0777232b1b Rename core/bin.c as cbin.c to avoid confussion with bin/bin.c 2016-08-08 10:45:49 +02:00
pancake
3e5f636869 Fix Vcdn to rename local vars - reported by @ret2libc 2016-08-08 01:00:47 +02:00
Álvaro Felipe Melchor
b8363bc5cc another fix due to regression 2016-08-07 19:58:34 +02:00
Álvaro Felipe Melchor
9f1deb5be6 try again to fix the regression 2016-08-07 19:27:50 +02:00
Álvaro Felipe Melchor
32335f7635 fix regression 2016-08-07 19:16:02 +02:00
Álvaro Felipe Melchor
b765f0e786 Fix #4639 - Problem with arm32 2016-08-07 18:00:40 +02:00
Álvaro Felipe Melchor
0bc983027f improve arm/thumb in elf file format and disasm 2016-08-07 17:38:34 +02:00
Roman Valls Guimerà
33c6d01531 [AVR] First approach to afCl/cdecl for AVR (#5453)
* First approach to afCl/cdecl. Thanks @oddcoder.
* Remove compilers that do not exist for AVR
* Remove unnecessary platform-specific code since 'cc-arch-bits' should be already a stable convention.
* Typo on the afC way
2016-08-07 17:14:14 +02:00
Ahmed Mohamed Abd El-MAwgood
5adf93a570 fixing aek- (#5454)
according to `ae?`,  aek- is used to delete all esil->stats key/value pairs, but it wasn't actually implemented.
2016-08-07 17:08:52 +02:00
pancake
b53a7bb84b Fix regression in AFR related to io_is_valid 2016-08-07 14:08:13 +02:00
pancake
a4ff60743f Follow fcn calls one step further WIP 2016-08-07 09:17:05 +01:00
pancake
2113751573 Fix some false positives in aad using the API instead of r2cmd 2016-08-05 14:41:59 +02:00
Ahmed Mohamed Abd El-MAwgood
4668bc5ea3 Adding nonull (#5441) 2016-08-05 13:35:44 +02:00
pancake
53e9e91b4c Increase rafind2 -ZS wide and do not run aad in aaa 2016-08-05 00:30:56 +02:00
pancake
5b189ee595 Fix #5447 - Implement aO command 2016-08-04 23:52:30 +02:00
Maijin
9a404b6d9c Add rowlog for aad in aaa 2016-08-04 14:26:30 -07:00
pancake
3ca1d5653c Add 'aad' to analyze data refs which are actually code 2016-08-04 22:53:18 +02:00
pancake
f840836af8 Add aad command to analyze data refs as code (LEA) 2016-08-04 22:52:33 +02:00
pancake
9fda59e26d Only use ~/.config/radare2/prefix/bin 2016-08-03 14:03:09 +02:00
pancake
d179c06af3 Support wide strings in rafind2 -ZS 2016-08-03 01:17:27 +02:00
Álvaro Felipe Melchor
a99d53357d Fix #5352 - Endianness problems for wopO command 2016-08-02 23:22:34 +02:00
pancake
4a190d770c Some anal cleanup and aim for the fwdjmp bb issue 2016-08-01 18:41:07 +02:00
pancake
d917902b4e Fix #5427 - ao[n] shows same bytes on all instructions 2016-08-01 16:18:24 +02:00
pancake
7b0622f85d Fix latest covs 2016-08-01 14:46:17 +02:00
pancake
5174f8f624 Fix #5436 - uninitialized var in izz 2016-08-01 14:19:51 +02:00
pancake
8e45f6248c Fix #5425 - Code cleanup and refactor 2016-08-01 13:58:14 +02:00
Alexandru Razvan Caciulescu
61518c2646 xrefs dir path fix 2016-08-01 12:55:47 +02:00
pancake
1e38b4521e Fix null deref in RBin.Symbol.bind 2016-08-01 12:36:20 +02:00
Moritz Eckert
143d2c3791 Fix #4965. Add support for luhn searching and hashing. 2016-08-01 12:34:54 +02:00
Maijin
f211c68095 Remove afg 2016-07-31 11:55:09 +02:00
pancake
8c8887846d Fix absolute path resolution in rop.db 2016-07-30 14:47:00 +02:00
Dario B
d23f3fc97d #5179 and TODO about avoid forks (#5401)
* removed some forks

* a bit of refactoring

* done test and fix bug

* fix code style
2016-07-30 14:29:49 +02:00
Alexandru Caciulescu
adeb5b524b Implemented save/restore rop.db for projects (#5414) 2016-07-30 14:28:45 +02:00
Ahmed Mohamed Abd El-MAwgood
7c8414f585 FIX #5392 display values of args and locals in debugger (#5417) 2016-07-29 19:35:34 +02:00
Eugene
ef8daed816 Fixes #5389 - Add aflqj 2016-07-29 19:34:43 +02:00
Moritz Eckert
e1efde0b1c Fix #5338 - Add ability to start RAP server in background. (#5416) 2016-07-29 19:32:27 +02:00
Alexandru Caciulescu
34147cd121 /Rk command for rop queries (#5403) 2016-07-28 15:05:38 +02:00
pancake
f2ac0a1d52 Enhance ignore call warning message and minor refactor in mach0 entitlements parser 2016-07-28 11:33:53 +02:00
Alexandru Caciulescu
fd76792386 All /R commands cache gadgets and use rop.db (#5398) 2016-07-27 16:19:33 +02:00
Ahmed Mohamed Abd El-MAwgood
2dbb3d8fc6 Calling convention profiles in SDB (#5358) 2016-07-27 13:50:14 +02:00
pancake
9b053064fd Fix dmp command for OSX and make it work with 1 parm instead of 3 2016-07-26 16:54:18 +02:00
pancake
2a2226978e Fix dmi on OSX and minor cydia tweak 2016-07-26 15:17:07 +02:00
pancake
085a156a86 Fix #5334 - add support to analyze interrupt handler functions 2016-07-25 20:15:50 +02:00
pancake
e829c007fd Fix #5371 - format string in blocksize error 2016-07-25 18:50:14 +02:00
Paul
6b9bc8560e iS[j|*|q] [hash] fix 2016-07-25 14:48:49 +02:00
Kodoque1
e582ab8dbb Correction for #5349 (#5369)
* q[y/n][y/n] options added

* Adding crowell remarks

* checking beginning whitespace and fixing else if

* updated

* cleaning update
2016-07-25 10:37:51 +02:00
pancake
6dfba715b1 Fix #5361 - realtime hexview edit mode 2016-07-25 05:14:48 +02:00
Álvaro Felipe Melchor
d52dfbdfe6 added help message into pv 2016-07-22 00:48:52 +02:00
Owlz
1d97857b67 Adding "8" modifier in doc
Adding in reference to the "8" modifier for pv.
2016-07-22 00:20:09 +02:00
Álvaro Felipe Melchor
8059f4be23 fix build 2016-07-21 23:15:52 +02:00
Álvaro Felipe Melchor
01fe87d467 fix coverity and some coding style 2016-07-21 22:56:58 +02:00
Álvaro Felipe Melchor
b2cd7fb23c improve thumb/arm detection 2016-07-20 23:07:07 +02:00
Maijin
b7d7593342 Add wcj 2016-07-19 23:55:36 +02:00
Ahmed Mohamed Abd El-MAwgood
67af958e63 FIX #5324 vars/args display 0 in afi and afll and add in aflj 2016-07-19 21:50:55 +02:00
diouziou
39907cd94a Typo Update cmd_write.c
Typo Added a missing )
2016-07-19 16:22:00 +02:00
Maijin
5c4b292f77 Fix #5325 Decide OR and remove unnecessary help 2016-07-18 00:59:16 +02:00
Maijin
9026c6b8b3 Fix #5340 ij command with debugging open 2016-07-18 00:39:03 +02:00
Maijin
1c744dea96 Fix #5342 dbg_file in PE breaks json output 2016-07-18 00:34:09 +02:00
Sushant Dinesh
aee2a7de95 aflj displays at information (#5330) 2016-07-15 03:21:09 +05:30
Jeffrey Crowell
951f110524 fix build 2016-07-13 00:41:38 -04:00
Jeffrey Crowell
b89bde9df9 reindent cmd_debug.c and fix tons of memleaks 2016-07-13 00:35:13 -04:00
Álvaro Felipe Melchor
7a2f32c281 compile dmh only with linux 2016-07-12 23:04:32 +02:00
javierprtd
07f0502c98 new commands dmh 2016-07-12 23:04:32 +02:00
Maijin
0c1dba02f1 Remove duplicate crc32c, crc32 from fileinfo 2016-07-12 23:03:11 +02:00
Maijin
c274afe748 Fix #3286 - Use stdbool.h 2016-07-12 22:15:19 +02:00
Kodoque
574e74e89a q[y/n][y/n] options added 2016-07-12 21:50:25 +02:00
monosource
b21603cfeb libr/core/cmd_debug: using r_core_cmd_help for "de" 2016-07-12 21:31:42 +02:00
monosource
bb79c50024 core/cmd_log: Fixed T description 2016-07-12 21:24:55 +02:00
Jeffrey Crowell
3c3775b3d0 fix broken build ( 2016-07-09 01:50:06 -04:00
Jeffrey Crowell
e65ceb5dee fix some memory leaks reported by coverity 2016-07-09 01:41:56 -04:00
Ahmed Mohamed Abd El-MAwgood
46b0e3f48e fixing windows types (#5308) 2016-07-08 11:06:36 +02:00
n4☠0r
b353733041 dmhc update (#5311)
* dmhc update: chunk flags and data dump support
2016-07-08 11:00:38 +02:00
Eugene
eb6702b254 Added missed lines&sorted (#5307) 2016-07-07 23:02:27 +02:00
Ahmed Mohamed Abd El-MAwgood
5586355bb8 autoloading windows types when file is windows executable (#5304)
and few other adjustements
2016-07-07 00:14:06 +02:00
pancake
e971fd810e Implement dmh* and fix some indents in previous commit 2016-07-06 23:59:29 +02:00
n4x0r
2a84841a67 dmhc feature for dmh extension update (#5302) 2016-07-06 23:41:43 +02:00
pancake
887897e02b Fix cmd_rop tests 2016-07-06 01:05:07 +02:00
pancake
f345656ec6 Fix cmd_search 2016-07-06 00:20:42 +02:00
Maijin
8cefeeb7b6 Add @o help 2016-07-06 00:02:49 +02:00
pancake
a3f818f7e0 Add rop.db and remove the misuse of asm.esil in /Rl 2016-07-05 23:42:08 +02:00
Álvaro Felipe Melchor
bc218f8b26 change int to const bool config_get_i rop search 2016-07-05 23:38:59 +02:00
pancake
0f8a5c8635 Fixes and enhancements for the previous commits 2016-07-05 23:25:16 +02:00
Alexandru Razvan Caciulescu
8434da3f2a ESIL output for /Rl command (and save gadgets in SDB) 2016-07-05 23:11:08 +02:00
Álvaro Felipe Melchor
79601b4949 dmh - show heap info (#5251) 2016-07-05 22:48:48 +02:00
Ahmed Mohamed Abd El-MAwgood
85dcb19dae fixing type link consumes no bytes (#5288)
implementing initial api for types
Adding types profiles for x86 and x86_64 architectures
2016-07-05 22:44:53 +02:00
pancake
57d7bdfdfc Fix #4928 - Show string context in search results 2016-07-05 22:19:36 +02:00
pancake
f85536ac76 Add agC for full program callgraph
Fix afi indentation issues
2016-07-05 17:37:29 +02:00
Rakholiya Jenish
339a5b7b18 fix iZ and negative o for large files (#5242)
correct the add section check

keep commented part to it's original code

int to ut64

minor fix and limit buffer size in case file size cannot be allocted

remove section check

show size in readable format

minor changes
2016-07-05 12:46:28 +02:00
pancake
ce1ce1cf63 Add +/- for the bit editor 2016-07-05 12:31:25 +02:00
pancake
8532e0c6da Initial implementation of Vd1, the bit editor 2016-07-05 05:25:45 +02:00
pancake
04de3e657f Assume AVR bins have no strings 2016-07-04 16:28:58 +02:00
Rene Laemmert
de37c7d71d removed double quotes from json result for search (#5280) 2016-07-04 13:01:13 +02:00
pancake
87ccfd34f5 Add fi[jn*] command to list flags in range 2016-07-03 22:00:43 +02:00
pancake
fe06f16b44 Add core.iorw in i command (merge fdmode + io.cache 2016-07-03 21:04:50 +02:00
pancake
7436ce01ee ecc [arg] - show color palete in css prefixing the CSS keys 2016-07-03 20:56:44 +02:00
pancake
6361f20f3d Fix indentation in core.config 2016-07-03 20:05:01 +02:00
Anton Kochkov
5cd31d7aa4 Fix help of eco cmd 2016-07-02 21:36:06 +03:00
monosource
cea1c14750 Typo fix "afss-" -> "afvs-" (#5261) 2016-07-01 19:46:01 +02:00
Ahmed Mohamed Abd El-MAwgood
b31dd80724 Args/vars the last commit (#5245)
renaming afa, afv and afe to afvb afvr, and afvs respectively
making arguments analysis obeys e anal.vars
improving the json format for args/vars
fixing varsub to use the new comands for x86 and arm
fixing var commenting commands to use the new commands var configuration
2016-07-01 16:15:29 +02:00
pancake
4c21937caa Reuse 6502 regsize hack for AVR 2016-07-01 15:22:10 +02:00
Jeffrey Crowell
365547ef82 libr/core/yank.c fix memleak 2016-07-01 01:00:06 -04:00
Álvaro Felipe Melchor
0e4e39db79 fix somes coverities 2016-06-30 23:38:41 +02:00
Anton Kochkov
f983244e92 Do not trust input for cmd length 2016-06-30 22:24:38 +03:00
Anton Kochkov
33ec5b9865 Fix coverities
CID 1357120
CID 1357121
CID 1357112
CID 1357099
2016-06-30 22:11:09 +03:00
pancake
98e90dd3cf Implement RSyscall.IO in disasm loop for X86 and AVR 2016-06-29 17:02:43 +02:00
Álvaro Felipe Melchor
4b08d38cb1 more mem leak fixes 2016-06-29 10:11:25 +02:00
Jeffrey Crowell
5317508cdb fix build 2016-06-28 23:54:57 -04:00
pancake
682a255f1d Fix #4665 - Add more core.num.value updates after write ops 2016-06-29 00:52:29 +02:00
pancake
59524ac8c4 Fix #4665 - Add wxs and fix crash in dbg println 2016-06-29 00:41:46 +02:00
Boris
bf6f243498 fix disassembling 'backwards' (#5228)
(e.g. pdj -1) producing wrong output, same as #5105
2016-06-28 23:21:46 +02:00
Jeffrey Crowell
c145740030 replace r_cons_printf("%s\n",p) r_cons_println(p)
move from 10% of code in vfprintf to just 6% \o/ for simple tests of r2
-c "aaa" -q /bin/ls
2016-06-26 00:52:03 -04:00
Jeffrey Crowell
10b9fc1db0 rm unneeded calls to r_cons_printf 2016-06-26 00:17:16 -04:00
pancake
b676e0acb3 Fix #5217 - Add anal.vars variable 2016-06-26 01:52:53 +02:00
Jeffrey Crowell
8f205587ba kill r_cons_puts add r_cons_print/r_cons_println 2016-06-25 13:49:58 -04:00
dx
fe57aefe67 Some memleak fixes in 'agj' (#5213) 2016-06-25 19:43:05 +02:00
pancake
6ace96c3a5 Fix #5160 - make afbj great again 2016-06-25 04:17:31 +02:00
pancake
7e4cb2749e Fix #5002 - @o is a new modifier to temporary switch to another fd 2016-06-25 03:43:32 +02:00
pancake
b9e9d7fe4c Fix #4936 - Verify call destination in aac 2016-06-25 03:37:01 +02:00
pancake
90d42c0418 Refactor pia/pda and implement pdaj and pda= 2016-06-25 03:36:49 +02:00
Joshua J. Drake
722c62827b Major rework to the native debugger (esp on Linux) (#5185)
The major contribution here is completely re-worked breakpoint hit/recoil
handling. This work fixes #4907 and lays the ground work for future native
debugger improvements (multi-threading, etc).

* Give a human friendly type to enums
* Change many wait functions to return RDebugReasonType
* Better return checking (from r_debug_reg_sync, r_bp_restore)
* Optimized register synchronization
* Lots of comments and whitespace changes
* Improved inferior death detection

Handle EXIT_PID events differently than DEAD process events

* Move breakpoint/recoil handling to wait/cont/step

Rather than handing breakpoint related things inside cmd_debug.c, do that
inside the r_debug API functions. This seems like the most logical place for it
to live since it should apply to just about any platform/architecture.  This
also centralizes calling into "cmd.bp" handling via the CoreBind callback.

* Track how the caller wishes to continue

It turns out that handling break point recoils is very complicated. The ptrace
API on Linux returns SIGTRAP for just about every type of operation (not just
breakpoints getting hit). Add the "recoil_mode" flag to indicate whether we are
single-stepping or continuing and whether or not we are inside the recoil.

* Proper handling for swstep=true

Since r_debug_step_soft calls r_debug_continue, it's already hitting the recoil
case there. Move the recoil handling from r_debug_step to r_debug_step_hard
only.

For the swstep=true case, special handling is required inside r_debug_recoil.
By resetting all of the breakpoints except the one we just hit, we ensure we
can step the original instruction and hit the new swstep breakpoint. Add a new
bp function called r_bp_restore_except to do this.

To make matters worse, we cannot use a BreakpointItem pointer because that
leads to a use-after-free condition. Instead, we the breakpoint address
instead.

Now breakpoints should work regardless of the swtep setting.

* Always call the recoil before continuing

Some callers of r_debug_continue might not have ever inserted any breakpoints
before. If we don't restore breakpoints before each call to the underlying
continue we won't hit them.

* Hide software step breakpoint events from the user

When a breakpoint even happens due to a software-step, hide it from the user.
They aren't really breakpoints as far as they are concerned.

* Improve process exit handling on Linux

There are three types of process exiting events on Linux:

1. PTRACE_EVENT_EXIT occurs just before a process exits. It's not possible to
prevent it from exiting, but it can be used to inspect the pre-exit state.
2. The process can exit for a variety of reasons and we can notice when we call
waitpid(2).
3. The process could die randomly on us :-/

On Windows, h->wait will return R_DEBUG_REASON_EXIT_PID, but it's more likely
on Linux to find out the process is already dead.

* Check more bits within waitpid status

We can often make a decision about what happened strictly by looking at the
status returned from waitpid. In other cases, we need to call
r_debug_handle_signals.

If we reach the end of this function without knowing what happened, consider it
an error.
2016-06-22 10:34:45 +02:00
pancake
bc02cdb4b1 Fix regression in afl/afi 2016-06-22 10:29:16 +02:00
pancake
f9482bcae7 Add console.html 2016-06-22 03:19:10 +02:00
Álvaro Felipe Melchor
8b957f8512 fix two uaf in anal.c 2016-06-21 23:32:40 +02:00
pancake
ab5f7bb9ee Update depgraph.pl 2016-06-21 13:16:00 +02:00
Joshua J. Drake
b03c1e2b3e Improve dkp and drp
Distinguish between "dXX" and "dXXYY" or "dXX?". Treat the latter two the same.
This provides the least surprise to the user when they mistype something.

Improve default handling in arp/drp

* Adds a new command "drp." for showing the register profile size.
* Provides better help for drpXXX commands.
* Provides help in the default case (eg. drpz)
* Fixes indentation
* Provides correct help strings for arp vs. drp

Improve default handling for "dko"

* Rework "dko" handling to simplify
* Use r_core_cmd_help
* Show help when things like "dkox" are used
* Prevent allocation/free when not necessary
2016-06-20 15:28:40 +02:00
Joshua J. Drake
16c27891a0 Switch to r_sys_perror for errors and fix two typos 2016-06-20 15:24:19 +02:00
Ahmed Mohamed Abd El-MAwgood
3bac42eda7 Improving variables on ARM (16, 32, 64) (#5146)
removing argument detection extension used in af now args are seperately detected by afCa
aa = af + afCa
using aliases as well as real registers
rewritten varsub
Fixing some of Arm esil and optimizing them for arg/var detection
2016-06-20 15:22:09 +02:00
pancake
550a91a17e Add asm.leahints to make @defragger happy 2016-06-20 09:46:03 +02:00
pancake
4caafc964d Refactor r_io, while fixing some bugs and use more RList 2016-06-20 00:29:41 +02:00
pancake
81c977c979 Refactor r2 -iL and add oL (load plugins before r2 -L) 2016-06-19 23:32:58 +02:00
Maijin
1117f5e19c Fix #3874 2016-06-19 12:30:30 +02:00
pancake
59f63e5f8d Handle Windows's noreturn call to ExitProcess 2016-06-19 12:26:58 +02:00
ekse
60220bc525 Check that a required argument was passed for a couple of commands. (#5166) 2016-06-17 23:17:24 +02:00
pancake
e2ab783250 Fix for regression in thumb/arm detection 2016-06-17 23:05:13 +02:00
pancake
016f5ec8ed Fix arm on thumb bins issue 2016-06-17 19:38:37 +02:00
pancake
3b0b7db100 Fix another oobread caused by callconv 2016-06-17 18:42:50 +02:00
pancake
bfa8eb740a Optimize callconv and fix two bugs related to op_pos 2016-06-17 18:38:25 +02:00
monosource
dc61e8c511 Change afbr description (#5163)
`afbr`'s description isn't worded properly. It doesn't actually print addresses of `ret` instructions, but of instructions which cause the flow of the program to leave the function body, like `call`, `jmp`, `hlt` etc.
2016-06-17 14:26:46 +02:00
pancake
1629dd2b64 Remove two unused fields in RAnalOp and some deadcode 2016-06-17 14:26:24 +02:00
pancake
3bbb4d098b Refix CDIV deoptimization 2016-06-17 12:37:18 +02:00
pancake
f96f00d62d Fix #5158 - Merge r_db into r_util 2016-06-17 12:19:16 +02:00
Joshua J. Drake
0431a0efdf Properly handle forks on Linux 2.5.46+ (#5153)
Linux 2.5.46 made changes to the ptrace(2) API to inform a tracer when various
events occur. These are known as PTRACE_EVENTs. Start handling PTRACE_EVENTs
by:

 * Handling PTRACE_EVENT_FORK and PTRACE_EVENT_EXIT
 * For _FORK, stores the newly created pid in dbg->forked_pid
 * Add the "dpc" command to select the most recently forked child process.
 * Add the "dpc*" command to show the recently forked process' pid.

Additional minor changes to white space are included.

NOTE: This partially addresses #3549. It does handleLinux before 2.5.46.
2016-06-17 04:20:18 +02:00
Joshua J. Drake
9f570114c7 Add "clone" to the "dcf" command (#5161)
Previously, "dcf" didn't not consider that "clone" may be used to create child
processes. Look for that and also update the text shown to the user.
2016-06-17 04:19:31 +02:00
pancake
911fef209a Implement afbr and * sub-variants to list return addresses of current function 2016-06-17 02:50:01 +02:00
Joshua J. Drake
9c21df9272 Minor cleanups to process handling (#5152)
* Fixed 'dpk' handling (signal wasn't being groked)
* Mostly comments added
* Some eprintfs added
2016-06-17 01:59:10 +02:00
pancake
ac2a80a1ef Fix bugs in CDIV implementation 2016-06-16 23:48:01 +02:00
Joshua J. Drake
691dd0a5c5 Make "dbt" output aligned to columns based on dbg->bits (#5151)
* Make "dbt" output aligned to columns based on dbg->bits
* Add spaces between sizeof and paren
2016-06-16 22:57:44 +02:00
UsusDei
5e7c93fc37 Add asm.hints and handle CDOV deoptimization
CDIV deoptimization
===================

This patch implements hints in the disassembler that
aim to assist the user in reading compiler-optimized divisions
by analysing the involved magic number.

Background
==========

Since integer divisions are usually very expensive on most architectures,
compilers try very hard to substitute them with cheaper operations.

One of the more advanced substitutions is described in the book __Hacker's Delight__,
chapter 10.
An actual implementation of the described algorithm in LLVM can be found in the
functions: `TargetLowering::BuildSDIV()` and `APInt::magic()`.

The optimization approximately transforms e.g.

```asm
xor edx, edx
idiv 39
```

into

```asm
mov eax, edi
mov edx, 0xd20d20d3
imul edx
lea eax, [rdx + rdi]
sar edi, 0x1f
sar eax, 5
sub eax, edi
```

Reading the optimized version and __seeing__ the constant 39 seems difficult.
Therefore I try to provide a small hint to the user.

Limitations
===========

* The current implementation only takes the magic number into account,
  therefore it may result in false positives.

* Due to the nature of the optimization, the given hint may be off by a power of two.
  Fixing this would require to analyse the following shift instructions.

* The hint is only shown in the line containing the magic number.
  The user still has to know which of the following instructions belong to the optimization.

TODO
====

* Implement the corresponding analysis for unsigned integers

* Implement the corresponding analysis for 64-bit integers.

* Improve the heuristic by also looking at the next few instructions.
  ( I don't really know how to iterate over the instructions in the disassember
  in a non-deprecated way. Maybe someone can drop me a hint? )

* Implement an exact analysis using the actual dataflow in radeco and use it
  to revert the optimization. ( I suppose this is outside the scope of radare )
2016-06-16 22:22:58 +02:00
Joshua J. Drake
285cd3b32f Minor tweaks to breakpoint handling
* Fix "dbm" help string
* Save <module>+<offset> as the name when using dbm
* Fix allocation patterns for "module"
* Remove commented out code
* White space fixes
2016-06-16 12:36:17 +02:00
Jeffrey Crowell
2f6d778aef cleanup usages of r_str_newf to meet style guide 2016-06-15 19:42:03 +00:00
pancake
84aa6782f1 Add trailing newline in afbj 2016-06-15 13:41:45 +02:00
Riccardo Schirone
04190287c1 core: fix uber confusing indentation in cmd_anal "afl" command 2016-06-15 11:15:42 +02:00
pancake
1bdcb740dc Fix regressions introduced in last commit 2016-06-15 00:23:44 +02:00
pancake
e032a48cbe Fix latest 26 COVs 2016-06-14 23:47:58 +02:00
Álvaro Felipe Melchor
7fa01a72ed add breakpoints into project file 2016-06-14 23:34:42 +02:00
robbje
a772452d27 Cgs (#5126)
* refactor function listing code

* adhere to style guide

* use tabs instead of spaces

* recover default behaviour for afi commands

* work in commentary and fix the two regression tests I broke

* some more cosmetic changes

* shorten function names
2016-06-14 17:54:17 +02:00
pancake
e4af7f9b23 Fixes for ELF/Thumb detection handling 2016-06-14 14:36:03 +02:00
pancake
21a01d08fe Fix warnings in debug.linux.coredump 2016-06-10 04:20:28 +02:00
pancake
702394caf9 Fix string flags realignment in disasm 2016-06-14 01:52:46 +02:00
pancake
56af25e5b5 Update r_core_sysenv_end 2016-06-14 01:33:46 +02:00
pancake
eda7899adc Various enhancements to aae 2016-06-14 01:30:40 +02:00