← 文章归档

pwnable.tw-death note笔记

其实这道题主要的难点是在编写可打印的shellcode,而且长度限制为80字节,网上能找到的通用的大概都超过了这个长度。 首先整理一下在可打印范围内能用的汇编指令: 1.数据传送: push/pop eax... pusha/popa 2.算术运算: inc/dec eax.…

其实这道题主要的难点是在编写可打印的shellcode,而且长度限制为80字节,网上能找到的通用的大概都超过了这个长度。

首先整理一下在可打印范围内能用的汇编指令:

1.数据传送: push/pop eax... pusha/popa

2.算术运算: inc/dec eax... sub al, 立即数 sub byte ptr [eax... + 立即数], al dl... sub byte ptr [eax... + 立即数], ah dh... sub dword ptr [eax... + 立即数], esi edi sub word ptr [eax... + 立即数], si di sub al dl..., byte ptr [eax... + 立即数] sub ah dh..., byte ptr [eax... + 立即数] sub esi edi, dword ptr [eax... + 立即数] sub si di, word ptr [eax... + 立即数]

3.逻辑运算: and al, 立即数 and dword ptr [eax... + 立即数], esi edi and word ptr [eax... + 立即数], si di and ah dh..., byte ptr [ecx edx... + 立即数] and esi edi, dword ptr [eax... + 立即数] and si di, word ptr [eax... + 立即数]

xor al, 立即数 xor byte ptr [eax... + 立即数], al dl... xor byte ptr [eax... + 立即数], ah dh... xor dword ptr [eax... + 立即数], esi edi xor word ptr [eax... + 立即数], si di xor al dl..., byte ptr [eax... + 立即数] xor ah dh..., byte ptr [eax... + 立即数] xor esi edi, dword ptr [eax... + 立即数] xor si di, word ptr [eax... + 立即数]

4.比较指令: cmp al, 立即数 cmp byte ptr [eax... + 立即数], al dl... cmp byte ptr [eax... + 立即数], ah dh... cmp dword ptr [eax... + 立即数], esi edi cmp word ptr [eax... + 立即数], si di cmp al dl..., byte ptr [eax... + 立即数] cmp ah dh..., byte ptr [eax... + 立即数] cmp esi edi, dword ptr [eax... + 立即数] cmp si di, word ptr [eax... + 立即数]

5.转移指令: push 56h pop eax cmp al, 43h jnz lable

<=> jmp lable

6.交换al, ah push eax xor ah, byte ptr [esp] // ah ^= al xor byte ptr [esp], ah // al ^= ah xor ah, byte ptr [esp] // ah ^= al pop eax

7.清零: push 44h pop eax sub al, 44h ; eax = 0

push esi push esp pop eax xor [eax], esi ; esi = 0

当然,上面汇编指令中的立即数大小也需要在可打印字符范围内。

但是最重要的一点就是:int 0x80不在这个范围内

其他的寄存器通过上述操作都能置0或者传值进去。但是int 0x80的机器码是:

0xcd 0x80

都不在可见字符范围内,这时候就需要我们进行很蛋疼的处理。

我们注意到,能用的运算指令只有sub,and,xor

但其实最好利用的还是sub,xor这个似乎无法让超过0x1f的数与0x80-0x1e的进行运算而得到可见字符范围内的数。(大概有一点语病??)

所以这里我选择了sub,经过长久的脑力挣扎,我发现0x50cd50cd在连续加上两次0x555555后每个字节都在可见字符范围内(最先想一次解决,然后发现根本不可能)

还有一点就是需要当前字串的地址,我们才能对输入的字符进行修改,这一点我也有点智障,最先覆盖了exit,发现根本找不到字符串的地址信息,后来仔细一想,我覆盖free不就行了吗,传进来的参数不就是字符串的地址?

搞清楚上面几点之后,这道题就不难了,然而最先没有想到索引可以为负,智障了好久。。。。。

COMMENTS

一起聊聊

0

正在搬小板凳…

留下一条评论

友善讨论,不需要注册。评论使用无感安全检查;管理员邮箱还需要 Token 验证。

Turnstile 无感防护验证码尚未配置,评论暂不可用