#!/usr/bin/perl # # # Written by zillion ( at safemode.org ) # # The script generates random TCP packets with random source address, # source port and random flags. Pretty funny and can be useful for firewall # testing # require 'getopts.pl'; use Net::RawIP; Getopts('i:p:a:'); $a = new Net::RawIP; if(!defined $opt_i) { print "Usage $0 -i -p -a \n"; exit; } print " ------------------------------------------------------------------------- ---------------\n"; sub create_packet { $ff = int rand(255); $gg = int rand(255); $hh = int rand(255); $ii = int rand(255); $src = int rand(9999); $ip = "$ff.$gg.$hh.$ii"; $count = 0; while($count < 6) { @vlag =(1,2); $flag = int rand(@vlag); push @flags, "$flag"; $count++; } format flags = | Address: @<<<<<<<<<<<<<< | Src: @<<<<| Psh: @<| Ack:@<| Rst: @<| Fin:@<| Urg:@< | Syn:@<| $ip $src $flags[0] $flags[1] $flags[2] $flags[3] $flags[4] $flags[5] . $~ = "flags"; write; $data = "Safemode rocks " x 5; $a->set({ ip => {saddr => $ip, ttl => 66, daddr => $opt_i }, tcp=> {dest => $opt_p, data => $data, psh => $flags[0], ack => $flags[1], rst => $flags[2], fin => $flags[3], urg => $flags[4], source => $src, syn => $flags[5]} }); $a->send(0,1); undef @flags; } $teller = 0; while($teller < $opt_a) { &create_packet; $teller++; } print " ------------------------------------------------------------------------- ---------------\n";