扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共6页)
BlowFish_Fun proc uses ebx edi esi edx ecx,BfNum:DWORD
MOV ECX,BfNum
MOV AL,CL
AND EAX,0FFh
SHR ECX,08
MOV EDX,EAX
MOV AL,CL
MOV EDI,offset key
AND EAX,0FFh
SHR ECX,08
MOV ESI,EAX
MOV EAX,ECX
SHR EAX,08
AND EAX,0FFh
AND ECX,0FFh
AND ESI,0FFFFh
AND EDX,0FFFFh
MOV EAX,[EDI+EAX*4+48h]
MOV EBX,[EDI+ECX*4+0448h]
MOV ECX,[EDI+ESI*4+0848h]
ADD EAX,EBX
XOR EAX,ECX
MOV ECX,[EDI+EDX*4+0C48h]
ADD EAX,ECX
RET
BlowFish_Fun endp
;BlowFish加密算法函数
BlowFish_En proc uses ebx edi esi edx ecx,highbf:DWORD,lowbf:DWORD
LOCAL num :DWORD
MOV EAX,highbf
MOV ECX,lowbf
MOV EAX,[EAX]
MOV ESI,[ECX]
MOV EDI,offset key
MOV num,10h
MOV EBX,EDI
loc_40108E:
XOR EAX,[EBX]
MOV EDX,EAX
invoke BlowFish_Fun,EAX
MOV ECX,num
XOR EAX,ESI
ADD EBX,4
DEC ECX
MOV ESI,EDX
MOV num,ECX
JNZ loc_40108E
MOV ECX,[EDI+40h]
MOV EDX,[EDI+44h]
XOR ECX,EAX
XOR EDX,ESI
MOV [BFHIGH],EDX
MOV [BFLOW],ECX
RET
BlowFish_En endp
;BlowFish初始化函数
BlowFish_Init proc uses ebx edi esi edx ecx,PWD:DWORD,len_PWD:DWORD
LOCAL pbox_num18:DWORD
LOCAL pbox_num4 :DWORD
LOCAL snum :DWORD
;初始化s盒
MOV ESI,offset key
MOV EAX,offset sbox1
LEA ECX,[ESI+48h]
loc_401141:
MOV EDX,0100h
loc_401146:
MOV EDI,[EAX]
ADD EAX,4
MOV [ECX],EDI
ADD ECX,4
DEC EDX
JNZ loc_401146
CMP EAX,offset sbox1+1000h
JL loc_401141
;初始化p盒
;第一步:原p盒与PWD逐项异或
MOV EDX,PWD
MOV EDI,offset pbox
XOR EAX,EAX
SUB EDI,ESI
MOV pbox_num18,12h
loc_401173:
XOR ECX,ECX
MOV pbox_num4,04
loc_40117D:
XOR EBX,EBX
MOV BL,[EAX+EDX]
SHL ECX,08
OR ECX,EBX
INC EAX
CMP EAX,len_PWD
JL loc_40118E
XOR EAX,EAX
loc_40118E:
MOV EBX,pbox_num4
DEC EBX
MOV pbox_num4,EBX
JNZ loc_40117D
MOV EBX,[EDI+ESI]
ADD ESI,4
XOR EBX,ECX
MOV ECX,pbox_num18
MOV [ESI-04],EBX
DEC ECX
MOV pbox_num18,ECX
JNZ loc_401173
;用连续的blowfish算法填充p盒
MOV EBX,offset key
XOR EAX,EAX
MOV BFLOW,EAX
MOV BFHIGH,EAX
MOV ESI,EBX
MOV EDI,09
loc_4011C4:
LEA EAX,BFLOW
LEA ECX,BFHIGH
invoke BlowFish_En,ECX,EAX
MOV EAX,BFHIGH
MOV ECX,BFLOW
MOV [ESI],EAX
MOV [ESI+04],ECX
ADD ESI,8
DEC EDI
JNZ loc_4011C4
;用连续的blowfish算法填充s盒
LEA ESI,[EBX+4Ch]
MOV snum,04 ;4个s盒。
loc_4011F2:
MOV EDI,80H ;每个盒填充80h=128次(每次填充两个数)。
loc_4011F7:
LEA ECX,BFLOW
LEA EDX,BFHIGH
invoke BlowFish_En,EDX,ECX
MOV ECX,BFHIGH
MOV EDX,BFLOW
MOV [ESI-04],ECX
MOV [ESI],EDX
ADD ESI,8
DEC EDI
JNZ loc_4011F7
DEC snum
JNZ loc_4011F2
RET
BlowFish_Init endp
;消息处理函数
_ProcDlgMain proc uses ebx edi esi edx ecx,hWnd:DWORD,wMsg:DWORD,wParam:DWORD,lParam:DWORD
mov eax,wMsg
.if eax==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0ffffh
.if eax==IDGEN
;如果你直接用ComputerID产生序列号,从这里到mov MYBFLOW,ebx一段应该屏蔽
invoke GetDlgItemText,hWnd,Edit1,offset szID,17
xor ebx,ebx
xor eax,eax
mov esi,offset szID
mov ecx,8
@@33:
or ebx,eax
xor eax,eax
lodsb
cmp eax,39h
jle @@3
sub eax,7
@@3:
sub eax,30h
shl ebx,4
loop @@33
or ebx,eax
mov MYBFHIGH,ebx
mov esi,offset szID+8
mov ecx,8
xor eax,eax
xor ebx,ebx
@@44:
or ebx,eax
lodsb
cmp eax,39h
jle @@4
sub eax,7
@@4:
sub eax,30h
shl ebx,4
loop @@44
or ebx,eax
mov MYBFLOW,ebx
;…………………………………………………………………………………………………………
;如果你直接用ComputerID产生序列号,这里后面的所有语句你都应将其激活
; invoke BlowFish_Init,offset PW_1,23
; invoke BlowFish_En,offset data1_p,offset data1_p+4
; MOV EAX,BFHIGH
; MOV MYBFHIGH,EAX
; MOV EAX,BFLOW
; MOV MYBFLOW,EAX
invoke BlowFish_Init,offset PW_2,18
invoke BlowFish_En,offset MYBFHIGH,offset MYBFLOW
MOV EAX,BFHIGH
MOV MYBFHIGH,EAX
MOV EAX,BFLOW
MOV MYBFLOW,EAX
invoke BlowFish_Init,offset PW_3,14
invoke BlowFish_En,offset MYBFHIGH,offset MYBFLOW
mov ebx,BFHIGH
mov eax,ebx
mov edi,offset szText
mov ecx,8
@@12:
mov eax,ebx
shl ebx,4
shr eax,28
cmp eax,9
jle @@11
add eax,7
@@11: add eax,30h
and eax,0ffh
stosb
loop @@12
mov ebx,BFLOW
mov eax,ebx
mov edi,offset szText+8
mov ecx,8
@@22:
mov eax,ebx
shl ebx,4
shr eax,28
cmp eax,9
jle @@21
add eax,7
@@21: add eax,30h
and eax,0ffh
stosb
loop @@22
xor eax,eax
mov [edi],eax
invoke SetDlgItemText,hWnd,Edit2,offset szText
mov eax,FALSE
ret
.elseif eax==IDCLOSE
invoke EndDialog,hWnd,NULL
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;主程序
start:
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,0
invoke ExitProcess,NULL
end start
end
;资源文件:rsrc.rc
;#include <Resource.h>
;#define IDGEN 10
;#define DLG_MAIN 100
;#define EDIT1 11
;#define EDIT2 12
;
;DLG_MAIN DIALOGEX 100,150,250,60
;STYLE DS_MODALFRAME|WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME
;CAPTION "BlowFish's CrackMe KenGen By 夜月[CCG] "
;FONT 9,"宋体"
;
;BEGIN
;CONTROL " ID:",-1,"Static",SS_LEFT,10,13,40,17
;CONTROL "SN:" ,-2,"Static",SS_CENTER,10,40,20,17
;CONTROL "" ,11,"Edit",ES_LEFT,30,13,150,10
;CONTROL "" ,12,"Edit",ES_LEFT,30,40,150,10
;CONTROL "GENERATE",IDGEN,"BUTTON",BS_PUSHBUTTON,200,11,40,15
;CONTROL "EXIT",IDCLOSE,"BUTTON",BS_PUSHBUTTON,200,36,41,14
;END
--------------------------------------------------------------------------------
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者