Skip to content

Commit ea0a779

Browse files
committed
Make it easier to check client info on network
1 parent 63e16c4 commit ea0a779

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

wifimap/clients/js/index.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ function setVariables() {
1111
show_probing = "yes";
1212
show_false_positives = "no";
1313
activeSite = "clients";
14+
15+
if (window.opener == null) {
16+
connectedClientsList = "";
17+
probingClientsList = "";
18+
} else {
19+
connectedClientsList = window.opener.connectedClientsList;
20+
probingClientsList = window.opener.probingClientsList;
21+
}
22+
23+
connectedClientsArray = [];
24+
connectedClientsFormatedArray = [];
25+
connectedList = "";
26+
probingClientsArray = [];
27+
probingClientsFormatedArray = [];
28+
probingList = "";
29+
30+
selectedMACnumber = "";
31+
selectedMAC = "";
1432
loadMapThemes();
1533
}
1634

@@ -129,6 +147,65 @@ function loadMap() {
129147

130148
}); //END downloadUrl
131149

150+
//This code is run when page is loaded
151+
probingClientsArray = window.opener.probingClientsList.split("<br>");
152+
connectedClientsArray = window.opener.connectedClientsList.split("<br>");
153+
154+
//Black magic to make a prompt for selecting client
155+
for (var i = 0; i < probingClientsArray.length-2; i++) {
156+
var num = i+1;
157+
probingClientsFormatedArray[i] = "P" + num + ": " + probingClientsArray[i+1];
158+
}
159+
//Make a long string (list) based on the array of probing clients
160+
probingList = probingClientsFormatedArray.join("\n");
161+
162+
for (var i = 0; i < connectedClientsArray.length-2; i++) {
163+
var num = i+1;
164+
connectedClientsFormatedArray[i] = "C" + num + ": " + connectedClientsArray[i+1];
165+
}
166+
//Make a long string (list) based on the array of connected clients
167+
connectedList = connectedClientsFormatedArray.join("\n");
168+
169+
//Only display prompt when the page is first loaded
170+
if (document.getElementById("searchinput").value == "") {
171+
172+
//Only display relevant headlines in prompt. length will be 1 if there is no data (3 if there is 1 item in array, 4 if there is 2 etc.)
173+
//First, check if there is a total of 1 client MAC sent from "network" page
174+
if ((probingClientsArray.length == 3 && connectedClientsArray.length == 1) || (probingClientsArray.length == 1 && connectedClientsArray.length == 3)) {
175+
//If there was only one MAC sent, check if it was a probing client, or a connected client
176+
if (probingClientsArray.length == 3 && connectedClientsArray.length == 1) {
177+
selectedMAC = probingClientsArray[1];
178+
selectedMACnumber = "thisCannotBeEmpty";
179+
} else if (probingClientsArray.length == 1 && connectedClientsArray.length == 3) {
180+
selectedMAC = connectedClientsArray[1];
181+
selectedMACnumber = "thisCannotBeEmpty";
182+
}
183+
//Check for other combinations of probing clients and connected clients
184+
} else if (probingClientsArray.length > 1 && connectedClientsArray.length > 1) {
185+
selectedMACnumber = prompt("Select which client you want to see data for (write P1, C1 etc.)\n\nProbing clients of selected network:\n" + probingList + "\n\nConnected clients of selected network:\n" + connectedList);
186+
} else if (probingClientsArray.length > 3 && connectedClientsArray.length == 1) {
187+
selectedMACnumber = prompt("Select which client you want to see data for (write P1, C1 etc.)\n\nProbing clients of selected network:\n" + probingList);
188+
} else if (probingClientsArray.length == 1 && connectedClientsArray.length > 3) {
189+
selectedMACnumber = prompt("Select which client you want to see data for (write P1, C1 etc.)\n\nConnected clients of selected network:\n" + connectedList);
190+
} else {
191+
selectedMACnumber = "";
192+
}
193+
}
194+
//Don't search for client data if selected network did not have any data
195+
if (selectedMACnumber != "") {
196+
197+
//Store user-selected MAC address to variable
198+
if (selectedMACnumber.charAt(0) == "P" || selectedMACnumber.charAt(0) == "p") {
199+
selectedMAC = probingClientsArray[selectedMACnumber.charAt(1)];
200+
} else if (selectedMACnumber.charAt(0) == "C" || selectedMACnumber.charAt(0) == "c") {
201+
selectedMAC = connectedClientsArray[selectedMACnumber.charAt(1)];
202+
}
203+
204+
//Write selectedMAC to search box, then click the button
205+
document.getElementById("searchinput").value = selectedMAC;
206+
document.getElementById('searchbutton').click()
207+
}
208+
132209
} //END loadMap
133210

