Restaurant

863KB
Open

Challenge Description :

Welcome to our Restaurant. Here, you can eat and drink as much as you want! Just don't overdo it..

Basic File Enumeration :

the file is a 64bit binary dynamically linked and not stripped which makes the binary reversing easier since the symbols will not be obfuscated, the only protection enabled is NX which makes the user input not executable in the stack so we cannot inject shellcode

┌──(kali㉿kali)-[~/hackthebox/pwn/restaurant]
└─$ file restaurant 
restaurant: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=34d48877c9e228a7bc7b66b34f0d4fa6353d20b4, not stripped
                                                                                                                                     
┌──(kali㉿kali)-[~/hackthebox/pwn/restaurant]
└─$ checksec --file=restaurant
[*] '/home/kali/hackthebox/pwn/restaurant/restaurant'
    Arch:     amd64-64-little
    RELRO:    Full RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)

let's open the binary with ghidra and take a look at the functions

first we have the main function which give the user option to choose between fill or drink

the interesting function is fill since it reads user input into a 0x32 local variable and takes up to 0x400 which gives very high space for buffer overflow, the drink function is not interesting since there is no vulenrability there

so to exploit this binary we will perform a return to libc attack (Ret2Libc Attack) since the binary is dynamically linked and there is no win functin to return to.

so to do it we will need to stages of payload the first will leak some function address from the Global Offset Table (GOT) and then use this address to calculate the libc base address and then we can find the system address which we will call in the second payload with '/bin/sh' as parameter to get shell.

Exploit :

Flag :

Last updated

Was this helpful?