der Anfang Regex um Daten zu extrahieren

This commit is contained in:
2025-01-25 23:14:05 +01:00
commit 69330864b1
2 changed files with 704 additions and 0 deletions

26
ban2mysql.pl Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use Data::Printer;
use File::Slurp;
# Connect to the database.
my $dbh = DBI->connect("DBI:MariaDB:database=kram;host=edna",
"steffen", "66WXRlvF0UUV",
{'RaiseError' => 1});
my @file = read_file('sys.log');
for my $l ( @file ) {
my ( $month, $day, $h, $m, $s, $kat, $src, $dst, $port ) = $l =~ /(.*?) (.*?) (..):(..):(..) 192.*banIP\/...-wan\/drop\/(.*?):.*SRC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) DST=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*DPT=(\d+)/;
if ( $month ) {
p $month;
p $src;
}
}
# $dbh->selectall_arrayref($statement);