Subversion Repositories ALCASAR

Rev

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

Rev 2973 Rev 2975
Line 169... Line 169...
169
				echo "<th>$l_gw</th>";
169
				echo "<th>$l_gw</th>";
170
			}
170
			}
171
		echo "</tr>";
171
		echo "</tr>";
172
		$IoT_capture = $conf["IOT_CAPTURE"];
172
		$IoT_capture = $conf["IOT_CAPTURE"];
173
		$output = array(); $detail = array(); $nb_ligne = 0;
173
		$output = array(); $detail = array(); $nb_ligne = 0;
174
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR MAC address
174
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR @MAC
175
		$detail = explode (" " , $output[1]);
175
		$detail = explode (" " , $output[1]);
176
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
176
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
177
		unset ($output);unset ($detail);
177
		unset ($output);unset ($detail);
178
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
178
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
179
		while (list(,$ligne) = each($output)){
179
		while (list(,$ligne) = each($output)){
180
			$detail = explode (" ", $ligne);
180
			$detail = explode (" ", $ligne);
181
			$nb_ligne ++;
181
			$nb_ligne ++;
182
			echo "<tr valign=\"middle\">";
182
			echo "<tr valign=\"middle\">";
183
			echo "<td>".$nb_ligne."</td>";
183
			echo "<td>".$nb_ligne."</td>";
184
			echo "<td>".$detail[1]."</td>";
184
			echo "<td>".$detail[1]."</td>"; // @IP
185
			echo "<td>$detail[0]";
185
			echo "<td>$detail[0]"; // @MAC
186
			if(file_exists('/usr/local/share/nmap-mac-prefixes')) // for each device on LAN, retrieve the MAC manufacturer
186
			if(file_exists('/usr/local/share/nmap-mac-prefixes')){ // retrieve @MAC manufacturer
187
			{
-
 
188
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
187
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
189
				exec ("grep $oui_id /usr/local/share/nmap-mac-prefixes | cut -f2", $mac_manufacturer);
188
				exec ("grep $oui_id /usr/local/share/nmap-mac-prefixes | cut -f2", $mac_manufacturer);
190
				if(! empty($mac_manufacturer[0])) echo " <font size=\"1\">($mac_manufacturer[0])</font>";
189
				if(! empty($mac_manufacturer[0])) echo " <font size=\"1\">($mac_manufacturer[0])</font>";
191
					else echo " <font size=\"1\">($l_unknown)</font>";
190
					else echo " <font size=\"1\">($l_unknown)</font>";
192
				unset($mac_manufacturer);
191
				unset($mac_manufacturer);
193
			}
192
			}
194
			exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file);
193
			exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file); // retrieve @MAC info
195
			if (!empty($mac_in_ether_file[0]))
194
			if (!empty($mac_in_ether_file[0])){
196
			{
-
 
197
				$mac_info= ltrim($mac_in_ether_file[0],'#');
195
				$mac_info= ltrim($mac_in_ether_file[0],'#');
198
				if (!empty($mac_info)) echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
196
				if (!empty($mac_info)) echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
199
			}
197
			}
200
			echo "</td><td>";
198
			echo "</td><td>";
201
			if ($detail[4] == "1"){ // authenticated equipment
199
			if ($detail[4] == "1"){ // is user authenticated ?
202
				$login = $detail[5];
200
				$login = $detail[5];
203
				unset ($found_users); unset ($cn);
201
				unset ($found_users); unset ($cn);
204
				$search = $login; $search_IN = 'username'; // is user in database ?
202
				$search = $login; $search_IN = 'username'; // search user in database
205
				if (is_file("../lib/sql/find.php"))
203
				if (is_file("../lib/sql/find.php"))
206
				include("../lib/sql/find.php");
204
				include("../lib/sql/find.php");
207
				if (isset ($found_users)) // user is in database
205
				if (isset ($found_users)){ // is user in database ? 
208
				{
-
 
209
					if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
206
					if (is_file("../lib/sql/user_info.php")) // retrieve user info (especialy $cn)
210
						include("../lib/sql/user_info.php");
207
						include("../lib/sql/user_info.php");
211
				}
208
				}
212
				if (! isset ($cn)){ $cn='-';}
209
				if (! isset ($cn)){ $cn='-';}
213
				# The user is an allowed MAC address
-
 
214
					if ($detail[5] == $detail[0]){
210
				if ($detail[5] == $detail[0]){ // is user an @MAC ?
215
						if (isset ($found_users)) { #MAC is in database
211
					if (isset ($found_users)){ // is @MAC allowed ?
216
							echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
212
						echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
217
							echo "</td><td>";
-
 
218
						}
-
 
219
						else { #MAC is temporarily allowed
-
 
220
							echo "<b>$l_mac_temporarily_allowed</b>";
-
 
221
							echo "</td><td>";
213
						echo "</td>";
222
							echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
-
 
223
							echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
214
						echo "<td>&nbsp;</td>"; // no 'disconnect' button for allowed @MAC
224
							if($IoT_capture == "on")
-
 
225
							{
-
 
226
								if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
-
 
227
								{
-
 
228
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_stop_capture_disconnect\">";
-
 
229
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
-
 
230
								}
-
 
231
 								else
-
 
232
								{
-
 
233
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
234
									echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
235
									$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
-
 
236
									if (file_exists($file))
-
 
237
										{
-
 
238
										echo "<BR><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
-
 
239
										}
-
 
240
								}	
-
 
241
							}
-
 
242
							else
-
 
243
								echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
244
 
-
 
245
							echo "</FORM></TD>";
-
 
246
						}
-
 
247
						# Disable temporarily @MAC access
-
 
248
					}
215
					}
249
				# The user is a humanoide ;-)
-
 
250
					else {
216
					else {
251
						if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
-
 
252
						else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
217
						echo "<b>$l_mac_temporarily_allowed</b>";
253
						echo "<TD>";
218
						echo "</td><td>";
254
						echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
219
						echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
255
						echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
220
						echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
-
 
221
						if($IoT_capture == "on"){
-
 
222
							if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
-
 
223
								echo "<input type=\"submit\" name=\"action\" value=\"$l_stop_capture_disconnect\">";
-
 
224
								echo "<input type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
-
 
225
							}
-
 
226
 							else {
256
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
227
								echo "<input type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
228
								echo "<br><input type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
229
								$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
257
						echo "</FORM></TD>";
230
								if (file_exists($file))	{
-
 
231
									echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
-
 
232
								}
-
 
233
							}	
258
						}
234
						}
-
 
235
						else echo "<input type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
236
						echo "</form></td>";
259
					}
237
					}
-
 
238
				}
