mirror of
https://github.com/hak5/nano-tetra-modules.git
synced 2025-10-29 16:58:09 +00:00
Add modules to repository
This commit is contained in:
65
SignalStrength/api/module.php
Normal file
65
SignalStrength/api/module.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php namespace pineapple;
|
||||
|
||||
class SignalStrength extends Module {
|
||||
public function route()
|
||||
{
|
||||
switch ($this->request->action) {
|
||||
case 'getVersionInfo':
|
||||
$this->getVersionInfo();
|
||||
break;
|
||||
case 'getWirelessInterfaces':
|
||||
$this->getWirelessInterfaces();
|
||||
break;
|
||||
case 'getInterfaceScan':
|
||||
$this->getInterfaceScan();
|
||||
break;
|
||||
case 'getInterfaceStatus':
|
||||
$this->getInterfaceStatus();
|
||||
break;
|
||||
case 'toggleInterface':
|
||||
$this->toggleInterface();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getVersionInfo() {
|
||||
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SignalStrength/module.info"));
|
||||
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
|
||||
}
|
||||
|
||||
protected function getInterfaceScan() {
|
||||
exec('iwlist "'.$this->request->selectedInterface.'" scanning | egrep "Cell |Channel|Quality|ESSID"', $interfaceScan);
|
||||
$interfaceScanArray = array();
|
||||
for($x=0;$x<count($interfaceScan);$x+=5) {
|
||||
$bssid = substr($interfaceScan[$x], strpos($wlan0ScanOutput[$x], ":") +29);
|
||||
$channel = substr($interfaceScan[$x+1], strpos($interfaceScan[$x+1], ":") +1);
|
||||
$quality = substr($interfaceScan[$x+3], strpos($interfaceScan[$x+3], "=") +1, 5);
|
||||
$strength = substr($interfaceScan[$x+3], strpos($interfaceScan[$x+3], "=", strpos(interfaceScan[$x+3], "=")+1)+1);
|
||||
$essid = substr($interfaceScan[$x+4], strpos($interfaceScan[$x+4], ":") +1);
|
||||
array_push($interfaceScanArray, array("bssid" => $bssid, "channel" => $channel, "quality" => $quality, "strength" => $strength, "essid" => $essid));
|
||||
}
|
||||
$this->response = array('interfaceScan' => $interfaceScanArray);
|
||||
}
|
||||
|
||||
protected function getWirelessInterfaces() {
|
||||
exec("iwconfig 2> /dev/null | grep \"wlan*\" | awk '{print $1}'", $interfaces);
|
||||
$this->response = array('interfaces' => $interfaces);
|
||||
}
|
||||
|
||||
protected function getInterfaceStatus() {
|
||||
exec("ifconfig -a | cut -c 1-19 | egrep 'wlan|UP|BROADCAST' | awk '{print $1}' | tail -n+4", $interfaceStatus);
|
||||
$interfaceStatusArray = array();
|
||||
for ($y=0;$y<count($interfaceStatus);$y+=2) {
|
||||
$interface = $interfaceStatus[$y];
|
||||
$status = "Down";
|
||||
if ($interfaceStatus[$y+1] == "UP") { $status = "Up"; }
|
||||
array_push($interfaceStatusArray, array("interface" => $interface, "status" => $status));
|
||||
}
|
||||
$this->response = array('interfaceStatus' => $interfaceStatusArray);
|
||||
}
|
||||
|
||||
protected function toggleInterface() {
|
||||
$toggle = ($this->request->status == "Down") ? 'up' : 'down';
|
||||
exec('ifconfig "'.$this->request->interface.'" "'.$toggle.'"', $toggleResponse);
|
||||
}
|
||||
}
|
||||
11
SignalStrength/js/Chart.min.js
vendored
Normal file
11
SignalStrength/js/Chart.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
102
SignalStrength/js/module.js
Normal file
102
SignalStrength/js/module.js
Normal file
@@ -0,0 +1,102 @@
|
||||
registerController('SignalStrengthController', ['$api', '$scope', function($api, $scope) {
|
||||
$scope.title = "Loading...";
|
||||
$scope.version = "Loading...";
|
||||
$scope.interfaces = [];
|
||||
$scope.interfaceStatus = [];
|
||||
$scope.selectedInterface = "";
|
||||
$scope.scanLoading = false;
|
||||
$scope.continuousScan = false;
|
||||
$scope.polarData = [];
|
||||
|
||||
// this function gets info from the module.info file
|
||||
$scope.getVersionInfo = (function() {
|
||||
$api.request({
|
||||
module: 'SignalStrength',
|
||||
action: 'getVersionInfo'
|
||||
}, function(response) {
|
||||
$scope.title = response.title;
|
||||
$scope.version = response.version;
|
||||
});
|
||||
});
|
||||
|
||||
// this function generates a random color for the graph.js graph to use
|
||||
function getRandomColor() {
|
||||
var letters = '0123456789ABCDEF'.split('');
|
||||
var color = '#';
|
||||
for (var i = 0; i < 6; i++ ) {
|
||||
color += letters[Math.floor(Math.random() * 16)];
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
// this function gets the cell info for an interface
|
||||
$scope.scanInterface = (function() {
|
||||
$scope.scanLoading = true;
|
||||
$api.request({
|
||||
module: 'SignalStrength',
|
||||
action: 'getInterfaceScan',
|
||||
selectedInterface: $scope.selectedInterface
|
||||
}, function (response) {
|
||||
$scope.scanLoading = false;
|
||||
$scope.interfaceScan = response.interfaceScan;
|
||||
polarDataArray = [];
|
||||
response.interfaceScan.forEach(function(scannedCell) {
|
||||
graphStrength = parseInt(scannedCell['strength'].substring(20, 23));
|
||||
graphStrength += 100;
|
||||
polarDataElement = {};
|
||||
polarDataElement['value'] = graphStrength;
|
||||
polarDataElement['color'] = getRandomColor();
|
||||
polarDataElement['label'] = scannedCell['essid'];
|
||||
polarDataArray.push(polarDataElement);
|
||||
});
|
||||
$scope.polarData = polarDataArray;
|
||||
// call the javascript function to draw the chart
|
||||
refreshChart();
|
||||
// RECURSION!!!!!!!
|
||||
if ($scope.continuousScan == true) {$scope.scanInterface();}
|
||||
});
|
||||
});
|
||||
|
||||
// this function builds the Scan Settings panel
|
||||
$scope.getWirelessInterfaces = (function() {
|
||||
$api.request({
|
||||
module: 'SignalStrength',
|
||||
action: 'getWirelessInterfaces'
|
||||
}, function(response) {
|
||||
$scope.interfaces = response.interfaces;
|
||||
$scope.selectedInterface = response.interfaces[0];
|
||||
});
|
||||
});
|
||||
|
||||
// this function gets the status for each wireless interface - Up or Down
|
||||
$scope.getInterfaceStatus = (function() {
|
||||
$api.request({
|
||||
module: 'SignalStrength',
|
||||
action: 'getInterfaceStatus'
|
||||
}, function(response) {
|
||||
$scope.interfaceStatus = response.interfaceStatus;
|
||||
});
|
||||
});
|
||||
|
||||
// this function toggles an interfaces state - Up or Down
|
||||
$scope.toggleInterface = (function(interfaceToToggle, interfaceStatus) {
|
||||
$api.request({
|
||||
module: 'SignalStrength',
|
||||
action: 'toggleInterface',
|
||||
interface: interfaceToToggle,
|
||||
status: interfaceStatus
|
||||
}, function(response) {
|
||||
$scope.getInterfaceStatus();
|
||||
});
|
||||
});
|
||||
|
||||
// this function toggles the continuous scan setting
|
||||
$scope.toggleContinuous = (function() {
|
||||
if ($scope.continuousScan == true) {$scope.continuousScan = false;} else {$scope.continuousScan = true;}
|
||||
});
|
||||
|
||||
// initialize the panels
|
||||
$scope.getVersionInfo();
|
||||
$scope.getWirelessInterfaces();
|
||||
$scope.getInterfaceStatus();
|
||||
}]);
|
||||
110
SignalStrength/module.html
Normal file
110
SignalStrength/module.html
Normal file
@@ -0,0 +1,110 @@
|
||||
<script type="text/javascript" src="/modules/SignalStrength/js/Chart.min.js"></script>
|
||||
<div ng-controller="SignalStrengthController">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="pull-left">{{title}}</h4>
|
||||
<h4 class="pull-right">v{{version}}</h4>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="pull-left">Scan Settings</h4>
|
||||
<span class="pull-right">Continuous:
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-xs btn-{{(continuousScan == true) ? 'success' : 'default'}}" ng-click="toggleContinuous()">On</button>
|
||||
<button class="btn btn-xs btn-{{(continuousScan == false) ? 'danger' : 'default'}}" ng-click="toggleContinuous()">Off</button>
|
||||
</div>
|
||||
</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div id="ScanSettings">
|
||||
<table class="table text-center">
|
||||
<tr>
|
||||
<td>
|
||||
<select class="form-control input-sm" ng-model="selectedInterface">
|
||||
<option ng-repeat="interface in interfaces">{{ interface }}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<img src="img/throbber.gif" ng-show="scanLoading">
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-success" ng-click="scanInterface()" ng-disabled="scanLoading">Scan</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-repeat="status in interfaceStatus">
|
||||
<td>
|
||||
<p>{{ status.interface }}</p>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-xs btn-{{(status.status=='Up') ? 'success' : 'default'}}" ng-click="toggleInterface(status.interface, status.status)">Up</button>
|
||||
<button class="btn btn-xs btn-{{(status.status=='Down') ? 'danger' : 'default'}}" ng-click="toggleInterface(status.interface, status.status)">Down</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading pointer" data-toggle="collapse" data-target="#ScanResultsTable">
|
||||
<h4 class="pull-left">Scan Results Table</h4>
|
||||
<span class="pull-right"><img src="img/throbber.gif" ng-show="scanLoading"></span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div id="ScanResultsTable" class="panel-collapse collapse in">
|
||||
<table class="table table-striped table-bordered text-center">
|
||||
<tr><th class="text-center">MAC Address</th><th class="text-center">Channel</th><th class="text-center">Quality</th><th class="text-center">Strength</th><th class="text-center">ESSID</th></tr>
|
||||
<tr ng-repeat="target in interfaceScan track by $index"><td>{{ target['bssid'] }}</td><td>{{ target['channel'] }}</td><td>{{ target['quality'] }}</td><td>{{ target['strength'] }}</td><td>{{ target['essid'] }}</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading pointer" data-toggle="collapse" data-target="#ScanResultsGraph">
|
||||
<h4 class="pull-left">Signal Level Graph</h4>
|
||||
<span class="pull-right"><img src="img/throbber.gif" ng-show="scanLoading"></span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div id="ScanResultsGraph" class="panel-collapse collapse in">
|
||||
<canvas id="polar-area" class="chart chart-polar-area" chart-data="chartdata" chart-labels="chartlabels" chart-legend="true"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading pointer" data-toggle="collapse" data-target="#AboutDiv">
|
||||
<h4 class="pull-left">About</h4>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div id="AboutDiv" class="panel-body panel-collapse collapse out">
|
||||
<p>SignalStrength leverages the 'iwlist [interface] scanning' command to gather signal strength and quality information about cells that are within range of the Pineapple.</p>
|
||||
<p><b>Continuous Scan</b> allows the function performing the scan to run recursively allowing the data to be constantly refreshed at the interval that each interface is capable of performing the scan. From testing, wlan0 seems to have a quicker refresh time, but suffers from not having as much range as wlan1. To stop the continuous scan, simply toggle the continuous button and wait for the currently executing scan to complete.</p>
|
||||
<p><b>Signal Level Graph</b> utilizies the signal strength attribute reported for each cell. Signal strength is measured in dBm which produces a negative value. In order to properly graph this value, the dBm reading is incremented by 100 to produce a positive number for each cell which gives an accurate comparison of signal strength between each cell as a positive number allowing it to be graphed properly. The numbers in the graph are therefore based on the signal strength dBm reading, but are not significant in and of themselves.</p>
|
||||
<p><b>Future Improvements:</b></p>
|
||||
<ul>
|
||||
<li>Ability to change chart type (polar, bar, line)</li>
|
||||
<li>Cells having a single color so when the graph refreshes the cell retains the same color</li>
|
||||
<li>Ability to focus on a single cell to make it easier to physically locate the cell based on increasing signal strength</li>
|
||||
</ul>
|
||||
<p><b>Changelog</b></p>
|
||||
<p>Version 1.0: initial release</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function refreshChart() {
|
||||
if(window.myPolarArea!==undefined)
|
||||
window.myPolarArea.destroy();
|
||||
var polarData = $('[ng-controller="SignalStrengthController"]').scope().polarData;
|
||||
var ctx = document.getElementById("polar-area").getContext("2d");
|
||||
window.myPolarArea = new Chart(ctx).PolarArea(polarData, {
|
||||
responsive:true,
|
||||
animation:false
|
||||
});
|
||||
}
|
||||
</script>
|
||||
10
SignalStrength/module.info
Normal file
10
SignalStrength/module.info
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"author": "r3dfish",
|
||||
"description": "Signal Strength gives real time info about wireless devices in range",
|
||||
"devices": [
|
||||
"nano",
|
||||
"tetra"
|
||||
],
|
||||
"title": "SignalStrength",
|
||||
"version": "1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user