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

function detection doesn't find callbacks f. eg. CreateThread, SetWindowsHookEx, etc. #5890

Open
pinkflawd opened this issue Sep 30, 2016 · 15 comments
Labels
RAnal Windows Microsoft Windows platform support issues
Projects

Comments

@pinkflawd
Copy link
Contributor

Function detection misses callback functions in Windows binaries, found to be true at least for CreateThread callback handlers and SetWindowsHookEx handlers.

Below, 0x1000282d should be a function address, but is handled as dword.

0x10002080      50             push eax
0x10002081      53             push ebx
0x10002082      ff75d4         push dword [ebp - local_2ch]
0x10002085      682d280010     push 0x1000282d
0x1000208a      53             push ebx
0x1000208b      53             push ebx
0x1000208c      ff1574400010   call dword [sym.imp.KERNEL32.dll_CreateThread] ; sym.imp.KERNEL32.dll_CreateThread
@radare
Copy link
Collaborator

radare commented Oct 4, 2016

can you share a sample bin?

@pinkflawd
Copy link
Contributor Author

@trufae
Copy link
Collaborator

trufae commented Oct 4, 2016

i dont see the same disasm at that offset. i mostly find refs to data in pushes, not code

@pinkflawd
Copy link
Contributor Author

oh right different binary. here a SetWindowsHookEx call is located in pdf @ 0x10012536, the callback thats not detected is 0x10013318:

0x10012550      50             push eax
0x10012551      6818330110     push 0x10013318
0x10012556      6a03           push 3
0x10012558      ff15a4820110   call dword [sym.imp.USER32.dll_SetWindowsHookExW] ; sym.imp.USER32.dll_SetWindowsHookExW
0x1001255e      eb13           jmp 0x10012573

also CreateThread is present in 0x1000f974:

0x1000fb12      8b3d34810110   mov edi, dword [sym.imp.KERNEL32.dll_CreateThread] 
0x1000fb18      8d45f0         lea eax, [ebp - local_10h]
0x1000fb1b      50             push eax
0x1000fb1c      6a04           push 4
0x1000fb1e      53             push ebx
0x1000fb1f      688fff0010     push 0x1000ff8f
0x1000fb24      53             push ebx
0x1000fb25      53             push ebx
0x1000fb26      ffd7           call edi

hope that helps

@radare radare closed this as completed in 3c22cbf Oct 4, 2016
@Maijin
Copy link
Contributor

Maijin commented Oct 4, 2016

I Don't see changes:

image

image

@Maijin Maijin reopened this Oct 4, 2016
@radare
Copy link
Collaborator

radare commented Oct 4, 2016

Use afr or aa

On 04 Oct 2016, at 21:11, Maijin [email protected] wrote:

I Don't see changes:


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

@radare
Copy link
Collaborator

radare commented Oct 4, 2016

And u have to analize to get anything in the disasm

On 04 Oct 2016, at 21:11, Maijin [email protected] wrote:

I Don't see changes:


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

@Maijin
Copy link
Contributor

Maijin commented Oct 4, 2016

It's analysed

@Maijin
Copy link
Contributor

Maijin commented Oct 4, 2016

image

image

@Maijin Maijin added the RAnal label Oct 13, 2016
@pinkflawd
Copy link
Contributor Author

Works, in a sense, when I issue an 'afr' command for each function where I suspect indirectly referenced code. This way I go through my binaries, get all the functions that e.g. contain a CreateThread, then 'afr' these again to have radare generate functions for the thread handler function.
Thats cool.
Would there be a way to add this analysis to e.g. aaa command, so callbacks are analyzed automatically? With my method, by definition, I always miss something.

@radare
Copy link
Collaborator

radare commented Oct 13, 2016

aa should run afr but the problem is that its probably analizing in different order and overlapping some functions.

you can try to set e anal.calls=true before aa and see if that solves the problem if not you can also do this:

e anal.hasnext=true
aac; afr;afr @@ sym*

sorry i have not much time lately to look deeper on this issue

On 13 Oct 2016, at 12:47, pinkflawd [email protected] wrote:

Works, in a sense, when I issue an 'afr' command for each function where I suspect indirectly referenced code. This way I go through my binaries, get all the functions that e.g. contain a CreateThread, then 'afr' these again to have radare generate functions for the thread handler function.
Thats cool.
Would there be a way to add this analysis to e.g. aaa command, so callbacks are analyzed automatically? With my method, by definition, I always miss something.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub #5890 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-lq21IS278VmOZDE60w8e6nuSfbXcks5qzgxfgaJpZM4KLDSd.

@pinkflawd
Copy link
Contributor Author

Awesome :D Second option works like charm :) Thanks a lot!
The pic is on top before, bottom is after, works like graph face lift ^^ 8 more functions found

comparison

@trufae
Copy link
Collaborator

trufae commented Oct 19, 2016

😍😍😍

On 14 Oct 2016, at 16:46, pinkflawd [email protected] wrote:

Awesome :D Second option works like charm :) Thanks a lot!
The pic is on top before, bottom is after, works like graph face lift ^^ 8 more functions found

https://cloud.githubusercontent.com/assets/5487036/19391603/a3dc5794-922d-11e6-927d-327b676cae71.png

You are receiving this because you commented.
Reply to this email directly, view it on GitHub #5890 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AGIjG8vaZTFBYu0ePJRen0ILf_MwkyHHks5qz5W3gaJpZM4KLDSd.

@stale stale bot removed the stale label Jun 22, 2020
@ret2libc
Copy link
Contributor

This has not received any activity in the last years. Was the issue fixed? If not, could you share a reproducer (the one listed has a password)?

@Maijin
Copy link
Contributor

Maijin commented Jun 29, 2020

Always same password "infected".

@XVilka XVilka added this to To do in Analysis via automation Jul 1, 2020
@XVilka XVilka added the Windows Microsoft Windows platform support issues label Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RAnal Windows Microsoft Windows platform support issues
Projects
Analysis
  
To do
Development

No branches or pull requests

6 participants