Skip to content

[POC Snippet Request] pwntools template #12

@Esonhugh

Description

@Esonhugh

Category

pwn

Tool

pwntools

Snippet Name

pwntools initial template

Snippet Content

from pwn import *
from ctypes import *

context(arch='amd64', log_level = 'debug',os = 'linux')
file='./chall'
elf=ELF(file)
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')

choice = 0x00
if choice:
    port=   27828
    target = 'remote.host'
    p = remote(target,port)
else:
    p = process(file)

s       = lambda data               :p.send(data)
sl      = lambda data               :p.sendline(data)
sa      = lambda x,data             :p.sendafter(x, data)
sla     = lambda x,data             :p.sendlineafter(x, data)
r       = lambda num=4096           :p.recv(num)
rl      = lambda num=4096           :p.recvline(num)
ru      = lambda x                  :p.recvuntil(x)
itr     = lambda                    :p.interactive()
uu32    = lambda data               :u32(data.ljust(4,b'\x00'))
uu64    = lambda data               :u64(data.ljust(8,b'\x00'))
uru64   = lambda                    :uu64(ru('\x7f')[-6:])
leak    = lambda name               :log.success('{} = {}'.format(name, hex(eval(name))))
libc_os   = lambda x                :libc_base + x
clear       =       lambda                            : os.system('clear')

def get_sb():
    return libc_base + libc.sym['system'], libc_base + next(libc.search(b'/bin/sh\x00'))

def debug(cmd=''):
    if choice==1:
        return  
    gdb.attach(p,gdbscript=cmd)

def malloc(size,content):
    pass

def edit(index,content):
    pass

def free(index):
    pass

def show(index):
    pass
  
commend = '''
b main
'''
debug(commend)

itr()

Short Description

pwntools init template

Trigger Prefix

from pwn import *

Language

python

more detail.

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions