本文是从看雪上学习的。网址如下:http://bbs.pediy.com/showthread.php?threadid=23014 。
算法分析部分还是直接从那里贴过来吧,以后备用:
===========================================分析说明=====================================================
【软件名称】Bad Sector CrackMe1
【下载地址】附件(附KeyGen源码,本文和CrackMe1)
【应用平台】Win9x/NT/2000/XP
【软件大小】10K
【软件限制】没有。
【保护方式】用户名+序列号
【破 解 者】andy00
【破解难度】1/10
【破解声明】只是为了熟悉逆向工程。
【破解工具】OllyDbg,ResHacker,Windows自带计算器
【注册机下载】仅提供源代码,支持共享软件
【软件简介】My firts Crackme..ahh.This one is damn easy and I expect from anyoneto create keygen
for it, but if you cant code one,it would be enough to understand how it calculates real serial.
Enjoy btw. it's not packed/protected. -Bad Sector
;======================================================================================================
【分析过程】
为了熟悉逆向工程,静态分析能力,不调试
1、 直接用OllyDbg反汇编,无壳;
2、 在ResHacker看到用户名栏ID为C8,注册码栏为C9
3、 在OllyDbg查找输入函数GetWindowText和GetDlgItemText,顺利地找到了GetDlgItemText,
找到nIDDlgItem(要获取字符串的控件的ID)参数为03EB的那一个,这个GetDlgItemText应该就是获取输入的注册码的地方了.
(这里说明下,我在xp sp3下是用的GetDlgItemTextA这个函数)
00401139 6A 32 push 32 ; nMaxCount=32;
0040113B 68 F3204000 push Crackme1.004020F3 ; lpNameBuf=004020F3;
00401140 68 C8000000 push 0C8 ; nIDDlgItem=C8;
00401145 FF75 08 push dword ptr ss:[ebp+8]
00401148 E8 DE000000 call <jmp.&USER32.GetDlgItemTextA> ; eax=GetDlgItemTextA(hDlg,nIDDlgItem,lpNameBuf,nMaxCount);
;取用户名到004020F3,用户名字符个数放到eax
0040114D 83F8 00 cmp eax,0
00401150 0F84 99000000 je Crackme1.004011EF ; if(eax==0) goto 004011EF(失败消息);没有输入则失败
00401156 83F8 04 cmp eax,4
00401159 0F82 90000000 jb Crackme1.004011EF ; if(eax<4) goto 004011EF(失败消息);字符数<4失败
0040115F 33C9 xor ecx