http://www.perlmonks.org?node_id=997515


in reply to Re^3: Inserting domain name into Snort rule
in thread Inserting domain name into Snort rule

First of all; thank you very much for your help. I did what you said and its very close but doing some weird stuff.

Here's what I have:
#!/usr/bin/perl

$work = "/var/tmp/work";
$input = "$work/domainlist.csv";

open (IN,"$input");
open (OUT,">domainlist.rules");
while (<IN>) {
  chomp();
  $domain = $_;

    $dns = join '|', '', ( map { sprintf('%02d',length $_), $_ } split /\./, $domain ), '00', '';
      print "$dns\n";
}

What I get is something like this:


|00|foobar|09|foodomain|04|com

|00|www|06|foobar|12|foobardomain|03|cc


If puts the zeros on the front instead of the end and doesn't give a count

then it counts the next sections correctly

then it always adds an extra count for the last part, maybe its counting a space or something