Please choose your action (say_hi, say_hello, say_goodbye, say_flag) :> say_hi
Please choose your action (say_hi, say_hello, say_goodbye, say_flag) :> say_hi
...
@@ -26,25 +26,76 @@ But with the third option:
...
@@ -26,25 +26,76 @@ But with the third option:
Please choose your action (say_hi, say_hello, say_goodbye, say_flag) :> say_flag
Please choose your action (say_hi, say_hello, say_goodbye, say_flag) :> say_flag
# No valid action!
# No valid action!
```
```
We can see that there are the different functions have different addresses, except for "say_flag".
We can see that there are the different functions have different addresses, except for "say_flag" which is disabled.
So lets search where we can find the "say_flag" function.
So lets search where in the binary we can find the "say_flag" function.
```bash
```bash
objdump -d app_compiled_64
objdump -d app_compiled_64
app_compiled_64: file format elf64-x86-64
# app_compiled_64: file format elf64-x86-64
...
# ...
00000000000011fa <say_flag>:
# 00000000000011fa <say_flag>:
...
# ...
0000000000001211 <say_hi>:
# 0000000000001211 <say_hi>:
...
# ...
0000000000001228 <say_hello>:
# 0000000000001228 <say_hello>:
...
# ...
```
```
We can see the address of the functions we previously called.
We can see the address of the functions we previously called.
Did you notice a difference in the pointer addresses?
When we executed the function "say_hi" address 0x555555555211 was printed but the objdump said it is located at at 0x0000000000001211.
So there is a offset between the addresses reported by objdump and the *real* addresses while running the program.
Keep this offset in mind, you'll need it later.
Thankfully, because we prefixed setarch `uname -m` -R to the binary, we disabled the [ASLR](https://www.techtarget.com/searchsecurity/definition/address-space-layout-randomization-ASLR) feature and the offset is the same on our system and the server.
> If you did run the app in a debugger e.g. gdb it is likely that ALSR is also disabled.
We do now know where we need to jump to obtain a flag, but how can we convince our program to jump to this address?
We do now know where we need to jump to obtain a flag, but how can we convince our program to jump to this address?
### Buffer overflow
### Buffer overflow
We can override the "input_buffer" and write the adress of our flag function directly into the stack
We can override the "input_buffer" and write the address of our flag function directly into the stack.
First we need to know the size of the "input_buffer".