#!/usr/bin/env ruby
#
# $Id: icmp-spew 174 2010-08-21 22:26:52Z jhart $
#
# Given a source and destination IP address
# and a data size, spew all 65536 possible ICMP
require 'rubygems'
require 'racket'
include Racket
if (ARGV.size != 3)
puts "Usage #{$0} "
exit!
end
def tick
@it += 1
@it = 0 if @it >= @ticks.size
print "\r#{@ticks[@it]}"
STDOUT.flush
end
def rand_icmp(n)
n.l3 = L3::IPv4.new
n.l3.src_ip= ARGV[0]
n.l3.dst_ip = ARGV[1]
n.l3.version = 0x4
n.l3.hlen = 0x5
n.l3.protocol = 0x1
n.l3.flags = 0x0
n.l3.foffset = 0x0
n.l4 = L4::ICMP.new(Misc.randstring(20))
n.sendpacket
tick
end
@it = 0
@ticks = %w( / - \\ | )
n = Racket::Racket.new
n.iface = "eth0"
puts "Spewing..."
while (true)
rand_icmp(n)
end
# vim: set ts=2 et sw=2: