Subversion Repositories ALCASAR

Rev

Rev 2853 | Rev 2888 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2853 Rev 2887
Line 88... Line 88...
88
	$l_connect = "Temporarily authorize";
88
	$l_connect = "Temporarily authorize";
89
	$l_captureon = "Authorize and capture";
89
	$l_captureon = "Authorize and capture";
90
	$l_captureoff = "Stop capture";
90
	$l_captureoff = "Stop capture";
91
	$l_captureonly_on = "Capture";
91
	$l_captureonly_on = "Capture";
92
}
92
}
-
 
93
function taille_fichier($fichier)
-
 
94
{
-
 
95
	$taille_fichier = filesize($fichier);
-
 
96
	if ($taille_fichier >= 1073741824){
-
 
97
		$taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go";}
-
 
98
	elseif ($taille_fichier >= 1048576){
-
 
99
		$taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo";}
-
 
100
	elseif ($taille_fichier >= 1024){
-
 
101
		$taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko";}
-
 
102
	else {$taille_fichier = $taille_fichier . " o";}
-
 
103
	return $taille_fichier;
-
 
104
}
93
 
105
 
94
if (isset($_POST['action'])){
106
if (isset($_POST['action'])){
-
 
107
	$mac= str_replace ("'",'',escapeshellarg($_POST['mac_addr']));
-
 
108
	unset($_POST['mac_addr']);
95
	switch ($_POST['action']){
109
	switch ($_POST['action']){
96
		case "$l_disconnect" :
110
		case "$l_disconnect" :
97
			$mac= $_POST['mac_addr'];
-
 
98
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
111
			exec("sudo /usr/sbin/chilli_query logout ".$mac);
99
			unset($_POST['mac_addr']);
-
 
100
		break;
112
		break;
101
		case "$l_stop_capture_disconnect" :
113
		case "$l_stop_capture_disconnect" :
102
			$mac= $_POST['mac_addr'];
-
 
103
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
114
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
104
			$file = '/tmp/capture_'.$mac.'.pcap';
-
 
105
			if (file_exists($file))
-
 
106
			{
-
 
107
				header('Content-Description : File Transfer');
-
 
108
				header('Content-Type: application/octet-stream');
-
 
109
				header('Content-disposition: attachement; filename='.basename($file).'');
-
 
110
				header('Expires: 0');
-
 
111
				header('Cache-Control: must-revalidate');
-
 
112
				header('Pragma: public');
-
 
113
				header('Content-Lenght: '.filesize($file));
-
 
114
				readfile($file);
-
 
115
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$macc);
-
 
116
				exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
115
			exec("sudo /usr/sbin/chilli_query logout ".$mac);
117
				unset($_POST['mac_addr']);
-
 
118
				exit;
-
 
119
			}
-
 
120
		break;
116
		break;
121
		case "$l_dissociate" :
117
		case "$l_dissociate" :
122
			exec("sudo /usr/sbin/chilli_query dhcp-release ".escapeshellarg($_POST['mac_addr']));
118
			exec("sudo /usr/sbin/chilli_query dhcp-release ".$mac);
123
			unset($_POST['mac_addr']);
-
 
124
		break;
119
		break;
125
		case "$l_connect" :
120
		case "$l_connect" :
126
			exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr']));
121
			exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
127
			unset($_POST['mac_addr']);
-
 
128
		break;
122
		break;
129
		case "$l_captureon" :
123
		case "$l_captureon" :
130
			$mac= $_POST['mac_addr'];
-
 
131
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
124
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
132
			exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr']));
125
			exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
133
			unset($_POST['mac_addr']);
-
 
134
		break;
126
		break;
135
		case "$l_captureonly_on" :
127
		case "$l_captureonly_on" :
136
			$mac= $_POST['mac_addr'];
-
 
137
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
128
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
138
		break;	
129
		break;	
139
		case "$l_captureoff" :
130
		case "$l_captureoff" :
140
			$mac= $_POST['mac_addr'];
-
 
141
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
131
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
142
			$file = '/tmp/capture_'.$mac.'.pcap';
-
 
143
			if (file_exists($file))
-
 
144
			{
-
 
145
				header('Content-Description : File Transfer');
-
 
146
				header('Content-Type: application/octet-stream');
-
 
147
				header('Content-disposition: attachement; filename='.basename($file).'');
-
 
148
				header('Expires: 0');
-
 
149
				header('Cache-Control: must-revalidate');
-
 
150
				header('Pragma: public');
-
 
151
				header('Content-Lenght: '.filesize($file));
-
 
152
				readfile($file);
-
 
153
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$mac);
-
 
154
				unset($_POST['mac_addr']);
-
 
155
				exit;
-
 
156
			}
-
 
157
		break;
132
		break;
158
	}
133
	}
159
}
134
}
160
?>
135
?>
161
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
136
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Line 248... Line 223...
248
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
223
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
249
								}
224
								}
250
 								else
225
 								else
251
								{
226
								{
252
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
227
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
253
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
228
									echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
229
									$file = '/var/Save/iot_captures/'.$mac.'.pcap';
-
 
230
									if (file_exists($file))
-
 
231
										{
-
 
232
										echo "<BR><a href=\"/save/iot_captures/$mac.pcap\">$mac.pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$mac.".pcap");echo ")";
-
 
233
										}
254
								}
234
								}
255
							}
235
							}
256
							else
236
							else
257
								echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
237
								echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
258
 
238
 
Line 293... Line 273...
293
				
273
				
294
				if($IoT_capture == "on")
274
				if($IoT_capture == "on")
295
				{
275
				{
296
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
276
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
297
					{
277
					{
298
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
278
						echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
299
					}
279
					}
300
					else
280
					else
301
					{
281
					{
302
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">";
282
						echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">";
303
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
283
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
284
						$file = '/var/Save/iot_captures/'.$mac.'.pcap';
-
 
285
						if (file_exists($file))
-
 
286
							{
-
 
287
							echo "<BR><a href=\"/save/iot_captures/$mac.pcap\">$mac.pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$mac.".pcap");echo ")";
-
 
288
							}
304
					}
289
					}
305
				}
290
				}
306
				echo "</FORM></TD>";
291
				echo "</FORM></TD>";
307
			}
292
			}
308
			unset ($mac_in_ether_file);
293
			unset ($mac_in_ether_file);