Difference between revisions of "Example 2b"

From SkullSecurity
Jump to navigation Jump to search
Line 5: Line 5:
As usual, esi is a pointer to the cdkey.  
As usual, esi is a pointer to the cdkey.  


<pre>.text:1901B26C                mov    [esp+6FCh+hashKey], 13AC9741h
<pre>
.text:1901B274                mov    ebx, 0Bh
    mov    ebp, 13AC9741h
.text:1901B279
    mov    ebx, 0Bh
.text:1901B279 loc_1901B279:                          ; CODE XREF: sub_1901AA30+887�j
 
.text:1901B279                movsx  eax, byte ptr [ebx+esi]
top:
.text:1901B27E                push    eax            ; int
    movsx  eax, byte ptr [ebx+esi]
.text:1901B27F                call    _toupper
    push    eax            ; Parameter to toupper()
.text:1901B284                add    esp, 4
    call    _toupper       ; Call toupper()
.text:1901B287                cmp    al, 37h
    add    esp, 4         ; Fix the stack (don't worry about this)
.text:1901B289                mov    byte ptr [ebx+esi], al
    cmp    al, 37h
.text:1901B28D                jg      short loc_1901B2A7
    mov    byte ptr [ebx+esi], al
.text:1901B28F                mov    ecx, [esp+6FCh+hashKey]
    jg      short body1
.text:1901B293                mov    dl, cl
    mov    ecx, ebp
.text:1901B295                and    dl, 7
    mov    dl, cl
.text:1901B298                xor    dl, al
    and    dl, 7
.text:1901B29A                shr    ecx, 3
    xor    dl, al
.text:1901B29D                mov    byte ptr [ebx+esi], dl
    shr    ecx, 3
.text:1901B2A1                mov    [esp+6FCh+hashKey], ecx
    mov    byte ptr [ebx+esi], dl
.text:1901B2A5                jmp    short loc_1901B2B6
    mov    ebp, ecx
.text:1901B2A7 ; ---------------------------------------------------------------------------
    jmp    short body2
.text:1901B2A7
 
.text:1901B2A7 loc_1901B2A7:                          ; CODE XREF: sub_1901AA30+85D�j
body1:
.text:1901B2A7                cmp    al, 41h
    cmp    al, 41h
.text:1901B2A9                jge    short loc_1901B2B6
    jge    short body2
.text:1901B2AB                mov    cl, bl
    mov    cl, bl
.text:1901B2AD                and    cl, 1
    and    cl, 1
.text:1901B2B0                xor    cl, al
    xor    cl, al
.text:1901B2B2                mov    byte ptr [esp+ebx+6FCh+cdkey], cl
    mov    byte ptr [ebx+esi], cl
.text:1901B2B6
 
.text:1901B2B6 loc_1901B2B6:                          ; CODE XREF: sub_1901AA30+875�j
body2:
.text:1901B2B6                                        ; sub_1901AA30+879�j
    dec    ebx
.text:1901B2B6                dec    ebx
    jns    short top
.text:1901B2B7                jns    short loc_1901B279
</pre>
</pre>

Revision as of 17:46, 17 November 2008

Stop hand.png This page is under construction. USE AT YOUR OWN RISK!







This is the third (and, basically, final) part of the Starcraft CDKey Decode. I'm going to present the code only, not the answer (although you can find the finished product around). This may cover things we haven't talked about (like a function call and local variables, for example).

As usual, esi is a pointer to the cdkey.

    mov     ebp, 13AC9741h
    mov     ebx, 0Bh

top:
    movsx   eax, byte ptr [ebx+esi]
    push    eax             ; Parameter to toupper()
    call    _toupper        ; Call toupper()
    add     esp, 4          ; Fix the stack (don't worry about this)
    cmp     al, 37h
    mov     byte ptr [ebx+esi], al
    jg      short body1
    mov     ecx, ebp
    mov     dl, cl
    and     dl, 7
    xor     dl, al
    shr     ecx, 3
    mov     byte ptr [ebx+esi], dl
    mov     ebp, ecx
    jmp     short body2

body1:
    cmp     al, 41h
    jge     short body2
    mov     cl, bl
    and     cl, 1
    xor     cl, al
    mov     byte ptr [ebx+esi], cl

body2:
    dec     ebx
    jns     short top