Inizio abilitazione modulo proxy
This commit is contained in:
82
proxy/conntrack.pl
Executable file
82
proxy/conntrack.pl
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/perl
|
||||
$|=1;
|
||||
|
||||
use DBI;
|
||||
|
||||
my $proxy_IP = '192.168.1.3';
|
||||
my $proxy_PORT = 3128;
|
||||
|
||||
`sysctl -w net.netfilter.nf_conntrack_acct=1`;
|
||||
|
||||
my $dbmysql = DBI->connect("DBI:mysql:;host=127.0.0.1", "pannello_proxy", "CuQlM1lfF4VZDCIP") or die ($DBI::errstr);
|
||||
$sts = $dbmysql->prepare("use pannello_vbc");
|
||||
$sts->execute ();
|
||||
|
||||
|
||||
#/usr/sbin/conntrack -E -p tcp --dport 3128 -oextended,id,timestamp -eDESTROY
|
||||
|
||||
open CT, "/usr/sbin/conntrack -E -eNEW,DESTROY -otimestamp,id -p tcp --dport $proxy_PORT |" or die "non va\n";
|
||||
|
||||
while (<CT>) {
|
||||
my $riga = $_;
|
||||
# print "$riga";
|
||||
|
||||
if ( $riga =~ /^\s*\[(\d+)\.\d+\]\s+\[NEW\] tcp\s+\d+ \d+ \S*\s*src=(\S+) dst=(\S+) sport=\d+ dport=(\d+)\s+\[\w+\] src=\S+ dst=\S+ sport=\d+ dport=\d+ id=(\d+)/ ) {
|
||||
my $remote_START = $1;
|
||||
my $remote_IP = $2;
|
||||
my $local_IP = $3;
|
||||
my $local_PORT = $4;
|
||||
my $thread_ID = $5;
|
||||
|
||||
my $query = " INSERT INTO
|
||||
proxy_dati
|
||||
(ip, thread, data_new)
|
||||
VALUES
|
||||
('$remote_IP', $thread_ID, FROM_UNIXTIME($remote_START))
|
||||
";
|
||||
# print "$query\n";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
|
||||
# print "$riga";
|
||||
}
|
||||
|
||||
|
||||
if ( $riga =~ /^\s*\[(\d+)\.\d+\]\s+\[DESTROY\] tcp\s+\d+ src=(\S+) dst=(\S+) sport=\d+ dport=(\d+) packets=\d+ bytes=(\d+) src=\S+ dst=\S+ sport=\d+ dport=\d+ packets=\d+ bytes=(\d+) \[\w+\] id=(\d+)/) {
|
||||
# next if ($2 != $proxy_IP);
|
||||
# next if ($3 != $proxy_PORT);
|
||||
|
||||
my $remote_DESTROY = $1;
|
||||
my $remote_IP = $2;
|
||||
my $local_IP = $3;
|
||||
my $local_PORT = $4;
|
||||
my $remote_SEND = $5;
|
||||
my $remote_RECEIVE = $6;
|
||||
my $thread_ID = $7;
|
||||
|
||||
print "IP: $remote_IP - ID: $thread_ID - Invati: $remote_SEND - Ricevuti: $remote_RECEIVE\n";
|
||||
|
||||
my $query = " UPDATE
|
||||
proxy_dati
|
||||
SET
|
||||
data_destroy = FROM_UNIXTIME($remote_DESTROY),
|
||||
inviati = $remote_SEND,
|
||||
ricevuti = $remote_RECEIVE,
|
||||
tempo = TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY)),
|
||||
vel_inv = $remote_SEND / TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY)),
|
||||
vel_ric = $remote_RECEIVE / TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY))
|
||||
WHERE
|
||||
thread = $thread_ID
|
||||
AND
|
||||
ip = '$remote_IP'
|
||||
AND
|
||||
data_destroy IS NULL
|
||||
";
|
||||
|
||||
# print "$query\n";
|
||||
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
}
|
||||
}
|
||||
close CT;
|
||||
@@ -1,17 +1,34 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti();
|
||||
$DIRITTI = diritti(1);
|
||||
view_top(); ?>
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?php include_once ("../core/top.php");?>
|
||||
<?php print "-- $DIRITTI --" ?>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php include_once ("../core/footer.php"); ?>
|
||||
<?php view_footer(); ?>
|
||||
|
||||
Reference in New Issue
Block a user