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

Cross references are broken in rebased binaries #5905

Open
oddcoder opened this issue Oct 3, 2016 · 16 comments
Open

Cross references are broken in rebased binaries #5905

oddcoder opened this issue Oct 3, 2016 · 16 comments

Comments

@oddcoder
Copy link
Contributor

oddcoder commented Oct 3, 2016

$> r2 challenge1.exe
[]>aaa
[]>iz ~pass                                                                                                                                                   
vaddr=0x0040d198 paddr=0x0000bf98 ordinal=001 sz=18 len=17 section=.rdata type=ascii string=Enter password:\r\n                                                      
vaddr=0x0040d1b8 paddr=0x0000bfb8 ordinal=003 sz=17 len=16 section=.rdata type=ascii string=Wrong password\r\n  
[]>axt 0x0040d198                                                                                                                                              
data 0x40144e push str.Enter_password:_r_n in sub.KERNEL32.dll_GetStdHandle_420  

$ r2 -B 0xfd0000 challenge1.exe
[]>aaa
[]>iz ~pass                                                                                                                                                   
vaddr=0x00fdd198 paddr=0x0000bf98 ordinal=001 sz=18 len=17 section=.rdata type=ascii string=Enter password:\r\n                                                           
vaddr=0x00fdd1b8 paddr=0x0000bfb8 ordinal=003 sz=17 len=16 section=.rdata type=ascii string=Wrong password\r\n 
[]>axt 0x00fdd198

this is the used binary
challenge1.exe.zip

@Maijin Maijin added the bug label Oct 20, 2016
@Maijin Maijin added this to the 3.3.0 milestone Jan 12, 2019
@Maijin Maijin changed the title aan and cross references are broken in rebased windows binary Ccross references are broken in rebased binaries Jan 12, 2019
@Maijin Maijin changed the title Ccross references are broken in rebased binaries Cross references are broken in rebased binaries Jan 12, 2019
@radare radare modified the milestones: 3.3.0, 3.4.0 - aprils Feb 7, 2019
@radare
Copy link
Collaborator

radare commented Mar 18, 2019

i think @ret2libc fixed this, can you confirm?

@ret2libc
Copy link
Contributor

I'm honestly not sure I did... or when. But please re-test the reproducer :)

@oddcoder
Copy link
Contributor Author

oddcoder commented Mar 18, 2019

nope, not fixed, actually addresses failed to relocate and triggered an issue in afta as well

➜  Downloads r2 -B 0xfd0000 challenge1.exe
[0x00fd170d]> aaa
[x] Analyze all flags starting with sym. and entry0 (aa)
[x] Analyze function calls (aac)
[x] Analyze len bytes of instructions for references (aar)
[Stack isn't initialized.s for all functions (aaft)
Try running aei and aeim commands before aft for default stack initialization
Stack isn't initialized.
[.. bunch of failing to initialize stacks ...]
Try running aei and aeim commands before aft for default stack initialization
Stack isn't initialized.
[x] Type matching analysis for all functions (aaft)
[x] Use -AA or aaaa to perform additional experimental analysis.
[0x00fd170d]> iz~pass
001 0x0000bf98 0x0040d198  17  18 (.rdata) ascii Enter password:\r\n
003 0x0000bfb8 0x0040d1b8  16  17 (.rdata) ascii Wrong password\r\n
[0x00fd170d]> axt 0x0040d1b8
[0x00fd170d]> axt 0x00fdd198

@radare
Copy link
Collaborator

radare commented Mar 19, 2019 via email

@radare
Copy link
Collaborator

radare commented Apr 15, 2019

Will be fixed with #13753. Do you wanna work on it? or at least write some tests when its implemented?

@oddcoder
Copy link
Contributor Author

sure I can unit test it once it is implemented just mention me in the PR, right now I can't see a pr for it

@radare radare modified the milestones: 3.5.0, 3.6.0 May 9, 2019
@radare
Copy link
Collaborator

radare commented May 9, 2019

enotime for this rls

@radare radare modified the milestones: 3.6.0, 3.8.0 - after r2con Jun 17, 2019
@radare radare modified the milestones: 3.9.0, 4.0.0 Sep 15, 2019
@radare radare modified the milestones: 4.0.0, 4.1.0 Oct 23, 2019
@radare
Copy link
Collaborator

radare commented Oct 23, 2019

can you provide a test?

@oddcoder
Copy link
Contributor Author

I have a trigger explained above ^ and the binary file as well

@radare
Copy link
Collaborator

radare commented Jan 17, 2020

cc @yossizap

@yossizap
Copy link
Contributor

Will look into it

@radare
Copy link
Collaborator

radare commented Jan 19, 2020

@yossizap 12h left for the release. any update on this?

@yossizap
Copy link
Contributor

yossizap commented Jan 19, 2020

Sorry, didn't have a ton of time. This is a PE specific issue.

imageBase = bin->nt_headers->optional_header.ImageBase;
if (!imageBase) {
//this should only happens with messed up binaries
//XXX this value should be user defined by bin.baddr
//but from here we can not access config API
imageBase = 0x10000;
}
return imageBase;

It uses the baddr from the header instead of using the actual binaddr. Attempting to fix.

@radare
Copy link
Collaborator

radare commented Jan 19, 2020

thanks

@yossizap
Copy link
Contributor

yossizap commented Jan 19, 2020

That was a separate issue that was misleading. Can't really find any other differences specific to PEs that deal with baddr. This will require more time, maybe I'll be able to find something tomorrow morning.

Not an issue in debug rebase btw, just with this type of rebase.

EDIT: Also, not an issue with other windows binaries. This seems to be specific to something in that binary.

@radare radare modified the milestones: 4.3.0, 4.4.0 Mar 2, 2020
@radare
Copy link
Collaborator

radare commented Mar 2, 2020

see the new rb command (needs to implement anal things)

@radare radare modified the milestones: 4.4.0 - pangolin, 4.5.0 Apr 12, 2020
@XVilka XVilka modified the milestones: 4.5.0 - Organized Chaos, 4.6.0 Jun 3, 2020
@radare radare modified the milestones: 5.3.0, 5.4.0 May 24, 2021
@radare radare modified the milestones: 5.4.0, 5.5.0 Jul 25, 2021
@trufae trufae removed this from the 5.6.0 milestone Jan 21, 2022
@trufae trufae removed the bug label Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants