{"id":59336,"date":"2024-09-01T04:10:35","date_gmt":"2024-09-01T01:10:35","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180933\/urgent11_check.rb.txt"},"modified":"2024-09-01T04:10:35","modified_gmt":"2024-09-01T01:10:35","slug":"urgent-11-scanner-based-on-detection-tool-by-armis","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/urgent-11-scanner-based-on-detection-tool-by-armis\/","title":{"rendered":"URGENT\/11 Scanner, Based On Detection Tool By Armis"},"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::Auxiliary::Scanner<br \/>include Msf::Exploit::Capture<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;URGENT\/11 Scanner, Based on Detection Tool by Armis&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module detects VxWorks and the IPnet IP stack, along with devices<br \/>vulnerable to CVE-2019-12258.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Ben Seri&#8217;, # Upstream tool<br \/>&#8216;Brent Cook&#8217;, # Metasploit module<br \/>&#8216;wvu&#8217; # Metasploit module<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2019-12258&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/armis.com\/urgent11&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/ArmisSecurity\/urgent11-detector&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2019-08-09&#8217;, # NVD entry publication<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Notes&#8217; =&gt; {&#8216;Stability&#8217; =&gt; [CRASH_SAFE]}<br \/>))<\/p>\n<p>register_options([<br \/>OptString.new(&#8216;RPORTS&#8217;, required: true, default: &#8220;21 22 23 80 443&#8221;, desc: &#8216;Target ports for TCP detections&#8217;)<br \/>])<\/p>\n<p>register_advanced_options([<br \/>OptInt.new(&#8216;RetransmissionRate&#8217;, required: true, default: 3, desc: &#8216;Send n TCP packets&#8217;)<br \/>])<\/p>\n<p>deregister_options(&#8216;PCAPFILE&#8217;, &#8216;FILTER&#8217;)<br \/>end<\/p>\n<p>#<br \/># Utility methods<br \/>#<\/p>\n<p>def rports<br \/>datastore[&#8216;RPORTS&#8217;].split(\/[\\s,]\/).collect{|i| (i.to_i.to_s == i) ? i.to_i : nil}.compact<br \/>end<\/p>\n<p>def filter(ip)<br \/>&#8220;src host #{ip} and dst host #{Rex::Socket.source_address(ip)}&#8221;<br \/>end<\/p>\n<p>#<br \/># Scanner methods<br \/>#<\/p>\n<p>def run_host(ip)<br \/># XXX: Configuring Ethernet and IP headers sends a UDP packet!<br \/>@config = PacketFu::Utils.whoami?(target: ip)<\/p>\n<p>open_pcap<br \/>capture.setfilter(filter(ip))<\/p>\n<p>port_open = false<br \/>rports.each do |rport|<br \/>port_open |= run_detections(ip, rport)<br \/>end<br \/>raise RuntimeError.new(&#8220;No ports open on #{ip} from #{datastore[&#8216;RPORTS&#8217;]}&#8221;) if !port_open<br \/>rescue RuntimeError =&gt; e<br \/>fail_with(Failure::BadConfig, e.message)<br \/>ensure<br \/>close_pcap<br \/>end<\/p>\n<p>def detections<br \/>%w[<br \/>tcp_dos_detection<br \/>tcp_malformed_options_detection<br \/>icmp_code_detection<br \/>icmp_timestamp_detection<br \/>]end<\/p>\n<p>def run_detections(ip, port)<br \/>print_status(&#8220;#{ip}:#{port} being checked&#8221;)<\/p>\n<p>final_ipnet_score = 0<br \/>final_vxworks_score = 0<br \/>affected_vulnerabilities = []\n<p>begin<br \/>sock = Rex::Socket::Tcp.create(<br \/>&#8216;PeerHost&#8217; =&gt; ip,<br \/>&#8216;PeerPort&#8217; =&gt; port<br \/>)<br \/>rescue<br \/>vprint_bad(&#8220;Could not connect to #{ip}:#{port}, cannot verify vulnerability&#8221;)<br \/>return false<br \/>end<\/p>\n<p>detections.each do |detection|<br \/>@ipnet_score = 0<br \/>@vxworks_score = 0<br \/>@vulnerable_cves = []\n<p>detection_name = detection.camelize<\/p>\n<p>begin<br \/>send(detection, sock, ip, port)<br \/>rescue StandardError =&gt; e<br \/>vprint_error(&#8220;#{detection_name} failed: #{e.message}&#8221;)<br \/>next<br \/>end<\/p>\n<p>vprint_status(<br \/>&#8220;\\t#{detection_name.ljust(30)}&#8221; \\<br \/>&#8220;\\tVxWorks: #{@vxworks_score}&#8221; \\<br \/>&#8220;\\tIPnet: #{@ipnet_score}&#8221;<br \/>)<\/p>\n<p>final_ipnet_score += @ipnet_score<br \/>final_vxworks_score += @vxworks_score<br \/>affected_vulnerabilities += @vulnerable_cves<br \/>end<\/p>\n<p>sock.close<\/p>\n<p>if final_ipnet_score &gt; 0<br \/>vprint_good(&#8220;#{ip}:#{port} detected as IPnet&#8221;)<br \/>elsif final_ipnet_score &lt; 0<br \/>vprint_error(&#8220;#{ip}:#{port} detected as NOT IPnet&#8221;)<br \/>end<\/p>\n<p>if final_vxworks_score &gt; 100<br \/>vprint_good(&#8220;#{ip}:#{port} detected as VxWorks&#8221;)<br \/>elsif final_vxworks_score &lt; 0<br \/>vprint_error(&#8220;#{ip}:#{port} detected as NOT VxWorks&#8221;)<br \/>end<\/p>\n<p>affected_vulnerabilities.each do |vuln|<br \/>msg = &#8220;#{ip}:#{port} affected by #{vuln}&#8221;<br \/>print_good(msg)<br \/>report_vuln(<br \/>host: ip,<br \/>name: name,<br \/>refs: references,<br \/>info: msg<br \/>)<br \/>end<br \/>true<br \/>end<\/p>\n<p>#<br \/># TCP detection methods<br \/>#<\/p>\n<p>def tcp_malformed_options_detection(sock, ip, port)<br \/>pkt = PacketFu::TCPPacket.new(config: @config)<\/p>\n<p># IP destination address<br \/>pkt.ip_daddr = ip<\/p>\n<p># TCP SYN with malformed options<br \/>pkt.tcp_dst = port<br \/>pkt.tcp_flags.syn = 1<br \/>pkt.tcp_opts = [2, 4, 1460].pack(&#8216;CCn&#8217;) + # MSS<br \/>[1].pack(&#8216;C&#8217;) + # NOP<br \/>[3, 2].pack(&#8216;CC&#8217;) + # WSCALE with invalid length<br \/>[3, 3, 0].pack(&#8216;CCC&#8217;) # WSCALE with valid length<br \/>pkt.recalc<\/p>\n<p>res = nil<\/p>\n<p>datastore[&#8216;RetransmissionRate&#8217;].times do<br \/>pkt.to_w<br \/>res = inject_reply(:tcp)<\/p>\n<p>break unless res<br \/>end<\/p>\n<p>unless res<br \/>return @vxworks_score = 0,<br \/>@ipnet_score = 50<br \/>end<\/p>\n<p>if res.tcp_flags.rst == 1 &amp;&amp;<br \/>res.tcp_dst == pkt.tcp_src &amp;&amp; res.tcp_dst == pkt.tcp_src<\/p>\n<p>return @vxworks_score = 100,<br \/>@ipnet_score = 100<br \/>end<\/p>\n<p>return @vxworks_score = -100,<br \/>@ipnet_score = -100<br \/>end<\/p>\n<p>def tcp_dos_detection(sock, ip, port)<br \/>pkt = PacketFu::TCPPacket.new(config: @config)<\/p>\n<p># IP destination address<br \/>pkt.ip_daddr = ip<\/p>\n<p># TCP SYN with malformed (truncated) WS option<br \/>pkt.tcp_src = sock.getlocalname.last<br \/>pkt.tcp_dst = sock.peerport<br \/>pkt.tcp_seq = rand(0xffffffff + 1)<br \/>pkt.tcp_ack = rand(0xffffffff + 1)<br \/>pkt.tcp_flags.syn = 1<br \/>pkt.tcp_opts = [3, 2].pack(&#8216;CC&#8217;) + # WSCALE with invalid length<br \/>[1, 0].pack(&#8216;CC&#8217;) # NOP + EOL<br \/>pkt.recalc<\/p>\n<p>res = nil<\/p>\n<p>datastore[&#8216;RetransmissionRate&#8217;].times do<br \/>pkt.to_w<br \/>res = inject_reply(:tcp)<\/p>\n<p>break unless res<br \/>end<\/p>\n<p>unless res<br \/>return @vxworks_score = 0,<br \/>@ipnet_score = 0<br \/>end<\/p>\n<p>if res.tcp_flags.rst == 1 &amp;&amp;<br \/>res.tcp_dst == pkt.tcp_src &amp;&amp; res.tcp_dst == pkt.tcp_src<\/p>\n<p>return @vxworks_score = 100,<br \/>@ipnet_score = 100,<br \/>@vulnerable_cves = [&#8216;CVE-2019-12258&#8217;]end<\/p>\n<p>return @vxworks_score = 0,<br \/>@ipnet_score = 0<br \/>end<\/p>\n<p>#<br \/># ICMP detection methods<br \/>#<\/p>\n<p>def icmp_code_detection(sock, ip, _port = nil)<br \/>pkt = PacketFu::ICMPPacket.new(config: @config)<\/p>\n<p># IP destination address<br \/>pkt.ip_daddr = ip<\/p>\n<p># ICMP echo request with non-zero code<br \/>pkt.icmp_type = 8<br \/>pkt.icmp_code = rand(0x01..0xff)<br \/>pkt.payload = capture_icmp_echo_pack<br \/>pkt.recalc<\/p>\n<p>pkt.to_w<br \/>res = inject_reply(:icmp)<\/p>\n<p>unless res<br \/>return @ipnet_score = 0<br \/>end<\/p>\n<p># Echo reply with zeroed code<br \/>if res.icmp_type == 0 &amp;&amp; res.icmp_code == 0<br \/>return @ipnet_score = 20<br \/>end<\/p>\n<p>@ipnet_score = -20<br \/>end<\/p>\n<p>def icmp_timestamp_detection(sock, ip, _port = nil)<br \/>pkt = PacketFu::ICMPPacket.new(config: @config)<\/p>\n<p># IP destination address<br \/>pkt.ip_daddr = ip<\/p>\n<p># Truncated ICMP timestamp request<br \/>pkt.icmp_type = 13<br \/>pkt.icmp_code = 0<br \/>pkt.payload = &#8220;\\x00&#8221; * 4<br \/>pkt.recalc<\/p>\n<p>pkt.to_w<br \/>res = inject_reply(:icmp)<\/p>\n<p>unless res<br \/>return @ipnet_score = 0<br \/>end<\/p>\n<p># Timestamp reply<br \/>if res.icmp_type == 14<br \/>return @ipnet_score = 90<br \/>end<\/p>\n<p>@ipnet_score = -30<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::Auxiliary::Scannerinclude Msf::Exploit::Capture def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;URGENT\/11 Scanner, Based on Detection Tool by Armis&#8217;,&#8216;Description&#8217; =&gt; %q{This module detects VxWorks and the IPnet IP stack, along with devicesvulnerable to CVE-2019-12258.},&#8216;Author&#8217; =&gt; [&#8216;Ben Seri&#8217;, # Upstream tool&#8216;Brent Cook&#8217;, # Metasploit module&#8216;wvu&#8217; # &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-59336","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59336","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=59336"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59336\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}