We expect a high standard of professionalism from you at all times while you are taking any of our courses. We expect all students to act in good faith at all times
TLDR: Don’t be a dick jerk
[v,va,s,sn,f]printf
[v,va,s,sn,f]scanf
setproctitle
, syslog
, and others!%<flags><width><precision><modifier><type>
%d
: print as signed decimal%x
: print as hex%c
: print as a character%p
: print out a value as a pointer%s
: print as a string?%n
: huh?h
: print half%hd
: print bottom 2 bytes%hn
: write two byteshh
: print half half (quarter)%hhd
: print bottom byte%hhn
: write one bytezfill()
in python%10c
pads the argument to 100 bytesprintf("%10c", 5);
> 5
printf("%10c", 10)
> 10
%10$x
prints the 10th argument as hexint a = 1, b = 2, c = 3;
printf("%2x", a, b, c);
> 0x2
printf(buffer);
AAAA BBAAAA
| ---------- | | ---------- |
| 0x41410000 | -> | 0x41414141 |
| 0x00004141 | -> | 0x00004242 |
| ---------- | | ---------- |
10
you’d just need to write 10
chars + %n0x08041234(134484532)
, how do we write 134M chars?addr,addr+1...
ASLR: randomizes the programs location in memory
PIE: program can only use relative jumps (needs ASLR)
RELRO: GOT is Read-Only (partial is trash, full is RIP)
PAC: you can only jump to signed pointers
NX: the stack isn’t executable (no shellcode)
Fortify: %n only allowed if fmtstr in read-only memory
0x565...
: binary base (PIE enabled)0x804...
: binary base (PIE disabled)0xf7f...
: library base0xff....
: stack baseand stack-dump walkthrough