All’addio di Kratorius
Patching e mazzo

Data

by "pnluck"

 

08/11/2004

UIC's Home Page

Published by Quequero

Qualche frase che ti piace se vuoi, non è obbligatorio

Un giorno l'altro faro' secco te e il word ;p

Qualche frase che ti piace se vuoi, non è obbligatorio

....

Pnluck, #crack-it,#pmode,#cryptorev

....

Difficoltà

( )NewBies (X)Intermedio ( )Avanzato ( )Master

 

Introduzione

Qui spiegerò cm riversare due ottimi crackme di Kratorius, il kratme e l’immagiantion, cmq non farò una descrizione precisa xkè i crackme so due :D

Tools usati

IDA e Ollydbg

URL o FTP del programma

Sezione crackme numero 3

Notizie sul programma

Il kratme mi so messo un paio di ore e ci sono riuscito, invece l’immagination sono bastati ¾ d’ora.

Nel kratme basta patchare un byte(per non NT, mentre per NT 3), mentre per l’immagination dobbiamo fare un img su misura :D

Essay

Kratme 

Iniziamo con il caricare il  kratme nell’IDA ora analizziamo dall’inizio, sono presenti molti op-code, che “fanno fesso” i debug, così vi riporto direttamente il codice disassemblato da me:

.text:00401000 start           proc near  //inizio

.text:00401000                 mov     eax, offset unk_40100A

.text:00401005                 add     eax, 2

.text:00401008                 jmp     eax   //salta a 40100A+2 = 40100C

.text:00401008 start           endp

.text:00401008

.text:00401008 ; ---------------------------------------------------------------------------

.text:0040100A unk_40100A      db  15h ;               ; DATA XREF: starto

.text:0040100B                 db    0 ; 

.text:0040100C ; ---------------------------------------------------------------------------

.text:0040100C                 jmp     short $+2

.text:0040100E                 nop

.text:0040100F                 call    non_fa_nada  //questa call non fa niente, è codice spazzatura

.text:00401014                 jmp     short loc_40101F

.text:00401016 ; ---------------------------------------------------------------------------

.text:00401016

.text:00401016 loc_401016:                             ; CODE XREF: .text:0040101Fj

.text:00401016                 call    salta_di_due //questa call è cm se facesse eip = eip+2

.text:0040101B                 nop

.text:0040101C                 nop

.text:0040101D                 jmp     short loc_401021 

.text:0040101F ; ---------------------------------------------------------------------------

.text:0040101F

.text:0040101F loc_40101F:                             ; CODE XREF: .text:00401014j

.text:0040101F                 jmp     short loc_401016

.text:00401021 ; ---------------------------------------------------------------------------

.text:00401021

.text:00401021 loc_401021:                             ; CODE XREF: .text:0040101Dj

.text:00401021                                         ; DATA XREF: .text:00401127o

.text:00401021                 push    offset aUser32  ; "user32"

.text:00401026                 call    LoadLibraryA

.text:0040102B                 call    non_fa_nada

.text:00401030                 push    offset aUser32  ; "user32"

.text:00401035                 call    GetModuleHandleA 

.text:0040103A                 call    salta_di_due

.text:0040103F                 nop

.text:00401040                 nop

.text:00401041                 push    offset aMessageboxa ; "MessageBoxA"   //carica MessageBoxA

.text:00401046                 push    eax

.text:00401047                 call    GetProcAddress

.text:0040104C                 mov     Message_box, eax  //salva l’handle di MessageBox

.text:00401051                 call    carica_nomi //vedete sotto ↓

________________________________________________________________________________________________________

.text:00401302 sub_401302      proc near               ; CODE XREF: .text:00401051p

.text:00401302                 pop     ebx

.text:00401303                 mov     eax, offset aKratme ; "KratMe"

.text:00401308                 mov     titolo_krat, eax

.text:0040130D                 mov     eax, offset aYourGoalIsToMa ; "Your goal is to make appear the congrat"...

.text:00401312                 mov     finestra_inizio, eax

.text:00401317                 mov     eax, offset aCongratulation ; "Congratulations! You solved this crackm"...

.text:0040131C                 mov     congratulation, eax

.text:00401321                 mov     eax, offset aSomethinkWentW ; "Somethink went wrong"

.text:00401326                 mov     some_error, eax

.text:0040132B                 mov     eax, offset aIThinkThatDebu ; "I think that debugger are useful, but n"...

.text:00401330                 mov     debug_prese, eax

.text:00401335                 jmp     ebx

.text:00401335 sub_401302      endp

//Si capisce da solo, è un smc :D

________________________________________________________________________________________________________

