mansk1es.medium.com

Vulnhub — Netstart 1 Writeup

mansk1es

mansk1es

Netstart is a ‘vulnhub’ Linux machine running a wine program vulnerable to Buffer Overflow, escalating privileges through user’s sudo permissions to root. Let’s get right to it.

First and foremost we start with the nmap scan:

Press enter or click to view image in full size

2 tcp ports open: 21(ftp) and port 2371(worldwire)

Looks like ‘ftp’ has anonymous login enabled. Let’s go and take a look:

Press enter or click to view image in full size

I’ve seen 2 files in the ftp directory, login.exe and login_support.dll, I downloaded them to my machine so I can examine and debug the program.

I now nc to port 2371

Press enter or click to view image in full size

Seems like we’ve got an input option. At this point I’m thinking BoF could be an option on this box.

Sending the downloaded files into CommandoVM to debug the program with Immunity Debugger, I setup an smbserver on my Kali and accessed it from Windows CommandoVM.

Press enter or click to view image in full size

Setting up the server on my Kali machine.
WIN+R and type \\ip\sharename, logging in with the credentials I setup.

Press enter or click to view image in full size

Successfully connected to the SMBServer, extracting the files to a folder called “login” I created.

Press enter or click to view image in full size

Files on the local machine.

Launched Immunity Debugger and opened login.exe. It required login_support.dll because.. you’ll see. (;

Press enter or click to view image in full size

opened ‘login.exe’ and ran the program.

Press enter or click to view image in full size

As we can see the program runs and waiting for connections.

I tried to connect to the CommandoVM on port 2371 and it successfully connected and requested the exact same thing as the target on port 2371. If this is vulnerable to BoF we can exploit the target machine!

Press enter or click to view image in full size

nc on the CommandoVM machine.

Now I’ve ran python scripts against the program located at CommandoVM on port 2371, every script will be documented here.

The fuzzing template.

Press enter or click to view image in full size

Fuzzing crashed at %s bytes. (1900 at this case)

We can see it crashed at 1900 bytes. Let’s generate a pattern using msf-pattern_create.

Press enter or click to view image in full size

Generated the following.

We run the next script against the program:

Press enter or click to view image in full size

Step 2

Press enter or click to view image in full size

The program crashed with the EIP — 65433765

We now see if we can find an offset using the EIP address.

Press enter or click to view image in full size

Offset found!

We found an exact match at 1702. We set our offset to 1702 in the next scripts!

Get mansk1es’s stories in your inbox

Join Medium for free to get updates from this writer.

We run the next script against the program to see if we can control the EIP to be 4 Bs.

Step 3

We can control the EIP! We overwritten the EIP with 4 Bs.

Press enter or click to view image in full size

EIP is 42424242 (4 times the letter B)

Now we need to find bad characters. We run the following script:

Press enter or click to view image in full size

Step 4 — BadChar finding

I’ve removed \x00 (null byte) from the bytearray because it is an already known bad character.

Press enter or click to view image in full size

Hmm, doesn’t seem like we have bad characters except for the null byte.

Now we use mona to identify vulnerable modules that has the least security.

Press enter or click to view image in full size

Running !mona modules in the console.

Remember login_support.dll? We can see login_support.dll has no security at all! Let’s try to find a JMP ESP address using the module, with ‘mona’ again.

Press enter or click to view image in full size

2 addresses found.

Great, we found 2 addresses, I’m going to use the address 0x625012b8 on my next scripts.

625012b8 is indeed JMP ESP. Now the next script is going to verify the address, I’m going to set a breakpoint at this address.

Press enter or click to view image in full size

Now let’s check Immunity Debugger:

Great. The EIP is our target.

Now I’m going to generate a shellcode with msfvenom. I’ve added x0a and x0d as bad characters, because they are commonly bad characters as well.

Press enter or click to view image in full size

Putting the generated shellcode on our attacking script:

Ignore the “try” comment.

Now we set up a nc listener listening to port 51337.

Press enter or click to view image in full size

Reverse shell returned.

We got a reverse shell!

Press enter or click to view image in full size

Use ‘fox’ can execute /usr/bin/systemctl as root. GTFObins have a page showing how to use that method.

Press enter or click to view image in full size

Let’s try this:

Press enter or click to view image in full size

We can see it is indeed invoking the `less` pager.

Now we type !sh in this ‘less’ pager.

Got root

We got root! Fun box — this machine is a great BoF practice.

proof.txt