<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>kernelkennel - crackmes</title>
    <subtitle>A small blog against my writeups, learnings and non-sponsored views on a whole bunch of things around security.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://kernelkennel.com/tags/crackmes/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://kernelkennel.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-07-08T15:00:00+00:00</updated>
    <id>https://kernelkennel.com/tags/crackmes/atom.xml</id>
    <entry xml:lang="en">
        <title>CrackMe2 by Pride</title>
        <published>2025-07-08T15:00:00+00:00</published>
        <updated>2025-07-08T15:00:00+00:00</updated>
        
        <author>
          <name>
            
              noblenote
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://kernelkennel.com/posts/crackme2/"/>
        <id>https://kernelkennel.com/posts/crackme2/</id>
        
        <content type="html" xml:base="https://kernelkennel.com/posts/crackme2/">&lt;h1 id=&quot;crackme2-by-pride&quot;&gt;CrackMe2 by Pride&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#crackme2-by-pride&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h1&gt;
&lt;p&gt;2025-07-08&lt;&#x2F;p&gt;
&lt;p&gt;First post! Here is my write up against the CrackMe2 binary by Pride, now kept on crackmes.one, previously *.de.&lt;&#x2F;p&gt;
&lt;p&gt;When opening the program itself, we&#x27;re greeted with three major prompts and inputs:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Asking for your name and inputting (it can take a string),&lt;&#x2F;li&gt;
&lt;li&gt;Asking for a serial (which is asked to be a whole number),&lt;&#x2F;li&gt;
&lt;li&gt;Asking for a master-serial, which seems to be a second stage serial.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Couldn&#x27;t seem to get much further than that when putting in a long string or a large number in either of these prompts and we&#x27;ll play by the rules and assume the serial needs a number &lt;em&gt;truly&lt;&#x2F;em&gt; before fudging around with it.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s open this up in OllyDbg to understand the assembly, the underlying structure of the program we&#x27;re running!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;enter-now&quot;&gt;Enter NOW&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#enter-now&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;When attaching OllyDbg as a debugger to the .exe, we have a very quaint start with not much of interest:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;PUSH EBP
MOV EBP, ESP
SUB ESP,8
MOV DWORD PTR SS:[ESP], 1
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We&#x27;re setting up the stack pointer and growing the stack.&lt;&#x2F;p&gt;
&lt;p&gt;Not too much is interesting here and we have a CALLs ahead of us with no idea if we have anything juicy yet or just a bunch of obfuscations, so let&#x27;s simply &lt;code&gt;step-over&lt;&#x2F;code&gt; to jump out of anything distressing until we can&#x27;t go any further because the program is pending out input into the buffer.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s set a breakpoint after this call (address &lt;code&gt;0x401448&lt;&#x2F;code&gt;) where we enter a name and then &lt;code&gt;step-over&lt;&#x2F;code&gt; to continue.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;For the rest of this writeup you&#x27;ll see that simply setting a breakpoint after a call that stops us because the program is pending input is a great initial move to understand what the program is doing.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;what-is-this-string-up-to&quot;&gt;What is this string up to&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#what-is-this-string-up-to&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;If we now &lt;code&gt;step-in&lt;&#x2F;code&gt; a few lines and jump into the CALL on &lt;code&gt;0x401458&lt;&#x2F;code&gt;, and move a bit down the call after inputting our serial, we see that the address &lt;code&gt;0x43C33A&lt;&#x2F;code&gt; is using strlen() and storing this into a DWORD offset from the EBP, interesting... we are getting the length of an inputted string from our &lt;code&gt;name&lt;&#x2F;code&gt; for future use.&lt;&#x2F;p&gt;
&lt;p&gt;On &lt;code&gt;0x40147B&lt;&#x2F;code&gt;, we jump into the CALL for putting in the serial. Let&#x27;s set a breakpoint on the address &lt;em&gt;after this call to step line by line what we are doing!&lt;&#x2F;em&gt; This is at &lt;code&gt;0x401480&lt;&#x2F;code&gt; of course. Another call up ahead, and we will set another breakpoint after it at &lt;code&gt;0x40148B&lt;&#x2F;code&gt; with &lt;code&gt;ADD EAX, 0CA&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Interesting! When breaking at this address before it runs through the addition, where ADD will do the following in pseudocode:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;ADD &amp;lt;into this&amp;gt;, &amp;lt;this value&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;We can see that EAX has been populated with the value of strlen()! For me, this was B (decimal 11), and we&#x27;re adding 0xCA which should go to 0xD5 given 0xB.&lt;&#x2F;p&gt;
&lt;p&gt;The next line is more arithmetic, so let&#x27;s step-into&#x2F;continue execution.&lt;&#x2F;p&gt;
&lt;p&gt;The next line is &lt;code&gt;XOR EAX, 3D8D40F&lt;&#x2F;code&gt;, meaning we now need to perform eXclusive OR against register EAX and 0x3D8D40F. eXclusive OR (XOR) is like a &lt;em&gt;not-equality operation&lt;&#x2F;em&gt;, in that the truth table is going to be as such:&lt;&#x2F;p&gt;
&lt;p&gt;A | B | A XOR B
1 | 0 | 1
1 | 1 | 0
0 | 1 | 1
0 | 0 | 0&lt;&#x2F;p&gt;
&lt;p&gt;Since one value (at EAX) is likely going to be way smaller than 0x3D8D40F (64541711), we&#x27;re going to get something close to this value as all leading bits ahead of our much smaller number will be 0.&lt;&#x2F;p&gt;
&lt;p&gt;Given &lt;code&gt;0xD5&lt;&#x2F;code&gt;, we&#x27;ll get &lt;code&gt;0x3D8D4DA&lt;&#x2F;code&gt; (64541914).
The next lines are interesting in that it is clear we&#x27;ll likely be comparing this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;MOV DWORD PTR SS:[EBP-38], EAX ;storing our result
MOV EAX, DWORD PTR SS:[EBP-30] ;getting a value further down the stack to EAX
CMP EAX, DWORD PTR SS:[EBP-38] ;we are comparing the two values!!!!!!!
JNZ SHORT CrackMe#.004014C6 ; the the apsr flags say its not zero(equal), lets jump
; if not, we can continue to &amp;quot;Gratz&amp;quot;!
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Awesome! So the first serial check is solved. In short:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;- Enter name, any str
- CrackMe checks strlen(name) and stores somewhere
- We get strlen(name) + 0xCA
- This sum is XOR 0x3D8D40F
- Chcked for equality with stored value in EBP-30, which is a constant value.
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now we can get back and do the next keygen! Given this, we can get by with knowing the values for further debugging.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;master-serial&quot;&gt;Master Serial&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#master-serial&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;This one is a lot easier and we can use the same debugging techniques here. Make sure to set a breakpoint on any execution after the address that gets stuck running awaiting input!&lt;&#x2F;p&gt;
&lt;p&gt;We get stuck on &lt;code&gt;0x40152A&lt;&#x2F;code&gt; calls to input the master serial now, and what is interesting without even going in is that we have a very similar set of instructions after we RET from this input call:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;MOV EAX, DWORD PTR SS:[EBP-2C] ; we are getting a value from -2C
ADD EAX, DWORD PTR SS:[EBP-38] ; hey... we&amp;#39;ve seen this guy before....
ADD EAX, 0D75E9 ; add a value to our beautiful EAX
MOV DWORD PTR SS:[EBP-3C], EAX
MOV EAX, DWORD PTR SS:[EBP-34]
CMP EAX DWORD PTR SS:[EBP-3C]
JNZ CrackMe#.00401569
... ; see you space cowboy...
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Hopefully it&#x27;s a little clearer now what we may be doing with some static analysis and with a warmup from our dynamic searching of the first serial.&lt;&#x2F;p&gt;
&lt;p&gt;We are putting back in our first serial that is correct and adding it to EAX which as a value from &lt;code&gt;EBP-2C&lt;&#x2F;code&gt;. We then &lt;code&gt;ADD 0x0D75E9&lt;&#x2F;code&gt; and put it away into &lt;code&gt;EBP-3C&lt;&#x2F;code&gt; for safekeeping before checking it. When running the program, we can see that EBP-2C at &lt;code&gt;0x40152F&lt;&#x2F;code&gt; is a static value of &lt;code&gt;0x183A0&lt;&#x2F;code&gt; So this means in short:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;- MOV 0x183A0 to EAX
- ADD the previous serial to EAX
- ADD 0xD75E9 to EAX
- Put it away for safekeeping
- Pull in EBP-34 which is our &amp;#39;true&amp;#39; master serial
- Check and jump if not equal!
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Easy enough! This one is a lot more easier since this is just addition and some moving around values in the stack.&lt;&#x2F;p&gt;
&lt;p&gt;Simply get the previous correct serial, add &lt;code&gt;0x183A0&lt;&#x2F;code&gt; (99232) and &lt;code&gt;0xD75E9&lt;&#x2F;code&gt; (882153) and we&#x27;re in business!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;keygen&quot;&gt;Keygen&lt;a class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;#keygen&quot; hidden=&quot;&quot;&gt;#&lt;&#x2F;a&gt;
&lt;&#x2F;h3&gt;
&lt;p&gt;Lovely simple keygen for this one, but great fun doing a little easy practice on x86 ASM. Let&#x27;s put all we know into use now in a tidy script:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;def main():
	name = input()
	nameLen = int(len(name))
	serial1 = nameLen + 0xCA
	serial1 = serial! ^ 0x3D8D40F
	print(&amp;quot;First Serial: &amp;quot; + serial1)
	serial2 = serial1 + 0x186A0 + 0xD75E9
	print(&amp;quot;Second Serial&amp;quot; + serial2)

if __name__ == &amp;quot;__main__&amp;quot;:
	main()
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This was a great little crackme, if a bit simple!&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
