Last active
June 6, 2016 02:43
-
-
Save dumpmycode/e056b43bb07462414b3bc50a41328c59 to your computer and use it in GitHub Desktop.
CDkey2 - skulllsecurity.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;Continuation from previous cdkey asm, this time I try to understand the next variation in asm code. | |
| lea edi, [esi + 0xb] ; edi = address of cdkey[0 + 11], address of 12th digit | |
| mov ecx, 0xc2 ; ecx = 194 | |
| top: | |
| mov eax, ecx ; eax = 194 or 0xc2 | |
| mov ebx, 0xc ; ebx = 12 | |
| cdq ; Convert eax from Double word to Quadruple word. so eax becomes edx:eax | |
| ; this also zero out any value previously in edx. | |
| idiv ebx ; eax / ebx. 194/12. values now becomes eax = 16, edx = 2 | |
| mov al, [edi] ; al = 12th digit hex value | |
| sub ecx, 0x11 ; 0xc2 - 0x11. 194 - 17. ecx = 177 or 0xb1 | |
| dec edi ; edi = cdkey[11 - 1]. edi = address of 11th digit cdkey | |
| cmp ecx, 7 ; is ecx = 7? 177 = 7? | |
| ; this next few instructions basically swap digits around. | |
| mov bl, [edx + esi] ; bl = cdkey [0 + 2] = 3rd digit cdkey hex value | |
| mov [edi + 1], bl ; copy 3rd digit hex value to cdkey[10+1] 12th digit. | |
| mov [edx + esi], al ; copy 12th digit hex value to cdkey[0+2] 3rd digit. | |
| jge top ; if ecx is greater or equal to 7, jump to top. | |
| ; else, continue to next instructions. | |
| #Sample of asm code rewritten in python: | |
| #!/usr/bin/env python | |
| cdkey = raw_input('Enter 13 digit cd key: ') | |
| ecx = 194 | |
| edi = 12 | |
| iter = 0 | |
| while ecx >= 7: | |
| iter += 1 | |
| remainder = ecx % 12 | |
| ecx = ecx-17 | |
| cdkeylist=list(cdkey) | |
| cdkeylist[edi] = cdkey[remainder] | |
| cdkeylist[remainder] = cdkey[edi] | |
| print('#{} Swapping digit position {} with {}. \n{} now becomes {}.\n'.format(iter, edi+1, remainder+1, cdkey, ''.join(cdkeylist))) | |
| edi = edi-1 | |
| cdkey = ''.join(cdkeylist) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment