小白算法基础教程:文件搜索算法过程分析
本帖最后由 东海浪子 于 2017-4-5 18:28 编辑目标软件:文件搜索分析下od中的算法代码,只有简单的几行,我想小白们也应该能看懂这个过程。大神大表哥们忽略。
先载入OD,运行。搜索“注册”,在字符串“注册成功”段首下段点。随意输入注册码。在段首断下来了,我们一步步分析,只有几行代码。大家应该有耐心的。
004050BE > \6A 14 push 0x14 ; /下断点; Case 3EA of switch 00405078
004050C0 .8D4424 10 lea eax,dword ptr ss: ;
004050C4 .50 push eax ;
004050C5 .68 E9030000 push 0x3E9 ;
004050CA .53 push ebx
004050CB .FF15 3C124100 call dword ptr ds:[<&USER32.GetDlgItemTe>; \获取输入的注册码
004050D1 .807C24 0C 41cmp byte ptr ss:,0x41 ;注册码第1位asc码和41比较
004050D6 .0F85 13010000 jnz 文件搜索.004051EF ;跳向注册码错误
004050DC .8A4424 0D mov al,byte ptr ss: ;注册码第2位asc码入al
004050E0 .3C 41 cmp al,0x41 ;al和41比较
004050E2 .0F8D 07010000 jge 文件搜索.004051EF ;注册码第2位asc大于等于41,跳向错误
004050E8 .8A4C24 0E mov cl,byte ptr ss: ;注册码第3位asc码入cl
004050EC .3AC1 cmp al,cl ;比较al(注册码第2位),cl(注册码第3位)
004050EE .0F8D FB000000 jge 文件搜索.004051EF ;al大于等于cl跳向错误
004050F4 .3A4C24 0F cmp cl,byte ptr ss: ;比较cl(注册码第3位)和注册码第4位
004050F8 .0F8E F1000000 jle 文件搜索.004051EF ;小于等于跳向错误
004050FE .56 push esi ;文件搜索.00405050
004050FF .57 push edi
00405100 .6A 00 push 0x0 ; /hTemplateFile = NULL
00405102 .6A 06 push 0x6 ; |Attributes = HIDDEN|SYSTEM
00405104 .6A 04 push 0x4 ; |Mode = OPEN_ALWAYS
00405106 .6A 00 push 0x0 ; |pSecurity = NULL
00405108 .6A 03 push 0x3 ; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
0040510A .68 000000C0 push 0xC0000000 ; |Access = GENERIC_READ|GENERIC_WRITE
0040510F .68 D82C4100 push 文件搜索.00412CD8 ; |C:\135.txt
00405114 .FF15 5C114100 call dword ptr ds:[<&KERNEL32.CreateFile>; \CreateFileA
0040511A .6A 00 push 0x0 ; /Origin = FILE_BEGIN
0040511C .6A 00 push 0x0 ; |pOffsetHi = NULL
0040511E .8BF0 mov esi,eax ; |
00405120 .6A 00 push 0x0 ; |OffsetLo = 0x0
00405122 .56 push esi ; |hFile = 00405050
00405123 .C64424 1F 00mov byte ptr ss:,0x0 ; |
00405128 .FF15 54114100 call dword ptr ds:[<&KERNEL32.SetFilePoi>; \SetFilePointer
0040512E .6A 00 push 0x0 ; /pOverlapped = NULL
00405130 .8D4C24 14 lea ecx,dword ptr ss: ; |
00405134 .51 push ecx ; |pBytesWritten = NULL
00405135 .6A 01 push 0x1 ; |nBytesToWrite = 0x1
00405137 .8D5424 1B lea edx,dword ptr ss: ; |
0040513B .52 push edx ; |Buffer = 0016A5BC
0040513C .56 push esi ; |hFile = 00405050
0040513D .C64424 23 44mov byte ptr ss:,0x44 ; |
00405142 .FF15 30114100 call dword ptr ds:[<&KERNEL32.WriteFile>>; \WriteFile
00405148 .56 push esi ; /hObject = 00405050
00405149 .FF15 AC104100 call dword ptr ds:[<&KERNEL32.CloseHandl>; \CloseHandle
0040514F .6A 00 push 0x0 ; /Style = MB_OK|MB_APPLMODAL
00405151 .68 DD2B4100 push 文件搜索.00412BDD ; |Title = ""
00405156 .68 782E4100 push 文件搜索.00412E78 ; |注册成功!
0040515B .6A 00 push 0x0 ; |hOwner = NULL
0040515D .FF15 30124100 call dword ptr ds:[<&USER32.MessageBoxA>>; \MessageBoxA
00405163 .B9 05000000 mov ecx,0x5
00405168 .BE 002D4100 mov esi,文件搜索.00412D00 ;已注册,你可以永久使用
0040516D .8D7C24 28 lea edi,dword ptr ss:
00405171 .F3:A5 rep movs dword ptr es:,dword ptr ds>
00405173 .8B0D C8694100 mov ecx,dword ptr ds:
00405179 .66:A5 movs word ptr es:,word ptr ds:
0040517B .33C0 xor eax,eax
0040517D .50 push eax ; /lParam = NULL
0040517E .A4 movs byte ptr es:,byte ptr ds: ; |
0040517F .894424 43 mov dword ptr ss:,eax ; |
00405183 .894424 47 mov dword ptr ss:,eax ; |
00405187 .894424 4B mov dword ptr ss:,eax ; |
0040518B .894424 4F mov dword ptr ss:,eax ; |
0040518F .884424 53 mov byte ptr ss:,al ; |
00405193 .A1 80694100 mov eax,dword ptr ds: ; |
00405198 .50 push eax ; |hInst = NULL
00405199 .68 9A020000 push 0x29A ; |hMenu = 0000029A (window)
0040519E .51 push ecx ; |hParent = NULL
0040519F .6A 1E push 0x1E ; |Height = 1E (30.)
004051A1 .68 C8000000 push 0xC8 ; |Width = C8 (200.)
004051A6 .6A 0A push 0xA ; |Y = A (10.)
004051A8 .68 26020000 push 0x226 ; |X = 226 (550.)
004051AD .68 00000050 push 0x50000000 ; |Style = WS_CHILD|WS_VISIBLE
004051B2 .8D5424 4C lea edx,dword ptr ss: ; |
004051B6 .52 push edx ; |WindowName = "槬"
004051B7 .68 C42C4100 push 文件搜索.00412CC4 ; |Static
004051BC .6A 00 push 0x0 ; |ExtStyle = 0
004051BE .FF15 2C124100 call dword ptr ds:[<&USER32.CreateWindow>; \CreateWindowExA
004051C4 .6A 00 push 0x0 ; /Result = 0x0
004051C6 .53 push ebx ; |hWnd = 00210294
004051C7 .A3 F8694100 mov dword ptr ds:,eax ; |
004051CC .C605 FC694100>mov byte ptr ds:,0x1 ; |
004051D3 .FF15 24124100 call dword ptr ds:[<&USER32.EndDialog>]; \EndDialog
004051D9 .5F pop edi ;user32.GetWindowLongA
004051DA .5E pop esi ;user32.GetWindowLongA
004051DB .33C0 xor eax,eax
004051DD .5B pop ebx ;user32.GetWindowLongA
004051DE .8B4C24 44 mov ecx,dword ptr ss: ;MSCTFIME.73647184
004051E2 .33CC xor ecx,esp
004051E4 .E8 00320000 call 文件搜索.004083E9
004051E9 .83C4 48 add esp,0x48
004051EC .C2 1000 retn 0x10
004051EF >6A 00 push 0x0 ; /Style = MB_OK|MB_APPLMODAL
004051F1 .68 DD2B4100 push 文件搜索.00412BDD ; |Title = ""
004051F6 .68 842E4100 push 文件搜索.00412E84 ; |注册码错误!
004051FB .6A 00 push 0x0 ; |hOwner = NULL
004051FD .FF15 30124100 call dword ptr ds:[<&USER32.MessageBoxA>>; \MessageBoxA
算法总结:
注册码只验证前4位。
1.第1位是"A"
2.第2位asc码要小于41
3.第3位注册码asc码要大于第2位注册码asc码
4.第4位注册码ASC码要小于第3位注册码ASC码
如果注册成功,在C盘创建135.txt文件,写入D。删除,就可变为未注册,可以继续玩了。
本帖最后由 jgs 于 2017-4-5 17:36 编辑
沙发,表哥现在玩算法了{:lol:} jgs 发表于 2017-4-5 17:35
沙发,表哥现在玩算法了
被你发现了{:sweat:}
膜拜会算法的表哥 谢谢表哥的教导好好学习天天向上 膜拜浪子老湿~~
带我玩算法~~~ 我也想学汇编 求老师带飞
楼上表哥带我 支持学习了啊
感谢楼主分享{:biggrin:}
页:
[1]