Avishai's CTF Writeups

...

View on GitHub

← Back to OverTheWire

This folder contains solutions for the Utumno wargame from OverTheWire.

utumno0

when i run the file, it says to read it, however i don’t have read permissions. so, i decided to try hooking the file, using hooking the put function.

After i saw the hooking works, i read the stack using printf("%p %p %p %p %p %p %p %p\n"), and then i saw addresses that starts with 0x804, maybe indicates on local variables on the stack, that might contain the password.

{% include_relative scripts/level0/hook.c %}

, you need to adjust the addresses on the stack of the (maybe) local variables.

the commands for compiling and linking the so file, here.

gcc -m32 -shared -fPIC -o hook.so hook.c -ldl
LD_PRELOAD=./hook.so /utumno/utumno0

image

Flag: ytvWa6DzmL

Next Level Writeup

utumno1

here, we need to put our shellcode after “sh_”. there is a small problem that we can’t use “\” in the shell code, because this char can’t be in filname

{% include_relative scripts/level1/level1.py %}
{% include_relative scripts/level1/script.sh %}

In the shellcode it tries to execute this command: system("sh"), so it means we need to link it to /bin/sh.

put the code in the files cat > script.sh and cat > shellcode.py

these are the commands that you need to run.

chmod +x script.sh
ln -sf /bin/sh sh
./script.sh

lastly, run this: /utumno/utumno1 .

image

Flag: RdUzprHKSm

Next Level Writeup

utumno2

first we can see there is no protection, and also ASLR disabled. image

then, after analyzing the code i realized that i can pass at the 9th place of envp some content that will be written to a buffer, and also i found out that the ret address is found in the stack after 16 bytes. so, what we need to do is override the ret address and put our shellcode.

because we run with envp, it overrides our regular SHELLCODE environment variable.

we need to find the address of the shellcode, try debugging and find it. for example: image (here i debug and put breakpoint on where the main of /utumno/utumno2 is find, it won’t change because ASLR is turned off)

{% include_relative scripts/level2/level2.c %}

, only change the address_of_shellcode variable and this should work.

image

Flag: h3kVKJZuid

Next Level Writeup

utumno3

first we can see there is no protection, and also ASLR disabled. image

i decompiled the file using ghidra, and find out that we can manipulate our input in order to override the return address to our shellcode address. image

{% include_relative scripts/level3/shellcode.py %}

, that runs: execve('/bin/cat','/tmp/passwwd')

{% include_relative scripts/level3/level3.py %}

, you need to change the address of the shellcode based on the address of your environment variable.

also, you need to run this command: ln -sf /etc/utumno_pass/utumno4 /tmp/passwwd

image

Flag: qHWLExh7C5

Next Level Writeup

utumno4

first we can see there is no protection, and also ASLR disabled. image

in this level we do buffer overflow, but we also need to pass one check, this check: image check that the len of the buffer answer on specific rule.

here you can find the shellcode shellcode.py

{% include_relative scripts/level4/level4.py %}

, you need to change the address of the shellcode based on the address of your environment variable.

image

Flag: vY134qxapL

Next Level Writeup

utumno5

same as level3, took the code from there.

{% include_relative scripts/level5/level5.c %}

image

Flag: aGlKWrixsh

Next Level Writeup

utumno6

first i took the code and decompiled it using ghidra. i can see integer overflow, that we can give it negative value and go back in the memory. image

the idea behind the attack is to override where the return address is found, and put our shellcode address. image

we can see that the address of the auStack_34 is located in [ebp-0x34], so if we’ll set arg1 = -1, we can override the address. than, we need to find where on the stack the return address is found, take this memory location, and this will be the new address of our auStack_34 image

{% include_relative scripts/level6/level6.py %}

.

image

Flag: VHOuCx7iA5

Next Level Writeup

utumno7

here we override the ebp stored register, and put there our address. in the code it called buffer_address, you need to put there the address of the buffer. also, there is address for the shellcode, which stored in shellcode_address.

{% include_relative scripts/level7/level7.py %}

, you need to fill these two fields with correct addresses.

image

Flag: oqnM7PWFIn

Next Level Writeup