学逆向论坛

找回密码
立即注册

只需一步,快速开始

发新帖

2万

积分

41

好友

1157

主题
发表于 2021-1-25 21:03:10 | 查看: 6854| 回复: 0

相关题目:

前言
现在pwn题是越来越高版本的libc,一场比赛ubuntu16.04,ubuntu18.04切来切去的十分难受。
极力推荐这个pwndocker,使用这个pwndocker就不用来回的切虚拟机,利用patchelf 或者process(["/path/to/ld.so", "./test"], env={"LD_PRELOAD":"/path/to/libc.so.6"})指定libc版本运行。
这个docker已经集成pwn常用工具以及各个版本libc。
included software
  • pwntools —— CTF framework and exploit development library
  • pwndbg —— a GDB plug-in that makes debugging with GDB suck less, with a focus on features needed by low-level software developers, hardware hackers, reverse-engineers and exploit developers
  • pwngdb —— gdb for pwn
  • ROPgadget —— facilitate ROP exploitation tool
  • roputils —— A Return-oriented Programming toolkit
  • one_gadget —— A searching one-gadget of execve(‘/bin/sh’, NULL, NULL) tool for amd64 and i386
  • angr —— A platform-agnostic binary analysis framework
  • radare2 —— A rewrite from scratch of radare in order to provide a set of libraries and tools to work with binary files
  • seccomp-tools —— Provide powerful tools for seccomp analysis
  • linux_server[64] —— IDA 7.0 debug server for linux
  • tmux —— a terminal multiplexer
  • ltrace —— trace library function call
  • strace —— trace system call
included glibc
Default compiled glibc path is /glibc.
  • 2.19 —— ubuntu 12.04 default libc version
  • 2.23 —— ubuntu 16.04 default libc version
  • 2.24 —— introduce vtable check in file struct
  • 2.27 —— pwndocker default glibc version
  • 2.28~2.31 —— latest libc versions
How to run in custom libc version?
code
1
2
3
cp /glibc/2.27/64/lib/ld-2.27.so /tmp/ld-2.27.so
patchelf --set-interpreter /tmp/ld-2.27.so ./test
LD_PRELOAD=./libc.so.6 ./test

or

code
1
2
from pwn import *
p = process(["/path/to/ld.so", "./test"], env={"LD_PRELOAD":"/path/to/libc.so.6"})

18.04 skysider/pwndocker 安装
docker hub 可以直接pull

bash
1
docker pull skysider/pwndocker


但是pull的太慢了,我已经把他传到了阿里云上,用下面这条命令即可

bash
1
docker pull registry.cn-hangzhou.aliyuncs.com/pwndocker/pwndocker-nocbtm:1.0

pull完之后重命名一下

bash
1
docker tag registry.cn-hangzhou.aliyuncs.com/pwndocker/pwndocker-nocbtm:1.0 skysider/pwndocker

使用姿势
建议用官方的使用姿势,用如下命令run起来

code
1
2
3
4
5
6
7
8
docker run -d
        --rm
        -h ${ctf_name}
        --name ${ctf_name}
        -v $(pwd)/${ctf_name}:/ctf/work
        -p 23946:23946
        --cap-add=SYS_PTRACE
        skysider/pwndocker

其中有两个重要的参数
-v $(pwd)/${ctf_name}:/ctf/work 是将当前目录下的文件映射到 docker /ctf/work目录下
这样你在物理机修改文件,docker里面也会发生变化,就不用再docker cp了
–cap-add=SYS_PTRACE 这个参数也是要一定加的,不然docker里面没法用gdb调试。
可以把上述命令放到 pwndocker_run.sh里面 方便下次使用

skysider/pwndocker 正确使用姿势

skysider/pwndocker 正确使用姿势
然后调试脚本时,要先进去tmux ,python脚本里面指定终端为 tmux

code
1
context.terminal = ['tmux', 'sp', '-h']


就可以 gdb.attach(p)了 如下图

skysider/pwndocker 正确使用姿势

skysider/pwndocker 正确使用姿势
温馨提示:
1.如果您喜欢这篇帖子,请给作者点赞评分,点赞会增加帖子的热度,评分会给作者加学币。(评分不会扣掉您的积分,系统每天都会重置您的评分额度)。
2.回复帖子不仅是对作者的认可,还可以获得学币奖励,请尊重他人的劳动成果,拒绝做伸手党!
3.发广告、灌水回复等违规行为一经发现直接禁言,如果本帖内容涉嫌违规,请点击论坛底部的举报反馈按钮,也可以在【投诉建议】板块发帖举报。
论坛交流群:672619046

小黑屋|手机版|站务邮箱|学逆向论坛 ( 粤ICP备2021023307号 )|网站地图

GMT+8, 2024-3-29 18:33 , Processed in 0.092215 second(s), 39 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表