Psi Beta Rho
Spring 2024 - Week 5
π£ Announcements
glibc linker
Enzo
dynamic linker
elf anatomy
typedef struct {
Elf64_Xword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
plt and got
relro
linker only populates runtime resolver
rest of GOT points to local functions that call the resolver with appropriate relocation index
resolver writes actual address so subsequent plt calls go to the right function
attack surface
leakless fini
ElfW(Dyn) *fini = map->l_info[DT_FINI];
if (fini != NULL)
DL_CALL_DT_FINI (map, ((void *) map->l_addr + fini->d_un.d_ptr));
typedef struct {
Elf64_Xword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
leakless fini
example chall
#include <unistd.h>
#include <stdlib.h>
long readint() {
char buf[0x11] = {};
read(0, buf, 0x10);
return atol(buf);
}
int main() {
char *p = malloc(0x3000);
for(;;) {
write(1, "idx: ", 5);
long idx = readint();
if(idx == 0)
break;
write(1, "data: ", 6);
read(0, p+idx, 8);
}
}
house of muney
Questions?
PBR Rahhh!