Skip to content

Commit 816c7fb

Browse files
committed
Unidbg
1 parent c30b292 commit 816c7fb

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Tool/Unidbg/A02/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,46 @@ public void HookMDStringold() {
151151
}
152152
```
153153

154+
函数Hook:
155+
156+
![](pic/02.png)
157+
158+
```java
159+
// HookZz hook Sc_EncryptWallEncode
160+
public void hookEncryptWallEncode() {
161+
// 获取HookZz对象,https://github.com/jmpews/HookZz
162+
IHookZz hookZz = HookZz.getInstance(emulator); // 加载HookZz,支持inline hook,文档看
163+
// enable hook
164+
hookZz.enable_arm_arm64_b_branch(); // 测试enable_arm_arm64_b_branch
165+
hookZz.wrap(module.base + 0xA284 + 1, new WrapCallback<HookZzArm32RegisterContext>() {
166+
Pointer buffer;
167+
@Override
168+
// 方法执行前
169+
public void preCall(Emulator<?> emulator, HookZzArm32RegisterContext ctx, HookEntryInfo info) {
170+
System.out.println("HookZz hook EncryptWallEncode");
171+
Pointer input1 = ctx.getPointerArg(0);
172+
Pointer input2 = ctx.getPointerArg(1);
173+
Pointer input3 = ctx.getPointerArg(2);
174+
// getString的参数i代表index,即input[i:]
175+
System.out.println("参数1:" + input1.getString(0));
176+
System.out.println("参数2:" + input2.getString(0));
177+
System.out.println("参数3:" + input3.getString(0));
178+
179+
buffer = ctx.getPointerArg(3);
180+
}
181+
@Override
182+
// 方法执行后
183+
public void postCall(Emulator<?> emulator, HookZzArm32RegisterContext ctx, HookEntryInfo info) {
184+
// getByteArray参数1是起始index,参数2是长度,我们不知道结果多长,就先设置0x100吧
185+
byte[] outputhex = buffer.getByteArray(0, 0x100);
186+
Inspector.inspect(outputhex, "EncryptWallEncode output");
187+
}
188+
});
189+
hookZz.disable_arm_arm64_b_branch();
190+
}
191+
192+
```
193+
154194
#### HookZz--寄存器
155195

156196
- 编写对该函数的Hook,首先因为不确定三个参数是指针还是数值,所以先全部做为数值处理,作为long类型看待,防止整数溢出
@@ -188,6 +228,10 @@ public void hook65540(){
188228

189229
#### HookZz--InlineHook
190230

231+
- 在有些时候,函数可能在程序中运行许多次,但我们只想观察此次此地的执行情况,那我们可能会使用inline hook,需要注意,inline hook 的时机是目标指令执行前。
232+
233+
![](pic/03.png)
234+
191235
- 通过base+offset inline wrap内部函数,在IDA看到为sub_xxx那些
192236

193237
```java

Tool/Unidbg/A02/pic/02.png

31.4 KB
Loading

Tool/Unidbg/A02/pic/03.png

47.5 KB
Loading

0 commit comments

Comments
 (0)