X-Git-Url: https://handorf.org/code/?p=soho-sigint.git;a=blobdiff_plain;f=client-wifi%2Fkismet.pl;fp=client-wifi%2Fkismet.pl;h=0000000000000000000000000000000000000000;hp=c784ee8f855e186a8d284c52bee55dbebe2f7ee6;hb=d9eef3618e5d1213bd3eead787dbc48ec2fa16b1;hpb=d6e95b6c679ed6041bb105b562acd36b56cb58eb diff --git a/client-wifi/kismet.pl b/client-wifi/kismet.pl deleted file mode 100755 index c784ee8..0000000 --- a/client-wifi/kismet.pl +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/perl - -use Net::Kismet; -use DBI; - -my $dbh = DBI->connect("DBI:mysql:database=wireless;host=127.0.0.1", - "USERNAME", "PASSWORD", - {'RaiseError' => 1}); - -$k = new Net::Kismet('localhost', 2501); -$k->register('SSID', \&ssidhandler, '*'); -$k->register('BSSID', \&bssidhandler, '*'); -$k->register('CLIENT', \&clienthandler, '*'); -#$k->timer_register(\&timer, 5); -KismetRun($k); - - -sub ssidhandler { - my $vars = shift; - my $ssid = ""; - if ($vars->{'ssid'} eq "") { - $ssid = ""; - } else { - $ssid = $vars->{'ssid'}; - } - #print $vars->{'mac'}."\n"; - #print "lt: ".$vars->{'lasttime'}."\n"; - #print "INSERT INTO ssid VALUES ('". $ssid. "', '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"; - #print "\n"; - my $sth = $dbh->prepare("SELECT LASTSEEN from ssid where SSID=? and MAC='" . $vars->{'mac'} . "'"); - $sth->execute($ssid); - if ($sth->rows() > 0) { - $sth = $dbh->prepare("UPDATE ssid set LASTSEEN=" . $vars->{'lasttime'} . " where SSID=? and MAC = '" . $vars->{'mac'} . "'"); - } else { - $sth = $dbh->prepare("INSERT INTO ssid VALUES (?, '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"); - } - $sth->execute($ssid); -} - -sub bssidhandler { - my $vars = shift; - #print $vars->{'bssid'}."\n"; - #print "lt: ".$vars->{'lasttime'}."\n"; - #print "INSERT INTO bssid VALUES ('". $vars->{'bssid'}. "', " . $vars->{'lasttime'} . ")"; - my $sth = $dbh->prepare("SELECT LASTSEEN from bssid where BSSID='" . $vars->{'bssid'} . "'"); - $sth->execute(); - if ($sth->rows() > 0) { - $dbh->do("UPDATE bssid set LASTSEEN=" . $vars->{'lasttime'} . " where BSSID = '" . $vars->{'bssid'} . "'"); - } else { - $dbh->do("INSERT INTO bssid VALUES ('". $vars->{'bssid'}. "', " . $vars->{'lasttime'} . ")"); - } - #$dbh->do("INSERT INTO bssid VALUES ('". $vars->{'bssid'}. "', " . $vars->{'lasttime'} . ")"); -} - -sub clienthandler { - my $vars = shift; - #print $vars->{'bssid'}."\n"; - #print $vars->{'mac'}."\n"; - #print "lt: ".$vars->{'lasttime'}."\n"; - my $sth = $dbh->prepare("SELECT LASTSEEN from clients where BSSID='". $vars->{'bssid'}. "' and MAC='" . $vars->{'mac'} . "'"); - $sth->execute(); - if ($sth->rows() > 0) { - $dbh->do("UPDATE clients set LASTSEEN=" . $vars->{'lasttime'} . " where BSSID = '". $vars->{'bssid'}. "' and MAC = '" . $vars->{'mac'} . "'"); - } else { - $dbh->do("INSERT INTO clients VALUES ('". $vars->{'bssid'}. "', '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"); - #$dbh->do("INSERT INTO clients VALUES ('". $ssid. "', '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"); - } - - #print "INSERT INTO clients VALUES ('". $vars->{'bssid'}. "', '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"; - #print "\n"; - #$dbh->do("INSERT INTO clients VALUES ('". $vars->{'bssid'}. "', '" . $vars->{'mac'} . "', " . $vars->{'lasttime'} . ")"); -} - - - -sub timer { - print "<>\n"; - # check for lame threads and kill if hung - my $rin = ""; - vec ( $rin, fileno ("PREAD00"), 1 ) = 1; - #while (1) { - if ( $nfound = select($rout=$rin, undef, undef, 0) ) { - $line = ; - #print "TIMER: $line"; - } - #} -} - -sub print_hash { - my $href = shift; - while( my( $key, $val ) = each %{$href} ) { - print "$key\t=>$val\n"; - } -}