0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[備忘録] pwntoolsからpwndbgを触るための環境構築

0
Last updated at Posted at 2026-06-19

概要

CTFのpwn問を解く際、pwntoolsからGDB Python APIを操作したくなった。
結構動かすまでに時間がかかったので備忘録として残しておく。

環境

  • Windows 11
  • WSL version: 2.6.3.0
  • Python 3.11.0

WSL が Windows 側の PATH を自動的に取り込まないようにする

直接は関係ないが、pyenvとかでバージョンを管理したいときに邪魔だった。

sudo tee /etc/wsl.conf >/dev/null <<'EOF'
[interop]
appendWindowsPath=false
EOF

wslを再起

wsl --shutdown
wsl 

uvを導入

pwndbgのインストールに必要

curl -LsSf https://astral.sh/uv/install.sh | sh

pwndbgを導入

一番上にあるPortable releaseではなく、かなり下のほうのReally from sourceでインストールする。
筆者環境ではPortableだとGDB起動時にpwndbgが読み込まれなかった

git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh

rpycのバージョンをそろえる

pwntoolsからpwndbg (gdb)を操作する際、RPyCライブラリを使ってGDB内Pythonと通信する

パスに通ってるpython環境のrpycのバージョンと、gdb側に入っているrpycのバージョンがずれてると、正しく通信が行えなくなる。

gdb側にそろえたほうが早い。

~/$ gdb
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
...
pwndbg> python import rpyc; print(rpyc.__version__)
6.0.2
~/$ python -m pip install rpyc==6.0.2

動作確認

あとはこのように書けば動いてくれるはず

test.py
import pwn

io = pwn.process('./chall')

result: tuple[int, pwn.gdb.Gdb] = pwn.gdb.attach(io, api=True)
pid, gdb = result

io.interactive()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?