Sunday 26 December 2010

KeyGenMe for Newbies :: Progressive KeygenMe #1


First tutorial from Ryscrow (Re-Xe blog is in French) about basic keygenning with a old crackme coded by Fargot
He have made a simple keygen in C
I've wanted to do the same..

base.asm:
.486
.model  flat, stdcall
option  casemap :none   ; case sensitive
include windows.inc

uselib  MACRO   libname
    include     libname.inc
    includelib  libname.lib
ENDM

uselib  user32
uselib  kernel32
DlgProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
IDC_OK          equ 1003
IDC_IDCANCEL    equ 1004

.data
szFormat db "%i",0
szSizeMin   db "Le nom doit faire au moins 5 caractères",0
szSizeMax   db "Le nom ne doit pas faire plus de 20 caractères",0
szCap       db "Progressive KeygenMe #1 KEYGEN",0

.data?
hInstance       dd      ?   ;dd can be written as dword

szName db 256 dup(?)
szCode db 256 dup(?)

.code
start:
    invoke  GetModuleHandle, NULL
    mov hInstance, eax
    invoke  DialogBoxParam, hInstance, 101, 0, ADDR DlgProc, 0
    invoke  ExitProcess, eax
; -----------------------------------------------------------------------
DlgProc proc    hWin    :DWORD,
        uMsg    :DWORD,
        wParam  :DWORD,
        lParam  :DWORD
    .if uMsg == WM_COMMAND
        .if wParam == IDC_OK
; -----------------------------------------------------------------------
;           TODO
; -----------------------------------------------------------------------
        invoke GetDlgItemText,hWin,1001,addr szName,sizeof szName
        CMP EAX,5
        JB @MinSize
        CMP EAX,014h
        JA @MaxSize
        MOV ECX,EAX
        LEA ESI,offset szName
        XOR EBX,EBX

@progress_00401083:
        MOVZX EAX,BYTE PTR DS:[ESI]
        ADD EBX,EAX
        INC ESI
        LOOPD @progress_00401083
        PUSH EBX
        PUSH offset szFormat               ; ASCII "%i"
        PUSH offset szCode
        CALL wsprintf
        invoke SetDlgItemText,hWin,1002,addr szCode
        ret
@MinSize:
invoke MessageBox,hWin,addr szSizeMin,addr szCap,MB_ICONEXCLAMATION
RET
@MaxSize:
invoke MessageBox,hWin,addr szSizeMax,addr szCap,MB_ICONEXCLAMATION
RET
        .elseif wParam == IDC_IDCANCEL
            invoke EndDialog,hWin,0
        .endif
    .elseif uMsg == WM_CLOSE
        invoke  EndDialog,hWin,0
    .endif
    xor eax,eax
    ret
DlgProc endp
end start

base.rc:
;This Resource Script was generated by WinAsm Studio.

#define IDC_OK 1003
#define IDC_CANCEL 1004

101 DIALOGEX 0,0,169,44
CAPTION "Base"
FONT 8,"Tahoma"
STYLE 0x80c80880
EXSTYLE 0x00000000
BEGIN
    CONTROL "OK",IDC_OK,"Button",0x00000001,110,5,50,14,0x00000000
    CONTROL "Cancel",IDC_CANCEL,"Button",0x00000000,110,23,50,14,0x00000000
    CONTROL "",1001,"Edit",0x00000080,7,7,90,12,0x00000200
    CONTROL "",1002,"Edit",0x00000080,7,24,90,12,0x00000200
END






Just 4 fun.

No comments:

Post a Comment