Posts Tagged ‘Networking’

Internet Redlight districts

Tuesday, April 8th, 2008

Taking some data gathered form various filters I’m investigating for the local schools network,a nd combining with some custom scraping tools which Blake has been assisting with Ive drawn a map of the location of some 15 000 IP addresses representing the seedy side of the Internet.

Hilbert Plot of a pile of porn sites

The image is rendered using the Hilbert Curve Program developed in conjunction with Nick Pilkington, as a project for VizSec 2007 last year.

Sorting IPv4 Addresses with GNU Sort

Tuesday, April 8th, 2008

While processing some rather large lists of addresses as part of a side project, I needed to be able to sort them in a numerical order within a shell script. I had a file with lines like:

  • 69.90.132.19
  • 69.90.132.22
  • 66.152.91.84
  • 208.122.204.181
  • 69.90.132.22
  • 69.90.132.31
  • 216.131.106.249
  • 216.131.84.26
  • 67.55.105.252
  • 208.64.44.102

Standard sort using sort –n only sorts on the first octet, and although it’s a improvement on alphabetic sorting its not ideal. The solution comes in specifying a pile of switches to sort:

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4

This gets it sorted in Numerical order, by octet, using a period (dot) as a separator between octets. Combining this with a –u flag gives one a nicely sorted, unique list of IP addresses. This could probably be extended to IPv6 without too much hastle.