Advertisement
Souhail_Hammou

CodeGate : Rev250 CmdLine Args Generation

Feb 23rd, 2014
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; Crackme Writeup : http://rce4fun.blogspot.com/
  3. ;
  4. .386
  5. .model flat,stdcall
  6. option casemap:none
  7.  
  8. include windows.inc
  9. include kernel32.inc
  10. includelib kernel32.lib
  11. include user32.inc
  12. includelib user32.lib
  13. include masm32.inc
  14. includelib masm32.lib
  15.  
  16. .data
  17. count dw 1
  18. first  dd NULL
  19. sec   dd NULL
  20. arg1 dd NULL
  21. arg2 dd NULL
  22. .data?
  23. inpuut db 1024 dup(?)
  24. .code
  25. start :
  26.     invoke StdOut,addr ppoint
  27.     inc word ptr ds:[count]
  28.     cmp word ptr ds:[count],2
  29.     ja above_1
  30.     mov [arg1],0A8276BFAh
  31.     mov [arg2],092F837EDh
  32. ; generates the 2 values.
  33. above_1 :
  34.     mov eax,[arg1]
  35.     xor eax,0B72AF098h
  36.     mov [first],eax
  37.     mov ecx, [arg2]
  38.     imul ecx,eax
  39.     xor ecx,[arg2]
  40.     mov [sec],ecx
  41.     ;jmp generate
  42. generate :
  43.     xor edi,edi
  44.     push edi
  45.     push 2
  46.     mov eax,[first]
  47.     push eax
  48.     call routine_1
  49.     add esp,8
  50.     imul eax,eax,7
  51.     mov ecx,[first]
  52.     imul ecx,ecx,1Dh
  53.     add eax,ecx
  54.     mov [arg1],eax
  55.     xor edx,edx
  56.     mov ecx,2
  57.     div ecx
  58.     add edx,5
  59.     push edx
  60.     mov edx,[sec]
  61.     xor edx,[arg1]
  62.     push edx
  63.     call routine_1
  64.     mov [arg2],eax
  65.     invoke StdIn,addr inpuut,200h  ; Check manually from debugger each of the 2 values stored at arg1 and arg2
  66.     jmp start
  67. routine_1 :
  68.     push ebp
  69.     mov ebp,esp
  70.     sub esp,8
  71.     mov dword ptr ss:[EBP-4],1
  72.     mov dword ptr ss:[EBP-8],0
  73.     jmp middle
  74.     sub_1:
  75.     mov eax,dword ptr ss:[EBP-8]
  76.     add eax,1
  77.     mov dword ptr ss:[ebp-8],eax
  78.     middle :
  79.     mov ecx, dword ptr ss:[EBP-8]
  80.     cmp ecx,dword ptr ss:[EBP+0Ch]
  81.     jnb get_out
  82.     mov edx,dword ptr ss:[ebp-4]
  83.     imul edx,dword ptr ss:[ebp+8]
  84.     mov dword ptr ss:[ebp-4],edx
  85.     jmp sub_1
  86.     get_out :
  87.     mov eax,dword ptr ss:[ebp-4]
  88.     mov esp,ebp
  89.     pop ebp
  90.     ret
  91. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement