Tuts 4 You

# How This Code For Keygen In Asm?

## Recommended Posts

How this code for keygen in asm?

I must need a way and for chose random digits.

Example 4 digit ABCD are random.

But only thing: A+B+C+D must 26 (hex)

How do?

This is a snippet from a keygen for Puma products.

In this case I needed just 3 random decimal digits A+B+C = Integer Value. But this code could be extended to four decimal digits A+B+C+D

; ?????????????????????????????????????????????????????????????????????????

.data

testval dd 0

Val1 dd 0

Val2 dd 0

Val3 dd 0

.code

; ?????????????????????????????????????????????????????????????????????????

; Random

; generate a random number between 0 and nRange-1

Random PROC uses edx ecx nRange: DWORD

INVOKE GetTickCount

mov ecx, 41C64E6Dh

mul ecx

and eax, 7FFFFFFh

mov ecx, nRange

sub edx, edx

div ecx

xchg eax, edx

ret

Random ENDP

; ?????????????????????????????????????????????????????????????????????????

; sumval is the integer value we want = A+B+C

; output A,B,C Val1,Val2,Val3

GenVals proc sumval :dword

tryagain:

mov eax, sumval

mov testval, eax

dec testval

invoke Random, testval

.if eax > 9

jmp tryagain

.endif

mov Val1, eax

mov eax, sumval

sub eax, Val1

mov testval, eax

dec testval

invoke Random, testval

.if eax > 9

jmp tryagain

.endif

mov Val2, eax

mov ebx, Val1

.if eax >= sumval

jmp tryagain

.else

mov ebx, eax

mov eax, sumval

sub eax, ebx

mov Val3, eax

.if eax > 9

jmp tryagain

.endif

.endif

ret

GenVals endp

; ?????????????????????????????????????????????????????????????????????????

If you code a four digit A+B+C+D = Integer example or find a better way - post it here

BTW what is the target for your keygen?

Z

Edited by Ziggy

Target is little japan game. Good for learn keygen.

INVOKE GetTickCount !!! Stupid, I must think that!

Thank much Ziggy.

Chineese Little Box, the Ku-Pan Game, isn't true?