	  Ŀ
	                                                              Ŀ
	    
	          
	          
	                                               
	                                               
	                                   
	                                   
	                                   
	                                                
	                                                
	                       
	                       
	                 
	                                                                  
	                                                                  
	                         
	                 p r o u d l y     p r e s e n t s                
	                         
	                                                                  
	Ŀ                                            www.tscube.cjb.net
	  



                      ͻ
                        Tutorial for mogul crackme #2   
                      ͼ



Ŀ
1. Intro 


This VB crackme is very easy to solve, I made this tutorial to show you how to use Smartcheck
to quickly locate the serial_generation routine in the Dead listing.



Ŀ
2. Speaking of Smartcheck... 


Run Smartcheck and open the crackme

name   : TSCube
serial : 123456

You can see two types of events :
[+] txtName_Change
[+] txtSerial_Change

If you expand one of the '[+] txtSerial_Change' events, you'll easily find the correct serial 
(it's the last line of this event) :

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
Trim(VARIANT:Byref String:"2750-TSCube-6")
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

name   : TSCube
serial : 2750-TSCube-6

So, the serial looks like XXXX-'Name'-strlen(Name). To find how XXXX is computed, we need to
expand the last '[+] txtName_Change' event :

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
Len(String : "TSCube") returns LONG:6
Mid(VARIANT:ByRef String:"TSCube",long:1,VARIANT:Integer:1)
Asc(String:"T") returns Integer:84
[...]
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

We can see that the ASCII values of our name are used... surely to compute this XXXX value.
Smartcheck won't tell use more things, so we need to fire WDASM to see what the crackme does
with these ASCII values.



Ŀ
3. WDASM 


The question is : WHERE in the dead listing are we going to find what we need ?

It's easy, click on the 'Mid(VARIANT:ByRef String:"TSCube",long:1,VARIANT:Integer:1)' to select
this line and look at the title of Smartcheck's right window :

=> CRACKME2.EXE!00002964 (no debug info)

That means that the line that interests us in WDASM is :
0x400000 (image base) + 0x2964 (offset given by Smartcheck) = 0x402964 !!!

We land in the middle of a 'for' loop :

<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
* Reference To: MSVBVM60.__vbaVarForInit, Ord:0000h
                                  |
:00402920 FF1538104000            Call dword ptr [00401038]

* Reference To: MSVBVM60.__vbaStrMove, Ord:0000h
                                  |
:00402926 8B1DC0104000            mov ebx, dword ptr [004010C0]

* Referenced by a (U)nconditional or (C)onditional Jump at Address:
|:004029CA(U)
|
:0040292C 85C0                    test eax, eax
:0040292E 0F849B000000            je 004029CF

[...]

* Reference To: MSVBVM60.rtcMidCharVar, Ord:0278h
                                  |
:00402963 FF1554104000            Call dword ptr [00401054]

=> well, it's not 0x402964, it's 0x402963 ;)

:00402969 8D45AC                  lea eax, dword ptr [ebp-54]
:0040296C 50                      push eax

* Reference To: MSVBVM60.__vbaStrVarMove, Ord:0000h
                                  |
:0040296D FF1514104000            Call dword ptr [00401014]
:00402973 8BD0                    mov edx, eax
:00402975 8D4DD8                  lea ecx, dword ptr [ebp-28]
:00402978 FFD3                    call ebx
:0040297A 8D4DAC                  lea ecx, dword ptr [ebp-54]
:0040297D 8D55BC                  lea edx, dword ptr [ebp-44]
:00402980 51                      push ecx
:00402981 52                      push edx
:00402982 6A02                    push 00000002

* Reference To: MSVBVM60.__vbaFreeVarList, Ord:0000h
                                  |
:00402984 FF1518104000            Call dword ptr [00401018]
:0040298A 8B45D8                  mov eax, dword ptr [ebp-28]
:0040298D 83C40C                  add esp, 0000000C
:00402990 50                      push eax

* Reference To: MSVBVM60.rtcAnsiValueBstr, Ord:0204h
                                  |
:00402991 FF1524104000            Call dword ptr [00401024]
:00402997 666BC005                imul ax, 0005

AX = name[i] * 5

:0040299B 8B5644                  mov edx, dword ptr [esi+44]
:0040299E 0F80AA000000            jo 00402A4E
:004029A4 0FBFC8                  movsx ecx, ax
:004029A7 03CA                    add ecx, edx

contains the sum of 'name[i]*5'

:004029A9 8D9554FFFFFF            lea edx, dword ptr [ebp+FFFFFF54]
:004029AF 0F8099000000            jo 00402A4E
:004029B5 894E44                  mov dword ptr [esi+44], ecx
:004029B8 8D8564FFFFFF            lea eax, dword ptr [ebp+FFFFFF64]
:004029BE 52                      push edx
:004029BF 8D4DDC                  lea ecx, dword ptr [ebp-24]
:004029C2 50                      push eax
:004029C3 51                      push ecx

* Reference To: MSVBVM60.__vbaVarForNext, Ord:0000h
                                  |
:004029C4 FF15CC104000            Call dword ptr [004010CC]
:004029CA E95DFFFFFF              jmp 0040292C
<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->

in 'C', it looks like :

int first_part=0;
for (int i=0;i<strlen(name);i++) first_part = first_part + name[i]*5;

Nothing to add, look at my (C) Javascript keygen for more details.



Ŀ
4. Outro 


Si t'as quelque chose a feter, vient donc faire un tour a Lambe (ca tombe bien, c'est a cote
de chez moi ;)


    ________     _______     _______
   /__   __/\   /  ____/\   /  ____/\
   \_/  /\_\/  /  /\___\/  /  /\___\/
    /  / /    /  /_/_     /  / / 
   /  / /    /____  /\   /  / /
  /  / /     \___/ / /  /  / /
 /  / /     ____/ / /  /  /_/_
/  / /     /_____/ /  /______/\
\__\/      \_____\/   \______\/ 28/07/2000

www.tscube.cjb.net