.text:00401056                 push    0

.text:00401058                 push    titolo_krat

.text:0040105E                 push    finestra_inizio

.text:00401064                 push    0

.text:00401066                 call    Message_box          //fa apparire la msg box iniziale

.text:0040106C                 add     esp, 10h

.text:0040106F                 call    p_addr_piu_uno

.text:00401074                 nop

.text:00401075                 push    offset aKernel32 ; "kernel32"

.text:0040107A                 call    GetModuleHandleA

.text:0040107F                 mov     dword_403336, eax

.text:00401084                 push    offset aExitprocess ; "ExitProcess"

.text:00401089                 push    dword_403336

.text:0040108F                 call    GetProcAddress

.text:00401094                 mov     exit_proc, eax   //salva l’handle di ExitProcess

.text:00401099                 push    offset aDebugbreak ; "DebugBreak"

.text:0040109E                 push    dword_403336

.text:004010A4                 call    GetProcAddress

.text:004010A9                 mov     debug_pres, eax //salva l’handle di DebugBreak

.text:004010AE                /push    offset loc_40110F   //carica la seh

.text:004010B3                |push    large dword ptr fs:0 

.text:004010BA                \mov     large fs:0, esp

.text:004010C1                 lea     eax, ds:4012BDh

.text:004010C7                 call    non_fa_nada

.text:004010CC                 mov     byte ptr [eax], 0CCh   //è un smc, ma dato che il codice è solo readable genera un eccezione

.text:004010CF                 lea     eax, ds:40110Fh

.text:004010D5                 cmp     byte ptr [eax], 0CCh

.text:004010D8                 jnz     short loc_4010E3

Spero che avete capito tutto, cmq arrivati all’eccezione, dobbiamo analizzare il suo gestore che è a 40110f:

.text:0040110F loc_40110F:                             ; DATA XREF: .text:004010AEo

.text:0040110F                 lea     eax, ds:40332Ah    

.text:00401115                 cmp     byte ptr [eax], 0CCh  //compara [40332a] con int3

.text:00401118                 jnz     short loc_401127  //qui, è cm se ci fosse jmp :D

.text:0040111A                 push    0

.text:0040111C                 mov     eax, exit_proc

.text:00401121                 call    eax

.text:00401123                 add     esp, 4

.text:00401126                 retn

.text:00401127 ; ---------------------------------------------------------------------------

.text:00401127

.text:00401127 loc_401127:                             ; CODE XREF: .text:00401118j

.text:00401127                                         ; DATA XREF: .text:0040112Co

.text:00401127                 mov     eax, offset loc_401021  //eax = 401021

.text:0040112C                 mov     ebx, offset loc_401127  //ebx = 401127

.text:00401131                 xor     ecx, ecx

.text:00401133

.text:00401133 loc_401133:                             ; CODE XREF: .text:00401143j

.text:00401133                 mov     edx, offset unk_40113B

.text:00401138                 inc     edx

.text:00401139                 jmp     edx   //salta..

.text:00401139 ; ---------------------------------------------------------------------------

.text:0040113B unk_40113B      db 0BAh ; ¦             ; DATA XREF: .text:00401133o

.text:0040113C ; ---------------------------------------------------------------------------

.text:0040113C                 add     ecx, [eax] //..qui, ad ecx viene aggiunto il valore dell’addr

.text:0040113E                 nop

.text:0040113F                 nop

.text:00401140                 inc     eax  //eax++

.text:00401141                 cmp     eax, ebx  //quando eax = ebx

.text:00401143                 jle     short loc_401133 //continua, se no re-inizia

.text:00401145                 cmp     ecx, 0ECDFC6BCh //fa un controllo tipo crc, x vedere se abbiamo modificato qualcosa

.text:0040114B                 jnz     proc_some_err

.text:00401151                 call    addr_pu_tre   //tipo eip +=3

.text:00401156                 xor     eax, eax

.text:00401158                 xor     ebx, ebx

.text:0040115A                 jmp     short loc_40115E

.text:0040115C ; ---------------------------------------------------------------------------

.text:0040115C

.text:0040115C loc_40115C:                             ; CODE XREF: .text:0040115Cj

.text:0040115C                 jmp     short loc_40115C

.text:0040115E ; ---------------------------------------------------------------------------

.text:0040115E

.text:0040115E loc_40115E:                             ; CODE XREF: .text:0040115Aj

.text:0040115E                 xor     eax, eax

.text:00401160                 mov     eax, 21h

.text:00401165                 add     eax, 99h

.text:0040116A                 xor     ebx, ebx

.text:0040116C                 mov     ebx, 89h

.text:00401171                 call    non_fa_nada

.text:00401176                 xor     ecx, ecx

.text:00401178                 mov     ecx, 52h

.text:0040117D                 xor     edx, edx

.text:0040117F                /push    offset loc_40119E   //carica la seh

.text:00401184                |push    large dword ptr fs:0

.text:0040118B                \mov     large fs:0, esp

.text:00401192                 mov     eax, debug_pres   //viene generate un eccezione tipo int 3

.text:00401197                 call    eax

.text:00401199                 jmp     go_msg_deb_pres  //se in olly non ignoriamo quell’eccezione

                                                        //ci troviamo qui, e ci fa apparire la msgbox di

                                                        //debug presente          

Fin qui ancora niente di interressante, cmq un altra eccezione, ora andiamo ad analizzare 40119e:

.text:0040119E loc_40119E:                             ; DATA XREF: .text:0040117Fo

.text:0040119E                 pop     large dword ptr fs:0

.text:004011A5                 add     esp, 4

.text:004011A8                 mov     edx, 13h

.text:004011AD                 sub     ecx, 10h

.text:004011B0                 xor     eax, edx

.text:004011B2                 xor     ecx, ebx

.text:004011B4                 mul     ebx

.text:004011B6                 call    proc_go_piu_tre  //tipo eip +=3

.text:004011BB                 nop

.text:004011BC                 nop

.text:004011BD                 nop

.text:004011BE                 cmp     eax, edx

.text:004011C0                 jnz     short loc_4011CC

.text:004011C2                 xor     eax, eax

.text:004011C4                 xor     ebx, ebx

.text:004011C6                 xor     ecx, ecx

.text:004011C8                 xor     edx, edx

.text:004011CA                 jmp     short loc_4011D4

.text:004011CC ; ---------------------------------------------------------------------------

.text:004011CC

.text:004011CC loc_4011CC:                             ; CODE XREF: .text:004011C0j

.text:004011CC                 xor     eax, eax

.text:004011CE                 xor     ebx, ebx

.text:004011D0                 xor     ecx, ecx

.text:004011D2                 xor     edx, edx

.text:004011D4

.text:004011D4 loc_4011D4:                             ; CODE XREF: .text:004011CAj

.text:004011D4                 call    p_addr_piu_uno   //tipo eip +=1

.text:004011D9                 nop

.text:004011DA                 mov     ah, 43h   // lo spiego dopo

.text:004011DC                 call    p_addr_piu_uno

.text:004011DC ; ---------------------------------------------------------------------------

.text:004011E1                 db 0BAh ; ¦

.text:004011E2 ; ---------------------------------------------------------------------------

.text:004011E2                 int     68h     // mov ah,43h && int 68h, serve per rivelare la presenza di debug, questo trucco funge solo su no xp like(quindi io l’ho noppato).Il risultato è 0F386h, se il prg è sotto debug

.text:004011E4                 nop

.text:004011E5                 nop

.text:004011E6                 call    non_fa_nada

.text:004011EB                 cmp     eax, 0F386h   //controlla la presenza di debug

.text:004011F0                 jz      go_msg_deb_pres  //se rileva un debug, salta

.text:004011F6                 call    p_addr_piu_uno

.text:004011FB                 nop

.text:004011FC                /push    offset loc_401243    //carica la seh

.text:00401201                |push    large dword ptr fs:0

.text:00401208                \mov     large fs:0, esp

.text:0040120F                 call    p_addr_piu_uno

.text:0040120F ; ---------------------------------------------------------------------------

.text:00401214                 db 0BAh ; ¦

.text:00401215 ; ---------------------------------------------------------------------------

.text:00401215                 mov     ax, 911h

.text:00401219                 pushf

.text:0040121A                 popf

.text:0040121B                 call    p_addr_piu_uno

.text:0040121B ; ---------------------------------------------------------------------------

.text:00401220                 db 0BAh ; ¦

.text:00401221 ; ---------------------------------------------------------------------------

.text:00401221                 mov     si, 4647h

.text:00401225                 call    p_addr_piu_uno

.text:00401225 ; ---------------------------------------------------------------------------

.text:0040122A                 db 0BAh ; ¦

.text:0040122B ; ---------------------------------------------------------------------------

.text:0040122B                 mov     di, 4A4Dh

.text:0040122F                 lea     dx, ds:4032F1h

.text:00401236                 mov     ecx, offset unk_40123E

.text:0040123B                 inc     ecx

.text:0040123C                 jmp     ecx

.text:0040123C ; ---------------------------------------------------------------------------

.text:0040123E unk_40123E      db 0BAh ; ¦             ; DATA XREF: .text:00401236o

