Recently , one of my friends told me that this task is really challenging as it contains some anti-reversing related stuff . So, I wanted to give it a try .
I grabbed the binary and threw it in olly and .....Ooops ..it just quits immediatly .
At first , I was stuck for minutes .because the binary is supposed to be landing on the entry point .
Then after googling up , I figured out that the moment when the debugger attaches to it the binary purposefully hits the ret instructions because of the TLS callback .
Well TLS stands for Thread Local Storage , it is section that resides in an executable that contains data variables particular to each thread and addresses of some functions (callbacks ) .
The windows loader ensures that the TLS section gets executed before it reaches the OEP of the program . Due to the fact that TLS gets executed first , task author managed to add some anti-debugging code in it ,therefore the debugger will not have a chance to hit the entry point .
To work this out , we need to use TLScatch plugin by waleed assar , which is used to set a breakpoints on TLS callbacks ,so that the debugger would be able to stop on the callback functions.
I re-opened the binary in olly and to started to check its behaviour .I noticed the presence of some anti-debugging techniques have been implemented in it .
At first , It gets the PEB (Process Environment Block) structure as it contains a value that indicates whether the binary is being debugged or not .
We can simply bypass it by setting EAX value to zero . So let's carry on and see the next anti-debug trick .
Well , a well trained eye will know that these consecutive calls is an indication of an anti-debug mechanism that will set SYSTEM_INFORMATION_CLASS parameter to ProcessDebugPort value.
Once again , just change the value of EAX in order to get over it .
This is yet another anti-debug technique was made . It obtains the value of NtglobalFlag by getting the PEB through TIB(Thread Information Block ).
After reaching the code section we will see a bunch of CALL instructions was created for obfuscation puposes , one of them is really interesting (0x00401070) which seems to print a string with a xor-decryption loop .
Having executed that function , 0x004010C0 routine displayed the Flag .

0 commentaires :
Enregistrer un commentaire