{"id":238,"date":"2017-05-04T14:31:46","date_gmt":"2017-05-04T14:31:46","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=238"},"modified":"2024-02-16T10:16:58","modified_gmt":"2024-02-16T10:16:58","slug":"software-cracking-example-1","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=238","title":{"rendered":"Software Cracking (Example 1)"},"content":{"rendered":"<p><strong>0. Building<\/strong><br \/>\nThe following crackme sourcecode got build with the C compiler from MinGW as PE x86.<\/p>\n<pre class=\"brush: cpp; gutter: false; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main()\r\n{\r\n    char strLicense[] = &quot;l_i_c_e_n_s_e&quot;;\r\n    int intLenLicense = sizeof(strLicense)\/sizeof(strLicense[0]);\r\n\r\n    char strInput[intLenLicense];\r\n    fputs(&quot;Enter the license:&quot;, stdout);\r\n    fgets(strInput, intLenLicense, stdin);\r\n\r\n    if(strncmp(strInput, strLicense, intLenLicense) != 0) {\r\n        fputs(&quot;Trial version&quot;, stdout);\r\n        return 1;\r\n    }\r\n    else\r\n        fputs(&quot;Full version&quot;, stdout);\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>1. Reverse Engineering<\/strong><br \/>\nFor the reverse engineering of the build program is OllyDbg used. The interesting section is shown in the following assembler code.<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n0040166E  MOV DWORD PTR SS:[ESP],a.00404044      ; ||||ASCII &quot;License:&quot;\r\n00401675  CALL &lt;JMP.&amp;msvcrt.fwrite&gt;              ; |||\\fwrite\r\n0040167A  MOV EAX,DWORD PTR DS:[&lt;&amp;msvcrt._iob&gt;]  ; |||\r\n0040167F  MOV EDX,EAX                            ; |||\r\n00401681  MOV EAX,DWORD PTR SS:[EBP-14]          ; |||\r\n00401684  MOV DWORD PTR SS:[ESP+8],EDX           ; |||\r\n00401688  MOV EDX,DWORD PTR SS:[EBP-C]           ; |||\r\n0040168B  MOV DWORD PTR SS:[ESP+4],EDX           ; |||\r\n0040168F  MOV DWORD PTR SS:[ESP],EAX             ; |||\r\n00401692  CALL &lt;JMP.&amp;msvcrt.fgets&gt;               ; ||\\fgets\r\n00401697  MOV EDX,DWORD PTR SS:[EBP-C]           ; ||\r\n0040169A  MOV EAX,DWORD PTR SS:[EBP-14]          ; ||\r\n0040169D  MOV DWORD PTR SS:[ESP+8],EDX           ; ||\r\n004016A1  LEA EDX,DWORD PTR SS:[EBP-22]          ; ||\r\n004016A4  MOV DWORD PTR SS:[ESP+4],EDX           ; ||\r\n004016A8  MOV DWORD PTR SS:[ESP],EAX             ; ||\r\n004016AB  CALL &lt;JMP.&amp;msvcrt.strncmp&gt;             ; |\\strncmp\r\n004016B0  TEST EAX,EAX                           ; |\r\n004016B2  JE SHORT a.004016E3                    ; |\r\n004016B4  MOV EAX,DWORD PTR DS:[&lt;&amp;msvcrt._iob&gt;]  ; |\r\n004016B9  ADD EAX,20                             ; |\r\n004016BC  MOV DWORD PTR SS:[ESP+C],EAX           ; |\r\n004016C0  MOV DWORD PTR SS:[ESP+8],0D            ; |\r\n004016C8  MOV DWORD PTR SS:[ESP+4],1             ; |\r\n004016D0  MOV DWORD PTR SS:[ESP],a.0040404D      ; |ASCII &quot;Trial version&quot;\r\n004016D7  CALL &lt;JMP.&amp;msvcrt.fwrite&gt;              ; \\fwrite\r\n004016DC  MOV EAX,1\r\n004016E1  JMP SHORT a.00401710\r\n004016E3  MOV EAX,DWORD PTR DS:[&lt;&amp;msvcrt._iob&gt;]  ; |\r\n004016E8  ADD EAX,20                             ; |\r\n004016EB  MOV DWORD PTR SS:[ESP+C],EAX           ; |\r\n004016EF  MOV DWORD PTR SS:[ESP+8],0C            ; |\r\n004016F7  MOV DWORD PTR SS:[ESP+4],1             ; |\r\n004016FF  MOV DWORD PTR SS:[ESP],a.0040405B      ; |ASCII &quot;Full version&quot;\r\n00401706  CALL &lt;JMP.&amp;msvcrt.fwrite&gt;              ; \\fwrite\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>2. Solution<\/strong><br \/>\n<u>Patch<\/u><br \/>\nThe easiest solution is to patch the program. The conditional jump for that is at 004016B2 below the important string comparison. Replace this conditional jump with an unconditional jump, cause a jump there leads to the &#8220;Full version&#8221;.<\/p>\n<p><u>Serial<\/u><br \/>\nAnother solution is to find out the requested license key. Set a breakpoint, above the important string comparison, at 004016A8 and start the debugger. The ASCII value in EDX is the license key and the ASCII value in EAX is the entered string.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0. Building The following crackme sourcecode got build with the C compiler from MinGW as PE x86. &nbsp; 1. Reverse<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[39],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/238"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=238"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":16718,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions\/16718"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}