.text:0040123F ; ---------------------------------------------------------------------------

.text:0040123F                 int     3  ; Trap to Debugger      //qui viene generate un eccezione      

.text:00401240                 nop

.text:00401241                 nop

.text:00401242                 nop

Abbiamo trovato di nuovo un eccezione, quindi ora andiamo ad analizzare il suo gestore a 401243:

.text:00401243 loc_401243:                             ; DATA XREF: .text:004011FCo

.text:00401243                 call    non_fa_nada

.text:00401248                 pop     large dword ptr fs:0

.text:0040124F                 add     esp, 4

.text:00401252                 lea     eax, ds:401367h

.text:00401258                 mov     edx, offset unk_401260

.text:0040125D                 inc     edx

.text:0040125E                 jmp     edx

.text:0040125E ; ---------------------------------------------------------------------------

.text:00401260 unk_401260      db 0BAh ; ¦             ; DATA XREF: .text:00401258o

.text:00401261 ; ---------------------------------------------------------------------------

.text:00401261                 cmp     byte ptr [eax], 34h

.text:00401264                 nop

.text:00401265                 jnz     short loc_401283  //qui è la parte più importante, infatti [401367] contiene un nop(90h), quindi dobbiamo cambiarlo in je

.text:00401267                 push    0

.text:00401269                 push    titolo_krat

.text:0040126F                 push    congratulation

.text:00401275                 push    0

.text:00401277                 mov     eax, Message_box  

.text:0040127C                 inc     eax

.text:0040127D                 dec     eax

.text:0040127E                 call    eax   //hiuuu appare la msgbox di comgratulazioni :D

.text:00401280                 add     esp, 10h

.text:00401283

.text:00401283 loc_401283:                             ; CODE XREF: .text:00401265j

.text:00401283                 jmp     short loc_4012A9  //esce

Ok abbiamo finito, vi ho spiegato solo le cose più particolari, cm avete capito il kratme è un susseguirsi di eccezioni, che devono essere seguite per arrivare alla soluzione, le call che ho rinominate per facilitare l’analisi.

Immagiantion

Qui dobbiamo creare  un file, ve ne accorgete dalla msgbox di errore che appare appena clicchiamo :D

Ora per trovare l’inizio della procedura cerchiamo CreateFile, risaliamo e ci troviamo a 401470, analiziamo :

.text:00401470                 sub     esp, 14h

.text:00401473                 push    ebx

.text:00401474                 push    esi

.text:00401475                 mov     esi, ds:LocalAlloc

.text:0040147B                 push    edi

.text:0040147C                 push    400h            ; uBytes

.text:00401481                 push    40h             ; uFlags

.text:00401483                 call    esi ; LocalAlloc

.text:00401485                 push    1Eh             ; uBytes

.text:00401487                 push    40h             ; uFlags

.text:00401489                 mov     ebx, eax

.text:0040148B                 call    esi ; LocalAlloc

.text:0040148D                 push    0               ; dwErrCode

.text:0040148F                 mov     [esp+24h+var_10], eax

.text:00401493                 call    ds:SetLastError

.text:00401499                 mov     edi, ds:CreateFileA  // edi = createfile

.text:0040149F                 push    0               ; hTemplateFile

.text:004014A1                 push    80000A0h        ; dwFlagsAndAttributes

.text:004014A6                 push    3               ; dwCreationDisposition

.text:004014A8                 push    0               ; lpSecurityAttributes

.text:004014AA                 push    0               ; dwShareMode

.text:004014AC                 push    80000000h       ; dwDesiredAccess

.text:004014B1                 push    offset aOhmygod_bmp ; lpFileName

.text:004014B6                 call    edi ; CreateFileA    //apre ohmygod.bmp

.text:004014B8                 mov     esi, eax

.text:004014BA                 call    ds:GetLastError      //prende l’ultimo errore

.text:004014C0                 test    eax, eax  //se

.text:004014C2                 jz      short loc_4014C9 //non c’è errore salta

.text:004014C4                 call    sub_401820

Ok allora prima di tutto creamo un file bmp chiamato ohmygod.bmp, in modo quella sgradevole messagebox non appaia.

.text:004014C9                 lea     eax, [esp+20h+var_C]

.text:004014CD                 push    ebx

.text:004014CE                 mov     ebx, [esp+24h+arg_0]

.text:004014D2                 lea     ecx, [esp+24h+var_8]

.text:004014D6                 push    eax

.text:004014D7                 lea     edx, [esp+28h+var_4]

.text:004014DB                 push    ecx

.text:004014DC                 push    edx

.text:004014DD                 push    esi

.text:004014DE                 push    ebx

