您的位置:首页 > 其它

【原创】OllyDBG 入门系列(四)-内存断点

2016-12-20 13:09 447 查看
http://bbs.pediy.com/showthread.php?t=21378

还是上次那个cm,不过这次的要求是写出注册机

那么就要先研究注册码是怎么来的,上次我们最开始找到的关键位置

00401306  |. /75 6B         jnz     short 00401373
00401308  |. |C1E8 10       shr     eax,0x10
0040130B  |. |66:0BC0       or      ax,ax
0040130E  |. |75 63         jnz     short 00401373
00401310  |. |8B35 9C334000 mov     esi,dword ptr ds:[0x40339C]      ;  这里就是我们函数中esi的初始值
00401316  |. |6A 28         push    0x28                             ; /Count = 28 (40.)
00401318  |. |68 C4334000   push    004033C4                         ; |Buffer = CrackHea.004033C4
0040131D  |. |FF35 90314000 push    dword ptr ds:[0x403190]          ; |hWnd = 00FF01AE (class='Edit',parent=000C0126)
00401323  |. |E8 4C010000   call    <jmp.&USER32.GetWindowTextA>     ; \GetWindowTextA
00401328  |. |E8 A5000000   call    004013D2                         ;  关键函数
0040132D  |. |3BC6          cmp     eax,esi                          ;  eax要和esi相等
0040132F  |. |75 42         jnz     short 00401373                   ;  不能跳
00401331  |. |EB 2C         jmp     short 0040135F
00401333  |. |4E 6F 77 20 7>ascii   "Now write a keyg"
00401343  |. |65 6E 20 61 6>ascii   "en and tut and y"
00401353  |. |6F 75 27 72 6>ascii   "ou're done.",0
0040135F  |> |6A 00         push    0x0                              ; /Style = MB_OK|MB_APPLMODAL
00401361  |. |68 0F304000   push    0040300F                         ; |Title = "Crudd's Crack Head"
00401366  |. |68 33134000   push    00401333                         ; |Text = "Now write a keygen and tut and you're done."
0040136B  |. |FF75 08       push    [arg.1]                          ; |hOwner
0040136E  |. |E8 19010000   call    <jmp.&USER32.MessageBoxA>        ; \MessageBoxA


具体位置如下

00401310  |.  8B35 9C334000 mov     esi,dword ptr ds:[0x40339C]      ;  这里就是我们函数中esi的初始值


这里的esi的初始值参与到了我们注册码的生成中,

所以这里我们确定位置,0x40339c ,然后下内存断点,找到初始化的代码位置。

这里有一个要注意的地方,内存断点只能设置一个并且在重启程序后会自动消失。

在数据窗口 右键–>转到–>表达式 或者用快捷键ctrl+g



下内存写入断点



运行起程序,发现断在了ntdll领空 alt+f9 回到用户领空

找到了关键函数

0040140C  /$  60            pushad
0040140D  |.  6A 00         push    0x0                              ; /RootPathName = NULL
0040140F  |.  E8 B4000000   call    <jmp.&KERNEL32.GetDriveTypeA>    ; \GetDriveTypeA
00401414  |.  A2 EC334000   mov     byte ptr ds:[0x4033EC],al        ;  得到磁盘类型 al=3
00401419  |.  6A 00         push    0x0                              ; /pFileSystemNameSize = NULL
0040141B  |.  6A 00         push    0x0                              ; |pFileSystemNameBuffer = NULL
0040141D  |.  6A 00         push    0x0                              ; |pFileSystemFlags = NULL
0040141F  |.  6A 00         push    0x0                              ; |pMaxFilenameLength = NULL
00401421  |.  6A 00         push    0x0                              ; |pVolumeSerialNumber = NULL
00401423  |.  6A 0B         push    0xB                              ; |MaxVolumeNameSize = B (11.)
00401425  |.  68 9C334000   push    0040339C                         ; |VolumeNameBuffer = CrackHea.0040339C
0040142A  |.  6A 00         push    0x0                              ; |RootPathName = NULL
0040142C  |.  E8 A3000000   call    <jmp.&KERNEL32.GetVolumeInformat>; \GetVolumeInformationA
00401431  |.  8D35 9C334000 lea     esi,dword ptr ds:[0x40339C]      ;  得到磁盘信息 VolumenameBuffer
00401437  |.  0FB60D EC3340>movzx   ecx,byte ptr ds:[0x4033EC]       ;  存放的是磁盘类型
0040143E  |.  33FF          xor     edi,edi                          ;  edi清零
00401440  |>  8BC1          mov     eax,ecx
00401442  |.  8B1E          mov     ebx,dword ptr ds:[esi]           ;  卷标的名称作为数值送入ebx
00401444  |.  F7E3          mul     ebx                              ;  相乘
00401446  |.  03F8          add     edi,eax                          ;  把值累加在edi中
00401448  |.  49            dec     ecx
00401449  |.  83F9 00       cmp     ecx,0x0
0040144C  |.^ 75 F2         jnz     short 00401440
0040144E  |.  893D 9C334000 mov     dword ptr ds:[0x40339C],edi
00401454  |.  61            popad
00401455  \.  C3            retn


可以直接分析,也可以代入到IDA里面分析



大体的流程就是 获得驱动类型和磁盘的卷标,然后把驱动类型的数值和磁盘卷标的名字转换为数值按4字节为单位,相乘并累加,最后存储到0x40339c中。

这样大体流程清楚了就容易写注册机了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: