lun4t1c@home:~$

Pwntools

导入库

from pwn import *

远程连接

if args.G:
    io = remote('ip', port)
else:
    io = process('FilePath')

运行脚本时加上参数 G 时进行远程连接,否则进行本地运行。

打印信息

log.info(str)
log.success(str)

一般用于打印泄露出来的地址等内容,也可作为程序运行进度的标记。

开启 debug

context.log_level = 'debug'

远程连接目标主机与本地调试的结果往往有差异,要常关注 debug 返回的信息。

生成 shellcode

第一种方式

context(arch='i386',os='linux')
shellcode = shellcraft.sh()
shellcode = asm(shellcode)

第二种方式

context.arch = 'i386'
shellcode = asm(shellcraft.sh())

打开文件 -> 读取 -> 输出

open_shellcode = shellcraft.i386.linux.open('flag')
read_shellcode = shellcraft.i386.linux.read(3, 'esp', 100)
write_shellcode = shellcraft.i386.linux.write(1, 'esp', 100)

汇编与反汇编

asm(code)
disasm(code)