home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / KEY.ASM < prev    next >
Encoding:
Assembly Source File  |  1999-03-04  |  3.8 KB  |  175 lines

  1. ;
  2. ; Copyright Shadow 1999
  3. ;
  4. .586p
  5. .model flat,stdcall
  6. locals
  7. jumps
  8.  
  9. UNICODE = 0
  10.  
  11.  
  12.  
  13. extrn   GetDlgItemTextA:proc
  14. extrn   _wsprintfA:proc
  15.  
  16.  
  17. DIALOG_1        equ     100
  18. IDC_EDIT1       equ     105
  19. IDC_EDIT2       equ     107
  20.  
  21. include w32.inc
  22.  
  23.  
  24. .data
  25.  
  26. hinstance       dd 0
  27. paint           PAINTSTRUCT <?>
  28. username        db 30 dup(0)
  29. hdc             dd 0
  30. key             db 30 dup(0)
  31. format          db "%lu",0
  32. number          dd 0
  33. temp            dd 0
  34. er        db "too short username!",0
  35. hf              db "Keygen for HF crackme II by Shadow/hf",0
  36. visit           db "http://members.xoom.com/hell_crack",0
  37. .code
  38.         
  39. start:
  40. ;
  41. ; this starts program only if there is no other copies running
  42. ;
  43.         mov     edx,offset visit
  44.         call    FindWindow,0,offset hf
  45.         .if     eax == 0
  46.                 call    GetModuleHandle,0
  47.                 mov     hinstance,eax
  48. ;
  49. ; create modal dialogbox from key.rc (template 100)
  50. ;
  51.                 call    DialogBoxParamA,hinstance,DIALOG_1,0,offset dialogf,0
  52.         .endif
  53.         call    ExitProcess,0
  54.  
  55.  
  56. PUBLIC dialogf
  57. dialogf proc hwnd:DWORD,umsg:DWORD,wparam:DWORD,lparam:DWORD
  58. ;
  59. ; This is basic callback procedure used by gui programs..
  60. ;
  61.         xor     eax,eax
  62.         mov     ax,word ptr umsg
  63.  
  64.         .if     ax == WM_DESTROY
  65.                 call    EndDialog,hwnd,0
  66.         .elseif ax == WM_CLOSE
  67.                 call    EndDialog,hwnd,0
  68.         .elseif ax == WM_COMMAND
  69.                 mov     ax,word ptr wparam
  70. ;
  71. ; Text char(s) entered to dialog?
  72.                 .if     ax == IDC_EDIT1
  73. ;
  74. ; Read username
  75. ;
  76.                         call    GetDlgItemTextA,hwnd,IDC_EDIT1,offset username,30
  77. ;
  78. ; If it's len > 4, then calculate and print keycode
  79. ;
  80.                         .if     eax > 4
  81.                             call    Calculate,offset username
  82.                             call    _wsprintfA,offset key,offset format,eax
  83.                              call    SetDlgItemTextA,hwnd,IDC_EDIT2,offset key
  84.             .else    
  85. ;
  86. ; no, print message username too short...
  87. ;
  88.                 call    SetDlgItemTextA,hwnd,IDC_EDIT2,offset er
  89.             .endif
  90.                 .endif
  91.         .elseif ax == WM_INITDIALOG
  92.                 ; to do-- add some stuff?
  93.         .elseif ax == WM_PAINT
  94.                 call    BeginPaint,hwnd,offset paint
  95.                 mov     hdc,eax
  96.                 call    EndPaint,hwnd,offset paint
  97.         .endif
  98.         xor     eax,eax
  99.         ret
  100.         
  101.  
  102. dialogf endp
  103.  
  104. Calculate proc pstr1:DWORD
  105.         mov     esi,pstr1
  106.         xor     eax,eax
  107.         mov     number,0
  108.  
  109. ; because I use assembler I almost ripped whole routine from
  110. ; crackme..
  111.  
  112. ;
  113. ; 1 char
  114. ;
  115.         lodsb
  116.         shl     eax,2
  117.         lea     eax,[eax+2*eax]
  118.         add     number,eax
  119.  
  120. ;
  121. ; 2 char
  122. ;
  123.  
  124.         xor     eax,eax
  125.         lodsb
  126.         lea     eax,[eax+4*eax]
  127.         lea     eax,[eax+4*eax]
  128.         add     number,eax
  129.  
  130. ;
  131. ; 3 char
  132. ;
  133.         xor     eax,eax
  134.         lodsb
  135.         add     eax,eax
  136.         add     number,eax
  137.  
  138. ;
  139. ; 4 char
  140. ;
  141.  
  142.         xor     eax,eax
  143.         lodsb
  144.         imul    eax,eax,0bh
  145.         add     number,eax
  146. ;
  147. ; final stage
  148. ;
  149.         call    Strlen,pstr1
  150. ; strlen  = eax
  151.  
  152.         mov     edx,number
  153.         imul    edx,number
  154.         imul    edx
  155.         ret
  156. Calculate endp
  157.  
  158. ;
  159. ; High optimized strlen - size and speed ;)
  160. ;
  161. Strlen proc pstr:DWORD
  162.         xor     al,al           ; scan for '0'
  163.         mov     edi,pstr        ; edi = pointer to buffer to search
  164.         or      ecx,0ffffffffh  ; how many times?
  165.         repnz                   ;
  166.         scasb                   ; repeat while not zero and ecx != 0
  167.         not     ecx             ; invert all bits
  168.         dec     ecx             ; ecx-1
  169.         xchg    eax,ecx         ; eax = strlen
  170.         ret                     ; return
  171. Strlen endp
  172. ends
  173. end start
  174.