<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-100631565877005209</id><updated>2011-04-21T16:07:33.342-07:00</updated><title type='text'>I Just Don't Cut It To Be L33T</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://imnot1337.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/100631565877005209/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://imnot1337.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Relentless L33t</name><uri>http://www.blogger.com/profile/13935458650505608250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-100631565877005209.post-755115045191571212</id><published>2007-08-13T03:29:00.000-07:00</published><updated>2007-08-13T18:09:43.844-07:00</updated><title type='text'>F-Secure Khallenge '07 @ Assembly,Helsinki Finland</title><content type='html'>Well lately I have nothing really useful to post so I guess I'll post about F-Secure's Assembly Challenge 2007.&lt;br /&gt;&lt;br /&gt;Binaries can be downloaded from http://www.f-secure.com/security_center/asm.html&lt;br /&gt;&lt;br /&gt;Here are among the few tools which could prove useful&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.vortex.prodigynet.co.uk/misc/ascii_conv.html"&gt;Ascii-hex-dec-bin converter&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.freedownloadscenter.com/Programming/Misc__Programming_Tools/OllyDbg.html"&gt;Ollydbg&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Question 1 :&lt;br /&gt;This here is a classic example of 'If you don't know how to get pass this, don't bother already!'&lt;br /&gt;But for enlightenment's sake I'll post with clues on how to pass this level. Don't get me wrong, I'm not trying to discourage anyone from proceeding with this challenge(s) but it's simply a phrase to illustrate how dead simple this binary is. I will list out the steps.&lt;br /&gt;&lt;br /&gt;1) Run the executable.&lt;br /&gt;&lt;br /&gt;2) What did you realize&lt;br /&gt; - Looks like a console program (duh)&lt;br /&gt; - It has some input streams --&gt; a key&lt;br /&gt; - Seems to authenticate something . At some point it has to compare something, be it a constant, encrypted string or something else.&lt;br /&gt; - It outputs a string right after it authenticates.&lt;br /&gt;&lt;br /&gt;3) From the way I look at it, there are several ways with solving this challenge. If you're using          Ollydbg like me, a noteworthy thing to do would probably be checking out string constants...&lt;br /&gt;&lt;br /&gt; - Okay looking for strings probably wasn't as helpful, but definitely yield something                        interesting. If you look closely enough you could see something along the lines of&lt;br /&gt;    "Congratulations,!Please send an email to ThisIs%s@khallenge.com x0Dx0A"&lt;br /&gt; - From here we know the string is not visible but has a memory buffer holding the remainder        of the string we want to extract which is probably %s string identifier.&lt;br /&gt;&lt;br /&gt;4) Now, you can either trace the program from start or ... Since we already know it's receiving some input and storing it in the buffer at some point, let's just hit f9 on ollydbg and run it till it waits for user input.&lt;br /&gt;&lt;br /&gt;5) At this point, the program should keep running and wait for user input. You might want to hit f-12 now to stop ollydebug while you input an arbitrary value into the input field and wait for the values to pop up on your memory. Upon keying in your arbitrary string (which is 'aaaa' in my case) and hitting enter on your console where you input, you should see you are now in ntdll's memory section. What you might want to do is hit alt-f9 and let ollydbg execute till user code.&lt;br /&gt;&lt;br /&gt;6) From here on you might want to hit f8 all the way till you see something like&lt;br /&gt;690010BF  68 10330069      PUSH FSC_Leve.69003310                                        ; /s2 = "Asm07REC"&lt;br /&gt;690010C4  68 A0310069      PUSH FSC_Leve.690031A0                                       ; |s1 = "aaaa"&lt;br /&gt;690010C9  FF15 88200069 CALL DWORD PTR DS:[&lt;&amp;amp;MSVCR71._stricmp&gt;]&lt;br /&gt;&lt;br /&gt;At this point i think the key is a dead giveaway. But assuming you don't want to re-run the program you could always&lt;br /&gt;&lt;br /&gt;i ) change the memory location to which it stores the buffer for scanf and modify that memory location.&lt;br /&gt;ii) Switch the zero flag on&lt;br /&gt; 690010D4  |. /75 1D         JNZ SHORT FSC_Leve.690010F3&lt;br /&gt; So that it doesn't take the jump and goes into the part where we saw the string                             "Congratulations ...."&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question 2 :&lt;br /&gt;&lt;br /&gt;One interesting point here is the way the anti debugging code was done. Some people might not even realize there is some form of anti-debugger in this piece of code. To start off I will Illustrate some concepts of this program as far as my understanding goes.&lt;br /&gt;&lt;br /&gt;The way the anti debugger in this binary was coded utilizes the TLS (Thread Local Storage) method so as to prevent debuggers like ollydbg (If i'm not mistaken ring-3 debuggers) to only have a break point on the entry point of the main program which can be referenced from &lt;a href="http://www.openrce.org/reference_library/files/reference/PE%20Format.pdf"&gt;OpenRCE's PE File Format Graph&lt;/a&gt; which is labeled as a DWORD : AddressOfEntryPoint in the _IMAGE_OPTIONAL_HEADER.&lt;br /&gt;&lt;br /&gt;The TLS structure however is located in _IMAGE_TLS_DIRECTORY_. If your computation was correct, the TLS address location should be in 004070CC.&lt;br /&gt;Based on that we refer to the _IMAGE_TLS_DIRECTORY_ and if we looked at the 4th Double Word in the struct, we should see a PIMAGE_TLS_CALLBACK *AddressOfCallBacks.&lt;br /&gt;So from there we have to compute 4 DWORD locations from the offset of 0x4070cc which is the value 0x004070F0.&lt;br /&gt;We then turn our attention to the memory location 0x004070F0 which is the value 0x004070A4.&lt;br /&gt;And then... we look at the memory location 0x004070A4 in the disassembler window. Voila! Looks like some code in ere.&lt;br /&gt;&lt;br /&gt;Here is the code dump for the TLS callback function.&lt;br /&gt;004070A4    837C24 08 01        CMP DWORD PTR SS:[ESP+8],1&lt;br /&gt;004070A9    75 1E                       JNZ SHORT FSC_Leve.004070C9&lt;br /&gt;004070AB    50                            PUSH EAX&lt;br /&gt;004070AC    64:A1 18000000  MOV EAX,DWORD PTR FS:[18]&lt;br /&gt;004070B2    8B40 30                  MOV EAX,DWORD PTR DS:[EAX+30]&lt;br /&gt;004070B5    0FB740 02             MOVZX EAX,WORD PTR DS:[EAX+2]&lt;br /&gt;004070B9    83F8 00                  CMP EAX,0&lt;br /&gt;004070BC    0F94C0                   SETE AL&lt;br /&gt;004070BF    6BC0 08                  IMUL EAX,EAX,8&lt;br /&gt;004070C2    2805 BD634000    SUB BYTE PTR DS:[4063BD],AL&lt;br /&gt;004070C8    58                             POP EAX&lt;br /&gt;004070C9    C3                             RETN&lt;br /&gt;&lt;br /&gt;If you know your way around kernel32's API you should be able to quickly identify that from the memory address functions 004070AC - 004070B5 are excerpts of code taken from kernel32.IsDebuggerPresent. What it does then is checks if there is a debugger attached to the program from the Process Environment Block (PEB) flag and then Subtracts 8 From the memory location 4063BD if there is no debugger present.&lt;br /&gt;&lt;br /&gt;At this point you might want to already change memory location 0x4063BD with the value FFFFAF99 to FFFFAF91 to fool the binary into thinking you don't have an attached debugger.&lt;br /&gt;&lt;br /&gt;Now let's go back to the main function of the program. We can tell that this binary is packed with UPX. So we scroll down right to the last operand at&lt;br /&gt;004063BC   .- E9 99AFFFFF   JMP FSC_Leve.0040135A&lt;br /&gt;&lt;br /&gt;Hit f4 to execute till that memory location 004063BC and hit f7 again to step into that jump.&lt;br /&gt;&lt;br /&gt;We could then immediately see we have&lt;br /&gt;00401352    33DB                    XOR EBX,EBX&lt;br /&gt;00401354    68 5A134000     PUSH FSC_Leve.0040135A&lt;br /&gt;00401359    C3                         RETN&lt;br /&gt;&lt;br /&gt;Zero-ing out EBX will then have later repercussions to the program yielding out proper results instead of fuzzy incorrect ones.&lt;br /&gt;That said let's execute it further.&lt;br /&gt;&lt;br /&gt;We can see later at memory address&lt;br /&gt;0040137D    FF25 5C304000   JMP DWORD PTR DS:[40305C]&lt;br /&gt;There is a direct jump to Kernel32.GetCommandLineA to parse the execution parameter for this binary. We could almost tell that the outcome of this binary is reliant on input parameters.&lt;br /&gt;&lt;br /&gt;Long story short at&lt;br /&gt;004011EC    35 6D562855     XOR EAX,5528566D&lt;br /&gt;&lt;br /&gt;we could see it XOR's the hex equivalent of your ascii input parameter with the mask 5528566D which results in the value 6578652E.&lt;br /&gt;&lt;br /&gt;The anti debugging part earlier which will affect the outcome is then demonstrated here with this particular instruction&lt;br /&gt;&lt;br /&gt;004011F1    30FC            XOR AH,BH&lt;br /&gt;&lt;br /&gt;At this point if your EBX is not zero-ed out, you will get a pseudorandomly XOR-ed AH which will affect the third character of your whole input parameter. Which is why some people out there are wondering why their 3rd input parameter is always changing.&lt;br /&gt;&lt;br /&gt;Execute it further and you will realize you will get answer which is&lt;br /&gt;&lt;br /&gt;Congratulation!&lt;br /&gt;Please send an e-mail to LuckyNumberIs_30503343_FSC@khallenge.com&lt;br /&gt;30503343 being the hex equivalent of your ascii input parameter.&lt;br /&gt;&lt;br /&gt;The last solution will be posted sometime soon when I gather enough energy to blog it up. However it won't be as straight forward as the first two so I will not spend too much time on trivial and simple methodologies and concepts but focus more on the challenge at hand.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/100631565877005209-755115045191571212?l=imnot1337.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imnot1337.blogspot.com/feeds/755115045191571212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=100631565877005209&amp;postID=755115045191571212' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/100631565877005209/posts/default/755115045191571212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/100631565877005209/posts/default/755115045191571212'/><link rel='alternate' type='text/html' href='http://imnot1337.blogspot.com/2007/08/f-secure-khallenge-07-assemblyhelsinki.html' title='F-Secure Khallenge &apos;07 @ Assembly,Helsinki Finland'/><author><name>Relentless L33t</name><uri>http://www.blogger.com/profile/13935458650505608250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
