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
would anyone like to discuss their progress
we’re writing the class notes for this weeks extended lecture
does anyone have a presentation (for bonus marks)
what is the problem with 2 factor authenticator
what’s the difference between
when might each be used?
basic example
0x18 [ ARGS ] <- parameters
0x14 [ EIP ] <- stored return pointer
0x10 [ EBP ] <- stored frame pointer
0x0C [ AAAAAAAA ] <- local vars
0x08 [ 00000001 ] <- an int?
0x04 [ DEADBEEF ] <- a pointer
0x00 [ 59454554 ] <- 4 characters
referenced in relation to ebp
e.g. ebp-0x4
ebp-0x4
ebp+0x8
tldr: trust is bad
what happens when you write more content than a buffer can hold
so where exactly does that content go
this could allow us to change the application flow
what functions cause buffer overflows?
char buffer[32] a;
// read content
gets(a);
fgets(a, 0x32, stdin)
// printf, but write to a string not stdout
sprintf(a, "%s %s %d", some, random, vars);
snprintf(a, "%s %s %d", 0x32, and, more, vars);
it’s not just reading content, but also copying?
char buffer[32] a, buffer[64] b;
// copy contents of b into a
strcpy(a, b);
strncpy(a, b, 64);
// append contents of b onto a
strcat(a, b);
strncat(a, b, strlen(a) + strlen(b));
binja is really nice and tells us the distance
if we wrote 40 bytes of padding, and one additional byte into the buffer, we would overwrite the int
kinda like bruteforce but smart
# gets(buffer)
$ AAAABBBBCCCCDDDDEEEEFFFF
# we SIGSEGV at EIP = EEEE
then we need 16 bytes of padding before the return address
pwntools
#
cyclic(20) # generate a chunk of length 20
#
c = cyclic_gen()
c.get(n) # get a chunk of length n
c.find(b'caaa') # (8,0,8): pos 8, which is chunk 0 at pos 8
bash
# you can also do it on commandline
cyclic 12 # aaaaaaabaaac
cyclic -l aaab # -> 1 = find chunk
cyclic -o aaae # -> 13 = find offset
ew cringe security stuff
position independent execution
win()
notice the region is entirely different
# no PIE
$ ./leak
win() is at 0x8041234
# with PIE
$ ./leak
win() is at 0x5650161
$ ./leak
win() is at 0x5650911
address space layout randomization
# turn aslr off
sudo sysctl kernel.randomize_va_space=0
# check if it's on
cat /proc/sys/kernel/randomize_va_space
ASLR is a kernel protection, PIE is a binary protection
they save the day and make overflows impossible
__stack_chk_fail()
thing is in some of the source code you’ll have read 0x1C [ ARGS ] <- parameters
0x18 [ EIP ] <- stored return pointer
0x14 [ EBP ] <- stored frame pointer
0x00 [ canary ] <- canary goes here
0x0C [ AAAA ] <- these are local vars
0x08 [ AAAA ]
0x04 [ AAAA ]
0x00 [ AAAA ]
real value stored somewhere else, and checked before the function returns
memory leaks basically