134211
//------------------------------------------------

wifimap/js/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function setVariables() {
1818
vendor_input = "";
1919
predefined_search = "%";
2020
activeSite = "overview";
21+
connectedClientsList = "";
22+
probingClientsList = "";
2123
loadMapThemes();
2224
}
2325

@@ -150,11 +152,15 @@ function loadMap() {
150152
parseFloat(BESTLAT),
151153
parseFloat(BESTLON));
152154

155+
156+
//This makes it so the buttons inside the pop-up windows will pass information about the network to their respective functions
157+
//In turn, that makes it possible to pass this data to the "location" and "clients" pages
153158
var BSSIDFunctionFriendly = '"' + BSSID + '"';
154-
var SSIDFunctionFriendly = '"' + SSID + '"';
159+
var connectedClientsFunctionFriendly = '"' + CONNECTED_CLIENTS + '"';
160+
var probingClientsFunctionFriendly = '"' + PROBING_CLIENTS + '"';
155161

156162
//This is the pop-up window that appears when clicking on a network
157-
var html = "<b>SSID: </b>" + SSID + "<br><b>MAC: </b>" + BSSID + "<br><b>Vendor: </b>" + VENDOR + "<br><br><b>Capabilities: </b>" + CAPABILITIES + "<br><b>Channel: </b>" + CHANNEL + " (" + FREQUENCY + " MHz)<br><b>Signal: </b>" + BESTLEVEL + " dBm<br><b>Last seen: </b>" + LASTSEEN + "<br><br><b>Connected clients: </b>" + CONNECTED_CLIENTS + "<br><b>Probing clients: </b>" + PROBING_CLIENTS + "<br><input type='button' onclick='getLocation(" + BSSIDFunctionFriendly + ");' value='Precise location' class='infoWindowSearchButton'> <input type='button' id='showclients' onclick='openClientTab();' value='Client info' class='infoWindowSearchButton'>";
163+
var html = "<b>SSID: </b>" + SSID + "<br><b>MAC: </b>" + BSSID + "<br><b>Vendor: </b>" + VENDOR + "<br><br><b>Capabilities: </b>" + CAPABILITIES + "<br><b>Channel: </b>" + CHANNEL + " (" + FREQUENCY + " MHz)<br><b>Signal: </b>" + BESTLEVEL + " dBm<br><b>Last seen: </b>" + LASTSEEN + "<br><br><b>Connected clients: </b>" + CONNECTED_CLIENTS + "<br><b>Probing clients: </b>" + PROBING_CLIENTS + "<br><input type='button' onclick='getLocation(" + BSSIDFunctionFriendly + ");' value='Precise location' class='infoWindowSearchButton'> <input type='button' id='showclients' onclick='openClientTab(" + connectedClientsFunctionFriendly + "," + probingClientsFunctionFriendly + ");' value='Client info' class='infoWindowSearchButton'>";
158164

159165
var marker = new google.maps.Marker({
160166
map: map,
@@ -214,8 +220,11 @@ function getLocation(BSSIDFunctionFriendly) {
214220
// openClientTab
215221
// opens a new tab, for client lookup
216222
//------------------------------------------------
217-
function openClientTab() {
218-
alert("Copy client MAC, and paste in client search box");
223+
function openClientTab(connectedClients,probingClients) {
224+
//Read the data passed to this function, and write it to global variables
225+
//Those variables will be read by the "clients" page
226+
connectedClientsList = connectedClients;
227+
probingClientsList = probingClients;
219228
var clientsWindow = window.open(clientsPageAddress);
220229
}
221230

0 commit comments

Comments
 (0)