amt has asked for the wisdom of the Perl Monks concerning the following question:
# Above this are DB queries to OpenAanval # idsMain.event.eid and idsMain.event.sid correspond # to snort.data.cid and snort.data.sid respectfully $dbh->do("use snort") or die "$!\n"; my $plh = $dbh->prepare("SELECT data_payload FROM data WHERE cid = '$e +id' AND sid = '$sid' LIMIT 1"); $plh->execute() or die "$!\n";; while( my @rows = $plh->fetchrow_array ){ $ea = $rows[0]; } $plh->finish; my $bit = 2; # size of gouping for (my ($j,$i) = 0; $i < length($ea);$j+=$bit, $i++) { if( $j+$bit <= length($ea) ) { #put into an array $pd[$i] = substr($ea,$j,$bit); } else { next; } # skip any errors } my $count = 0; # count for number of tuples in a row foreach my $this (@pd){ next if (length($this) != 2); # skip errors from above $eb .= "\n" if( (($count % 16) == 0) && ($count != 0) ); # ins +ert cr/lf when 16 chars are printed $eb .= "$this "; #cat this array entry $count++; } ##### Sample output (padded in comments ;) #30 XX 02 01 00 04 08 73 33 35 XX 37 31 XX 62 A0 #2E 02 04 BE 41 XX 34 02 01 00 02 01 00 30 20 30 #0E 06 0A 2B 06 01 02 01 02 XX 01 0A XX 05 00 30 #0E XX 0A 2B 06 01 XX 01 02 02 01 10 03 05 00 ##### XX inserted to protect the innocent
$dbh->do("use snort"); my $plh = $dbh->prepare("SELECT data_payload FROM data WHERE cid = '$e +id' AND sid = '$sid' LIMIT 1"); $plh->execute(); while( my @rows = $plh->fetchrow_array ){ $ea = $rows[0] =~ s/([a-fA-F0-9]{2,2})/chr(hex($1))/exg; } $plh->finish;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Snort data_payload decoding
by Joost (Canon) on Oct 14, 2004 at 14:56 UTC | |
by amt (Monk) on Oct 14, 2004 at 15:12 UTC | |
by ikegami (Patriarch) on Oct 14, 2004 at 15:51 UTC | |
by amt (Monk) on Oct 14, 2004 at 16:23 UTC | |
by ikegami (Patriarch) on Oct 14, 2004 at 16:32 UTC | |
|