Daily Tips - Vol3
Daily Tips - Vol3
ida UI crash
但是脚本中并没有用到这个东西,ai给的猜测是:可能是某个别的插件的冲突。 在plugin下面用rg搜索关键词:
1
2
3
4
5
6
7
8
9
10
(venv13) ~\Tool\Reverse\IDA_9.2\plugins> rg 'UI_hook'
(venv13) ~\Tool\Reverse\IDA_9.2\plugins> rg "get_lines_rendering_info"
patching\core.py
121: self._ui_hooks.get_lines_rendering_info = self._highlight_lines
patching\util\ida.py
26: def get_lines_rendering_info(self, out, widget, rin):
patching\ui\preview_ui.py
469: self._ui_hooks.get_lines_rendering_info = self._highlight_lines
发现是patching这个插件导致的,将其移除后问题消失. (刚开始搜索UI_hook没有找到,原来实际代码中是_ui_hooks)
TODO: ida dmp
Makefile
最近在学how2heap, 尝试以2.35版本的libc学习. 编写一个Makefile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CC := cc
# 编译选项
CFLAGS := -O2 -Wall -Wextra
# 链接选项
LDFLAGS :=
# 指定SRCS: 匹配.c后缀
SRCS := $(wildcard *.c)
# 指定BINS: 由SRCS去掉.c得到
BINS := $(patsubst %.c,%,$(SRCS))
.PHONY: all clean
# 默认目标all (make <==> make all)
all: $(BINS)
# 任意目标 xxx,如果有对应的 xxx.c,就可以用这条规则生成
# $@ = 当前目标名,例如 large_bin_attack
# $< = 第一个依赖,例如 large_bin_attack.c
%: %.c
$(CC) $(CFLAGS) -g -o $@ $< $(LDFLAGS)
clean:
rm -f $(BINS)
(只有加上 -g, 才包含调试信息,让gdb能直接调试源码)
现在尝试给Makefile增加一个选项make patch,用patchelf设置所有binary的interpreter和rpath:
1
2
3
4
5
patch: $(BINS)
for f in $(BINS); do \
echo "[*] patching $$f"; \
patchelf --set-interpreter "$(pwd)/lib/ld-linux-x86-64.so.2" --set-rpath "$(pwd)/lib" $$f; \
done
但是经过尝试,上面的写法并不能成功,原因是 $(command)在Makefile中并不会被当作shell命令执行展开($在Makefile中一般表示变量) 方法1: 可以使用内建的$(CURDIR)来代替. 方法2: 将$进行转义,方法是连写两次: $$(pwd).
pwndbg glibc version
当我们用pwndbg调试一个使用了非系统libc的binary时,可以通过:
1
set glibc 2.35
然后重新run,就能正常使用bins等功能了
优化
执行large bin attack的时候,发现最后的assert失败。调试后发现,问题出在:程序似乎直接跳过了代码中的malloc(0x18)部分,导致两个相邻的large bin合并,后面完全失控。
反编译发现:malloc(0x18)确实不存在.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
125 │ 11c3: e8 a8 fe ff ff call 1070 <printf@plt>
126 │ 11c8: bf 28 04 00 00 mov $0x428,%edi
127 │ 11cd: e8 be fe ff ff call 1090 <malloc@plt>
128 │ 11d2: 48 8d 3d 0f 11 00 00 lea 0x110f(%rip),%rdi
129 │ 11d9: 48 8d 68 f0 lea -0x10(%rax),%rbp
130 │ 11dd: 49 89 c4 mov %rax,%r12
131 │ 11e0: 31 c0 xor %eax,%eax
132 │ 11e2: 48 89 ee mov %rbp,%rsi
133 │ 11e5: e8 86 fe ff ff call 1070 <printf@plt>
134 │ 11ea: 48 8d 3d 27 11 00 00 lea 0x1127(%rip),%rdi
135 │ 11f1: e8 5a fe ff ff call 1050 <puts@plt>
136 │ 11f6: bf 0a 00 00 00 mov $0xa,%edi
137 │ 11fb: e8 40 fe ff ff call 1040 <putchar@plt>
138 │ 1200: bf 18 04 00 00 mov $0x418,%edi
139 │ 1205: e8 86 fe ff ff call 1090 <malloc@plt>
猜测:Makefile中的-O2将这没有用到的malloc(0x18)给优化掉了. 删去这个选项后,恢复正常
This post is licensed under CC BY 4.0 by the author.
