I’ve been irritated by Nessus’s HTML output one too many times. I hate the fact that the list by host is in random order. Who thought that was a good idea?
#!/usr/bin/perl open F, "<index.html"; my @R = <F>; close F; my $R = join '',@R; my ($one, $two) = split /Notes.+?<tr>/s, $R; my ($two, $three) = ($two =~ m!(.*)(</tr>.</table>.*$)!s); my @O = split /</tr>.<tr>/si, $two; my @X = join '</tr><tr>', (sort by_ip @O); print $one, '<tr>',@X, $three; sub by_ip { my @a = $a =~ /(d+).(d+).(d+).(d+)/; my @b = $b =~ /(d+).(d+).(d+).(d+)/; $a[0] <=> $b[0] || $a[1] <=> $b[1] || $a[2] <=> $b[2] || $a[3] <=> $b[3] || $a <=> $b }
The list should now be ordered first by hostname, and then by IP address. Share and enjoy.