.text:004014DF                 call    analizzo_bmp   //strana call

.text:004014E4                 add     esp, 18h

.text:004014E7                 test    eax, eax   //se eax != 0 salta

.text:004014E9                 jnz     short loc_4014F4 

.text:004014EB                 push    ebx

.text:004014EC                 call    sub_401610

.text:004014F1                 add     esp, 4

Ora se usiamo un qualsiasi debug notiamo ke se ritorna 0, vuol dire che il bmp analizzato ha qualcosa che non và.

Quella call verifica la se è larghezza “412 pixel”, l’altezza “73 pixel” e la profondità è “24dpi”, raga non posso essere preciso al massimo xkè non conosco il formato bmp, e ke la grandezza è 88.1kb vedete in 4010de se il volere calcolato è 160aah ( a me usciva 160ac che l’ho modificato con un hex editor, all’interno del file bmp), cmq nell’allegato c’è un bmp fungente :D. Continuiamo con l’analisi, ah vi dico che ci ho messo ½ per calcolare la grandezza dell’img :P

.text:004014F4 loc_4014F4:                             ; CODE XREF: sub_401470+79j

.text:004014F4                 mov     ebx, ds:CloseHandle

.text:004014FA                 push    ebp

.text:004014FB                 push    esi             ; hObject

.text:004014FC                 call    ebx ; CloseHandle  //chiude il file

.text:004014FE                 push    0               ; hTemplateFile

.text:00401500                 push    80000A0h        ; dwFlagsAndAttributes

.text:00401505                 push    3               ; dwCreationDisposition

.text:00401507                 push    0               ; lpSecurityAttributes

.text:00401509                 push    0               ; dwShareMode

.text:0040150B                 push    80000000h       ; dwDesiredAccess

.text:00401510                 push    offset aOhmygod_bmp ; lpFileName  //riapre il file

.text:00401515                 call    edi ; CreateFileA

.text:00401517                 mov     esi, eax

.text:00401519                 push    esi

.text:0040151A                 call    prendi_user   //prende l’user dal file

.text:0040151F                 push    esi

.text:00401520                 mov     edi, eax

.text:00401522                 call    prendi_psw   //prende dal file la psw

.text:00401527                 push    edi

.text:00401528                 mov     ebp, eax

.text:0040152A                 call    genera_psw  //genera la psw dal nick

.text:0040152F                 add     esp, 0Ch

.text:00401532                 mov     [esp+24h+lpString1], eax

.text:00401536                 push    esi             ; hObject

.text:00401537                 call    ebx ; CloseHandle

.text:00401539                 mov     eax, [esp+24h+lpString1]

.text:0040153D                 push    ebp             ; lpString2  //psw letta

.text:0040153E                 push    eax             ; lpString1  //psw generata

.text:0040153F                 call    ds:lstrcmpA    //compara la psw inserita con quella generata

.text:00401545                 mov     esi, [esp+24h+arg_0]

.text:00401549                 pop     ebp

.text:0040154A                 test    eax, eax

.text:0040154C                 jz      short loc_401557

Raga non vi riporto le call, xkè il tute si allungherebbe e cmq ve le spiego qua

Nella call prendi_user, vengono presi 9dword (una alla volta) per leggere l’user. Es per prendere p: 70 00 00 00

Nella call prendi_psw, vengono presi 5dword (sempre una alla volta) per leggere la psw

Nella call genera_psw, viene generata la psw in questo modo, viene presa una char dell’user e gli viene sottratto 1. Es es psw di bcdef è abcde.

Quindi l’user può essere lungo 9char, e la psw 5 char.

Ok ora abbiamo finito, non vado più avanti xkè subito dopo esce la msgbox di congratulazioni e poi viene caricata l’img nel prg :D

Per oggi è tutto alla prossima

                                                                                                                 Pnluck

Note finali

Tutto il chan di crack-it, que , ged , b0 ,geo e i miei boss Nt e Quake

Disclaimer

Vorrei ricordare che il software va comprato e  non rubato, dovete registrare il vostro prodotto dopo il periodo di valutazione. Non mi ritengo responsabile per eventuali danni causati al vostro computer determinati dall'uso improprio di questo tutorial. Questo documento è stato scritto per invogliare il consumatore a registrare legalmente i propri programmi, e non a fargli fare uso dei tantissimi file crack presenti in rete, infatti tale documento aiuta a comprendere lo sforzo che ogni sviluppatore ha dovuto portare avanti per fornire ai rispettivi consumatori i migliori prodotti possibili.

Reversiamo al solo scopo informativo e per migliorare la nostra conoscenza del linguaggio Assembly.