-
 
239
				else { // The user is a humanoide ;-)
-
 
240
					if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
-
 
241
					else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
-
 
242
					echo "<td>";
-
 
243
					echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
-
 
244
					echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
-
 
245
					echo "<input type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
246
					echo "</form></td>";
-
 
247
				}
-
 
248
			}
260
			# equipment without authenticated user
249
			// equipment without authenticated user
261
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
250
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){ 
262
				echo "ALCASAR system";
251
				echo "ALCASAR system";
263
				echo "<TD>";
252
				echo "<td>";
264
				echo "&nbsp;";
253
				echo "&nbsp;";
265
				echo "</TD>";
254
				echo "</td>";
266
				}	
255
			}	
267
			else {  
256
			else {  
268
				echo "&nbsp;";
257
				echo "&nbsp;";
269
				echo "<TD>";		
258
				echo "<td>";		
270
				echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
259
				echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
271
				# Dissociate user (... or other) who is not connected yet
260
				# Dissociate user (... or other) who is not connected yet
272
				echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
261
				echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
273
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
262
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
274
				if (empty($mac_in_ether_file[1]))
263
				if (empty($mac_in_ether_file[1])){
275
				{
-
 
276
					echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
264
					echo "<input type=\"submit\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
277
				}
265
				}
278
				echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
266
				echo "<input type=\"submit\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
279
				
-
 
280
				if($IoT_capture == "on")
267
				if($IoT_capture == "on"){
281
				{
-
 
282
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
268
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
283
					{
-
 
284
						echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
269
						echo "<br><input type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
285
					}
270
					}
286
					else
271
					else {
287
					{
-
 
288
						echo "<BR><INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">";
272
						echo "<br><input type=\"submit\" name=\"action\" value=\"$l_captureon\">";
289
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
273
						echo "<input type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
290
						$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
274
						$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
291
						if (file_exists($file))
275
						if (file_exists($file)) {
292
							{
-
 
293
							echo "<BR><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
276
							echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
294
							}
277
						}
295
					}
278
					}
296
				}
279
				}
297
				echo "</FORM></TD>";
280
				echo "</form></td>";
298
			}
281
			}
299
			if ($conf['MULTIWAN'] !== 'Off') {
282
			if ($conf['MULTIWAN'] !== 'Off') {
300
				if ($detail[4] == "1"){ // authenticated equipment
283
				if ($detail[4] == "1"){ // authenticated user
301
					while (list(,$ligne2) = each($list_ip_gw)){
284
					while (list(,$ligne2) = each($list_ip_gw)){
302
						$detail2 = explode (" ", $ligne2);
285
						$detail2 = explode (" ", $ligne2);
303
						if ($detail2[0] == $detail[1]){
286
						if ($detail2[0] == $detail[1]){
304
							echo "<td>$detail2[1]</td>";
287
							echo "<td>$detail2[1]</td>";
-
 
288
							reset ($list_ip_gw);
305
							break;}
289
							break;
-
 
290
						}
306
					}
291
					}
307
				}
292
				}
308
				else {
-
 
309
					echo "<td> </td>";
293
			else echo "<td>&nbsp;</td>"; 
310
				}
-
 
311
			}
294
			}
312
			unset ($mac_in_ether_file);
295
			unset ($mac_in_ether_file);
313
			echo "</tr>";
296
			echo "</tr>";
314
		}
297
		}
315
		?>
298
		?>