能力值:
( LV2,RANK:10 )
|
-
-
2 楼
notepad2换个软件就行了
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
代码放在获得文件地址后载入比较合适 要看程序如何绘制再看怎么绘制 中午再详细说
|
能力值:
( LV3,RANK:20 )
|
-
-
4 楼
谢谢你指点下。
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
我用的是5.1.2600.5512版本的
资源里没有主窗口,看来是运行时才绘制的
中断后CreateFileW看到
01003394 |. 56 push esi ; /hTemplateFile
01003395 |. 68 80000000 push 80 ; |Attributes = NORMAL
0100339A |. 6A 03 push 3 ; |Mode = OPEN_EXISTING
0100339C |. 56 push esi ; |pSecurity
0100339D |. 6A 03 push 3 ; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
0100339F |. 68 00000080 push 80000000 ; |Access = GENERIC_READ
010033A4 |. BE 28960001 mov esi, 01009628 ; |UNICODE "D:\text.txt"
010033A9 |. 56 push esi ; |FileName => "D:\text.txt"
010033AA |. FF15 04110001 call dword ptr [<&KERNEL32.CreateFile>; \CreateFileW
010033B0 |. 83F8 FF cmp eax, -1
010033B3 |. A3 80A40001 mov dword ptr [100A480], eax
010033B8 |. 75 08 jnz short 010033C2
010033BA |. 56 push esi
010033BB |. E8 601A0000 call 01004E20
010033C0 |. EB 0C jmp short 010033CE
010033C2 |> 6A FF push -1
010033C4 |. 56 push esi
010033C5 |. E8 AF1D0000 call 01005179
010033CA |. 85C0 test eax, eax
010033CC |. 75 06 jnz short 010033D4
010033CE |> 893D 80A40001 mov dword ptr [100A480], edi
010033D4 |> 5F pop edi
010033D5 |. 5E pop esi
010033D6 \. C3 retn
这里可以存下文件地址
中断SetWindowTextW,多次Ctrl+F9后看到
01002B41 |. 51 push ecx ; /lParam
01002B42 |. 6A 01 push 1 ; |wParam = 1
01002B44 |. 68 0B040000 push 40B ; |Message = WM_USER+11.
01002B49 |. 50 push eax ; |hWnd => 4A035A
01002B4A |. FF15 40120001 call dword ptr [<&USER32.SendMessageW>; \SendMessageW
01002B50 |> FF35 44900001 push dword ptr [1009044] ; /StringToAdd = " - 记事本"
01002B56 |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370] ; |
01002B5C |. 50 push eax ; |ConcatString
01002B5D |. FF15 18110001 call dword ptr [<&KERNEL32.lstrcatW>] ; \lstrcatW
01002B63 |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370]
01002B69 |. 50 push eax ; /Text
01002B6A |. FF35 30980001 push dword ptr [1009830] ; |hWnd = 001F03C8 ('text.txt - 记事本',class='Notepad')
01002B70 |. FF15 F0110001 call dword ptr [<&USER32.SetWindowTex>; \SetWindowTextW
01002B76 |. 8B4D FC mov ecx, dword ptr [ebp-4]
01002B79 |. E8 C9450000 call 01007147
01002B7E |. C9 leave
01002B7F \. C2 0400 retn 4
看不出什么似乎,查找内存“Ln”
000B8EBE 4C 00 6E 00 20 00 25 00 64 00 2C 00 20 00 43 00 L.n. .%.d.,. .C.
000B8ECE 6F 00 6C 00 20 00 25 00 64 00 20 00 20 00 00 00 o.l. .%.d. . ...
下硬件断点,中断在
77C13BD5 66:85DB test bx, bx
77C13BD8 ^ 0F85 49F6FFFF jnz 77C13227
77C13BDE 5F pop edi
77C13BDF 5E pop esi
77C13BE0 8B4D FC mov ecx, dword ptr [ebp-4]
77C13BE3 8B85 E4FBFFFF mov eax, dword ptr [ebp-41C]
77C13BE9 5B pop ebx
77C13BEA E8 A43D0100 call 77C27993
77C13BEF C9 leave
77C13BF0 C3 retn
两次Ctrl+F9,回到程序领空,往上翻
01002A55 /$ 8BFF mov edi, edi ;下断点,重新运行
01002A57 |. 55 push ebp
01002A58 |. 8BEC mov ebp, esp
01002A5A |. 81EC C8070000 sub esp, 7C8
01002A60 |. A1 04960001 mov eax, dword ptr [1009604]
01002A65 |. 66:83A5 FCFEF>and word ptr [ebp-104], 0
01002A6D |. 56 push esi
01002A6E |. 8B75 08 mov esi, dword ptr [ebp+8]
01002A71 |. 57 push edi
01002A72 |. 6A 3F push 3F
01002A74 |. 8945 FC mov dword ptr [ebp-4], eax
01002A77 |. 59 pop ecx
01002A78 |. FF35 40900001 push dword ptr [1009040] ; /String2 = "无标题"
01002A7E |. 33C0 xor eax, eax ; |
01002A80 |. 8DBD FEFEFFFF lea edi, dword ptr [ebp-102] ; |
01002A86 |. F3:AB rep stos dword ptr es:[edi] ; |
01002A88 |. 56 push esi ; |String1
01002A89 |. 66:AB stos word ptr es:[edi] ; |
01002A8B |. FF15 28110001 call dword ptr [<&KERNEL32.lstrcmpW>] ; \lstrcmpW
01002A91 |. 85C0 test eax, eax
01002A93 |. 75 19 jnz short 01002AAE
01002A95 |. FF35 40900001 push dword ptr [1009040]
01002A9B |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370]
01002AA1 |. 68 36010000 push 136
01002AA6 |. 50 push eax
01002AA7 |. E8 5DF9FFFF call 01002409
01002AAC |. EB 66 jmp short 01002B14
01002AAE |> 56 push esi ; /FileName
01002AAF |. FF15 24110001 call dword ptr [<&KERNEL32.GetFileAtt>; \GetFileAttributesW
01002AB5 |. 8D85 38F8FFFF lea eax, dword ptr [ebp-7C8]
01002ABB |. 50 push eax ; /pFindFileData
01002ABC |. 56 push esi ; |FileName
01002ABD |. FF15 20110001 call dword ptr [<&KERNEL32.FindFirstF>; \FindFirstFileW
01002AC3 |. 8BF8 mov edi, eax
01002AC5 |. 83FF FF cmp edi, -1
01002AC8 |. 74 22 je short 01002AEC
01002ACA |. 8D85 64F8FFFF lea eax, dword ptr [ebp-79C]
01002AD0 |. 50 push eax
01002AD1 |. BE 04010000 mov esi, 104
01002AD6 |. 56 push esi
01002AD7 |. 8D85 88FAFFFF lea eax, dword ptr [ebp-578]
01002ADD |. 50 push eax
01002ADE |. E8 26F9FFFF call 01002409
01002AE3 |. 57 push edi ; /hSearch
01002AE4 |. FF15 1C110001 call dword ptr [<&KERNEL32.FindClose>>; \FindClose
01002AEA |. EB 13 jmp short 01002AFF
01002AEC |> 56 push esi
01002AED |. BE 04010000 mov esi, 104
01002AF2 |. 56 push esi
01002AF3 |. 8D85 88FAFFFF lea eax, dword ptr [ebp-578]
01002AF9 |. 50 push eax
01002AFA |. E8 0AF9FFFF call 01002409
01002AFF |> 56 push esi ; /BufCount
01002B00 |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370] ; |
01002B06 |. 50 push eax ; |Buffer
01002B07 |. 8D85 88FAFFFF lea eax, dword ptr [ebp-578] ; |
01002B0D |. 50 push eax ; |FilePath
01002B0E |. FF15 D4120001 call dword ptr [<&comdlg32.GetFileTit>; \GetFileTitleW
01002B14 |> 6A 01 push 1
01002B16 |. 6A 01 push 1
01002B18 |. FF35 C8900001 push dword ptr [10090C8] ; |format = " Ln %d, Col %d "
01002B1E |. 8D85 FCFEFFFF lea eax, dword ptr [ebp-104] ; |
01002B24 |. 6A 7F push 7F ; |count = 7F (127.)
01002B26 |. 50 push eax ; |wstr
01002B27 |. FF15 14130001 call dword ptr [<&msvcrt._snwprintf>] ; \_snwprintf<<<<<<<<<<<<<<这里是绘制函数
01002B2D |. A1 34980001 mov eax, dword ptr [1009834] ;<<<<<<<<<<<<<<<<<<<回到这里
01002B32 |. 83C4 14 add esp, 14
01002B35 |. 85C0 test eax, eax
01002B37 |. 5F pop edi
01002B38 |. 5E pop esi
01002B39 |. 74 15 je short 01002B50
01002B3B |. 8D8D FCFEFFFF lea ecx, dword ptr [ebp-104]
01002B41 |. 51 push ecx ; /lParam
01002B42 |. 6A 01 push 1 ; |wParam = 1
01002B44 |. 68 0B040000 push 40B ; |Message = WM_USER+11.
01002B49 |. 50 push eax ; |hWnd => 4903B8
01002B4A |. FF15 40120001 call dword ptr [<&USER32.SendMessageW>; \SendMessageW
01002B50 |> FF35 44900001 push dword ptr [1009044] ; /StringToAdd = " - 记事本"
01002B56 |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370] ; |
01002B5C |. 50 push eax ; |ConcatString
01002B5D |. FF15 18110001 call dword ptr [<&KERNEL32.lstrcatW>] ; \lstrcatW
01002B63 |. 8D85 90FCFFFF lea eax, dword ptr [ebp-370]
01002B69 |. 50 push eax ; /Text
01002B6A |. FF35 30980001 push dword ptr [1009830] ; |hWnd = 002303C8 ('text.txt - 记事本',class='Notepad')
01002B70 |. FF15 F0110001 call dword ptr [<&USER32.SetWindowTex>; \SetWindowTextW
01002B76 |. 8B4D FC mov ecx, dword ptr [ebp-4]
01002B79 |. E8 C9450000 call 01007147
01002B7E |. C9 leave ; (initial cpu selection)
01002B7F \. C2 0400 retn 4
注意这里
01002B16 |. 6A 01 push 1
01002B18 |. FF35 C8900001 push dword ptr [10090C8] ; |format = " Ln %d, Col %d "
01002B1E |. 8D85 FCFEFFFF lea eax, dword ptr [ebp-104] ; |
01002B24 |. 6A 7F push 7F ; |count = 7F (127.)
01002B26 |. 50 push eax ; |wstr
01002B27 |. FF15 14130001 call dword ptr [<&msvcrt._snwprintf>] ; \_snwprintf
看到堆栈为
0007F314 0007F9F4 |wstr = 0007F9F4
0007F318 0000007F |count = 7F (127.)
0007F31C 000B8EB8 |format = " Ln %d, Col %d "
0007F320 00000001 |<%d> = 1
0007F324 00000001 \<%d> = 1
这样绘制的地方就知道了
剩下的就是看下msvcrt的相关函数后顺着程序的思路操作就可以了
不过我还有问题想请教
状态栏的分隔是怎么弄出来的?不清楚啊。。。
|
能力值:
( LV4,RANK:50 )
|
-
-
6 楼
. 需要用SendMessageW函数来设置文本
具体实现:
空白区段写入一下代码( 0100874A):
LEA EAX,DWORD PTR SS:[EBP-370]//文件名
push EAX
push 0 //状态栏索引,选第一个
PUSH 40B //设置文本
PUSH DWORD PTR DS:[1009834] //状态栏句柄
CALL 77D2929A //调用SendMessageW
LEA EAX,DWORD PTR SS:[EBP-370] //还原被我们修改掉的那句(即01002B56)
jmp 01002B5C //跳回原来 在程序中修改:(Ctrl+g 定位到 01002B56)
01002B56 8D85 90FCFFFF LEA EAX,DWORD PTR SS:[EBP-370] ; |
01002B5C 50 PUSH EAX ; |ConcatString 修改成
jmp 0100874A
01002B5C 50 PUSH EAX ; |ConcatString
附件:
修改后的记事本.rar
.
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
我绕得太远了 楼上偏移是怎么算出来的?能不能顺便说明一下寄存器的操作是什么意思。看着还是乱乱的
|
能力值:
( LV4,RANK:50 )
|
-
-
8 楼
加载NOTEPAD.EXE,设置两个断点
bp SendMessageW
bp SetWindowTextW
按几下F9后断在以下位置:(01001CFA,从这开始看)
01001CC5 |. FF35 C8900001 PUSH DWORD PTR DS:[10090C8] ; |format = " Ln %d, Col %d "
01001CCB |. 8D85 FCFEFFFF LEA EAX,DWORD PTR SS:[EBP-104] ; |
01001CD1 |. 6A 7F PUSH 7F ; |count = 7F (127.)
01001CD3 |. 50 PUSH EAX ; |wstr
01001CD4 |. FF15 14130001 CALL DWORD PTR DS:[<&msvcrt._snwprintf>] ; \_snwprintf //格式化文本 Ln %d, Col %d
01001CDA |. A1 34980001 MOV EAX,DWORD PTR DS:[1009834] //这里就是状态栏窗口句柄,为什么呢?往下看
01001CDF |. 66:8365 FA 00 AND WORD PTR SS:[EBP-6],0
01001CE4 |. 83C4 14 ADD ESP,14
01001CE7 |. 85C0 TEST EAX,EAX
01001CE9 |. 74 11 JE SHORT NOTEPAD.01001CFC
01001CEB |. 8D8D FCFEFFFF LEA ECX,DWORD PTR SS:[EBP-104]
01001CF1 |. 51 PUSH ECX //设置文本,这里就是Ln %d, Col %d 格式化后的值了
01001CF2 6A 01 PUSH 1 //状态栏列的索引,怎么知道?猜想--测试。(把1改成0就知道了)
01001CF4 |. 68 0B040000 PUSH 40B //消息类型
01001CF9 |. 50 PUSH EAX //窗口句柄,这里是设置状态栏,所以EAX就是状态栏地址,往上看,可以知道EAX的值为DWORD PTR DS:[1009834]
01001CFA |. FFD6 CALL ESI //断在这里,ESI就是SendMessageW ,往上看,解读他的参数
01001CFC |> 8B4D FC MOV ECX,DWORD PTR SS:[EBP-4]
01001CFF |. 893D 20960001 MOV DWORD PTR DS:[1009620],EDI
01001D05 |. 5F POP EDI
01001D06 |. 5E POP ESI
01001D07 |. 891D 24960001 MOV DWORD PTR DS:[1009624],EBX
01001D0D |. 5B POP EBX
01001D0E |. E8 34540000 CALL NOTEPAD.01007147
01001D13 |. C9 LEAVE
01001D14 \. C2 0400 RETN 4
01001D17 CC INT3
--------------------------
根据上面的分析,得出,可以使用 SendMessageW函数设置状态栏
函数所需的四个参数分别为
SendMessageW( EAX,DWORD PTR DS:[1009834](状态栏句柄),40B(消息类型),0(item索引),文本(未知))
现在只差文本未获得,继续F9
按几下之后,断在以下位置(01002B70,从这开始看):
01002B3B |. 8D8D FCFEFFFF LEA ECX,DWORD PTR SS:[EBP-104]
01002B41 |. 51 PUSH ECX ; /lParam
01002B42 |. 6A 01 PUSH 1 ; |wParam = 1
01002B44 |. 68 0B040000 PUSH 40B ; |Message = WM_USER+11.
01002B49 |. 50 PUSH EAX ; |hWnd => 30414
01002B4A |. FF15 40120001 CALL DWORD PTR DS:[<&USER32.SendMessageW>; \SendMessageW
01002B50 |> FF35 44900001 PUSH DWORD PTR DS:[1009044] ; /StringToAdd = " - 记事本"//这里 - 记事本入栈,
01002B56 8D85 90FCFFFF LEA EAX,DWORD PTR SS:[EBP-370] //所以这里就是文件名了
01002B5C 50 PUSH EAX ; |ConcatString
01002B5D FF15 18110001 CALL DWORD PTR DS:[<&KERNEL32.lstrcatW>] ; \lstrcatW //调用lstrcatW将EAX的字符串连接上" - 记事本",所以在这里之前的EAX就是我们需要的文本(文件名)
01002B63 8D85 90FCFFFF LEA EAX,DWORD PTR SS:[EBP-370]
01002B69 50 PUSH EAX
01002B6A FF35 30980001 PUSH DWORD PTR DS:[1009830]
01002B70 FF15 F0110001 CALL DWORD PTR DS:[<&USER32.SetWindowTex>; USER32.SetWindowTextW //断在这里,这里设置记事本窗口标题,那么它的参数EAX肯定是xxx-记事本,所以往上看
01002B76 8B4D FC MOV ECX,DWORD PTR SS:[EBP-4]
01002B79 E8 C9450000 CALL NOTEPAD.01007147
01002B7E |. C9 LEAVE
01002B7F \. C2 0400 RETN 4
01002B82 CC INT3
------------------------
根据上段代码,我们得知文件名就是LEA EAX,DWORD PTR SS:[EBP-370]
----------------------------------------------------
所以
汇编代码应该如下面这么写:
LEA EAX,DWORD PTR SS:[EBP-370]//文件名
push EAX
push 0 //状态栏索引,选第一个
PUSH 40B //设置文本
PUSH DWORD PTR DS:[1009834] //状态栏句柄
CALL 77D2929A //调用SendMessageW
LEA EAX,DWORD PTR SS:[EBP-370] //还原被我们修改掉的那句(即01002B56)
jmp 01002B5C //跳回原来
|
能力值:
( LV3,RANK:20 )
|
-
-
9 楼
谢谢楼上两位指教。这些天有工作事情忙.没空看。
真的谢谢指教。
|
能力值:
( LV2,RANK:10 )
|
-
-
10 楼
0100337E /$ 8BFF mov edi, edi
01003380 |. 56 push esi
01003381 |. 57 push edi
01003382 |. 8B3D 80A40001 mov edi, dword ptr [100A480]
01003388 |. 33F6 xor esi, esi
0100338A |. 56 push esi
0100338B |. E8 7FF3FFFF call 0100270F
01003390 |. 85C0 test eax, eax
01003392 |. 74 40 je short 010033D4
01003394 |. 56 push esi ; /hTemplateFile
01003395 |. 68 80000000 push 80 ; |Attributes = NORMAL
0100339A |. 6A 03 push 3 ; |Mode = OPEN_EXISTING
0100339C |. 56 push esi ; |pSecurity
0100339D |. 6A 03 push 3 ; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
0100339F |. 68 00000080 push 80000000 ; |Access = GENERIC_READ
010033A4 BE 28960001 mov esi, 01009628
010033A9 |. 56 push esi ; |FileName => ""
010033AA |. FF15 04110001 call dword ptr [<&KERNEL32.CreateFile>; \CreateFileW
这里有绝对路径
如果要弄绝对路径而不只是文件名的话
010033A4 BE 28960001 mov esi, 01009628
在这一句跳到自己的代码的话,要怎么处理01009628的值?
这里找不到句柄哦,SendMessageW又该怎么写?
楼主客气了。都是在学习~~~
|
能力值:
( LV4,RANK:50 )
|
-
-
11 楼
全路径的地址是这样的
LEA EAX,DWORD PTR SS:[EBP-20C]
楼上说
至于文件路径的获取,可以这么写
把原来的
LEA EAX,DWORD PTR SS:[EBP-370]//文件名
push EAX
NOP掉
改成 push 01009628
至于为什么这样子。
下个断点 bp GetFileAttributesW
因为记事本打开文件会查看文件属性,而GetFileAttributesW第一个参数就是文件路径。所以断点在这里最合适。
断下之后就很明了了,esi就是指向文件路径了
|
能力值:
( LV2,RANK:10 )
|
-
-
12 楼
我的基础还是不够啊 受教了~ 多谢!
|
能力值:
( LV3,RANK:20 )
|
-
-
13 楼
思路很好.非常感谢.
|