📄 crypto.asm
字号:
.model tiny
.386
Org 100h
.data
INTRONAME db 13,10,'Crypto v3.1 - Key Generator by Quantico [mEX/c4N]',13,10
db 13,10,'Enter your name : ','$',13,10
COMPANY db 13,10,'Enter your company : ','$',13,10
DUMBO db 13,10,'You must enter something...',13,10,'$'
STORENAME db 18h, 19h dup(0)
STORECOMP db 18h, 19h dup(0)
THEIRCODE db 13,10,'Your code is : '
STORECODE db 10 dup(0),13,10,'$'
DATATABLE1 db '#serB&nz|mfM1/5(!sd$Mq.{s]+sFjtKpzSdtzoXqmb^Al@dv:s?x/'
DATATABLE2 db '|b!pz*ls;rn|lf$vi^Axpe)rx5aic&9/2m5lsi4@0dmZw94cmqpfhw'
Convert_Digs db '0123456789ABCDEF'
.code
.startup
MAIN PROC NEAR
MOV AH, 09h
MOV DX, OFFSET INTRONAME
INT 21h ; show the lovely intro and
; ask for our name
MOV AH, 0Ah
MOV DX, OFFSET STORENAME
INT 21h ; get what they typed
CMP BYTE PTR [STORENAME+1], 0 ; did they enter nothing ?
JE DUMB ; then tell them
MOV AH, 09h
MOV DX, OFFSET COMPANY ; ask for company
INT 21h
MOV AH, 0Ah
MOV DX, OFFSET STORECOMP
INT 21h ; get input
CMP BYTE PTR [STORECOMP+1], 0 ; enter nothing ?
JE DUMB ; tell them
CALL MAKEKEY ; the main procedure
MOV AH, 09h
MOV DX, OFFSET THEIRCODE ; show them the code
INT 21h
JMP FINISH ; go to quit
DUMB:
MOV AH, 09h
MOV DX, OFFSET DUMBO ; tell them to enter something
INT 21h
FINISH:
MOV AH, 4Ch
INT 21h ; quit program
MAIN ENDP
MAKEKEY PROC NEAR
MOV ESI, 0C69AA96Ch ; esi = C69AA96C
OR ESI, 000000378h ;
PUSH ESI ; save result for use later
LEA ESI, STORENAME+2 ; esi = name
MOVSX EAX, BYTE PTR [ESI-1] ; eax = namelength
CALL NEXTSTAGE ; make first calculations
POP ESI ; restore esi
ADD ESI, EAX ; then add the call result
PUSH ESI ; save it again
LEA ESI, STORECOMP+2 ; esi = company
MOVSX EAX, BYTE PTR [ESI-1] ; eax = companylength
CALL NEXTSTAGE ; make second calculations
POP ESI ; restore esi
ADD EAX, ESI ; add both parts
XOR EBX, EBX ; clear ebx
XOR EDX, EDX ; clear edx
MOV EDI, OFFSET STORECODE ; place to put the string of the code
MOV ECX, 10d ; number base 10
CALL convert_num ; number2string so we can print it
RET ; return
MAKEKEY ENDP
NEXTSTAGE PROC NEAR
XOR EDI, EDI
XOR ECX, ECX
GETMORE:
MOVSX EBX, BYTE PTR [EAX+ECX+DATATABLE1]
MOVSX EBP, BYTE PTR [ECX+ESI]
LEA EDX, DWORD PTR [ECX+01]
IMUL EBX, EBP
MOVSX ECX, BYTE PTR [ECX+DATATABLE2]
IMUL EBX, ECX
IMUL EBX, EDX
ADD EDI, EBX
MOV ECX, EDX
CMP EDX, EAX ; end of input ?
JL GETMORE ; if not, go for more
MOV EAX, EDI ; eax = call result
RET
NEXTSTAGE ENDP
Convert_Num proc near
pushf
pushAD
sub esp, 4
mov ebp,esp
cld
mov esi, edi
push esi
;--- loop for each digit
sub bh, bh
mov dword ptr [ebp], eax ;save low word
mov dword ptr [ebp+4], edx ;save high word
sub esi, esi ;count digits
Connum1:
inc esi
mov eax, dword ptr [ebp+4] ;high word of value
sub edx, edx ;clear for divide
div ecx ;divide, DX gets remainder
mov dword ptr [ebp+4],eax ;save quotient (new high word)
mov eax, dword ptr [ebp] ;low word of value
div ecx ;divide, DX gets remainder
; (the digit)
mov dword ptr [ebp], eax ;save quotient (new low word)
mov bl, dl
mov al, byte ptr [Convert_Digs+ebx] ;get the digit
stosb ;store
cmp dword ptr [ebp], 0 ;check if low word zero
jne Connum1 ;jump if not
cmp dword ptr [ebp+4], 0 ;check if high word zero
jne Connum1 ;jump if not
sub al, al
stosb ;store the terminator
;--- reverse digits
pop ecx ;restore start of string
xchg ecx, esi
shr ecx, 1 ;number of reverses
jz Connum3 ;jump if none
xchg edi, esi
sub esi, 2 ;point to last digit
Connum2 :
mov al, byte ptr [edi] ;load front character
xchg al, byte ptr [esi] ;swap with end character
stosb ;store new front character
dec esi ;back up
loopd Connum2 ;loop back for each digit
;--- finished
Connum3 :
add esp, 4
popad
popf
ret
endp ;Convert_Num
END MAIN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -