Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pdf" truncates the printout of disassembly if function has unreachable instructions #7473

Closed
FrankLorenz opened this issue May 11, 2017 · 4 comments

Comments

@FrankLorenz
Copy link

I analyzed and patched the IOLI crackme's with radare2. When I patched an executable so it jumps over several lines of assembly, making it "unreachable" (dead code), I observed that r2 will no longer print out the whole disassembly of the function with pdf @ sym.function but omit the printout of the lower part.

Because the number of printed lines corresponds to the "realsz" value on afi command, I assume the bug is to use the "realsz" value instead of the "size" value when calculating the range to print out.

@FrankLorenz
Copy link
Author

FrankLorenz commented May 11, 2017

crackme_sample.zip

Added binary -- ZIP password is "crackme"

To reproduce, just do:

> aa
> pdf @ sym.check

You can see that "realsz" differs from "size":

[0x080483d0]> afi @ sym.check
#
offset: 0x080484c8
name: sym.check
size: 106
realsz: 48
stackframe: 44
call-convention: cdecl
cyclomatic-cost : 21
cyclomatic-complexity: 2
bits: 32
type: sym [NEW]
num-bbs: 3
edges: 3
end-bbs: 0
call-refs: 0x08048384 C 0x08048526 J 0x08048484 C 0x080484dc J 
data-refs: 0x00000008 0x00000013 
code-xrefs: 
in-degree: 0
out-degree: 2
data-xrefs: 
locals:2
args: 1
var int local_ch @ ebp-0xc
var int local_8h @ ebp-0x8
arg int arg_8h @ ebp+0x8
diff: type: new

@chairkov
Copy link
Contributor

@radareorg @FrankLorenz just a regression test for different size, Thanks for the hint.

#!/bin/sh
for a in . .. ../.. ../../.. ; do [ -e $a/tests.sh ] && . $a/tests.sh ; done

NAME='ELF: IOLI - crackme0x05'
FILE=../../../bins/elf/ioli/crackme0x05
ARGS=
CMDS="aa ;afi @sym.check|head -5|tail -2| awk '{print $2}'| sort -u| wc -l"
EXPECT='1
'
run_test

@radare
Copy link
Collaborator

radare commented May 13, 2017 via email

@radare
Copy link
Collaborator

radare commented May 13, 2017 via email

@radare radare closed this as completed in 0327540 May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants