User Tools

Site Tools


projects:wifi_scanner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
projects:wifi_scanner [2020/01/06 23:37]
neil
projects:wifi_scanner [2020/01/06 23:42]
neil
Line 55: Line 55:
  
 ==== trim.php ==== ==== trim.php ====
-TBC+<code php> 
 +#​!/​usr/​bin/​php 
 +<?php 
 +if(empty($argv[1])) { 
 +    exit("​Missing filename\n"​);​ 
 +
 +$filename = $argv[1]; 
 +$handle = fopen($filename,​ "​r"​);​ 
 +if ($handle) { 
 +    while (($line = fgets($handle)) !== false) { 
 +        $data = explode("​ ", $line); 
 +        $datetime = date("​Y-m-d H:i", strtotime($data[0]."​ "​.substr($data[1],​0,​ 8))); 
 +        $mac_addresses = preg_match_all("/​(([a-fA-F0-9]{2}[:​|\-]?​){6}) /", $line, $matches);​ 
 +        if(is_array($matches[0])) { 
 +            $macs = array_unique($matches[0]);​ 
 +            foreach($macs as $mac) { 
 +                $mac = trim($mac);​ 
 +                $rawdata[$datetime.$mac]['​datetime'​] = $datetime;​ 
 +                $rawdata[$datetime.$mac]['​mac'​] = $mac; 
 +            } 
 +         } 
 +    } 
 +} else { 
 +    exit("​Error opening file\n"​);​ 
 +
 + 
 +foreach($rawdata as $datetime=>​$val) { 
 +    echo $val['​datetime'​]."​\t"​.$val['​mac'​]."​\n";​ 
 +
 + 
 +?> 
 +</​code>​
  
 ===== Analysing the data ===== ===== Analysing the data =====
projects/wifi_scanner.txt · Last modified: 2020/08/03 16:11 by admin