#!/bin/bash

# WARNING
# do NOT use this script on large flow files with a large number
# of IP addresses space in default config. Do not lower the time
# variable of the sleep statement, otherwise you create a
# flood attack against ripe or arin.
# 

A=`awk '{ if (length($6) > 6 || length($9) > 6) {
	split($6,A,"."); 
	split($9,B,"."); 
# assume all networks larger /24, useful if large IP space present
#			printf("%d.%d.%d.0\n%d.%d.%d.0\n", A[1], A[2], A[3], B[1], B[2], B[3]);      
# do not assume any minimum network mask
	printf("%d.%d.%d.%d\n%d.%d.%d.%d\n", A[1], A[2], A[3], A[4], B[1], B[2], B[3], B[4]);      
   }	
 }' $1 | sort -n | uniq`

for f in $A ; do
	echo $f 
	whois $f | awk '{if ( (index($0,"NET") != 0 && index($0,":") == 0) || ( $1 == "owner:" || $1 == "role:" || $s == "address:" || $1 == "descr:" || $1 == "inetnum:" || $1 == "NetRange:" || $1 == "CIDR:" || index($1,"OrgName") != 0 )) print "# "$0;}'

	let t=$RANDOM/3000+6
	sleep $t
done
