90,70 → 90,45 |
$l_captureoff = "Stop capture"; |
$l_captureonly_on = "Capture"; |
} |
function taille_fichier($fichier) |
{ |
$taille_fichier = filesize($fichier); |
if ($taille_fichier >= 1073741824){ |
$taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go";} |
elseif ($taille_fichier >= 1048576){ |
$taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo";} |
elseif ($taille_fichier >= 1024){ |
$taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko";} |
else {$taille_fichier = $taille_fichier . " o";} |
return $taille_fichier; |
} |
|
if (isset($_POST['action'])){ |
$mac= str_replace ("'",'',escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
switch ($_POST['action']){ |
case "$l_disconnect" : |
$mac= $_POST['mac_addr']; |
exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
exec("sudo /usr/sbin/chilli_query logout ".$mac); |
break; |
case "$l_stop_capture_disconnect" : |
$mac= $_POST['mac_addr']; |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &'); |
$file = '/tmp/capture_'.$mac.'.pcap'; |
if (file_exists($file)) |
{ |
header('Content-Description : File Transfer'); |
header('Content-Type: application/octet-stream'); |
header('Content-disposition: attachement; filename='.basename($file).''); |
header('Expires: 0'); |
header('Cache-Control: must-revalidate'); |
header('Pragma: public'); |
header('Content-Lenght: '.filesize($file)); |
readfile($file); |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$macc); |
exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
exit; |
} |
exec("sudo /usr/sbin/chilli_query logout ".$mac); |
break; |
case "$l_dissociate" : |
exec("sudo /usr/sbin/chilli_query dhcp-release ".escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
exec("sudo /usr/sbin/chilli_query dhcp-release ".$mac); |
break; |
case "$l_connect" : |
exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
exec("sudo /usr/sbin/chilli_query authorize mac ".$mac); |
break; |
case "$l_captureon" : |
$mac= $_POST['mac_addr']; |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &'); |
exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr'])); |
unset($_POST['mac_addr']); |
exec("sudo /usr/sbin/chilli_query authorize mac ".$mac); |
break; |
case "$l_captureonly_on" : |
$mac= $_POST['mac_addr']; |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &'); |
break; |
case "$l_captureoff" : |
$mac= $_POST['mac_addr']; |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &'); |
$file = '/tmp/capture_'.$mac.'.pcap'; |
if (file_exists($file)) |
{ |
header('Content-Description : File Transfer'); |
header('Content-Type: application/octet-stream'); |
header('Content-disposition: attachement; filename='.basename($file).''); |
header('Expires: 0'); |
header('Cache-Control: must-revalidate'); |
header('Pragma: public'); |
header('Content-Lenght: '.filesize($file)); |
readfile($file); |
exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$mac); |
unset($_POST['mac_addr']); |
exit; |
} |
break; |
} |
} |
250,7 → 225,12 |
else |
{ |
echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">"; |
echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">"; |
echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">"; |
$file = '/var/Save/iot_captures/'.$mac.'.pcap'; |
if (file_exists($file)) |
{ |
echo "<BR><a href=\"/save/iot_captures/$mac.pcap\">$mac.pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$mac.".pcap");echo ")"; |
} |
} |
} |
else |
295,12 → 275,17 |
{ |
if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON") |
{ |
echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">"; |
echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">"; |
} |
else |
{ |
echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">"; |
echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">"; |
echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">"; |
$file = '/var/Save/iot_captures/'.$mac.'.pcap'; |
if (file_exists($file)) |
{ |
echo "<BR><a href=\"/save/iot_captures/$mac.pcap\">$mac.pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$mac.".pcap");echo ")"; |
} |
} |
} |
echo "</FORM></TD>"; |