Merge branch 'master' into master

pull/37/head
Andreas Nilsen 2018-08-29 21:09:09 +02:00 committed by GitHub
commit 1086d78237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 7735 additions and 7983 deletions

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class DNSMasqSpoof extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -25,205 +26,174 @@ class DNSMasqSpoof extends Module
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'toggleDNSMasqSpoofOnBoot':
$this->toggleDNSMasqSpoofOnBoot();
break;
case 'saveLandingPageData':
$this->saveLandingPageData();
break;
case 'getLandingPageData':
$this->getLandingPageData();
break;
case 'saveHostsData':
$this->saveHostsData();
break;
case 'getHostsData':
$this->getHostsData();
break;
case 'toggleDNSMasqSpoofOnBoot':
$this->toggleDNSMasqSpoofOnBoot();
break;
case 'saveLandingPageData':
$this->saveLandingPageData();
break;
case 'getLandingPageData':
$this->getLandingPageData();
break;
case 'saveHostsData':
$this->saveHostsData();
break;
case 'getHostsData':
$this->getHostsData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dnsmasqspoof.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dnsmasqspoof.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' && exec("grep addn-hosts /etc/dnsmasq.conf") !== '' ? 1 : 0;
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' && exec("grep addn-hosts /etc/dnsmasq.conf") !== '' ? 1 : 0;
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/DNSMasqSpoof/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/DNSMasqSpoof/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("dnsmasq"))
{
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("dnsmasq")) {
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/DNSMasqSpoof.progress'))
{
if (!file_exists('/tmp/DNSMasqSpoof.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleDNSMasqSpoofOnBoot()
{
if(exec("cat /etc/rc.local | grep DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/DNSMasqSpoof\/scripts\/autostart_dnsmasqspoof.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/DNSMasqSpoof\/scripts\/autostart_dnsmasqspoof.sh/d' /etc/rc.local");
}
}
private function toggleDNSMasqSpoof()
{
if(!$this->checkRunning("dnsmasq"))
{
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dnsmasqspoof.sh start");
}
else
{
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dnsmasqspoof.sh stop");
}
}
if (!$this->checkRunning("dnsmasq")) {
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dnsmasqspoof.sh start");
} else {
$this->execBackground("/pineapple/modules/DNSMasqSpoof/scripts/dnsmasqspoof.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/DNSMasqSpoof.progress'))
{
if (!$this->checkDependency("dnsmasq"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/DNSMasqSpoof.progress')) {
if (!$this->checkDependency("dnsmasq")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if($this->checkRunning("dnsmasq"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("dnsmasq")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep DNSMasqSpoof/scripts/autostart_dnsmasqspoof.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$bootLabelON = "default";
$bootLabelOFF = "danger";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
private function refreshOutput()
{
if ($this->checkDependency("dnsmasq")) {
if ($this->checkRunning("dnsmasq")) {
$this->response = "DNSMasq Spoof is running...";
} else {
$this->response = "DNSMasq Spoof is not running...";
}
} else {
$this->response = "DNSMasq Spoof is not installed...";
}
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function saveLandingPageData()
{
$filename = '/www/index.php';
file_put_contents($filename, $this->request->configurationData);
}
private function refreshOutput()
{
if ($this->checkDependency("dnsmasq"))
{
if ($this->checkRunning("dnsmasq"))
{
$this->response = "DNSMasq Spoof is running...";
}
else
{
$this->response = "DNSMasq Spoof is not running...";
}
}
else
{
$this->response = "DNSMasq Spoof is not installed...";
}
}
private function getLandingPageData()
{
$configurationData = file_get_contents('/www/index.php');
$this->response = array("configurationData" => $configurationData);
}
private function saveLandingPageData()
{
$filename = '/www/index.php';
file_put_contents($filename, $this->request->configurationData);
}
private function getLandingPageData()
{
$configurationData = file_get_contents('/www/index.php');
$this->response = array("configurationData" => $configurationData);
}
private function saveHostsData()
{
$filename = '/pineapple/modules/DNSMasqSpoof/hosts/dnsmasq.hosts';
file_put_contents($filename, $this->request->configurationData);
}
private function getHostsData()
{
$configurationData = file_get_contents('/pineapple/modules/DNSMasqSpoof/hosts/dnsmasq.hosts');
$this->response = array("configurationData" => $configurationData);
}
private function saveHostsData()
{
$filename = '/pineapple/modules/DNSMasqSpoof/hosts/dnsmasq.hosts';
file_put_contents($filename, $this->request->configurationData);
}
private function getHostsData()
{
$configurationData = file_get_contents('/pineapple/modules/DNSMasqSpoof/hosts/dnsmasq.hosts');
$this->response = array("configurationData" => $configurationData);
}
}

View File

@ -2,17 +2,17 @@ registerController('DNSMasqSpoof_Controller', ['$api', '$scope', '$rootScope', '
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'DNSMasqSpoof',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'DNSMasqSpoof',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,32 +37,32 @@ registerController('DNSMasqSpoof_ControlsController', ['$api', '$scope', '$rootS
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false
installed: false,
refreshOutput: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "DNSMasqSpoof",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "DNSMasqSpoof",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.toggleDNSMasqSpoof = (function() {
if($scope.status != "Stop")
$scope.toggleDNSMasqSpoof = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -73,149 +73,138 @@ registerController('DNSMasqSpoof_ControlsController', ['$api', '$scope', '$rootS
$rootScope.status.refreshOutput = false;
$api.request({
module: 'DNSMasqSpoof',
action: 'toggleDNSMasqSpoof',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
module: 'DNSMasqSpoof',
action: 'toggleDNSMasqSpoof',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'DNSMasqSpoof',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'DNSMasqSpoof',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.toggleDNSMasqSpoofOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.toggleDNSMasqSpoofOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'DNSMasqSpoof',
action: 'toggleDNSMasqSpoofOnBoot',
}, function(response) {
module: 'DNSMasqSpoof',
action: 'toggleDNSMasqSpoofOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'DNSMasqSpoof',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'DNSMasqSpoof',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'DNSMasqSpoof',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'DNSMasqSpoof',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'DNSMasqSpoof',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'DNSMasqSpoof',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('DNSMasqSpoof_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope,$interval) {
$scope.output = 'Loading...';
$scope.filter = '';
registerController('DNSMasqSpoof_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "DNSMasqSpoof",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
module: "DNSMasqSpoof",
action: "refreshOutput",
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -235,14 +224,14 @@ registerController('DNSMasqSpoof_HostsController', ['$api', '$scope', '$timeout'
action: 'saveHostsData',
configurationData: $scope.configurationData
}, function(response) {
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$timeout(function(){
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
});
});
@ -274,14 +263,14 @@ registerController('DNSMasqSpoof_LandingPageController', ['$api', '$scope', '$ti
action: 'saveLandingPageData',
configurationData: $scope.configurationData
}, function(response) {
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$timeout(function(){
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
});
});

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "DNSMasq Spoof",
"version": "1.0"
"version": "1.1"
}

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class DNSspoof extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,301 +35,269 @@ class DNSspoof extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleDNSspoofOnBoot':
$this->toggleDNSspoofOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'saveLandingPageData':
$this->saveLandingPageData();
break;
case 'getLandingPageData':
$this->getLandingPageData();
break;
case 'saveHostsData':
$this->saveHostsData();
break;
case 'getHostsData':
$this->getHostsData();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleDNSspoofOnBoot':
$this->toggleDNSspoofOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'saveLandingPageData':
$this->saveLandingPageData();
break;
case 'getLandingPageData':
$this->getLandingPageData();
break;
case 'saveHostsData':
$this->saveHostsData();
break;
case 'getHostsData':
$this->getHostsData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dnsspoof.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dnsspoof.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/DNSspoof/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/DNSspoof/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("dnsspoof"))
{
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("dnsspoof")) {
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/DNSspoof.progress'))
{
if (!file_exists('/tmp/DNSspoof.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleDNSspoofOnBoot()
{
if(exec("cat /etc/rc.local | grep DNSspoof/scripts/autostart_dnsspoof.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/DNSspoof/scripts/autostart_dnsspoof.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/DNSspoof\/scripts\/autostart_dnsspoof.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep DNSspoof/scripts/autostart_dnsspoof.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/DNSspoof/scripts/autostart_dnsspoof.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/DNSspoof\/scripts\/autostart_dnsspoof.sh/d' /etc/rc.local");
}
}
private function toggleDNSspoof()
{
if(!$this->checkRunning("dnsspoof"))
{
$this->uciSet("dnsspoof.run.interface", $this->request->interface);
if (!$this->checkRunning("dnsspoof")) {
$this->uciSet("dnsspoof.run.interface", $this->request->interface);
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dnsspoof.sh start");
}
else
{
$this->uciSet("dnsspoof.run.interface", '');
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dnsspoof.sh start");
} else {
$this->uciSet("dnsspoof.run.interface", '');
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dnsspoof.sh stop");
}
}
$this->execBackground("/pineapple/modules/DNSspoof/scripts/dnsspoof.sh stop");
}
}
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("dnsspoof.run.interface"));
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("dnsspoof.run.interface"));
}
private function refreshStatus()
{
if (!file_exists('/tmp/DNSspoof.progress'))
{
if (!$this->checkDependency("dnsspoof"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/DNSspoof.progress')) {
if (!$this->checkDependency("dnsspoof")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if($this->checkRunning("dnsspoof"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("dnsspoof")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep DNSspoof/scripts/autostart_dnsspoof.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep DNSspoof/scripts/autostart_dnsspoof.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$bootLabelON = "default";
$bootLabelOFF = "danger";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
private function refreshOutput()
{
if ($this->checkDependency("dnsspoof")) {
if ($this->checkRunning("dnsspoof")) {
$path = "/pineapple/modules/DNSspoof/log";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$latest_ctime = 0;
$latest_filename = '';
private function refreshOutput()
{
if ($this->checkDependency("dnsspoof"))
{
if ($this->checkRunning("dnsspoof"))
{
$path = "/pineapple/modules/DNSspoof/log";
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$latest_ctime = 0;
$latest_filename = '';
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/DNSspoof/log/".$latest_filename));
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if ($this->request->filter != "") {
$filter = $this->request->filter;
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/DNSspoof/log/".$latest_filename));
$cmd = "cat /pineapple/modules/DNSspoof/log/".$latest_filename." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/DNSspoof/log/".$latest_filename;
}
if ($this->request->filter != "")
{
$filter = $this->request->filter;
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "DNSspoof is not running...";
}
} else {
$this->response = "DNSspoof is not installed...";
}
}
$cmd = "cat /pineapple/modules/DNSspoof/log/".$latest_filename." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/DNSspoof/log/".$latest_filename;
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/DNSspoof/log/*"));
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "DNSspoof is not running...";
}
}
else
{
$this->response = "DNSspoof is not installed...";
}
}
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/DNSspoof/log/*"));
echo json_encode(array($entryDate, $entryName));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
echo json_encode(array($entryDate, $entryName));
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/DNSspoof/log/".$this->request->file));
exec("cat /pineapple/modules/DNSspoof/log/".$this->request->file, $output);
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/DNSspoof/log/".$this->request->file));
exec ("cat /pineapple/modules/DNSspoof/log/".$this->request->file, $output);
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/DNSspoof/log/".$this->request->file);
}
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/DNSspoof/log/".$this->request->file));
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/DNSspoof/log/".$this->request->file);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("dnsspoof.autostart.interface", $settings->interface);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/DNSspoof/log/".$this->request->file));
}
private function saveLandingPageData()
{
$filename = '/www/index.php';
file_put_contents($filename, $this->request->configurationData);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("dnsspoof.autostart.interface", $settings->interface);
}
private function getLandingPageData()
{
$configurationData = file_get_contents('/www/index.php');
$this->response = array("configurationData" => $configurationData);
}
private function saveLandingPageData()
{
$filename = '/www/index.php';
file_put_contents($filename, $this->request->configurationData);
}
private function getLandingPageData()
{
$configurationData = file_get_contents('/www/index.php');
$this->response = array("configurationData" => $configurationData);
}
private function saveHostsData()
{
$filename = '/etc/pineapple/spoofhost';
file_put_contents($filename, $this->request->configurationData);
}
private function getHostsData()
{
$configurationData = file_get_contents('/etc/pineapple/spoofhost');
$this->response = array("configurationData" => $configurationData);
}
private function saveHostsData()
{
$filename = '/etc/pineapple/spoofhost';
file_put_contents($filename, $this->request->configurationData);
}
private function getHostsData()
{
$configurationData = file_get_contents('/etc/pineapple/spoofhost');
$this->response = array("configurationData" => $configurationData);
}
}

View File

@ -2,17 +2,17 @@ registerController('DNSspoof_Controller', ['$api', '$scope', '$rootScope', '$int
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'DNSspoof',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'DNSspoof',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,33 +37,33 @@ registerController('DNSspoof_ControlsController', ['$api', '$scope', '$rootScope
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "DNSspoof",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "DNSspoof",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.toggleDNSspoof = (function() {
if($scope.status != "Stop")
$scope.toggleDNSspoof = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -75,150 +75,146 @@ registerController('DNSspoof_ControlsController', ['$api', '$scope', '$rootScope
$rootScope.status.refreshHistory = false;
$api.request({
module: 'DNSspoof',
action: 'toggleDNSspoof',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'DNSspoof',
action: 'toggleDNSspoof',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'DNSspoof',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'DNSspoof',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.toggleDNSspoofOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.toggleDNSspoofOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'DNSspoof',
action: 'toggleDNSspoofOnBoot',
}, function(response) {
module: 'DNSspoof',
action: 'toggleDNSspoofOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'DNSspoof',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'DNSspoof',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'DNSspoof',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'DNSspoof',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'DNSspoof',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'DNSspoof',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('DNSspoof_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope,$interval) {
$scope.output = 'Loading...';
registerController('DNSspoof_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "DNSspoof",
action: "refreshOutput",
module: "DNSspoof",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -227,52 +223,52 @@ registerController('DNSspoof_HistoryController', ['$api', '$scope', '$rootScope'
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "DNSspoof",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.refreshHistory = (function() {
$api.request({
module: "DNSspoof",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "DNSspoof",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "DNSspoof",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "DNSspoof",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "DNSspoof",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'DNSspoof',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$api.request({
module: 'DNSspoof',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -295,14 +291,14 @@ registerController('DNSspoof_HostsController', ['$api', '$scope', '$timeout', fu
action: 'saveHostsData',
configurationData: $scope.configurationData
}, function(response) {
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$timeout(function(){
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
});
});
@ -334,14 +330,14 @@ registerController('DNSspoof_LandingPageController', ['$api', '$scope', '$timeou
action: 'saveLandingPageData',
configurationData: $scope.configurationData
}, function(response) {
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$timeout(function(){
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
});
});

1
DNSspoof/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "DNSspoof",
"version": "1.3"
"version": "1.4"
}

View File

@ -12,8 +12,8 @@ touch /tmp/DNSspoof.progress
if [ "$1" = "install" ]; then
if [ "$2" = "internal" ]; then
opkg update
opkg install dnsspoof
opkg update
opkg install dnsspoof
elif [ "$2" = "sd" ]; then
opkg update
opkg install dnsspoof --dest sd
@ -28,8 +28,8 @@ if [ "$1" = "install" ]; then
uci commit dnsspoof.module.installed
elif [ "$1" = "remove" ]; then
opkg remove dnsspoof
rm -rf /etc/config/dnsspoof
opkg remove dnsspoof
rm -rf /etc/config/dnsspoof
fi
rm /tmp/DNSspoof.progress

View File

@ -11,5 +11,5 @@ HOSTSFILE="/etc/pineapple/spoofhost"
if [ "$1" = "start" ]; then
dnsspoof -i ${MYINTERFACE} -f ${HOSTSFILE} > /dev/null 2> /pineapple/modules/DNSspoof/log/output_${MYTIME}.log
elif [ "$1" = "stop" ]; then
killall dnsspoof
killall -9 dnsspoof
fi

View File

@ -1,18 +1,19 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class Deauth extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
$this->refreshStatus();
break;
@ -25,285 +26,255 @@ class Deauth extends Module
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'getInterfaces':
case 'getInterfaces':
$this->getInterfaces();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'togglemdk3OnBoot':
$this->togglemdk3OnBoot();
break;
case 'getListsData':
$this->getListsData();
break;
case 'saveListsData':
$this->saveListsData();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'togglemdk3OnBoot':
$this->togglemdk3OnBoot();
break;
case 'getListsData':
$this->getListsData();
break;
case 'saveListsData':
$this->saveListsData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("deauth.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("deauth.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Deauth/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Deauth/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("mdk3"))
{
$this->execBackground("/pineapple/modules/Deauth/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/Deauth/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("mdk3")) {
$this->execBackground("/pineapple/modules/Deauth/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/Deauth/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function togglemdk3OnBoot()
{
if(exec("cat /etc/rc.local | grep Deauth/scripts/autostart_deauth.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Deauth/scripts/autostart_deauth.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/Deauth\/scripts\/autostart_deauth.sh/d' /etc/rc.local");
}
}
private function togglemdk3OnBoot()
{
if (exec("cat /etc/rc.local | grep Deauth/scripts/autostart_deauth.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Deauth/scripts/autostart_deauth.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/Deauth\/scripts\/autostart_deauth.sh/d' /etc/rc.local");
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/Deauth.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/Deauth.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function togglemdk3()
{
if(!$this->checkRunning("mdk3"))
{
$this->uciSet("deauth.run.interface", $this->request->interface);
if (!$this->checkRunning("mdk3")) {
$this->uciSet("deauth.run.interface", $this->request->interface);
$this->execBackground("/pineapple/modules/Deauth/scripts/deauth.sh start");
}
else
{
$this->uciSet("deauth.run.interface", '');
$this->execBackground("/pineapple/modules/Deauth/scripts/deauth.sh start");
} else {
$this->uciSet("deauth.run.interface", '');
$this->execBackground("/pineapple/modules/Deauth/scripts/deauth.sh stop");
}
}
$this->execBackground("/pineapple/modules/Deauth/scripts/deauth.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/Deauth.progress'))
{
if (!$this->checkDependency("mdk3"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/Deauth.progress')) {
if (!$this->checkDependency("mdk3")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("mdk3"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("mdk3")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep Deauth/scripts/autostart_deauth.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep Deauth/scripts/autostart_deauth.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$bootLabelON = "default";
$bootLabelOFF = "danger";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
private function refreshOutput()
{
if ($this->checkDependency("mdk3")) {
if ($this->checkRunning("mdk3")) {
exec("cat /tmp/deauth.log", $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
} else {
$this->response = "Deauth is not running...";
}
} else {
$this->response = "mdk3 is not installed...";
}
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | awk '{print $1}'", $interfaceArray);
private function refreshOutput()
{
if ($this->checkDependency("mdk3"))
{
if ($this->checkRunning("mdk3"))
{
exec ("cat /tmp/deauth.log", $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
else
{
$this->response = "Deauth is not running...";
}
}
else
{
$this->response = "mdk3 is not installed...";
}
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("deauth.run.interface"));
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | awk '{print $1}'", $interfaceArray);
private function scanForNetworks()
{
$interface = escapeshellarg($this->request->interface);
if (substr($interface, -4, -1) === "mon") {
if ($interface == "'wlan1mon'") {
exec("killall pineap");
exec("killall pinejector");
}
exec("airmon-ng stop {$interface}");
$interface = substr($interface, 0, -4) . "'";
exec("iw dev {$interface} scan &> /dev/null");
}
exec("iwinfo {$interface} scan", $apScan);
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("deauth.run.interface"));
}
$apArray = preg_split("/^Cell/m", implode("\n", $apScan));
$returnArray = array();
foreach ($apArray as $apData) {
$apData = explode("\n", $apData);
$accessPoint = array();
$accessPoint['mac'] = substr($apData[0], -17);
$accessPoint['ssid'] = substr(trim($apData[1]), 8, -1);
if (mb_detect_encoding($accessPoint['ssid'], "auto") === false) {
continue;
}
private function scanForNetworks()
{
$interface = escapeshellarg($this->request->interface);
if (substr($interface, -4, -1) === "mon") {
if ($interface == "'wlan1mon'") {
exec("killall pineap");
exec("killall pinejector");
}
exec("airmon-ng stop {$interface}");
$interface = substr($interface, 0, -4) . "'";
exec("iw dev {$interface} scan &> /dev/null");
}
exec("iwinfo {$interface} scan", $apScan);
$accessPoint['channel'] = intval(substr(trim($apData[2]), -2));
$apArray = preg_split("/^Cell/m", implode("\n", $apScan));
$returnArray = array();
foreach ($apArray as $apData) {
$apData = explode("\n", $apData);
$accessPoint = array();
$accessPoint['mac'] = substr($apData[0], -17);
$accessPoint['ssid'] = substr(trim($apData[1]), 8, -1);
if (mb_detect_encoding($accessPoint['ssid'], "auto") === false) {
continue;
}
$signalString = explode(" ", trim($apData[3]));
$accessPoint['signal'] = substr($signalString[0], 8);
$accessPoint['quality'] = substr($signalString[1], 9);
$accessPoint['channel'] = intval(substr(trim($apData[2]), -2));
$security = substr(trim($apData[4]), 12);
if ($security === "none") {
$accessPoint['security'] = "Open";
} else {
$accessPoint['security'] = $security;
}
$signalString = explode(" ", trim($apData[3]));
$accessPoint['signal'] = substr($signalString[0], 8);
$accessPoint['quality'] = substr($signalString[1], 9);
if ($accessPoint['mac'] && trim($apData[1]) !== "ESSID: unknown") {
array_push($returnArray, $accessPoint);
}
}
$this->response = $returnArray;
}
$security = substr(trim($apData[4]), 12);
if ($security === "none") {
$accessPoint['security'] = "Open";
} else {
$accessPoint['security'] = $security;
}
private function getSettings()
{
$settings = array(
'speed' => $this->uciGet("deauth.settings.speed"),
'channels' => $this->uciGet("deauth.settings.channels"),
'mode' => $this->uciGet("deauth.settings.mode")
);
$this->response = array('settings' => $settings);
}
if ($accessPoint['mac'] && trim($apData[1]) !== "ESSID: unknown") {
array_push($returnArray, $accessPoint);
}
}
$this->response = $returnArray;
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("deauth.settings.speed", $settings->speed);
$this->uciSet("deauth.settings.channels", $settings->channels);
$this->uciSet("deauth.settings.mode", $settings->mode);
}
private function getSettings()
{
$settings = array(
'speed' => $this->uciGet("deauth.settings.speed"),
'channels' => $this->uciGet("deauth.settings.channels"),
'mode' => $this->uciGet("deauth.settings.mode")
);
$this->response = array('settings' => $settings);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("deauth.autostart.interface", $settings->interface);
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("deauth.settings.speed", $settings->speed);
$this->uciSet("deauth.settings.channels", $settings->channels);
$this->uciSet("deauth.settings.mode", $settings->mode);
}
private function getListsData()
{
$blacklistData = file_get_contents('/pineapple/modules/Deauth/lists/blacklist.lst');
$whitelistData = file_get_contents('/pineapple/modules/Deauth/lists/whitelist.lst');
$this->response = array("blacklistData" => $blacklistData, "whitelistData" => $whitelistData );
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("deauth.autostart.interface", $settings->interface);
}
private function getListsData()
{
$blacklistData = file_get_contents('/pineapple/modules/Deauth/lists/blacklist.lst');
$whitelistData = file_get_contents('/pineapple/modules/Deauth/lists/whitelist.lst');
$this->response = array("blacklistData" => $blacklistData, "whitelistData" => $whitelistData );
}
private function saveListsData()
{
$filename = '/pineapple/modules/Deauth/lists/blacklist.lst';
file_put_contents($filename, $this->request->blacklistData);
$filename = '/pineapple/modules/Deauth/lists/whitelist.lst';
file_put_contents($filename, $this->request->whitelistData);
}
private function saveListsData()
{
$filename = '/pineapple/modules/Deauth/lists/blacklist.lst';
file_put_contents($filename, $this->request->blacklistData);
$filename = '/pineapple/modules/Deauth/lists/whitelist.lst';
file_put_contents($filename, $this->request->whitelistData);
}
}

View File

@ -2,17 +2,17 @@ registerController('Deauth_Controller', ['$api', '$scope', '$rootScope', '$inter
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'Deauth',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'Deauth',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,32 +37,32 @@ registerController('Deauth_ControlsController', ['$api', '$scope', '$rootScope',
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false
installed: false,
refreshOutput: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: 'Deauth',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: 'Deauth',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.togglemdk3 = (function() {
if($scope.status != "Stop")
$scope.togglemdk3 = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -73,146 +73,142 @@ registerController('Deauth_ControlsController', ['$api', '$scope', '$rootScope',
$rootScope.status.refreshOutput = false;
$api.request({
module: 'Deauth',
action: 'togglemdk3',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
module: 'Deauth',
action: 'togglemdk3',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.getInterfaces();
$scope.starting = false;
$scope.refreshStatus();
$scope.getInterfaces();
}, 3000);
})
}, 3000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'Deauth',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'Deauth',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.togglemdk3OnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.togglemdk3OnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'Deauth',
action: 'togglemdk3OnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
module: 'Deauth',
action: 'togglemdk3OnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'Deauth',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'Deauth',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'Deauth',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'Deauth',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Deauth',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Deauth',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('Deauth_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: 'Deauth',
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
module: 'Deauth',
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -260,116 +256,116 @@ registerController('Deauth_EditorController', ['$api', '$scope', '$rootScope', '
blacklistData: $scope.blacklistData,
whitelistData: $scope.whitelistData
}, function(response) {
$scope.saveListsLabel = "success";
$scope.saveLists = "Saved";
$scope.saveListsLabel = "success";
$scope.saveLists = "Saved";
$timeout(function(){
$scope.saveListsLabel = "primary";
$scope.saveLists = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveListsLabel = "primary";
$scope.saveLists = "Save";
$scope.saving = false;
}, 2000);
});
});
$scope.addWhitelist = (function() {
if($scope.whitelistData != "")
if ($scope.whitelistData != "")
$scope.whitelistData = $scope.whitelistData + '\n' + '# ' + $scope.selectedAP.ssid + '\n' + $scope.selectedAP.mac;
else
$scope.whitelistData = '# ' + $scope.selectedAP.ssid + '\n' + $scope.selectedAP.mac;
});
$scope.addBlacklist = (function() {
if($scope.blacklistData != "")
if ($scope.blacklistData != "")
$scope.blacklistData = $scope.blacklistData + '\n' + '# ' + $scope.selectedAP.ssid + '\n' + $scope.selectedAP.mac;
else
$scope.blacklistData = '# ' + $scope.selectedAP.ssid + '\n' + $scope.selectedAP.mac;
});
$scope.scanForNetworks = (function() {
$scope.scanLabel = "warning";
$scope.scan = "Scanning...";
$scope.scanning = true;
$scope.scanLabel = "warning";
$scope.scan = "Scanning...";
$scope.scanning = true;
$api.request({
module: 'Deauth',
action: 'scanForNetworks',
interface: $scope.selectedInterface
}, function(response) {
$scope.scanLabel = "success";
$scope.scan = "Done";
$api.request({
module: 'Deauth',
action: 'scanForNetworks',
interface: $scope.selectedInterface
}, function(response) {
$scope.scanLabel = "success";
$scope.scan = "Done";
$timeout(function(){
$scope.scanLabel = "default";
$scope.scan = "Scan";
$scope.scanning = false;
}, 2000);
$timeout(function() {
$scope.scanLabel = "default";
$scope.scan = "Scan";
$scope.scanning = false;
}, 2000);
$scope.accessPoints = response;
$scope.selectedAP = $scope.accessPoints[0];
});
$scope.accessPoints = response;
$scope.selectedAP = $scope.accessPoints[0];
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Deauth',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'Deauth',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.getInterfaces();
$scope.getListsData();
$scope.getInterfaces();
$scope.getListsData();
}]);
registerController('Deauth_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
$scope.settings = {
speed : "",
channels : "",
mode : "whitelist"
};
$scope.settings = {
speed: "",
channels: "",
mode: "whitelist"
};
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.getSettings = function() {
$api.request({
module: 'Deauth',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.getSettings = function() {
$api.request({
module: 'Deauth',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$api.request({
module: 'Deauth',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$api.request({
module: 'Deauth',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$timeout(function(){
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$timeout(function() {
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$scope.getSettings();
$scope.getSettings();
}]);

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Deauth",
"version": "1.5"
"version": "1.6"
}

View File

@ -101,7 +101,7 @@ if [ "$1" = "start" ]; then
mdk3 ${MYMONITOR} d ${SPEED} ${CHANNEL} ${MODE} >> ${LOG} &
elif [ "$1" = "stop" ]; then
killall -9 mdk3
killall -9 mdk3
rm ${TMPBLACKLIST}
rm ${TMPWHITELIST}
rm ${LOG}

View File

@ -12,8 +12,8 @@ touch /tmp/Deauth.progress
if [ "$1" = "install" ]; then
if [ "$2" = "internal" ]; then
opkg update
opkg install mdk3
opkg update
opkg install mdk3
elif [ "$2" = "sd" ]; then
opkg update
opkg install mdk3 --dest sd

View File

@ -1,147 +1,143 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class LogManager extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshFilesList':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshFilesList':
$this->refreshFilesList();
break;
case 'downloadFilesList':
$this->downloadFilesList();
break;
case 'deleteFilesList':
$this->deleteFilesList();
break;
case 'downloadFilesList':
$this->downloadFilesList();
break;
case 'deleteFilesList':
$this->deleteFilesList();
break;
case 'viewModuleFile':
$this->viewModuleFile();
break;
case 'deleteModuleFile':
$this->deleteModuleFile();
break;
case 'downloadModuleFile':
$this->downloadModuleFile();
break;
case 'downloadModuleFile':
$this->downloadModuleFile();
break;
}
}
private function dataSize($path)
{
$blah = exec( "/usr/bin/du -sch $path | tail -1 | awk {'print $1'}" );
return $blah;
}
private function dataSize($path)
{
$blah = exec("/usr/bin/du -sch $path | tail -1 | awk {'print $1'}");
return $blah;
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/LogManager/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/LogManager/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function downloadFilesList()
{
$files = $this->request->files;
private function downloadFilesList()
{
$files = $this->request->files;
exec("mkdir /tmp/dl/");
foreach($files as $file)
{
exec("cp ".$file." /tmp/dl/");
}
exec("cd /tmp/dl/ && tar -czf /tmp/files.tar.gz *");
exec("rm -rf /tmp/dl/");
exec("mkdir /tmp/dl/");
foreach ($files as $file) {
exec("cp ".$file." /tmp/dl/");
}
exec("cd /tmp/dl/ && tar -czf /tmp/files.tar.gz *");
exec("rm -rf /tmp/dl/");
$this->response = array("download" => $this->downloadFile("/tmp/files.tar.gz"));
}
$this->response = array("download" => $this->downloadFile("/tmp/files.tar.gz"));
}
private function deleteFilesList()
{
$files = $this->request->files;
private function deleteFilesList()
{
$files = $this->request->files;
foreach($files as $file)
{
exec("rm -rf ".$file);
}
}
foreach ($files as $file) {
exec("rm -rf ".$file);
}
}
private function refreshFilesList()
{
$modules = array();
foreach(glob('/pineapple/modules/*/log/*') as $file)
{
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
private function refreshFilesList()
{
$modules = array();
foreach (glob('/pineapple/modules/*/log/*') as $file) {
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach(glob('/pineapple/modules/*/dump/*') as $file)
{
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach (glob('/pineapple/modules/*/dump/*') as $file) {
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach(glob('/pineapple/modules/*/scan/*') as $file)
{
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach (glob('/pineapple/modules/*/scan/*') as $file) {
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach(glob('/pineapple/modules/*/capture/*') as $file)
{
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
foreach (glob('/pineapple/modules/*/capture/*') as $file) {
$module = array();
$module['file'] = basename($file);
$module['path'] = $file;
$module['size'] = $this->dataSize($file);
$module['title'] = explode("/", dirname($file))[3];
$module['date'] = gmdate("F d Y H:i:s", filemtime($file));
$module['timestamp'] = filemtime($file);
$modules[] = $module;
}
usort($modules, create_function('$a, $b','if($a["timestamp"] == $b["timestamp"]) return 0; return ($a["timestamp"] > $b["timestamp"]) ? -1 : 1;'));
usort($modules, create_function('$a, $b', 'if($a["timestamp"] == $b["timestamp"]) return 0; return ($a["timestamp"] > $b["timestamp"]) ? -1 : 1;'));
$this->response = array("files" => $modules);
}
$this->response = array("files" => $modules);
}
private function viewModuleFile()
{
$log_date = gmdate("F d Y H:i:s", filemtime($this->request->file));
exec ("strings ".$this->request->file, $output);
private function viewModuleFile()
{
$log_date = gmdate("F d Y H:i:s", filemtime($this->request->file));
exec("strings ".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date, "name" => basename($this->request->file));
else
$this->response = array("output" => "Empty file...", "date" => $log_date, "name" => basename($this->request->file));
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date, "name" => basename($this->request->file));
} else {
$this->response = array("output" => "Empty file...", "date" => $log_date, "name" => basename($this->request->file));
}
}
private function deleteModuleFile()
{
exec("rm -rf ".$this->request->file);
}
private function deleteModuleFile()
{
exec("rm -rf ".$this->request->file);
}
private function downloadModuleFile()
{
$this->response = array("download" => $this->downloadFile($this->request->file));
}
private function downloadModuleFile()
{
$this->response = array("download" => $this->downloadFile($this->request->file));
}
}

View File

@ -2,17 +2,17 @@ registerController('LogManager_Controller', ['$api', '$scope', '$rootScope', '$i
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'LogManager',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'LogManager',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -27,89 +27,93 @@ registerController('LogManager_FilesController', ['$api', '$scope', '$rootScope'
$scope.updateSelectedFiles = (function() {
$scope.selectedFilesArray = [];
angular.forEach($scope.selectedFiles, function(key,value) { if(key) { $scope.selectedFilesArray.push(value); } });
angular.forEach($scope.selectedFiles, function(key, value) {
if (key) {
$scope.selectedFilesArray.push(value);
}
});
});
$scope.updateAllSelectedFiles = (function() {
$scope.selectedFilesArray = [];
if($scope.selectedAll)
{
angular.forEach($scope.files, function(key,value) { $scope.selectedFilesArray.push(key.path); $scope.selectedFiles[key.path] = true; });
if ($scope.selectedAll) {
angular.forEach($scope.files, function(key, value) {
$scope.selectedFilesArray.push(key.path);
$scope.selectedFiles[key.path] = true;
});
$scope.selectedAll = true;
}
else
{
$scope.selectedAll = false;
$scope.selectedFiles = {};
} else {
$scope.selectedAll = false;
$scope.selectedFiles = {};
}
});
$scope.refreshFilesList = (function() {
$api.request({
module: "LogManager",
action: "refreshFilesList"
}, function(response) {
$scope.files = response.files;
})
});
$scope.refreshFilesList = (function() {
$api.request({
module: "LogManager",
action: "refreshFilesList"
}, function(response) {
$scope.files = response.files;
})
});
$scope.downloadFilesList = (function() {
$api.request({
module: "LogManager",
action: "downloadFilesList",
files: $scope.selectedFilesArray
}, function(response) {
module: "LogManager",
action: "downloadFilesList",
files: $scope.selectedFilesArray
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
window.location = '/api/?download=' + response.download;
}
})
});
})
});
$scope.deleteFilesList = (function() {
$api.request({
module: "LogManager",
action: "deleteFilesList",
files: $scope.selectedFilesArray
}, function(response) {
module: "LogManager",
action: "deleteFilesList",
files: $scope.selectedFilesArray
}, function(response) {
$scope.refreshFilesList();
$scope.selectedFiles = {};
$scope.updateSelectedFiles();
})
});
})
});
$scope.viewFile = (function(param) {
$api.request({
module: "LogManager",
action: "viewModuleFile",
file: param
}, function(response) {
$scope.fileOutput = response.output;
$scope.fileDate = response.date;
$scope.fileName = response.name;
})
});
$scope.viewFile = (function(param) {
$api.request({
module: "LogManager",
action: "viewModuleFile",
file: param
}, function(response) {
$scope.fileOutput = response.output;
$scope.fileDate = response.date;
$scope.fileName = response.name;
})
});
$scope.deleteFile = (function(param) {
$api.request({
module: "LogManager",
action: "deleteModuleFile",
file: param
}, function(response) {
$scope.refreshFilesList();
})
});
$scope.deleteFile = (function(param) {
$api.request({
module: "LogManager",
action: "deleteModuleFile",
file: param
}, function(response) {
$scope.refreshFilesList();
})
});
$scope.downloadFile = (function(param) {
$api.request({
module: 'LogManager',
action: 'downloadModuleFile',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$api.request({
module: 'LogManager',
action: 'downloadModuleFile',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshFilesList();

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Log Manager",
"version": "1.2"
"version": "1.3"
}

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class Occupineapple extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -25,266 +26,256 @@ class Occupineapple extends Module
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'getInterfaces':
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getLists':
$this->getLists();
break;
case 'showList':
$this->showList();
break;
case 'deleteList':
$this->deleteList();
break;
case 'saveListData':
$this->saveListData();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'togglemdk3OnBoot':
$this->togglemdk3OnBoot();
break;
case 'getLists':
$this->getLists();
break;
case 'showList':
$this->showList();
break;
case 'deleteList':
$this->deleteList();
break;
case 'saveListData':
$this->saveListData();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'togglemdk3OnBoot':
$this->togglemdk3OnBoot();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("occupineapple.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("occupineapple.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Occupineapple/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Occupineapple/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("mdk3"))
{
$this->execBackground("/pineapple/modules/Occupineapple/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/Occupineapple/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("mdk3")) {
$this->execBackground("/pineapple/modules/Occupineapple/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/Occupineapple/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function togglemdk3OnBoot()
{
if(exec("cat /etc/rc.local | grep Occupineapple/scripts/autostart_occupineapple.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Occupineapple/scripts/autostart_occupineapple.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/Occupineapple\/scripts\/autostart_occupineapple.sh/d' /etc/rc.local");
}
}
private function togglemdk3OnBoot()
{
if (exec("cat /etc/rc.local | grep Occupineapple/scripts/autostart_occupineapple.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Occupineapple/scripts/autostart_occupineapple.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/Occupineapple\/scripts\/autostart_occupineapple.sh/d' /etc/rc.local");
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/Occupineapple.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/Occupineapple.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function togglemdk3()
{
if(!$this->checkRunning("mdk3"))
{
$this->uciSet("occupineapple.run.interface", $this->request->interface);
$this->uciSet("occupineapple.run.list", $this->request->list);
if (!$this->checkRunning("mdk3")) {
$this->uciSet("occupineapple.run.interface", $this->request->interface);
$this->uciSet("occupineapple.run.list", $this->request->list);
$this->execBackground("/pineapple/modules/Occupineapple/scripts/occupineapple.sh start");
}
else
{
$this->uciSet("occupineapple.run.interface", '');
$this->uciSet("occupineapple.run.list", '');
$this->execBackground("/pineapple/modules/Occupineapple/scripts/occupineapple.sh start");
} else {
$this->uciSet("occupineapple.run.interface", '');
$this->uciSet("occupineapple.run.list", '');
$this->execBackground("/pineapple/modules/Occupineapple/scripts/occupineapple.sh stop");
}
}
$this->execBackground("/pineapple/modules/Occupineapple/scripts/occupineapple.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/Occupineapple.progress'))
{
if (!$this->checkDependency("mdk3"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/Occupineapple.progress')) {
if (!$this->checkDependency("mdk3")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("mdk3"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("mdk3")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep Occupineapple/scripts/autostart_occupineapple.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep Occupineapple/scripts/autostart_occupineapple.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$bootLabelON = "default";
$bootLabelOFF = "danger";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
private function refreshOutput()
{
if ($this->checkDependency("mdk3")) {
if ($this->checkRunning("mdk3")) {
exec("cat /tmp/occupineapple.log", $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
} else {
$this->response = "Occupineapple is not running...";
}
} else {
$this->response = "mdk3 is not installed...";
}
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | awk '{print $1}'", $interfaceArray);
private function refreshOutput()
{
if ($this->checkDependency("mdk3"))
{
if ($this->checkRunning("mdk3"))
{
exec ("cat /tmp/occupineapple.log", $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
else
{
$this->response = "Occupineapple is not running...";
}
}
else
{
$this->response = "mdk3 is not installed...";
}
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("occupineapple.run.interface"));
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | awk '{print $1}'", $interfaceArray);
private function getLists()
{
$listArray = array();
$listList = array_reverse(glob("/pineapple/modules/Occupineapple/lists/*"));
array_push($listArray, "--");
foreach ($listList as $list) {
array_push($listArray, basename($list));
}
$this->response = array("lists" => $listArray, "selected" => $this->uciGet("occupineapple.run.list"));
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("occupineapple.run.interface"));
}
private function showList()
{
$listData = file_get_contents('/pineapple/modules/Occupineapple/lists/'.$this->request->list);
$this->response = array("listData" => $listData);
}
private function getLists()
{
$listArray = array();
$listList = array_reverse(glob("/pineapple/modules/Occupineapple/lists/*"));
array_push($listArray, "--");
foreach ($listList as $list) {
array_push($listArray, basename($list));
}
$this->response = array("lists" => $listArray, "selected" => $this->uciGet("occupineapple.run.list"));
}
private function deleteList()
{
exec("rm -rf /pineapple/modules/Occupineapple/lists/".$this->request->list);
}
private function showList()
{
$listData = file_get_contents('/pineapple/modules/Occupineapple/lists/'.$this->request->list);
$this->response = array("listData" => $listData);
}
private function saveListData()
{
$filename = "/pineapple/modules/Occupineapple/lists/".$this->request->list;
file_put_contents($filename, $this->request->listData);
}
private function deleteList()
{
exec("rm -rf /pineapple/modules/Occupineapple/lists/".$this->request->list);
}
private function getSettings()
{
$settings = array(
'speed' => $this->uciGet("occupineapple.settings.speed"),
'channel' => $this->uciGet("occupineapple.settings.channel"),
'adHoc' => $this->uciGet("occupineapple.settings.adHoc"),
'wepBit' => $this->uciGet("occupineapple.settings.wepBit"),
'wpaTKIP' => $this->uciGet("occupineapple.settings.wpaTKIP"),
'wpaAES' => $this->uciGet("occupineapple.settings.wpaAES"),
'validMAC' => $this->uciGet("occupineapple.settings.validMAC")
);
$this->response = array('settings' => $settings);
}
private function saveListData()
{
$filename = "/pineapple/modules/Occupineapple/lists/".$this->request->list;
file_put_contents($filename, $this->request->listData);
}
private function getSettings()
{
$settings = array(
'speed' => $this->uciGet("occupineapple.settings.speed"),
'channel' => $this->uciGet("occupineapple.settings.channel"),
'adHoc' => $this->uciGet("occupineapple.settings.adHoc"),
'wepBit' => $this->uciGet("occupineapple.settings.wepBit"),
'wpaTKIP' => $this->uciGet("occupineapple.settings.wpaTKIP"),
'wpaAES' => $this->uciGet("occupineapple.settings.wpaAES"),
'validMAC' => $this->uciGet("occupineapple.settings.validMAC")
);
$this->response = array('settings' => $settings);
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("occupineapple.settings.speed", $settings->speed);
$this->uciSet("occupineapple.settings.channel", $settings->channel);
if ($settings->adHoc) $this->uciSet("occupineapple.settings.adHoc", 1); else $this->uciSet("occupineapple.settings.adHoc", 0);
if ($settings->wepBit) $this->uciSet("occupineapple.settings.wepBit", 1); else $this->uciSet("occupineapple.settings.wepBit", 0);
if ($settings->wpaTKIP) $this->uciSet("occupineapple.settings.wpaTKIP", 1); else $this->uciSet("occupineapple.settings.wpaTKIP", 0);
if ($settings->wpaAES) $this->uciSet("occupineapple.settings.wpaAES", 1); else $this->uciSet("occupineapple.settings.wpaAES", 0);
if ($settings->validMAC) $this->uciSet("occupineapple.settings.validMAC", 1); else $this->uciSet("occupineapple.settings.validMAC", 0);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("occupineapple.autostart.interface", $settings->interface);
$this->uciSet("occupineapple.autostart.list", $settings->list);
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("occupineapple.settings.speed", $settings->speed);
$this->uciSet("occupineapple.settings.channel", $settings->channel);
if ($settings->adHoc) {
$this->uciSet("occupineapple.settings.adHoc", 1);
} else {
$this->uciSet("occupineapple.settings.adHoc", 0);
}
if ($settings->wepBit) {
$this->uciSet("occupineapple.settings.wepBit", 1);
} else {
$this->uciSet("occupineapple.settings.wepBit", 0);
}
if ($settings->wpaTKIP) {
$this->uciSet("occupineapple.settings.wpaTKIP", 1);
} else {
$this->uciSet("occupineapple.settings.wpaTKIP", 0);
}
if ($settings->wpaAES) {
$this->uciSet("occupineapple.settings.wpaAES", 1);
} else {
$this->uciSet("occupineapple.settings.wpaAES", 0);
}
if ($settings->validMAC) {
$this->uciSet("occupineapple.settings.validMAC", 1);
} else {
$this->uciSet("occupineapple.settings.validMAC", 0);
}
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("occupineapple.autostart.interface", $settings->interface);
$this->uciSet("occupineapple.autostart.list", $settings->list);
}
}

View File

@ -2,17 +2,17 @@ registerController('Occupineapple_Controller', ['$api', '$scope', '$rootScope',
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'Occupineapple',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'Occupineapple',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -40,33 +40,33 @@ registerController('Occupineapple_ControlsController', ['$api', '$scope', '$root
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshLists : false
installed: false,
refreshOutput: false,
refreshLists: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: 'Occupineapple',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: 'Occupineapple',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.togglemdk3 = (function() {
if($scope.status != "Stop")
$scope.togglemdk3 = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -77,169 +77,166 @@ registerController('Occupineapple_ControlsController', ['$api', '$scope', '$root
$rootScope.status.refreshOutput = false;
$api.request({
module: 'Occupineapple',
action: 'togglemdk3',
interface: $scope.selectedInterface,
list: $scope.selectedList
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
module: 'Occupineapple',
action: 'togglemdk3',
interface: $scope.selectedInterface,
list: $scope.selectedList
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.getInterfaces();
$scope.starting = false;
$scope.refreshStatus();
$scope.getInterfaces();
}, 3000);
})
}, 3000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'Occupineapple',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface, list : $scope.selectedList }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'Occupineapple',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface,
list: $scope.selectedList
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.togglemdk3OnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.togglemdk3OnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'Occupineapple',
action: 'togglemdk3OnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
module: 'Occupineapple',
action: 'togglemdk3OnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'Occupineapple',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'Occupineapple',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'Occupineapple',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getLists = (function(param) {
$api.request({
module: 'Occupineapple',
action: 'getLists'
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'Occupineapple',
action: 'handleDependenciesStatus'
}, function(response) {
$scope.lists = response.lists;
if(response.selected != "")
$scope.selectedList = response.selected;
else
$scope.selectedList = $scope.lists[0];
$rootScope.status.refreshLists = false;
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Occupineapple',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
$scope.getLists();
$rootScope.$watch('status.refreshLists', function(param) {
if(param) {
$scope.getLists();
}, 5000);
}
});
});
$scope.getLists = (function(param) {
$api.request({
module: 'Occupineapple',
action: 'getLists'
}, function(response) {
$scope.lists = response.lists;
if (response.selected != "")
$scope.selectedList = response.selected;
else
$scope.selectedList = $scope.lists[0];
$rootScope.status.refreshLists = false;
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Occupineapple',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
$scope.getLists();
$rootScope.$watch('status.refreshLists', function(param) {
if (param) {
$scope.getLists();
}
});
}]);
registerController('Occupineapple_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: 'Occupineapple',
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
module: 'Occupineapple',
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -260,29 +257,28 @@ registerController('Occupineapple_EditorController', ['$api', '$scope', '$rootSc
$scope.getLists = (function(param) {
$api.request({
module: 'Occupineapple',
action: 'getLists'
}, function(response) {
$scope.lists = response.lists;
});
module: 'Occupineapple',
action: 'getLists'
}, function(response) {
$scope.lists = response.lists;
});
});
$scope.showList = (function() {
$scope.output = "";
if($scope.selectedList != "--") {
if ($scope.selectedList != "--") {
$scope.listName = $scope.selectedList;
$scope.saveList = "Save List";
$api.request({
module: 'Occupineapple',
action: 'showList',
list: $scope.selectedList
}, function(response) {
$scope.listData = response.listData;
});
}
else {
module: 'Occupineapple',
action: 'showList',
list: $scope.selectedList
}, function(response) {
$scope.listData = response.listData;
});
} else {
$scope.listName = "";
$scope.listData = "";
$scope.saveList = "New List";
@ -299,79 +295,76 @@ registerController('Occupineapple_EditorController', ['$api', '$scope', '$rootSc
action: 'deleteList',
list: $scope.selectedList
}, function(response) {
$scope.deleteListLabel = "success";
$scope.deleteList = "Deleted";
$scope.deleteListLabel = "success";
$scope.deleteList = "Deleted";
$timeout(function(){
$scope.deleteListLabel = "danger";
$scope.deleteList = "Delete List";
$scope.deleting = false;
}, 2000);
$timeout(function() {
$scope.deleteListLabel = "danger";
$scope.deleteList = "Delete List";
$scope.deleting = false;
}, 2000);
$scope.getLists();
$scope.selectedList = '--';
$scope.listName = "";
$scope.listData = "";
$scope.getLists();
$scope.selectedList = '--';
$scope.listName = "";
$scope.listData = "";
$scope.saveList = "New List";
$scope.saveList = "New List";
$rootScope.status.refreshLists = true;
$rootScope.status.refreshLists = true;
});
});
$scope.saveListData = (function() {
if($scope.selectedList != "--" && $scope.listName != "")
{
$scope.saveListLabel = "warning";
$scope.saveList = "Saving...";
$scope.saving = true;
if ($scope.selectedList != "--" && $scope.listName != "") {
$scope.saveListLabel = "warning";
$scope.saveList = "Saving...";
$scope.saving = true;
$api.request({
module: 'Occupineapple',
action: 'saveListData',
listData: $scope.listData,
list: $scope.selectedList
}, function(response) {
$scope.saveListLabel = "success";
$scope.saveList = "Saved";
$api.request({
module: 'Occupineapple',
action: 'saveListData',
listData: $scope.listData,
list: $scope.selectedList
}, function(response) {
$scope.saveListLabel = "success";
$scope.saveList = "Saved";
$timeout(function(){
$scope.saveListLabel = "primary";
$scope.saveList = "Save List";
$scope.saving = false;
}, 2000);
});
}
else if($scope.selectedList == "--" && $scope.listName != "")
{
$scope.saveListLabel = "warning";
$scope.saveList = "Saving...";
$scope.saving = true;
$timeout(function() {
$scope.saveListLabel = "primary";
$scope.saveList = "Save List";
$scope.saving = false;
}, 2000);
});
} else if ($scope.selectedList == "--" && $scope.listName != "") {
$scope.saveListLabel = "warning";
$scope.saveList = "Saving...";
$scope.saving = true;
if($scope.listName.search(".list") == -1 && $scope.listName.search(".mlist") == -1)
$scope.listName = $scope.listName + ".list";
if ($scope.listName.search(".list") == -1 && $scope.listName.search(".mlist") == -1)
$scope.listName = $scope.listName + ".list";
$api.request({
module: 'Occupineapple',
action: 'saveListData',
listData: $scope.listData,
list: $scope.listName
}, function(response) {
$scope.saveListLabel = "success";
$scope.saveList = "Saved";
$api.request({
module: 'Occupineapple',
action: 'saveListData',
listData: $scope.listData,
list: $scope.listName
}, function(response) {
$scope.saveListLabel = "success";
$scope.saveList = "Saved";
$timeout(function(){
$scope.saveListLabel = "primary";
$scope.saveList = "Save List";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveListLabel = "primary";
$scope.saveList = "Save List";
$scope.saving = false;
}, 2000);
$scope.getLists();
$scope.selectedList = $scope.listName;
$scope.getLists();
$scope.selectedList = $scope.listName;
$rootScope.status.refreshLists = true;
});
}
$rootScope.status.refreshLists = true;
});
}
});
$scope.getListData = (function() {
@ -388,52 +381,52 @@ registerController('Occupineapple_EditorController', ['$api', '$scope', '$rootSc
}]);
registerController('Occupineapple_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
$scope.settings = {
speed : "",
channel : "",
adHoc : false,
wepBit : false,
wpaTKIP : false,
wpaAES : false,
validMAC : false
};
$scope.settings = {
speed: "",
channel: "",
adHoc: false,
wepBit: false,
wpaTKIP: false,
wpaAES: false,
validMAC: false
};
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.getSettings = function() {
$api.request({
module: 'Occupineapple',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.getSettings = function() {
$api.request({
module: 'Occupineapple',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$api.request({
module: 'Occupineapple',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$api.request({
module: 'Occupineapple',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$timeout(function(){
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$timeout(function() {
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$scope.getSettings();
$scope.getSettings();
}]);

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Occupineapple",
"version": "1.5"
"version": "1.6"
}

View File

@ -29,8 +29,8 @@ if [ "$1" = "install" ]; then
uci commit occupineapple.module.installed
elif [ "$1" = "remove" ]; then
opkg remove mdk3
rm -rf /etc/config/occupineapple
opkg remove mdk3
rm -rf /etc/config/occupineapple
fi
rm /tmp/Occupineapple.progress

View File

@ -105,7 +105,7 @@ if [ "$1" = "start" ]; then
mdk3 ${MYMONITOR} b ${SPEED} ${CHANNEL} ${OPTIONS} ${MYLIST} >> ${LOG} &
elif [ "$1" = "stop" ]; then
killall mdk3
killall -9 mdk3
rm -rf /tmp/occupineapple.run
rm ${LOG}
fi

View File

@ -7,13 +7,13 @@ class OnlineHashCrack extends Module
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'clearOutput':
case 'clearOutput':
$this->clearOutput();
break;
case 'refreshStatus':
@ -25,45 +25,45 @@ class OnlineHashCrack extends Module
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'submitWPAOnline':
$this->submitWPAOnline();
break;
case 'submitWPAOnlineStatus':
$this->submitWPAOnlineStatus();
break;
case 'submitHashOnline':
$this->submitHashOnline();
break;
case 'submitHashOnlineStatus':
$this->submitHashOnlineStatus();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'getCapFiles':
$this->getCapFiles();
break;
case 'submitWPAOnline':
$this->submitWPAOnline();
break;
case 'submitWPAOnlineStatus':
$this->submitWPAOnlineStatus();
break;
case 'submitHashOnline':
$this->submitHashOnline();
break;
case 'submitHashOnlineStatus':
$this->submitHashOnlineStatus();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'getCapFiles':
$this->getCapFiles();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("onlinehashcrack.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("onlinehashcrack.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/OnlineHashCrack/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/OnlineHashCrack/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
@ -94,51 +94,51 @@ class OnlineHashCrack extends Module
private function refreshStatus()
{
if (!file_exists('/tmp/OnlineHashCrack.progress'))
{
if(!$this->checkDependency("curl"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
}
}
else
{
if(!$this->checkDependency("curl"))
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function refreshOutput()
{
if (file_exists("/tmp/onlinehashcrack.log"))
{
$output = file_get_contents("/tmp/onlinehashcrack.log");
if(!empty($output))
$this->response = $output;
else
$this->response = " ";
}
if (file_exists("/tmp/onlinehashcrack.log"))
{
$output = file_get_contents("/tmp/onlinehashcrack.log");
if(!empty($output))
$this->response = $output;
else
{
$this->response = " ";
}
$this->response = " ";
}
else
{
$this->response = " ";
}
}
private function clearOutput()
{
@ -147,14 +147,14 @@ class OnlineHashCrack extends Module
private function submitWPAOnlineStatus()
{
if (!file_exists('/tmp/OnlineHashCrack.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
}
if (!file_exists('/tmp/OnlineHashCrack.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
}
}
private function submitWPAOnline()
@ -165,14 +165,14 @@ class OnlineHashCrack extends Module
private function submitHashOnlineStatus()
{
if (!file_exists('/tmp/OnlineHashCrack.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
}
if (!file_exists('/tmp/OnlineHashCrack.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
}
}
private function submitHashOnline()
@ -191,14 +191,13 @@ class OnlineHashCrack extends Module
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("onlinehashcrack.settings.email", $settings->email);
$settings = $this->request->settings;
$this->uciSet("onlinehashcrack.settings.email", $settings->email);
}
private function getCapFiles()
{
exec("find -L /pineapple/modules/ -type f -name \"*.**cap\" 2>&1", $filesArray);
$this->response = array("files" => $filesArray);
exec("find -L /pineapple/modules/ -type f -name \"*.**cap\" 2>&1", $filesArray);
$this->response = array("files" => $filesArray);
}
}

View File

@ -2,17 +2,17 @@ registerController('OnlineHashCrack_Controller', ['$api', '$scope', '$rootScope'
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'OnlineHashCrack',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'OnlineHashCrack',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -29,91 +29,91 @@ registerController('OnlineHashCrack_ControlsController', ['$api', '$scope', '$ro
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
generated : false,
refreshOutput : false,
refreshKnownHosts : false
installed: false,
generated: false,
refreshOutput: false,
refreshKnownHosts: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "OnlineHashCrack",
action: "refreshStatus"
}, function(response) {
module: "OnlineHashCrack",
action: "refreshStatus"
}, function(response) {
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'OnlineHashCrack',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'OnlineHashCrack',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'OnlineHashCrack',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'OnlineHashCrack',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$scope.refreshStatus();
$interval.cancel($scope.handleDependenciesInterval);
}
});
}, 5000);
}
});
});
$interval.cancel($scope.handleDependenciesInterval);
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
}]);
registerController('OnlineHashCrack_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "OnlineHashCrack",
action: "refreshOutput",
module: "OnlineHashCrack",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearOutput = (function() {
$api.request({
module: "OnlineHashCrack",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
$scope.clearOutput = (function() {
$api.request({
module: "OnlineHashCrack",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -134,27 +134,27 @@ registerController('OnlineHashCrack_HashController', ['$api', '$scope', '$rootSc
action: 'submitHashOnline',
hashes: $scope.hashes
}, function(response) {
$scope.submitHashLabel = "warning";
$scope.submitHash = "Working...";
$scope.working = true;
$scope.submitHashLabel = "warning";
$scope.submitHash = "Working...";
$scope.working = true;
$scope.submitHashOnlineInterval = $interval(function(){
$api.request({
module: 'OnlineHashCrack',
action: 'submitHashOnlineStatus'
}, function(response) {
if (response.success === true){
$scope.working = false;
$interval.cancel($scope.submitHashOnlineInterval);
$scope.submitHashOnlineInterval = $interval(function() {
$api.request({
module: 'OnlineHashCrack',
action: 'submitHashOnlineStatus'
}, function(response) {
if (response.success === true) {
$scope.working = false;
$interval.cancel($scope.submitHashOnlineInterval);
$scope.submitHashLabel = "primary";
$scope.submitHash = "Submit";
$scope.submitHashLabel = "primary";
$scope.submitHash = "Submit";
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshKnownHosts = true;
}
});
}, 5000);
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshKnownHosts = true;
}
});
}, 5000);
});
});
@ -172,19 +172,19 @@ registerController('OnlineHashCrack_WPAController', ['$api', '$scope', '$rootSco
$scope.files = [];
$scope.getCapFiles = function() {
$api.request({
module: 'OnlineHashCrack',
action: 'getCapFiles'
}, function(response) {
$scope.files = response.files;
});
$api.request({
module: 'OnlineHashCrack',
action: 'getCapFiles'
}, function(response) {
$scope.files = response.files;
});
};
$scope.submitWPAOnline = (function() {
$rootScope.status.refreshOutput = false;
$rootScope.status.refreshKnownHosts = false;
if($scope.selectedFile != '')
if ($scope.selectedFile != '')
$file = $scope.selectedFile;
else
$file = $scope.file;
@ -194,27 +194,27 @@ registerController('OnlineHashCrack_WPAController', ['$api', '$scope', '$rootSco
action: 'submitWPAOnline',
file: $file
}, function(response) {
$scope.submitWPALabel = "warning";
$scope.submitWPA = "Working...";
$scope.working = true;
$scope.submitWPALabel = "warning";
$scope.submitWPA = "Working...";
$scope.working = true;
$scope.submitWPAOnlineInterval = $interval(function(){
$api.request({
module: 'OnlineHashCrack',
action: 'submitWPAOnlineStatus'
}, function(response) {
if (response.success === true){
$scope.working = false;
$interval.cancel($scope.submitWPAOnlineInterval);
$scope.submitWPAOnlineInterval = $interval(function() {
$api.request({
module: 'OnlineHashCrack',
action: 'submitWPAOnlineStatus'
}, function(response) {
if (response.success === true) {
$scope.working = false;
$interval.cancel($scope.submitWPAOnlineInterval);
$scope.submitWPALabel = "primary";
$scope.submitWPA = "Submit";
$scope.submitWPALabel = "primary";
$scope.submitWPA = "Submit";
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshKnownHosts = true;
}
});
}, 5000);
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshKnownHosts = true;
}
});
}, 5000);
});
});
@ -223,46 +223,46 @@ registerController('OnlineHashCrack_WPAController', ['$api', '$scope', '$rootSco
}]);
registerController('OnlineHashCrack_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
$scope.settings = {
email : ""
};
$scope.settings = {
email: ""
};
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.getSettings = function() {
$api.request({
module: 'OnlineHashCrack',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.getSettings = function() {
$api.request({
module: 'OnlineHashCrack',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$api.request({
module: 'OnlineHashCrack',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$api.request({
module: 'OnlineHashCrack',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$timeout(function(){
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$timeout(function() {
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$scope.getSettings();
$scope.getSettings();
}]);

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Online Hash Crack",
"version": "1.3"
"version": "1.4"
}

View File

@ -27,9 +27,8 @@ if [ "$1" = "install" ]; then
uci commit onlinehashcrack.module.installed
elif [ "$1" = "remove" ]; then
opkg remove curl
rm -rf /etc/config/onlinehashcrack
opkg remove curl
rm -rf /etc/config/onlinehashcrack
fi
rm /tmp/OnlineHashCrack.progress

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class Responder extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,330 +35,381 @@ class Responder extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleResponderOnBoot':
$this->toggleResponderOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleResponderOnBoot':
$this->toggleResponderOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("responder.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("responder.module.installed")));
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Responder/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Responder/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("python"))
{
$this->execBackground("/pineapple/modules/Responder/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/Responder/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("python")) {
$this->execBackground("/pineapple/modules/Responder/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/Responder/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/Responder.progress'))
{
if (!file_exists('/tmp/Responder.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleResponderOnBoot()
{
if(exec("cat /etc/rc.local | grep Responder/scripts/autostart_responder.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Responder/scripts/autostart_responder.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/Responder\/scripts\/autostart_responder.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep Responder/scripts/autostart_responder.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/Responder/scripts/autostart_responder.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/Responder\/scripts\/autostart_responder.sh/d' /etc/rc.local");
}
}
private function toggleResponder()
{
if(!$this->checkRunning("Responder.py"))
{
$this->uciSet("responder.run.interface", $this->request->interface);
if (!$this->checkRunning("Responder.py")) {
$this->uciSet("responder.run.interface", $this->request->interface);
$this->execBackground("/pineapple/modules/Responder/scripts/responder.sh start");
}
else
{
$this->uciSet("responder.run.interface", '');
$this->execBackground("/pineapple/modules/Responder/scripts/responder.sh start");
} else {
$this->uciSet("responder.run.interface", '');
$this->execBackground("/pineapple/modules/Responder/scripts/responder.sh stop");
}
}
$this->execBackground("/pineapple/modules/Responder/scripts/responder.sh stop");
}
}
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("responder.run.interface"));
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("responder.run.interface"));
}
private function refreshStatus()
{
if (!file_exists('/tmp/Responder.progress'))
{
if (!$this->checkDependency("python"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/Responder.progress')) {
if (!$this->checkDependency("python")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if($this->checkRunning("Responder.py"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("Responder.py")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep Responder/scripts/autostart_responder.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if (exec("cat /etc/rc.local | grep Responder/scripts/autostart_responder.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$verbose = false;
$status = "Not running";
$statusLabel = "danger";
$verbose = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function refreshOutput()
{
if ($this->checkDependency("python"))
{
if($this->checkRunning("Responder.py"))
{
if (file_exists("/pineapple/modules/Responder/dep/responder/logs/Responder-Session.log"))
{
if ($this->request->filter != "")
{
$filter = $this->request->filter;
private function refreshOutput()
{
if ($this->checkDependency("python")) {
if ($this->checkRunning("Responder.py")) {
if (file_exists("/pineapple/modules/Responder/dep/responder/logs/Responder-Session.log")) {
if ($this->request->filter != "") {
$filter = $this->request->filter;
$cmd = "strings /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log | ".$filter;
}
else
{
$cmd = "strings /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log";
}
$cmd = "strings /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log | ".$filter;
} else {
$cmd = "strings /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log";
}
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
else
{
$this->response = "Empty log...";
}
}
else
{
$this->response = "Responder is not running...";
}
}
else
{
$this->response = "Responder is not installed...";
}
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
} else {
$this->response = "Empty log...";
}
} else {
$this->response = "Responder is not running...";
}
} else {
$this->response = "Responder is not installed...";
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/Responder/log/*"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/Responder/log/*"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/Responder/log/".$this->request->file));
exec ("strings /pineapple/modules/Responder/log/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/Responder/log/".$this->request->file));
exec("strings /pineapple/modules/Responder/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/Responder/log/".$this->request->file);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/Responder/log/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/Responder/log/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/Responder/log/".$this->request->file));
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("responder.autostart.interface", $settings->interface);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("responder.autostart.interface", $settings->interface);
}
private function getSettings()
{
$settings = array(
'SQL' => $this->uciGet("responder.settings.SQL"),
'SMB' => $this->uciGet("responder.settings.SMB"),
'Kerberos' => $this->uciGet("responder.settings.Kerberos"),
'FTP' => $this->uciGet("responder.settings.FTP"),
'POP' => $this->uciGet("responder.settings.POP"),
'SMTP' => $this->uciGet("responder.settings.SMTP"),
'IMAP' => $this->uciGet("responder.settings.IMAP"),
'HTTP' => $this->uciGet("responder.settings.HTTP"),
'HTTPS' => $this->uciGet("responder.settings.HTTPS"),
'DNS' => $this->uciGet("responder.settings.DNS"),
'LDAP' => $this->uciGet("responder.settings.LDAP"),
'basic' => $this->uciGet("responder.settings.basic"),
'wredir' => $this->uciGet("responder.settings.wredir"),
'NBTNS' => $this->uciGet("responder.settings.NBTNS"),
'fingerprint' => $this->uciGet("responder.settings.fingerprint"),
'wpad' => $this->uciGet("responder.settings.wpad"),
'forceWpadAuth' => $this->uciGet("responder.settings.forceWpadAuth"),
'forceLmDowngrade' => $this->uciGet("responder.settings.forceLmDowngrade"),
'verbose' => $this->uciGet("responder.settings.verbose"),
'analyse' => $this->uciGet("responder.settings.analyse")
);
$this->response = array('settings' => $settings);
}
private function getSettings()
{
$settings = array(
'SQL' => $this->uciGet("responder.settings.SQL"),
'SMB' => $this->uciGet("responder.settings.SMB"),
'Kerberos' => $this->uciGet("responder.settings.Kerberos"),
'FTP' => $this->uciGet("responder.settings.FTP"),
'POP' => $this->uciGet("responder.settings.POP"),
'SMTP' => $this->uciGet("responder.settings.SMTP"),
'IMAP' => $this->uciGet("responder.settings.IMAP"),
'HTTP' => $this->uciGet("responder.settings.HTTP"),
'HTTPS' => $this->uciGet("responder.settings.HTTPS"),
'DNS' => $this->uciGet("responder.settings.DNS"),
'LDAP' => $this->uciGet("responder.settings.LDAP"),
'basic' => $this->uciGet("responder.settings.basic"),
'wredir' => $this->uciGet("responder.settings.wredir"),
'NBTNS' => $this->uciGet("responder.settings.NBTNS"),
'fingerprint' => $this->uciGet("responder.settings.fingerprint"),
'wpad' => $this->uciGet("responder.settings.wpad"),
'forceWpadAuth' => $this->uciGet("responder.settings.forceWpadAuth"),
'proxyAuth' => $this->uciGet("responder.settings.proxyAuth"),
'forceLmDowngrade' => $this->uciGet("responder.settings.forceLmDowngrade"),
'verbose' => $this->uciGet("responder.settings.verbose"),
'analyse' => $this->uciGet("responder.settings.analyse")
);
$this->response = array('settings' => $settings);
}
private function setSettings()
{
$settings = $this->request->settings;
if ($settings->SQL) $this->updateSetting("SQL", 1); else $this->updateSetting("SQL", 0);
if ($settings->SMB) $this->updateSetting("SMB", 1); else $this->updateSetting("SMB", 0);
if ($settings->Kerberos) $this->updateSetting("Kerberos", 1); else $this->updateSetting("Kerberos", 0);
if ($settings->FTP) $this->updateSetting("FTP", 1); else $this->updateSetting("FTP", 0);
if ($settings->POP) $this->updateSetting("POP", 1); else $this->updateSetting("POP", 0);
if ($settings->SMTP) $this->updateSetting("SMTP", 1); else $this->updateSetting("SMTP", 0);
if ($settings->IMAP) $this->updateSetting("IMAP", 1); else $this->updateSetting("IMAP", 0);
if ($settings->HTTP) $this->updateSetting("HTTP", 1); else $this->updateSetting("HTTP", 0);
if ($settings->HTTPS) $this->updateSetting("HTTPS", 1); else $this->updateSetting("HTTPS", 0);
if ($settings->DNS) $this->updateSetting("DNS", 1); else $this->updateSetting("DNS", 0);
if ($settings->LDAP) $this->updateSetting("LDAP", 1); else $this->updateSetting("LDAP", 0);
private function setSettings()
{
$settings = $this->request->settings;
if ($settings->SQL) {
$this->updateSetting("SQL", 1);
} else {
$this->updateSetting("SQL", 0);
}
if ($settings->SMB) {
$this->updateSetting("SMB", 1);
} else {
$this->updateSetting("SMB", 0);
}
if ($settings->Kerberos) {
$this->updateSetting("Kerberos", 1);
} else {
$this->updateSetting("Kerberos", 0);
}
if ($settings->FTP) {
$this->updateSetting("FTP", 1);
} else {
$this->updateSetting("FTP", 0);
}
if ($settings->POP) {
$this->updateSetting("POP", 1);
} else {
$this->updateSetting("POP", 0);
}
if ($settings->SMTP) {
$this->updateSetting("SMTP", 1);
} else {
$this->updateSetting("SMTP", 0);
}
if ($settings->IMAP) {
$this->updateSetting("IMAP", 1);
} else {
$this->updateSetting("IMAP", 0);
}
if ($settings->HTTP) {
$this->updateSetting("HTTP", 1);
} else {
$this->updateSetting("HTTP", 0);
}
if ($settings->HTTPS) {
$this->updateSetting("HTTPS", 1);
} else {
$this->updateSetting("HTTPS", 0);
}
if ($settings->DNS) {
$this->updateSetting("DNS", 1);
} else {
$this->updateSetting("DNS", 0);
}
if ($settings->LDAP) {
$this->updateSetting("LDAP", 1);
} else {
$this->updateSetting("LDAP", 0);
}
if ($settings->basic) $this->uciSet("responder.settings.basic", 1); else $this->uciSet("responder.settings.basic", 0);
if ($settings->wredir) $this->uciSet("responder.settings.wredir", 1); else $this->uciSet("responder.settings.wredir", 0);
if ($settings->NBTNS) $this->uciSet("responder.settings.NBTNS", 1); else $this->uciSet("responder.settings.NBTNS", 0);
if ($settings->fingerprint) $this->uciSet("responder.settings.fingerprint", 1); else $this->uciSet("responder.settings.fingerprint", 0);
if ($settings->wpad) $this->uciSet("responder.settings.wpad", 1); else $this->uciSet("responder.settings.wpad", 0);
if ($settings->forceWpadAuth) $this->uciSet("responder.settings.forceWpadAuth", 1); else $this->uciSet("responder.settings.forceWpadAuth", 0);
if ($settings->forceLmDowngrade) $this->uciSet("responder.settings.forceLmDowngrade", 1); else $this->uciSet("responder.settings.forceLmDowngrade", 0);
if ($settings->verbose) $this->uciSet("responder.settings.verbose", 1); else $this->uciSet("responder.settings.verbose", 0);
if ($settings->analyse) $this->uciSet("responder.settings.analyse", 1); else $this->uciSet("responder.settings.analyse", 0);
}
private function updateSetting($setting, $value)
{
if ($value) {
$this->uciSet("responder.settings.".$setting, 1);
exec("/bin/sed -i 's/^".$setting." .*/".$setting." = On/g' /pineapple/modules/Responder/dep/responder/Responder.conf");
}
else {
$this->uciSet("responder.settings.".$setting, 0);
exec("/bin/sed -i 's/^".$setting." .*/".$setting." = Off/g' /pineapple/modules/Responder/dep/responder/Responder.conf");
}
}
if ($settings->basic) {
$this->uciSet("responder.settings.basic", 1);
} else {
$this->uciSet("responder.settings.basic", 0);
}
if ($settings->wredir) {
$this->uciSet("responder.settings.wredir", 1);
} else {
$this->uciSet("responder.settings.wredir", 0);
}
if ($settings->NBTNS) {
$this->uciSet("responder.settings.NBTNS", 1);
} else {
$this->uciSet("responder.settings.NBTNS", 0);
}
if ($settings->fingerprint) {
$this->uciSet("responder.settings.fingerprint", 1);
} else {
$this->uciSet("responder.settings.fingerprint", 0);
}
if ($settings->wpad) {
$this->uciSet("responder.settings.wpad", 1);
} else {
$this->uciSet("responder.settings.wpad", 0);
}
if ($settings->forceWpadAuth) {
$this->uciSet("responder.settings.forceWpadAuth", 1);
} else {
$this->uciSet("responder.settings.forceWpadAuth", 0);
}
if ($settings->proxyAuth) {
$this->uciSet("responder.settings.proxyAuth", 1);
} else {
$this->uciSet("responder.settings.proxyAuth", 0);
}
if ($settings->forceLmDowngrade) {
$this->uciSet("responder.settings.forceLmDowngrade", 1);
} else {
$this->uciSet("responder.settings.forceLmDowngrade", 0);
}
if ($settings->verbose) {
$this->uciSet("responder.settings.verbose", 1);
} else {
$this->uciSet("responder.settings.verbose", 0);
}
if ($settings->analyse) {
$this->uciSet("responder.settings.analyse", 1);
} else {
$this->uciSet("responder.settings.analyse", 0);
}
}
private function updateSetting($setting, $value)
{
if ($value) {
$this->uciSet("responder.settings.".$setting, 1);
exec("/bin/sed -i 's/^".$setting." .*/".$setting." = On/g' /pineapple/modules/Responder/dep/responder/Responder.conf");
} else {
$this->uciSet("responder.settings.".$setting, 0);
exec("/bin/sed -i 's/^".$setting." .*/".$setting." = Off/g' /pineapple/modules/Responder/dep/responder/Responder.conf");
}
}
}

5
Responder/dep/responder/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Responder logs
*.db
*.txt
*.log

View File

@ -2,17 +2,17 @@ registerController('Responder_Controller', ['$api', '$scope', '$rootScope', '$in
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'Responder',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'Responder',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,33 +37,33 @@ registerController('Responder_ControlsController', ['$api', '$scope', '$rootScop
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "Responder",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "Responder",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.toggleResponder = (function() {
if($scope.status != "Stop")
$scope.toggleResponder = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -75,149 +75,145 @@ registerController('Responder_ControlsController', ['$api', '$scope', '$rootScop
$rootScope.status.refreshHistory = false;
$api.request({
module: 'Responder',
action: 'toggleResponder',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'Responder',
action: 'toggleResponder',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
}, 2000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'Responder',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'Responder',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.toggleResponderOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.toggleResponderOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'Responder',
action: 'toggleResponderOnBoot',
}, function(response) {
module: 'Responder',
action: 'toggleResponderOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'Responder',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'Responder',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'Responder',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'Responder',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'Responder',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'Responder',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('Responder_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope,$interval) {
$scope.output = 'Loading...';
registerController('Responder_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "Responder",
action: "refreshOutput",
module: "Responder",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -226,52 +222,52 @@ registerController('Responder_HistoryController', ['$api', '$scope', '$rootScope
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "Responder",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.refreshHistory = (function() {
$api.request({
module: "Responder",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "Responder",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "Responder",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "Responder",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "Responder",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'Responder',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
$api.request({
module: 'Responder',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -279,65 +275,66 @@ registerController('Responder_HistoryController', ['$api', '$scope', '$rootScope
}]);
registerController('Responder_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
$scope.settings = {
SQL : false,
SMB : false,
Kerberos : false,
FTP : false,
POP : false,
SMTP : false,
IMAP : false,
HTTP : false,
HTTPS : false,
DNS : false,
LDAP : false,
basic : false,
wredir : false,
NBTNS : false,
fingerprint : false,
wpad : false,
forceWpadAuth : false,
forceLmDowngrade : false,
verbose : false,
analyse : false
};
$scope.settings = {
SQL: false,
SMB: false,
Kerberos: false,
FTP: false,
POP: false,
SMTP: false,
IMAP: false,
HTTP: false,
HTTPS: false,
DNS: false,
LDAP: false,
basic: false,
wredir: false,
NBTNS: false,
fingerprint: false,
wpad: false,
forceWpadAuth: false,
proxyAuth: false,
forceLmDowngrade: false,
verbose: false,
analyse: false
};
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.getSettings = function() {
$api.request({
module: 'Responder',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.getSettings = function() {
$api.request({
module: 'Responder',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$api.request({
module: 'Responder',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$api.request({
module: 'Responder',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$timeout(function(){
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$timeout(function() {
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$scope.getSettings();
$scope.getSettings();
}]);

1
Responder/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -126,6 +126,7 @@
<div class="checkbox"><label><input type="checkbox" ng-model="settings.fingerprint"> This option allows you to fingerprint a host that issued an NBT-NS or LLMNR query.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.wpad"> Start the WPAD rogue proxy server.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.forceWpadAuth"> Force NTLM/Basic authentication on wpad.dat file retrieval. This may cause a login prompt.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.proxyAuth"> Force NTLM (transparently)/Basic (prompt) authentication for the proxy. WPAD doesn't need to be ON. This option is highly effective when combined with -r.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.forceLmDowngrade"> Force LM hashing downgrade for Windows XP/2003 and earlier.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.verbose"> Increase verbosity.</label></div>
<div class="checkbox"><label><input type="checkbox" ng-model="settings.analyse"> Analyze mode. This option allows you to see NBT-NS, BROWSER, LLMNR requests without responding.</label></div>

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Responder",
"version": "1.0"
"version": "1.1"
}

View File

@ -14,6 +14,7 @@ NBTNS=`uci get responder.settings.NBTNS`
FINGERPRINT=`uci get responder.settings.fingerprint`
WPAD=`uci get responder.settings.wpad`
FORCEWPADAUTH=`uci get responder.settings.forceWpadAuth`
PROXYAUTH=`uci get responder.settings.proxyAuth`
FORCELMDOWNGRADE=`uci get responder.settings.forceLmDowngrade`
VERBOSE=`uci get responder.settings.verbose`
ANALYSE=`uci get responder.settings.analyse`
@ -33,6 +34,7 @@ if [ "$NBTNS" -ne 0 ]; then OPTIONS="${OPTIONS} --NBTNSdomain"; fi
if [ "$FINGERPRINT" -ne 0 ]; then OPTIONS="${OPTIONS} --fingerprint"; fi
if [ "$WPAD" -ne 0 ]; then OPTIONS="${OPTIONS} --wpad"; fi
if [ "$FORCEWPADAUTH" -ne 0 ]; then OPTIONS="${OPTIONS} --ForceWpadAuth"; fi
if [ "$PROXYAUTH" -ne 0 ]; then OPTIONS="${OPTIONS} --ProxyAuth"; fi
if [ "$FORCELMDOWNGRADE" -ne 0 ]; then OPTIONS="${OPTIONS} --lm"; fi
if [ "$VERBOSE" -ne 0 ]; then OPTIONS="${OPTIONS} --verbose"; fi
if [ "$ANALYSE" -ne 0 ]; then OPTIONS="${OPTIONS} --analyze"; fi

View File

@ -48,9 +48,9 @@ if [ "$1" = "install" ]; then
uci commit responder.module.installed
elif [ "$1" = "remove" ]; then
opkg remove python-logging
opkg remove python-openssl
rm -rf /etc/config/responder
opkg remove python-logging
opkg remove python-openssl
rm -rf /etc/config/responder
fi
rm /tmp/Responder.progress

View File

@ -14,6 +14,7 @@ NBTNS=`uci get responder.settings.NBTNS`
FINGERPRINT=`uci get responder.settings.fingerprint`
WPAD=`uci get responder.settings.wpad`
FORCEWPADAUTH=`uci get responder.settings.forceWpadAuth`
PROXYAUTH=`uci get responder.settings.proxyAuth`
FORCELMDOWNGRADE=`uci get responder.settings.forceLmDowngrade`
VERBOSE=`uci get responder.settings.verbose`
ANALYSE=`uci get responder.settings.analyse`
@ -27,6 +28,7 @@ if [ "$1" = "start" ]; then
if [ "$FINGERPRINT" -ne 0 ]; then OPTIONS="${OPTIONS} --fingerprint"; fi
if [ "$WPAD" -ne 0 ]; then OPTIONS="${OPTIONS} --wpad"; fi
if [ "$FORCEWPADAUTH" -ne 0 ]; then OPTIONS="${OPTIONS} --ForceWpadAuth"; fi
if [ "$PROXYAUTH" -ne 0 ]; then OPTIONS="${OPTIONS} --ProxyAuth"; fi
if [ "$FORCELMDOWNGRADE" -ne 0 ]; then OPTIONS="${OPTIONS} --lm"; fi
if [ "$VERBOSE" -ne 0 ]; then OPTIONS="${OPTIONS} --verbose"; fi
if [ "$ANALYSE" -ne 0 ]; then OPTIONS="${OPTIONS} --analyze"; fi
@ -35,7 +37,6 @@ if [ "$1" = "start" ]; then
elif [ "$1" = "stop" ]; then
pgrep -f Responder.py | xargs kill -9
cp /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log /pineapple/modules/Responder/log/responder_${MYTIME}.log
echo '' > /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log
cp /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log /pineapple/modules/Responder/log/responder_${MYTIME}.log
echo '' > /pineapple/modules/Responder/dep/responder/logs/Responder-Session.log
fi

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class SSLsplit extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,311 +35,266 @@ class SSLsplit extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleSSLsplitOnBoot':
$this->toggleSSLsplitOnBoot();
break;
case 'handleCertificate':
$this->handleCertificate();
break;
case 'handleCertificateStatus':
$this->handleCertificateStatus();
break;
case 'saveConfigurationData':
$this->saveConfigurationData();
break;
case 'getConfigurationData':
$this->getConfigurationData();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleSSLsplitOnBoot':
$this->toggleSSLsplitOnBoot();
break;
case 'handleCertificate':
$this->handleCertificate();
break;
case 'handleCertificateStatus':
$this->handleCertificateStatus();
break;
case 'saveConfigurationData':
$this->saveConfigurationData();
break;
case 'getConfigurationData':
$this->getConfigurationData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("sslsplit.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("sslsplit.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SSLsplit/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SSLsplit/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleCertificate()
{
if(!file_exists("/pineapple/modules/SSLsplit/cert/certificate.crt"))
{
$this->execBackground("/pineapple/modules/SSLsplit/scripts/generate_certificate.sh");
$this->response = array('success' => true);
}
else
{
exec("rm -rf /pineapple/modules/SSLsplit/cert/certificate.*");
$this->response = array('success' => true);
}
}
if (!file_exists("/pineapple/modules/SSLsplit/cert/certificate.crt")) {
$this->execBackground("/pineapple/modules/SSLsplit/scripts/generate_certificate.sh");
$this->response = array('success' => true);
} else {
exec("rm -rf /pineapple/modules/SSLsplit/cert/certificate.*");
$this->response = array('success' => true);
}
}
private function handleCertificateStatus()
{
if (!file_exists('/tmp/SSLsplit_certificate.progress'))
{
if (!file_exists('/tmp/SSLsplit_certificate.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
}
private function handleDependencies()
{
if(!$this->checkDependency("sslsplit"))
{
$this->execBackground("/pineapple/modules/SSLsplit/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/SSLsplit/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("sslsplit")) {
$this->execBackground("/pineapple/modules/SSLsplit/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/SSLsplit/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/SSLsplit.progress'))
{
if (!file_exists('/tmp/SSLsplit.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleSSLsplitOnBoot()
{
if(exec("cat /etc/rc.local | grep SSLsplit/scripts/autostart_sslsplit.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/SSLsplit/scripts/autostart_sslsplit.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/SSLsplit\/scripts\/autostart_sslsplit.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep SSLsplit/scripts/autostart_sslsplit.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/SSLsplit/scripts/autostart_sslsplit.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/SSLsplit\/scripts\/autostart_sslsplit.sh/d' /etc/rc.local");
}
}
private function toggleSSLsplit()
{
if(!$this->checkRunning("sslsplit"))
{
$this->execBackground("/pineapple/modules/SSLsplit/scripts/sslsplit.sh start");
}
else
{
$this->execBackground("/pineapple/modules/SSLsplit/scripts/sslsplit.sh stop");
}
}
if (!$this->checkRunning("sslsplit")) {
$this->execBackground("/pineapple/modules/SSLsplit/scripts/sslsplit.sh start");
} else {
$this->execBackground("/pineapple/modules/SSLsplit/scripts/sslsplit.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/SSLsplit.progress'))
{
if(!$this->checkDependency("sslsplit"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/SSLsplit.progress')) {
if (!$this->checkDependency("sslsplit")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("sslsplit"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("sslsplit")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep SSLsplit/scripts/autostart_sslsplit.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep SSLsplit/scripts/autostart_sslsplit.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (!file_exists('/tmp/SSLsplit_certificate.progress'))
{
if(!file_exists("/pineapple/modules/SSLsplit/cert/certificate.crt"))
{
$certificate = "Not generated";
$certificateLabel = "danger";
$generated = false;
$generating = false;
}
else
{
$certificate = "Generated";
$certificateLabel = "success";
$generated = true;
$generating = false;
}
}
else
{
$certificate = "Generating...";
$certificateLabel = "warning";
$generated = false;
$generating = true;
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if (!file_exists('/tmp/SSLsplit_certificate.progress')) {
if (!file_exists("/pineapple/modules/SSLsplit/cert/certificate.crt")) {
$certificate = "Not generated";
$certificateLabel = "danger";
$generated = false;
$generating = false;
} else {
$certificate = "Generated";
$certificateLabel = "success";
$generated = true;
$generating = false;
}
} else {
$certificate = "Generating...";
$certificateLabel = "warning";
$generated = false;
$generating = true;
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
$certificate = "Not generated";
$certificateLabel = "danger";
$generating = false;
$certificate = "Not generated";
$certificateLabel = "danger";
$generating = false;
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed,
"certificate" => $certificate, "certificateLabel" => $certificateLabel, "generating" => $generating, "generated" => $generated,
"install" => $install, "installLabel" => $installLabel,
"bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed,
"certificate" => $certificate, "certificateLabel" => $certificateLabel, "generating" => $generating, "generated" => $generated,
"install" => $install, "installLabel" => $installLabel,
"bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function refreshOutput()
{
if($this->checkDependency("sslsplit"))
{
if ($this->checkRunning("sslsplit"))
{
if(file_exists("/pineapple/modules/SSLsplit/connections.log"))
{
if ($this->request->filter != "")
{
$filter = $this->request->filter;
if ($this->checkDependency("sslsplit")) {
if ($this->checkRunning("sslsplit")) {
if (file_exists("/pineapple/modules/SSLsplit/connections.log")) {
if ($this->request->filter != "") {
$filter = $this->request->filter;
$cmd = "cat /pineapple/modules/SSLsplit/connections.log"." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/SSLsplit/connections.log";
}
$cmd = "cat /pineapple/modules/SSLsplit/connections.log"." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/SSLsplit/connections.log";
}
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty connections log...";
}
else
{
$this->response = "No connections log...";
}
}
else
{
$this->response = "SSLsplit is not running...";
}
}
else
{
$this->response = "SSLsplit is not installed...";
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty connections log...";
}
} else {
$this->response = "No connections log...";
}
} else {
$this->response = "SSLsplit is not running...";
}
} else {
$this->response = "SSLsplit is not installed...";
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/SSLsplit/log/*"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/SSLsplit/log/*"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/SSLsplit/log/".$this->request->file));
exec ("cat /pineapple/modules/SSLsplit/log/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/SSLsplit/log/".$this->request->file));
exec("cat /pineapple/modules/SSLsplit/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/SSLsplit/log/".$this->request->file);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/SSLsplit/log/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/SSLsplit/log/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/SSLsplit/log/".$this->request->file));
}
private function saveConfigurationData()
{
$filename = '/pineapple/modules/SSLsplit/rules/iptables';
file_put_contents($filename, $this->request->configurationData);
}
private function saveConfigurationData()
{
$filename = '/pineapple/modules/SSLsplit/rules/iptables';
file_put_contents($filename, $this->request->configurationData);
}
private function getConfigurationData()
{
$configurationData = file_get_contents('/pineapple/modules/SSLsplit/rules/iptables');
$this->response = array("configurationData" => $configurationData);
}
private function getConfigurationData()
{
$configurationData = file_get_contents('/pineapple/modules/SSLsplit/rules/iptables');
$this->response = array("configurationData" => $configurationData);
}
}

View File

@ -2,17 +2,17 @@ registerController('SSLsplit_Controller', ['$api', '$scope', '$rootScope', '$int
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'SSLsplit',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'SSLsplit',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,70 +37,70 @@ registerController('SSLsplit_ControlsController', ['$api', '$scope', '$rootScope
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
generated : false,
refreshOutput : false,
refreshHistory : false
installed: false,
generated: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "SSLsplit",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
module: "SSLsplit",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$scope.verbose = response.verbose;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.generated = response.generated;
$scope.certificate = response.certificate;
if(response.generating) $scope.generating = true;
if (response.generating) $scope.generating = true;
$scope.certificateLabel = response.certificateLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
})
});
$scope.handleCertificate = (function() {
if($scope.certificate != "Generated")
$scope.handleCertificate = (function() {
if ($scope.certificate != "Generated")
$scope.certificate = "Generating...";
else
$scope.certificate = "Removing...";
$api.request({
module: 'SSLsplit',
action: 'handleCertificate'
}, function(response){
if (response.success === true) {
module: 'SSLsplit',
action: 'handleCertificate'
}, function(response) {
if (response.success === true) {
$scope.certificateLabel = "warning";
$scope.generating = true;
$scope.handleCertificateInterval = $interval(function(){
$api.request({
module: 'SSLsplit',
action: 'handleCertificateStatus'
}, function(response) {
if (response.success === true){
$scope.generating = false;
$interval.cancel($scope.handleCertificateInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleCertificateInterval = $interval(function() {
$api.request({
module: 'SSLsplit',
action: 'handleCertificateStatus'
}, function(response) {
if (response.success === true) {
$scope.generating = false;
$interval.cancel($scope.handleCertificateInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.toggleSSLsplit = (function() {
if($scope.status != "Stop")
$scope.toggleSSLsplit = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -112,123 +112,117 @@ registerController('SSLsplit_ControlsController', ['$api', '$scope', '$rootScope
$rootScope.status.refreshHistory = false;
$api.request({
module: 'SSLsplit',
action: 'toggleSSLsplit',
module: 'SSLsplit',
action: 'toggleSSLsplit',
verbose: $scope.verbose
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
}, 2000);
})
});
$scope.toggleSSLsplitOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.toggleSSLsplitOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'SSLsplit',
action: 'toggleSSLsplitOnBoot',
}, function(response) {
module: 'SSLsplit',
action: 'toggleSSLsplitOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'SSLsplit',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'SSLsplit',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'SSLsplit',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'SSLsplit',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$scope.refreshStatus();
$interval.cancel($scope.handleDependenciesInterval);
}
});
}, 5000);
}
});
});
$interval.cancel($scope.handleDependenciesInterval);
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
}]);
registerController('SSLsplit_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "SSLsplit",
action: "refreshOutput",
module: "SSLsplit",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -237,52 +231,52 @@ registerController('SSLsplit_HistoryController', ['$api', '$scope', '$rootScope'
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "SSLsplit",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.refreshHistory = (function() {
$api.request({
module: "SSLsplit",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "SSLsplit",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "SSLsplit",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "SSLsplit",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "SSLsplit",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'SSLsplit',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
$api.request({
module: 'SSLsplit',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -305,14 +299,14 @@ registerController('SSLsplit_ConfigurationController', ['$api', '$scope', '$time
action: 'saveConfigurationData',
configurationData: $scope.configurationData
}, function(response) {
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$scope.saveConfigurationLabel = "success";
$scope.saveConfiguration = "Saved";
$timeout(function(){
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveConfigurationLabel = "primary";
$scope.saveConfiguration = "Save";
$scope.saving = false;
}, 2000);
});
});

1
SSLsplit/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "SSLsplit",
"version": "1.2"
"version": "1.3"
}

View File

@ -21,8 +21,4 @@ sh /pineapple/modules/SSLsplit/rules/iptables
iptables -t nat -A POSTROUTING -j MASQUERADE
if [ ! -d /pineapple/modules/SSLsplit/log ]; then
mkdir /pineapple/modules/SSLsplit/log
fi
sslsplit -D -l /pineapple/modules/SSLsplit/connections.log -L /pineapple/modules/SSLsplit/log/output_${MYTIME}.log -k /pineapple/modules/SSLsplit/cert/certificate.key -c /pineapple/modules/SSLsplit/cert/certificate.crt ssl 0.0.0.0 8443 tcp 0.0.0.0 8080

View File

@ -8,10 +8,6 @@ MYTIME=`date +%s`
killall sslsplit
if [ ! -d /pineapple/modules/SSLsplit/log ]; then
mkdir /pineapple/modules/SSLsplit/log
fi
if [ "$1" = "start" ]; then
echo '1' > /proc/sys/net/ipv4/ip_forward

View File

@ -1,67 +1,71 @@
<?php namespace pineapple;
class iwlist_parser{
function iwlist_parser(){
}
class iwlist_parser
{
public function iwlist_parser()
{
}
function parseString( $string ){
if(empty($string)) return false;
public function parseString($string)
{
if (empty($string)) {
return false;
}
// Rueckgabe dieser Funktion:
// $array[device][Cell#][Cell-Feld] = Wert
// z.b. $array[eth0][1][ESSID] = "MGees_WLan"
// Rueckgabe dieser Funktion:
// $array[device][Cell#][Cell-Feld] = Wert
// z.b. $array[eth0][1][ESSID] = "MGees_WLan"
$ergebnis = array();
$ergebnis = array();
$string = explode( "\n", $string );
$string = explode("\n", $string);
$device = $cell = "";
$device = $cell = "";
foreach($string as $zeile){
if(substr( $zeile, 0, 1 ) != ' '){
$device = substr($zeile, 0, strpos($zeile, ' '));
$ergebnis[$device] = array();
}
else{
$zeile = trim($zeile);
// Zeile kann sein:
// Cell ## - Address: Wert
// Feld:Wert
// Quality=bla Signal Level=bla2
if(substr($zeile, 0, 5) == 'Cell '){
$cell = (int)substr($zeile, 5, 2);
$ergebnis[$device][$cell] = array();
$doppelp_pos = strpos($zeile, ':');
$ergebnis[$device][$cell]['Address'] =
trim(substr($zeile, $doppelp_pos + 1));
}
elseif(substr($zeile, 0, 8) == 'Quality='){
$first_eq_pos = strpos($zeile, '=');
$last_eq_pos = strrpos($zeile, '=');
$slash_pos = strpos($zeile, '/') - $first_eq_pos;
//$ergebnis[$device][$cell]['Quality'] = trim(substr($zeile, $first_eq_pos + 1, $slash_pos - 1));
$ergebnis[$device][$cell]['Quality'] = trim(number_format (substr($zeile, $first_eq_pos + 1, $slash_pos - 1) * 100 / 70, 0));
$ergebnis[$device][$cell]['Signal level'] = trim(substr($zeile, $last_eq_pos + 1));
}
else{
$doppelp_pos = strpos($zeile, ':');
$feld = trim( substr( $zeile, 0, $doppelp_pos ) );
if(!empty($ergebnis[$device][$cell][$feld]))
$ergebnis[$device][$cell][$feld] .= "\n";
// Leer- und "-Zeichen rausschmeissen - ESSID steht immer in ""
@$ergebnis[$device][$cell][$feld] .= trim(str_replace('"', '', substr($zeile, $doppelp_pos + 1)));
}
}
}
return $ergebnis;
}
foreach ($string as $zeile) {
if (substr($zeile, 0, 1) != ' ') {
$device = substr($zeile, 0, strpos($zeile, ' '));
$ergebnis[$device] = array();
} else {
$zeile = trim($zeile);
// Zeile kann sein:
// Cell ## - Address: Wert
// Feld:Wert
// Quality=bla Signal Level=bla2
if (substr($zeile, 0, 5) == 'Cell ') {
$cell = (int)substr($zeile, 5, 2);
$ergebnis[$device][$cell] = array();
$doppelp_pos = strpos($zeile, ':');
$ergebnis[$device][$cell]['Address'] =
trim(substr($zeile, $doppelp_pos + 1));
} elseif (substr($zeile, 0, 8) == 'Quality=') {
$first_eq_pos = strpos($zeile, '=');
$last_eq_pos = strrpos($zeile, '=');
$slash_pos = strpos($zeile, '/') - $first_eq_pos;
//$ergebnis[$device][$cell]['Quality'] = trim(substr($zeile, $first_eq_pos + 1, $slash_pos - 1));
$ergebnis[$device][$cell]['Quality'] = trim(number_format(substr($zeile, $first_eq_pos + 1, $slash_pos - 1) * 100 / 70, 0));
$ergebnis[$device][$cell]['Signal level'] = trim(substr($zeile, $last_eq_pos + 1));
} else {
$doppelp_pos = strpos($zeile, ':');
$feld = trim(substr($zeile, 0, $doppelp_pos));
if (!empty($ergebnis[$device][$cell][$feld])) {
$ergebnis[$device][$cell][$feld] .= "\n";
}
// Leer- und "-Zeichen rausschmeissen - ESSID steht immer in ""
@$ergebnis[$device][$cell][$feld] .= trim(str_replace('"', '', substr($zeile, $doppelp_pos + 1)));
}
}
}
return $ergebnis;
}
function parseScanAll(){
return $this -> parseString( shell_exec( "iwlist scan 2> /dev/null" ));
}
public function parseScanAll()
{
return $this -> parseString(shell_exec("iwlist scan 2> /dev/null"));
}
function parseScanDev( $device ){
return $this -> parseString( shell_exec( "iwlist ".$device." scan 2> /dev/null" ));
}
public function parseScanDev($device)
{
return $this -> parseString(shell_exec("iwlist ".$device." scan 2> /dev/null"));
}
}
?>

View File

@ -1,4 +1,5 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
@ -6,13 +7,13 @@ require_once('/pineapple/modules/SiteSurvey/api/iwlist_parser.php');
class SiteSurvey extends Module
{
public function __construct($request)
{
parent::__construct($request, __CLASS__);
$this->iwlistparse = new iwlist_parser();
}
public function __construct($request)
{
parent::__construct($request, __CLASS__);
$this->iwlistparse = new iwlist_parser();
}
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
@ -27,394 +28,399 @@ class SiteSurvey extends Module
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMonitors':
$this->getMonitors();
break;
case 'startMonitor':
$this->startMonitor();
break;
case 'stopMonitor':
$this->stopMonitor();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'refreshCapture':
$this->refreshCapture();
break;
case 'viewCapture':
$this->viewCapture();
break;
case 'deleteCapture':
$this->deleteCapture();
break;
case 'downloadCapture':
$this->downloadCapture();
break;
case 'toggleCapture':
$this->toggleCapture();
break;
case 'toggleDeauth':
$this->toggleDeauth();
break;
case 'getProcesses':
$this->getProcesses();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMonitors':
$this->getMonitors();
break;
case 'startMonitor':
$this->startMonitor();
break;
case 'stopMonitor':
$this->stopMonitor();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'refreshCapture':
$this->refreshCapture();
break;
case 'viewCapture':
$this->viewCapture();
break;
case 'deleteCapture':
$this->deleteCapture();
break;
case 'downloadCapture':
$this->downloadCapture();
break;
case 'toggleCapture':
$this->toggleCapture();
break;
case 'toggleDeauth':
$this->toggleDeauth();
break;
case 'getProcesses':
$this->getProcesses();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("sitesurvey.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("sitesurvey.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SiteSurvey/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/SiteSurvey/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("mdk3"))
{
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("mdk3")) {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/SiteSurvey.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/SiteSurvey.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/SiteSurvey.progress'))
{
if(!$this->checkDependency("iwlist"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
}
if (!file_exists('/tmp/SiteSurvey.progress')) {
if (!$this->checkDependency("iwlist")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
}
if (file_exists("/tmp/SiteSurvey.log") && (!$this->checkRunning("airodump-ng") || !$this->checkRunning("aireplay-ng"))) exec("rm -rf /tmp/SiteSurvey.log");
if (file_exists("/tmp/SiteSurvey_deauth.lock") && !$this->checkRunning("aireplay-ng")) exec("rm -rf /tmp/SiteSurvey_deauth.lock");
if (file_exists("/tmp/SiteSurvey_capture.lock") && !$this->checkRunning("airodump-ng")) exec("rm -rf /tmp/SiteSurvey_capture.lock");
if (file_exists("/tmp/SiteSurvey.log") && (!$this->checkRunning("airodump-ng") || !$this->checkRunning("aireplay-ng"))) {
exec("rm -rf /tmp/SiteSurvey.log");
}
if (file_exists("/tmp/SiteSurvey_deauth.lock") && !$this->checkRunning("aireplay-ng")) {
exec("rm -rf /tmp/SiteSurvey_deauth.lock");
}
if (file_exists("/tmp/SiteSurvey_capture.lock") && !$this->checkRunning("airodump-ng")) {
exec("rm -rf /tmp/SiteSurvey_capture.lock");
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function toggleCapture()
{
$ap = $this->request->ap;
private function toggleCapture()
{
$ap = $this->request->ap;
if(!$this->checkRunning("airodump-ng"))
{
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/capture.sh start ".$this->request->interface." ".$ap->mac." ".$ap->channel);
}
else
{
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/capture.sh stop");
}
}
if (!$this->checkRunning("airodump-ng")) {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/capture.sh start ".$this->request->interface." ".$ap->mac." ".$ap->channel);
} else {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/capture.sh stop");
}
}
private function toggleDeauth()
{
$ap = $this->request->ap;
$client = $this->request->client;
private function toggleDeauth()
{
$ap = $this->request->ap;
$client = $this->request->client;
if(!$this->checkRunning("aireplay-ng"))
{
if(!empty($client))
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh start ".$this->request->interface." ".$ap->mac." ".$client);
else
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh start ".$this->request->interface." ".$ap->mac);
}
else
{
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh stop");
}
}
if (!$this->checkRunning("aireplay-ng")) {
if (!empty($client)) {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh start ".$this->request->interface." ".$ap->mac." ".$client);
} else {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh start ".$this->request->interface." ".$ap->mac);
}
} else {
$this->execBackground("/pineapple/modules/SiteSurvey/scripts/deauth.sh stop");
}
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | grep -v \"mon*\" | awk '{print $1}'", $interfaceArray);
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | grep -v \"mon*\" | awk '{print $1}'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray);
}
$this->response = array("interfaces" => $interfaceArray);
}
private function getMonitors()
{
exec("iwconfig 2> /dev/null | grep \"mon*\" | awk '{print $1}'", $monitorArray);
private function getMonitors()
{
exec("iwconfig 2> /dev/null | grep \"mon*\" | awk '{print $1}'", $monitorArray);
$this->response = array("monitors" => $monitorArray);
}
$this->response = array("monitors" => $monitorArray);
}
private function startMonitor()
{
exec("airmon-ng start ".$this->request->interface);
}
private function startMonitor()
{
exec("airmon-ng start ".$this->request->interface);
}
private function stopMonitor()
{
exec("airmon-ng stop ".$this->request->monitor);
}
private function stopMonitor()
{
exec("airmon-ng stop ".$this->request->monitor);
}
private function refreshCapture()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/SiteSurvey/capture/*.cap"));
private function refreshCapture()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/SiteSurvey/capture/*.cap"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
$entryBSSID = exec("awk -F, '/BSSID/ {i=1; next} i {print $1}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i],".cap").".csv | head -1");
$entryESSID = exec("awk -F, '/BSSID/ {i=1; next} i {print $14}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i],".cap").".csv | head -1");
$entryIVS = exec("awk -F, '/BSSID/ {i=1; next} i {print $11}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i],".cap").".csv | head -1");
$entryBSSID = exec("awk -F, '/BSSID/ {i=1; next} i {print $1}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i], ".cap").".csv | head -1");
$entryESSID = exec("awk -F, '/BSSID/ {i=1; next} i {print $14}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i], ".cap").".csv | head -1");
$entryIVS = exec("awk -F, '/BSSID/ {i=1; next} i {print $11}' /pineapple/modules/SiteSurvey/capture/".basename($log_list[$i], ".cap").".csv | head -1");
exec("aircrack-ng -a 2 -w - -b ".$entryBSSID." ".$log_list[$i]." 2>&1", $entryHandshake);
if(in_array("Passphrase not in dictionary", $entryHandshake)) $entryHandshake = "Yes"; else $entryHandshake = "No";
exec("aircrack-ng -a 2 -w - -b ".$entryBSSID." ".$log_list[$i]." 2>&1", $entryHandshake);
if (in_array("Passphrase not in dictionary", $entryHandshake)) {
$entryHandshake = "Yes";
} else {
$entryHandshake = "No";
}
echo json_encode(array($entryDate, $entryName, $entryESSID, $entryBSSID, $entryIVS, $entryHandshake));
echo json_encode(array($entryDate, $entryName, $entryESSID, $entryBSSID, $entryIVS, $entryHandshake));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadCapture()
{
$file = basename($this->request->file, ".cap");
private function downloadCapture()
{
$file = basename($this->request->file, ".cap");
exec("mkdir /tmp/dl/");
exec("cp /pineapple/modules/SiteSurvey/capture/".$file.".* /tmp/dl/");
exec("cd /tmp/dl/ && tar -czf /tmp/".$file.".tar.gz *");
exec("rm -rf /tmp/dl/");
exec("mkdir /tmp/dl/");
exec("cp /pineapple/modules/SiteSurvey/capture/".$file.".* /tmp/dl/");
exec("cd /tmp/dl/ && tar -czf /tmp/".$file.".tar.gz *");
exec("rm -rf /tmp/dl/");
$this->response = array("download" => $this->downloadFile("/tmp/".$file.".tar.gz"));
}
$this->response = array("download" => $this->downloadFile("/tmp/".$file.".tar.gz"));
}
private function viewCapture()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/SiteSurvey/capture/".$this->request->file));
exec ("strings /pineapple/modules/SiteSurvey/capture/".basename($this->request->file, ".cap").".csv", $output);
private function viewCapture()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/SiteSurvey/capture/".$this->request->file));
exec("strings /pineapple/modules/SiteSurvey/capture/".basename($this->request->file, ".cap").".csv", $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty dump...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty dump...", "date" => $log_date);
}
}
private function deleteCapture()
{
$file = basename($this->request->file,".cap");
exec("rm -rf /pineapple/modules/SiteSurvey/capture/".$file.".*");
}
private function deleteCapture()
{
$file = basename($this->request->file, ".cap");
exec("rm -rf /pineapple/modules/SiteSurvey/capture/".$file.".*");
}
private function scanForNetworks()
{
if (file_exists("/tmp/SiteSurvey_deauth.lock") && !$this->checkRunning("aireplay-ng")) exec("rm -rf /tmp/SiteSurvey_deauth.lock");
if (file_exists("/tmp/SiteSurvey_capture.lock") && !$this->checkRunning("airodump-ng")) exec("rm -rf /tmp/SiteSurvey_capture.lock");
private function scanForNetworks()
{
if (file_exists("/tmp/SiteSurvey_deauth.lock") && !$this->checkRunning("aireplay-ng")) {
exec("rm -rf /tmp/SiteSurvey_deauth.lock");
}
if (file_exists("/tmp/SiteSurvey_capture.lock") && !$this->checkRunning("airodump-ng")) {
exec("rm -rf /tmp/SiteSurvey_capture.lock");
}
$clientArray = array();
if($this->request->duration && $this->request->monitor != "" && $this->request->type == 'clientAP')
{
exec("killall -9 airodump-ng && rm -rf /tmp/sitesurvey-*");
$clientArray = array();
if ($this->request->duration && $this->request->monitor != "" && $this->request->type == 'clientAP') {
exec("killall -9 airodump-ng && rm -rf /tmp/sitesurvey-*");
$this->execBackground("airodump-ng --write /tmp/sitesurvey ".$this->request->monitor." &> /dev/null ");
sleep($this->request->duration);
$this->execBackground("airodump-ng --write /tmp/sitesurvey ".$this->request->monitor." &> /dev/null ");
sleep($this->request->duration);
exec("cat /tmp/sitesurvey-01.csv | tail -n +$(($(cat /tmp/sitesurvey-01.csv | grep -n \"Station MAC\" | cut -f1 -d:)+1)) | tr '\r' '\n' > /tmp/sitesurvey-01.tmp");
exec("sed '/^$/d' < /tmp/sitesurvey-01.tmp > /tmp/sitesurvey-01.clients");
exec("cat /tmp/sitesurvey-01.csv | tail -n +$(($(cat /tmp/sitesurvey-01.csv | grep -n \"Station MAC\" | cut -f1 -d:)+1)) | tr '\r' '\n' > /tmp/sitesurvey-01.tmp");
exec("sed '/^$/d' < /tmp/sitesurvey-01.tmp > /tmp/sitesurvey-01.clients");
$file_handle = fopen("/tmp/sitesurvey-01.clients", "r");
while (!feof($file_handle))
{
$line = fgets($file_handle); $line = str_replace(" ", "", $line);
$clientArray[] = explode(",", $line);
}
fclose($file_handle);
$file_handle = fopen("/tmp/sitesurvey-01.clients", "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
$line = str_replace(" ", "", $line);
$clientArray[] = explode(",", $line);
}
fclose($file_handle);
exec("killall -9 airodump-ng");
}
exec("killall -9 airodump-ng");
}
$p = $this->iwlistparse->parseScanDev($this->request->interface);
$apArray = $p[$this->request->interface];
$p = $this->iwlistparse->parseScanDev($this->request->interface);
$apArray = $p[$this->request->interface];
$returnArray = array();
foreach ($apArray as $apData) {
$accessPoint = array();
$accessPoint['mac'] = $apData["Address"];
$accessPoint['ssid'] = $apData["ESSID"];
$accessPoint['channel'] = intval($apData["Channel"]);
$returnArray = array();
foreach ($apArray as $apData) {
$accessPoint = array();
$accessPoint['mac'] = $apData["Address"];
$accessPoint['ssid'] = $apData["ESSID"];
$accessPoint['channel'] = intval($apData["Channel"]);
$frequencyData = explode(' ', $apData["Frequency"]);
$accessPoint['frequency'] = $frequencyData[0];
$frequencyData = explode(' ', $apData["Frequency"]);
$accessPoint['frequency'] = $frequencyData[0];
$accessPoint['signal'] = $apData["Signal level"];
$accessPoint['quality'] = intval($apData["Quality"]);
$accessPoint['signal'] = $apData["Signal level"];
$accessPoint['quality'] = intval($apData["Quality"]);
if($apData["Quality"] <= 25) $accessPoint['qualityLabel'] = "danger";
else if($apData["Quality"] <= 50) $accessPoint['qualityLabel'] = "warning";
else if($apData["Quality"] <= 100) $accessPoint['qualityLabel'] = "success";
if ($apData["Quality"] <= 25) {
$accessPoint['qualityLabel'] = "danger";
} elseif ($apData["Quality"] <= 50) {
$accessPoint['qualityLabel'] = "warning";
} elseif ($apData["Quality"] <= 100) {
$accessPoint['qualityLabel'] = "success";
}
if(file_exists("/tmp/SiteSurvey_capture.lock"))
{
if(file_get_contents("cat /tmp/SiteSurvey_capture.lock") == $apData["Address"]) $accessPoint['captureOnSelected'] = 1;
else $accessPoint['captureOnSelected'] = 0;
}
else
{
$accessPoint['captureOnSelected'] = 0;
}
if (file_exists("/tmp/SiteSurvey_capture.lock")) {
if (file_get_contents("cat /tmp/SiteSurvey_capture.lock") == $apData["Address"]) {
$accessPoint['captureOnSelected'] = 1;
} else {
$accessPoint['captureOnSelected'] = 0;
}
} else {
$accessPoint['captureOnSelected'] = 0;
}
if($this->checkRunning("airodump-ng")) $accessPoint['captureRunning'] = 1;
else $accessPoint['captureRunning'] = 0;
if ($this->checkRunning("airodump-ng")) {
$accessPoint['captureRunning'] = 1;
} else {
$accessPoint['captureRunning'] = 0;
}
if(file_exists("/tmp/SiteSurvey_deauth.lock"))
{
$targetArray = explode("\n", file_get_contents("/tmp/SiteSurvey_deauth.lock"));
if($targetArray[0] == $apData["Address"]) $accessPoint['deauthOnSelected'] = 1;
else $accessPoint['deauthOnSelected'] = 0;
}
else
{
$accessPoint['deauthOnSelected'] = 0;
}
if (file_exists("/tmp/SiteSurvey_deauth.lock")) {
$targetArray = explode("\n", file_get_contents("/tmp/SiteSurvey_deauth.lock"));
if ($targetArray[0] == $apData["Address"]) {
$accessPoint['deauthOnSelected'] = 1;
} else {
$accessPoint['deauthOnSelected'] = 0;
}
} else {
$accessPoint['deauthOnSelected'] = 0;
}
if($this->checkRunning("aireplay-ng")) $accessPoint['deauthRunning'] = 1;
else $accessPoint['deauthRunning'] = 0;
if ($this->checkRunning("aireplay-ng")) {
$accessPoint['deauthRunning'] = 1;
} else {
$accessPoint['deauthRunning'] = 0;
}
if($apData["Encryption key"] == "on")
{
$WPA = strstr($apData["IE"], "WPA Version 1");
$WPA2 = strstr($apData["IE"], "802.11i/WPA2 Version 1");
if ($apData["Encryption key"] == "on") {
$WPA = strstr($apData["IE"], "WPA Version 1");
$WPA2 = strstr($apData["IE"], "802.11i/WPA2 Version 1");
$auth_type = str_replace("\n"," ",$apData["Authentication Suites (1)"]);
$auth_type = implode(' ',array_unique(explode(' ', $auth_type)));
$auth_type = str_replace("\n", " ", $apData["Authentication Suites (1)"]);
$auth_type = implode(' ', array_unique(explode(' ', $auth_type)));
$cipher = $apData["Pairwise Ciphers (2)"] ? $apData["Pairwise Ciphers (2)"] : $apData["Pairwise Ciphers (1)"];
$cipher = str_replace("\n"," ",$cipher);
$cipher = implode(', ',array_unique(explode(' ', $cipher)));
$cipher = $apData["Pairwise Ciphers (2)"] ? $apData["Pairwise Ciphers (2)"] : $apData["Pairwise Ciphers (1)"];
$cipher = str_replace("\n", " ", $cipher);
$cipher = implode(', ', array_unique(explode(' ', $cipher)));
if($WPA2 != "" && $WPA != "") $accessPoint['encryption'] = 'Mixed WPA/WPA2';
else if($WPA2 != "") $accessPoint['encryption'] = 'WPA2';
else if($WPA != "") $accessPoint['encryption'] = 'WPA';
else $accessPoint['encryption'] = 'WEP';
if ($WPA2 != "" && $WPA != "") {
$accessPoint['encryption'] = 'Mixed WPA/WPA2';
} elseif ($WPA2 != "") {
$accessPoint['encryption'] = 'WPA2';
} elseif ($WPA != "") {
$accessPoint['encryption'] = 'WPA';
} else {
$accessPoint['encryption'] = 'WEP';
}
$accessPoint['cipher'] = $cipher;
$accessPoint['auth'] = $auth_type;
}
else
{
$accessPoint['encryption'] = 'None';
$accessPoint['cipher'] = '';
$accessPoint['auth'] = '';
}
$accessPoint['cipher'] = $cipher;
$accessPoint['auth'] = $auth_type;
} else {
$accessPoint['encryption'] = 'None';
$accessPoint['cipher'] = '';
$accessPoint['auth'] = '';
}
$accessPoint['clients'] = array();
foreach ($clientArray as $clientData)
{
if($clientData[5] == $accessPoint['mac'])
{
array_push($accessPoint['clients'], $clientData[0]);
}
}
$accessPoint['clients'] = array();
foreach ($clientArray as $clientData) {
if ($clientData[5] == $accessPoint['mac']) {
array_push($accessPoint['clients'], $clientData[0]);
}
}
exec("rm -rf /tmp/sitesurvey-*");
exec("rm -rf /tmp/sitesurvey-*");
array_push($returnArray, $accessPoint);
}
array_push($returnArray, $accessPoint);
}
$this->response = $returnArray;
}
$this->response = $returnArray;
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getProcesses()
{
$returnArray = array();
private function getProcesses()
{
$returnArray = array();
$process = array();
if (file_exists("/tmp/SiteSurvey_deauth.lock") && $this->checkRunning("aireplay-ng"))
{
$targetArray = explode("\n", file_get_contents("/tmp/SiteSurvey_deauth.lock"));
$process = array();
if (file_exists("/tmp/SiteSurvey_deauth.lock") && $this->checkRunning("aireplay-ng")) {
$targetArray = explode("\n", file_get_contents("/tmp/SiteSurvey_deauth.lock"));
$process['target'] = $targetArray[0];
$process['client'] = $targetArray[1];
$process['name'] = "aireplay-ng";
$process['target'] = $targetArray[0];
$process['client'] = $targetArray[1];
$process['name'] = "aireplay-ng";
array_push($returnArray, $process);
}
array_push($returnArray, $process);
}
$process = array();
if (file_exists("/tmp/SiteSurvey_capture.lock") && $this->checkRunning("airodump-ng"))
{
$process['target'] = exec("cat /tmp/SiteSurvey_capture.lock");
$process['name'] = "airodump-ng";
$process = array();
if (file_exists("/tmp/SiteSurvey_capture.lock") && $this->checkRunning("airodump-ng")) {
$process['target'] = exec("cat /tmp/SiteSurvey_capture.lock");
$process['name'] = "airodump-ng";
array_push($returnArray, $process);
}
$this->response = $returnArray;
}
array_push($returnArray, $process);
}
$this->response = $returnArray;
}
}

View File

@ -0,0 +1 @@
Captures will be saved here.

View File

@ -2,17 +2,17 @@ registerController('SiteSurvey_Controller', ['$api', '$scope', '$rootScope', '$i
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'SiteSurvey',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'SiteSurvey',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,62 +37,62 @@ registerController('SiteSurvey_ControlsController', ['$api', '$scope', '$rootSco
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshCapture : false
installed: false,
refreshCapture: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: 'SiteSurvey',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: 'SiteSurvey',
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'SiteSurvey',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'SiteSurvey',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'SiteSurvey',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'SiteSurvey',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
$scope.refreshStatus();
}]);
@ -128,38 +128,35 @@ registerController('SiteSurvey_ScanController', ['$api', '$scope', '$rootScope',
$scope.autoRefreshInterval = false;
$scope.sortType = 'ssid';
$scope.sortReverse = false;
$scope.search = '';
$scope.sortReverse = false;
$scope.search = '';
$scope.clearFilter = (function() {
$scope.sortType = 'ssid';
$scope.sortReverse = false;
$scope.search = '';
$scope.sortType = 'ssid';
$scope.sortReverse = false;
$scope.search = '';
});
$scope.getMACInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'SiteSurvey',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'SiteSurvey',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
if ($scope.autoRefreshInterval) {
$scope.autoRefreshInterval = false;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.autoRefreshInterval = true;
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
@ -169,56 +166,56 @@ registerController('SiteSurvey_ScanController', ['$api', '$scope', '$rootScope',
});
$scope.startMonitor = (function() {
$scope.startMonLabel = "warning";
$scope.startMon = "Starting...";
$scope.startingMon = true;
$scope.startMonLabel = "warning";
$scope.startMon = "Starting...";
$scope.startingMon = true;
$api.request({
module: 'SiteSurvey',
action: 'startMonitor',
interface: $scope.selectedInterface
}, function(response) {
$scope.startMonLabel = "success";
$scope.startMon = "Done";
$api.request({
module: 'SiteSurvey',
action: 'startMonitor',
interface: $scope.selectedInterface
}, function(response) {
$scope.startMonLabel = "success";
$scope.startMon = "Done";
$timeout(function(){
$scope.getInterfaces();
$scope.getMonitors();
$timeout(function() {
$scope.getInterfaces();
$scope.getMonitors();
$scope.startMonLabel = "default";
$scope.startMon = "Start Monitor";
$scope.startingMon = false;
}, 2000);
});
$scope.startMonLabel = "default";
$scope.startMon = "Start Monitor";
$scope.startingMon = false;
}, 2000);
});
});
$scope.stopMonitor = (function() {
$scope.stopMonLabel = "warning";
$scope.stopMon = "Stopping...";
$scope.stoppingMon = true;
$scope.stopMonLabel = "warning";
$scope.stopMon = "Stopping...";
$scope.stoppingMon = true;
$api.request({
module: 'SiteSurvey',
action: 'stopMonitor',
monitor: $scope.selectedMonitor
}, function(response) {
$scope.stopMonLabel = "success";
$scope.stopMon = "Done";
$api.request({
module: 'SiteSurvey',
action: 'stopMonitor',
monitor: $scope.selectedMonitor
}, function(response) {
$scope.stopMonLabel = "success";
$scope.stopMon = "Done";
$timeout(function(){
$scope.getInterfaces();
$scope.getMonitors();
$timeout(function() {
$scope.getInterfaces();
$scope.getMonitors();
$scope.stopMonLabel = "default";
$scope.stopMon = "Stop Monitor";
$scope.stoppingMon = false;
}, 2000);
});
$scope.stopMonLabel = "default";
$scope.stopMon = "Stop Monitor";
$scope.stoppingMon = false;
}, 2000);
});
});
$scope.isCaptureRunning = (function() {
for (var i = 0, len = $scope.accessPoints.length; i < len; i++) {
if($scope.accessPoints[i]['captureRunning'] == 1) {
if ($scope.accessPoints[i]['captureRunning'] == 1) {
$scope.captureRunning = true;
break;
}
@ -228,7 +225,7 @@ registerController('SiteSurvey_ScanController', ['$api', '$scope', '$rootScope',
$scope.isDeauthRunning = (function() {
for (var i = 0, len = $scope.accessPoints.length; i < len; i++) {
if($scope.accessPoints[i]['deauthRunning'] == 1) {
if ($scope.accessPoints[i]['deauthRunning'] == 1) {
$scope.deauthRunning = true;
break;
}
@ -237,190 +234,198 @@ registerController('SiteSurvey_ScanController', ['$api', '$scope', '$rootScope',
});
$scope.onTimeout = function() {
if(counter === 0) {
$timeout.cancel(mytimeout);
$scope.scan = "Collecting results...";
return;
}
counter--;
$scope.scan = "Scanning... " + $filter('date')(new Date(1970, 0, 1).setSeconds(counter), 'mm:ss');
mytimeout = $timeout($scope.onTimeout, 1000);
if (counter === 0) {
$timeout.cancel(mytimeout);
$scope.scan = "Collecting results...";
return;
}
counter--;
$scope.scan = "Scanning... " + $filter('date')(new Date(1970, 0, 1).setSeconds(counter), 'mm:ss');
mytimeout = $timeout($scope.onTimeout, 1000);
};
$scope.scanForNetworks = (function() {
$scope.scanLabel = "warning";
$scope.scanning = true;
$scope.scanLabel = "warning";
$scope.scanning = true;
if($scope.scanType == 'clientAP')
{
counter = $scope.scanDuration;
$scope.onTimeout();
}
else {
$scope.scan = "Scanning...";
}
if ($scope.scanType == 'clientAP') {
counter = $scope.scanDuration;
$scope.onTimeout();
} else {
$scope.scan = "Scanning...";
}
$api.request({
module: 'SiteSurvey',
action: 'scanForNetworks',
interface: $scope.selectedInterface,
monitor: $scope.selectedMonitor,
type: $scope.scanType,
duration: $scope.scanDuration
}, function(response) {
$scope.scanLabel = "success";
$scope.scan = "Done";
$api.request({
module: 'SiteSurvey',
action: 'scanForNetworks',
interface: $scope.selectedInterface,
monitor: $scope.selectedMonitor,
type: $scope.scanType,
duration: $scope.scanDuration
}, function(response) {
$scope.scanLabel = "success";
$scope.scan = "Done";
$scope.accessPoints = response;
$scope.isCaptureRunning();
$scope.isDeauthRunning();
$scope.accessPoints = response;
$scope.isCaptureRunning();
$scope.isDeauthRunning();
$timeout(function(){
$scope.scanLabel = "info";
$scope.scan = "Scan";
$scope.scanning = false;
$timeout(function() {
$scope.scanLabel = "info";
$scope.scan = "Scan";
$scope.scanning = false;
if($scope.autoRefreshInterval)
$scope.scanForNetworks();
}, 2000);
if ($scope.autoRefreshInterval)
$scope.scanForNetworks();
}, 2000);
$timeout(function(){ $scope.getProcesses(); }, 2000);
});
$timeout(function() {
$scope.getProcesses();
}, 2000);
});
});
$scope.stopCapture = (function() {
angular.forEach($scope.accessPoints, function(apData, id) {
$scope.accessPoints[id]['captureRunning'] = 0;
$scope.accessPoints[id]['captureOnSelected'] = 0;
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleCapture',
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isCaptureRunning();
$timeout(function() {
$scope.getProcesses();
}, 1000);
});
});
$scope.stopDeauth = (function() {
angular.forEach($scope.accessPoints, function(apData, id) {
$scope.accessPoints[id]['deauthRunning'] = 0;
$scope.accessPoints[id]['deauthOnSelected'] = 0;
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleDeauth',
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isDeauthRunning();
$timeout(function() {
$scope.getProcesses();
}, 1000);
});
});
$scope.toggleCapture = (function(ap) {
angular.forEach($scope.accessPoints, function(apData, id) {
if ($scope.accessPoints[id]['captureRunning'] == 1)
$scope.accessPoints[id]['captureRunning'] = 0;
else
$scope.accessPoints[id]['captureRunning'] = 1
if (apData['mac'] == ap['mac'])
if ($scope.accessPoints[id]['captureOnSelected'] == 1)
$scope.accessPoints[id]['captureOnSelected'] = 0;
else
$scope.accessPoints[id]['captureOnSelected'] = 1;
else
$scope.accessPoints[id]['captureOnSelected'] = 0;
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleCapture',
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isCaptureRunning();
module: 'SiteSurvey',
action: 'toggleCapture',
interface: $scope.selectedMonitor,
ap: ap
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isCaptureRunning();
$timeout(function(){ $scope.getProcesses(); }, 1000);
});
$timeout(function() {
$scope.getProcesses();
}, 2000);
});
});
$scope.stopDeauth = (function() {
$scope.toggleDeauth = (function(ap, client) {
angular.forEach($scope.accessPoints, function(apData, id) {
if ($scope.accessPoints[id]['deauthRunning'] == 1)
$scope.accessPoints[id]['deauthRunning'] = 0;
else
$scope.accessPoints[id]['deauthRunning'] = 1
if (apData['mac'] == ap['mac'])
if ($scope.accessPoints[id]['deauthOnSelected'] == 1)
$scope.accessPoints[id]['deauthOnSelected'] = 0;
else
$scope.accessPoints[id]['deauthOnSelected'] = 1;
else
$scope.accessPoints[id]['deauthOnSelected'] = 0;
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleDeauth',
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isDeauthRunning();
module: 'SiteSurvey',
action: 'toggleDeauth',
interface: $scope.selectedMonitor,
ap: ap,
client: client
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isDeauthRunning();
$timeout(function(){ $scope.getProcesses(); }, 1000);
});
});
$scope.toggleCapture = (function(ap) {
angular.forEach($scope.accessPoints, function(apData, id) {
if($scope.accessPoints[id]['captureRunning'] == 1)
$scope.accessPoints[id]['captureRunning'] = 0;
else
$scope.accessPoints[id]['captureRunning'] = 1
if(apData['mac'] == ap['mac'])
if($scope.accessPoints[id]['captureOnSelected'] == 1)
$scope.accessPoints[id]['captureOnSelected'] = 0;
else
$scope.accessPoints[id]['captureOnSelected'] = 1;
else
$scope.accessPoints[id]['captureOnSelected'] = 0;
$timeout(function() {
$scope.getProcesses();
}, 2000);
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleCapture',
interface: $scope.selectedMonitor,
ap: ap
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isCaptureRunning();
$timeout(function(){ $scope.getProcesses(); }, 2000);
});
});
$scope.toggleDeauth = (function(ap, client) {
angular.forEach($scope.accessPoints, function(apData, id) {
if($scope.accessPoints[id]['deauthRunning'] == 1)
$scope.accessPoints[id]['deauthRunning'] = 0;
else
$scope.accessPoints[id]['deauthRunning'] = 1
if(apData['mac'] == ap['mac'])
if($scope.accessPoints[id]['deauthOnSelected'] == 1)
$scope.accessPoints[id]['deauthOnSelected'] = 0;
else
$scope.accessPoints[id]['deauthOnSelected'] = 1;
else
$scope.accessPoints[id]['deauthOnSelected'] = 0;
});
$rootScope.status.refreshCapture = false;
$api.request({
module: 'SiteSurvey',
action: 'toggleDeauth',
interface: $scope.selectedMonitor,
ap: ap,
client: client
}, function(response) {
$rootScope.status.refreshCapture = true;
$scope.isDeauthRunning();
$timeout(function(){ $scope.getProcesses(); }, 2000);
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'SiteSurvey',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
$scope.selectedInterface = $scope.interfaces[0];
});
});
$api.request({
module: 'SiteSurvey',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.getMonitors = (function() {
$api.request({
module: 'SiteSurvey',
action: 'getMonitors'
}, function(response) {
$scope.monitors = response.monitors;
$scope.selectedMonitor = $scope.monitors[0];
});
});
$api.request({
module: 'SiteSurvey',
action: 'getMonitors'
}, function(response) {
$scope.monitors = response.monitors;
$scope.selectedMonitor = $scope.monitors[0];
});
});
$scope.getProcesses = (function() {
$api.request({
module: 'SiteSurvey',
action: 'getProcesses'
}, function(response) {
$scope.processes = response;
});
});
$api.request({
module: 'SiteSurvey',
action: 'getProcesses'
}, function(response) {
$scope.processes = response;
});
});
$scope.getInterfaces();
$scope.getMonitors();
@ -432,53 +437,56 @@ registerController('SiteSurvey_CaptureController', ['$api', '$scope', '$rootScop
$scope.capture = [];
$scope.captureOutput = 'Loading...';
$scope.captureDate = 'Loading...';
$scope.throbber = false;
$scope.refreshCapture = (function() {
$api.request({
module: "SiteSurvey",
action: "refreshCapture"
}, function(response) {
$scope.capture = response;
})
});
$scope.viewCapture = (function(param) {
$scope.refreshCapture = (function() {
$api.request({
module: "SiteSurvey",
action: "viewCapture",
module: "SiteSurvey",
action: "refreshCapture"
}, function(response) {
$scope.capture = response;
})
});
$scope.viewCapture = (function(param) {
$api.request({
module: "SiteSurvey",
action: "viewCapture",
file: param
}, function(response) {
$scope.captureOutput = response.output;
}, function(response) {
$scope.captureOutput = response.output;
$scope.captureDate = response.date;
})
});
})
});
$scope.deleteCapture = (function(param) {
$scope.deleteCapture = (function(param) {
$api.request({
module: "SiteSurvey",
action: "deleteCapture",
module: "SiteSurvey",
action: "deleteCapture",
file: param
}, function(response) {
$scope.refreshCapture();
})
});
}, function(response) {
$scope.refreshCapture();
})
});
$scope.downloadCapture = (function(param) {
$api.request({
module: 'SiteSurvey',
action: 'downloadCapture',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.throbber = true;
$api.request({
module: 'SiteSurvey',
action: 'downloadCapture',
file: param
}, function(response) {
$scope.throbber = false;
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshCapture();
$rootScope.$watch('status.refreshCapture', function(param) {
if(param) {
if (param) {
$scope.refreshCapture();
}
});

View File

@ -355,6 +355,7 @@
<button type="button" class="btn btn-fixed-length btn-sm btn-default" data-toggle="modal" data-target="#captureModal" ng-click="viewCapture(entry[1])">View</button>
<button type="button" class="btn btn-sm btn-default" ng-click="downloadCapture(entry[1])">Download</button>
<button type="button" class="btn btn-fixed-length btn-sm btn-danger" ng-click="deleteCapture(entry[1])">Delete</button>
&nbsp <img src="/img/throbber.gif" ng-show="throbber"/>
</div>
</td>
</tr>

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Site Survey",
"version": "1.4"
"version": "1.5"
}

View File

@ -14,9 +14,8 @@ BSSID=$3
CHANNEL=$4
if [ "$1" = "start" ]; then
killall -9 airodump-ng
rm ${LOG}
rm ${LOG}
rm ${LOCK}
echo -e "Starting Capture..." > ${LOG}
@ -49,25 +48,18 @@ if [ "$1" = "start" ]; then
fi
fi
echo -e "Monitor : ${MYMONITOR}" >> ${LOG}
echo -e "Monitor : ${MYMONITOR}" >> ${LOG}
echo -e "BSSID : ${BSSID}" >> ${LOG}
echo -e "Channel : ${CHANNEL}" >> ${LOG}
echo ${BSSID} > ${LOCK}
# make sure the folder exists
if [ ! -d /pineapple/modules/SiteSurvey/capture ]; then
mkdir /pineapple/modules/SiteSurvey/capture
fi
airodump-ng -c ${CHANNEL} --bssid ${BSSID} -w /pineapple/modules/SiteSurvey/capture/capture_${MYTIME} ${MYMONITOR} &> /dev/null &
echo -e "Capture is running..." >> ${LOG}
elif [ "$1" = "stop" ]; then
killall -9 airodump-ng
rm ${LOG}
rm ${LOG}
rm ${LOCK}
fi

View File

@ -23,8 +23,6 @@ if [ "$1" = "install" ]; then
uci set sitesurvey.module.installed=1
uci commit sitesurvey.module.installed
mkdir /pineapple/modules/SiteSurvey/capture
elif [ "$1" = "remove" ]; then
rm -rf /etc/config/sitesurvey
fi

View File

@ -4,5 +4,3 @@ $MYDATA=exec("head -n 1 /proc/stat");
$MYDATE=exec("date");
echo $MYDATE."\n".$MYDATA."\n";
?>

View File

@ -4,5 +4,3 @@ $MYDATA=exec("grep ".$_GET['if']." /proc/net/dev | tr -s ' ' ' '");
$MYDATE=exec("date");
echo $MYDATE."\n".$MYDATA."\n";
?>

View File

@ -1,322 +1,330 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class Status extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'getSystem':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'getSystem':
$this->getSystem();
break;
case 'getCPU':
case 'getCPU':
$this->getCPU();
break;
case 'getDHCP':
case 'getDHCP':
$this->getDHCP();
break;
case 'getMemory':
case 'getMemory':
$this->getMemory();
break;
case 'getWiFi':
case 'getWiFi':
$this->getWiFi();
break;
case 'getSwap':
case 'getSwap':
$this->getSwap();
break;
case 'getStorage':
case 'getStorage':
$this->getStorage();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'getPingInfo':
$this->getPingInfo();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'getPingInfo':
$this->getPingInfo();
break;
}
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Status/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/Status/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function getSystem()
{
$current_time = exec("date");
$up_time = exec("uptime | awk -F, '{sub(\".*up \",x,$1);print $1}'");
$hostname = exec("uci get system.@system[0].hostname");
$machine = $cpu = trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
private function getSystem()
{
$current_time = exec("date");
$up_time = exec("uptime | awk -F, '{sub(\".*up \",x,$1);print $1}'");
$hostname = exec("uci get system.@system[0].hostname");
$machine = $cpu = trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
$info = array(
'currentTime' => $current_time,
'uptime' => $up_time,
'hostname' => $hostname,
'machine' => $machine
);
$info = array(
'currentTime' => $current_time,
'uptime' => $up_time,
'hostname' => $hostname,
'machine' => $machine
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getCPU()
{
$cpu = trim(exec("cat /proc/cpuinfo | grep cpu | awk -F: '{print $2}'"));
$bogo = trim(exec("cat /proc/cpuinfo | grep Bogo | awk -F: '{print $2}'"));
$type = trim(exec("cat /proc/cpuinfo | grep type | awk -F: '{print $2}'"));
private function getCPU()
{
$cpu = trim(exec("cat /proc/cpuinfo | grep cpu | awk -F: '{print $2}'"));
$bogo = trim(exec("cat /proc/cpuinfo | grep Bogo | awk -F: '{print $2}'"));
$type = trim(exec("cat /proc/cpuinfo | grep type | awk -F: '{print $2}'"));
$stat1 = $this->getCoreInformation(); sleep(1); $stat2 = $this->getCoreInformation();
$data = $this->getCpuPercentages($stat1, $stat2);
$cpu_load_ptg = 100 - $data['cpu0']['idle'];
$cpu_load_all = exec("uptime | awk -F 'average:' '{ print $2}'");
$stat1 = $this->getCoreInformation();
sleep(1);
$stat2 = $this->getCoreInformation();
$data = $this->getCpuPercentages($stat1, $stat2);
$cpu_load_ptg = 100 - $data['cpu0']['idle'];
$cpu_load_all = exec("uptime | awk -F 'average:' '{ print $2}'");
$info = array(
'cpuModel' => $cpu,
'bogoMIPS' => $bogo,
'type' => $type,
'loadAveragePourcentage' => $cpu_load_ptg,
'loadAverageAll' => $cpu_load_all
);
$info = array(
'cpuModel' => $cpu,
'bogoMIPS' => $bogo,
'type' => $type,
'loadAveragePourcentage' => $cpu_load_ptg,
'loadAverageAll' => $cpu_load_all
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getDHCP()
{
private function getDHCP()
{
$dhcpClients = explode("\n", trim(shell_exec("cat /tmp/dhcp.leases")));
$clientsList = array();
for ($i=0;$i<count($dhcpClients);$i++) {
if ($dhcpClients[$i] != "") {
$dhcp_client = explode(" ", $dhcpClients[$i]);
$mac_address = $dhcp_client[1];
$ip_address = $dhcp_client[2];
$hostname = $dhcp_client[3];
$dhcpClients = explode("\n", trim(shell_exec("cat /tmp/dhcp.leases")));
$clientsList = array();
for($i=0;$i<count($dhcpClients);$i++)
{
if($dhcpClients[$i] != "")
{
$dhcp_client = explode(" ", $dhcpClients[$i]);
$mac_address = $dhcp_client[1];
$ip_address = $dhcp_client[2];
$hostname = $dhcp_client[3];
array_push($clientsList, array("hostname" => $hostname, "mac" => $mac_address, "ip" =>$ip_address));
}
}
array_push($clientsList, array("hostname" => $hostname, "mac" => $mac_address, "ip" =>$ip_address));
}
}
$info = array(
'clientsList' => $clientsList
);
$info = array(
'clientsList' => $clientsList
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getMemory()
{
$mem_total = exec("free | grep \"Mem:\" | awk '{ print $2 }'");
$mem_used = exec("free | grep \"Mem:\" | awk '{ print $3 }'");
$mem_free = exec("free | grep \"Mem:\" | awk '{ print $4 }'");
private function getMemory()
{
$mem_total = exec("free | grep \"Mem:\" | awk '{ print $2 }'");
$mem_used = exec("free | grep \"Mem:\" | awk '{ print $3 }'");
$mem_free = exec("free | grep \"Mem:\" | awk '{ print $4 }'");
$mem_free_ptg = round(($mem_free / $mem_total) * 100);
$mem_used_ptg = 100 - $mem_free_ptg;
$mem_free_ptg = round(($mem_free / $mem_total) * 100);
$mem_used_ptg = 100 - $mem_free_ptg;
$mem_total = $this->kbytesToString($mem_total);
$mem_used = $this->kbytesToString($mem_used);
$mem_free = $this->kbytesToString($mem_free);
$mem_total = $this->kbytesToString($mem_total);
$mem_used = $this->kbytesToString($mem_used);
$mem_free = $this->kbytesToString($mem_free);
$info = array(
'memoryTotal' => $mem_total,
'memoryFree' => $mem_free,
'memoryFreePourcentage' => $mem_free_ptg,
'memoryUsed' => $mem_used,
'memoryUsedPourcentage' => $mem_used_ptg
);
$info = array(
'memoryTotal' => $mem_total,
'memoryFree' => $mem_free,
'memoryFreePourcentage' => $mem_free_ptg,
'memoryUsed' => $mem_used,
'memoryUsedPourcentage' => $mem_used_ptg
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getWiFi()
{
$wifiClients = explode("\n", trim(shell_exec("iw dev wlan0 station dump | grep \"Station\"")));
$wifiClientsList = array();
for ($i=0;$i<count($wifiClients);$i++) {
if ($wifiClients[$i] != "") {
$wifi_client = explode(" ", $wifiClients[$i]);
$mac_address = $wifi_client[1];
$ip_address = exec("cat /tmp/dhcp.leases | grep \"".$mac_address."\" | awk '{ print $3}'");
$hostname = exec("cat /tmp/dhcp.leases | grep \"".$mac_address."\" | awk '{ print $4}'");
private function getWiFi()
{
$wifiClients = explode("\n", trim(shell_exec("iw dev wlan0 station dump | grep \"Station\"")));
$wifiClientsList = array();
for($i=0;$i<count($wifiClients);$i++)
{
if($wifiClients[$i] != "")
{
$wifi_client = explode(" ", $wifiClients[$i]);
$mac_address = $wifi_client[1];
$ip_address = exec("cat /tmp/dhcp.leases | grep \"".$mac_address."\" | awk '{ print $3}'");
$hostname = exec("cat /tmp/dhcp.leases | grep \"".$mac_address."\" | awk '{ print $4}'");
array_push($wifiClientsList, array("hostname" => $hostname, "mac" => $mac_address, "ip" =>$ip_address));
}
}
array_push($wifiClientsList, array("hostname" => $hostname, "mac" => $mac_address, "ip" =>$ip_address));
}
}
$info = array(
'wifiClientsList' => $wifiClientsList
);
$info = array(
'wifiClientsList' => $wifiClientsList
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getSwap()
{
$swap_total = exec("free | grep \"Swap:\" | awk '{ print $2 }'");
$swap_used = exec("free | grep \"Swap:\" | awk '{ print $3 }'");
$swap_free = exec("free | grep \"Swap:\" | awk '{ print $4 }'");
private function getSwap()
{
$swap_total = exec("free | grep \"Swap:\" | awk '{ print $2 }'");
$swap_used = exec("free | grep \"Swap:\" | awk '{ print $3 }'");
$swap_free = exec("free | grep \"Swap:\" | awk '{ print $4 }'");
if ($swap_total != 0) {
$swap_available = true;
} else {
$swap_available = false;
}
if($swap_total != 0) $swap_available = true; else $swap_available = false;
if ($swap_available) {
$swap_free_ptg = round(($swap_free / $swap_total) * 100);
} else {
$swap_free_ptg = 0;
}
$swap_used_ptg = 100 - $swap_free_ptg;
if($swap_available) $swap_free_ptg = round(($swap_free / $swap_total) * 100); else $swap_free_ptg = 0;
$swap_used_ptg = 100 - $swap_free_ptg;
$swap_total = $this->kbytesToString($swap_total);
$swap_used = $this->kbytesToString($swap_used);
$swap_free = $this->kbytesToString($swap_free);
$swap_total = $this->kbytesToString($swap_total);
$swap_used = $this->kbytesToString($swap_used);
$swap_free = $this->kbytesToString($swap_free);
$info = array(
'swapAvailable' => $swap_available,
'swapTotal' => $swap_total,
'swapFree' => $swap_free,
'swapFreePourcentage' => $swap_free_ptg,
'swapUsed' => $swap_used,
'swapUsedPourcentage' => $swap_used_ptg
);
$info = array(
'swapAvailable' => $swap_available,
'swapTotal' => $swap_total,
'swapFree' => $swap_free,
'swapFreePourcentage' => $swap_free_ptg,
'swapUsed' => $swap_used,
'swapUsedPourcentage' => $swap_used_ptg
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getStorage()
{
$dfAll = explode("\n", trim(shell_exec("df | grep -v \"Filesystem\"")));
$dfList = array();
for ($i=0;$i<count($dfAll);$i++) {
$df_name = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $1}'");
$df_mount = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $6}'");
$df_total = $this->kbytesToString(exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $2}'"));
$df_used = $this->kbytesToString(exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $3}'"));
$df_used_ptg = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $5}'");
private function getStorage()
{
$dfAll = explode("\n", trim(shell_exec("df | grep -v \"Filesystem\"")));
$dfList = array();
for($i=0;$i<count($dfAll);$i++) {
$df_name = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $1}'");
$df_mount = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $6}'");
$df_total = $this->kbytesToString(exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $2}'"));
$df_used = $this->kbytesToString(exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $3}'"));
$df_used_ptg = exec("df | grep -v \"Filesystem\" | grep \"".$dfAll[$i]."\" | awk '{ print $5}'");
array_push($dfList, array("name" => $df_name, "mount" => $df_mount, "usedPourcentage" =>$df_used_ptg, "used" => $df_used, "total" => $df_total));
}
array_push($dfList, array("name" => $df_name, "mount" => $df_mount, "usedPourcentage" =>$df_used_ptg, "used" => $df_used, "total" => $df_total));
}
$info = array(
'storagesList' => $dfList
);
$info = array(
'storagesList' => $dfList
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getInterfaces()
{
$interfaces = explode("\n", trim(shell_exec("ifconfig | grep 'encap:Ethernet' | cut -d' ' -f1")));
$interfacesList = array();
for ($i=0;$i<count($interfaces);$i++) {
$interface_name = $interfaces[$i];
private function getInterfaces()
{
$interfaces = explode("\n", trim(shell_exec("ifconfig | grep 'encap:Ethernet' | cut -d' ' -f1")));
$interfacesList = array();
for($i=0;$i<count($interfaces);$i++)
{
$interface_name = $interfaces[$i];
$mac_address = exec("ifconfig ".$interfaces[$i]." | grep 'HWaddr' | awk '{ print $5}'");
$mac_address = $mac_address != "" ? $mac_address : "-";
$ip_address = exec("ifconfig ".$interfaces[$i]." | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'");
$ip_address = $ip_address != "" ? $ip_address : "-";
$subnet_mask = exec("ifconfig ".$interfaces[$i]." | grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'");
$subnet_mask = $subnet_mask != "" ? $subnet_mask : "-";
$gateway = exec("netstat -r | grep 'default' | grep ".$interfaces[$i]." | awk '{ print $2}'");
$gateway = $gateway != "" ? $gateway : "-";
$mac_address = exec("ifconfig ".$interfaces[$i]." | grep 'HWaddr' | awk '{ print $5}'"); $mac_address = $mac_address != "" ? $mac_address : "-";
$ip_address = exec("ifconfig ".$interfaces[$i]." | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"); $ip_address = $ip_address != "" ? $ip_address : "-";
$subnet_mask = exec("ifconfig ".$interfaces[$i]." | grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'"); $subnet_mask = $subnet_mask != "" ? $subnet_mask : "-";
$gateway = exec("netstat -r | grep 'default' | grep ".$interfaces[$i]." | awk '{ print $2}'"); $gateway = $gateway != "" ? $gateway : "-";
$mode = exec("iwconfig ".$interfaces[$i]." | grep 'Mode:' | cut -d: -f2 | awk '{ print $1}'");
$tx_power = exec("iwconfig ".$interfaces[$i]." | grep 'Tx-Power=' | cut -d= -f2");
$mode = exec("iwconfig ".$interfaces[$i]." | grep 'Mode:' | cut -d: -f2 | awk '{ print $1}'");
$tx_power = exec("iwconfig ".$interfaces[$i]." | grep 'Tx-Power=' | cut -d= -f2");
array_push($interfacesList, array("name" => $interface_name, "mac" => $mac_address, "ip" =>$ip_address, "subnet" => $subnet_mask, "gateway" => $gateway, "mode" => $mode, "txpower" => $tx_power));
}
array_push($interfacesList, array("name" => $interface_name, "mac" => $mac_address, "ip" =>$ip_address, "subnet" => $subnet_mask, "gateway" => $gateway, "mode" => $mode, "txpower" => $tx_power));
}
$wan = @file_get_contents("http://cloud.wifipineapple.com/ip.php");
$wan = $wan != "" ? $wan : "-";
$gateway = exec("netstat -r | grep 'default' | awk '{ print $2}'");
$gateway = $gateway != "" ? $gateway : "-";
$dnsAll = explode("\n", trim(shell_exec("cat /tmp/resolv.conf.auto | grep nameserver | awk '{ print $2}'")));
$dnsList = array();
for ($i=0;$i<count($dnsAll);$i++) {
array_push($dnsList, array("name" => "DNS ".($i+1), "ip" => $dnsAll[$i]));
}
$wan = @file_get_contents("http://cloud.wifipineapple.com/ip.php"); $wan = $wan != "" ? $wan : "-";
$gateway = exec("netstat -r | grep 'default' | awk '{ print $2}'"); $gateway = $gateway != "" ? $gateway : "-";
$dnsAll = explode("\n", trim(shell_exec("cat /tmp/resolv.conf.auto | grep nameserver | awk '{ print $2}'")));
$dnsList = array();
for($i=0;$i<count($dnsAll);$i++) {
array_push($dnsList, array("name" => "DNS ".($i+1), "ip" => $dnsAll[$i]));
}
$info = array(
'wanIpAddress' => $wan,
'wanGateway' => $gateway,
'dnsList' => $dnsList,
'interfacesList' => $interfacesList
);
$info = array(
'wanIpAddress' => $wan,
'wanGateway' => $gateway,
'dnsList' => $dnsList,
'interfacesList' => $interfacesList
);
$this->response = array('info' => $info);
}
$this->response = array('info' => $info);
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getPingInfo()
{
exec("ping -c4 ".$this->request->ip, $output);
$this->response = array('title' => $this->request->ip, "output" => implode("\n", array_reverse($output)));
}
private function getPingInfo()
{
exec ("ping -c4 ".$this->request->ip, $output);
$this->response = array('title' => $this->request->ip, "output" => implode("\n", array_reverse($output)));
}
private function kbytesToString($kb)
{
$units = array('TB','GB','MB','KB');
$scale = 1024*1024*1024;
$ui = 0;
private function kbytesToString($kb)
{
$units = array('TB','GB','MB','KB');
$scale = 1024*1024*1024;
$ui = 0;
while (($kb < $scale) && ($scale > 1)) {
$ui++;
$scale = $scale / 1024;
}
return sprintf("%0.2f %s", ($kb/$scale), $units[$ui]);
}
while (($kb < $scale) && ($scale > 1))
{
$ui++;
$scale = $scale / 1024;
}
return sprintf("%0.2f %s", ($kb/$scale),$units[$ui]);
}
private function getCoreInformation()
{
$data = file('/proc/stat');
$cores = array();
private function getCoreInformation()
{
$data = file('/proc/stat');
$cores = array();
foreach ($data as $line) {
if (preg_match('/^cpu[0-9]/', $line)) {
$info = explode(' ', $line);
$cores[] = array(
'user' => $info[1],
'nice' => $info[2],
'sys' => $info[3],
'idle' => $info[4]
);
}
}
foreach( $data as $line )
{
if( preg_match('/^cpu[0-9]/', $line) )
{
$info = explode(' ', $line );
$cores[] = array(
'user' => $info[1],
'nice' => $info[2],
'sys' => $info[3],
'idle' => $info[4]
);
}
}
return $cores;
}
return $cores;
}
private function getCpuPercentages($stat1, $stat2)
{
if (count($stat1) !== count($stat2)) {
return;
}
private function getCpuPercentages($stat1, $stat2)
{
if( count($stat1) !== count($stat2) )
{
return;
}
$cpus = array();
$cpus = array();
for ($i = 0, $l = count($stat1); $i < $l; $i++) {
$dif = array();
$dif['user'] = $stat2[$i]['user'] - $stat1[$i]['user'];
$dif['nice'] = $stat2[$i]['nice'] - $stat1[$i]['nice'];
$dif['sys'] = $stat2[$i]['sys'] - $stat1[$i]['sys'];
$dif['idle'] = $stat2[$i]['idle'] - $stat1[$i]['idle'];
$total = array_sum($dif);
$cpu = array();
for( $i = 0, $l = count($stat1); $i < $l; $i++)
{
$dif = array();
$dif['user'] = $stat2[$i]['user'] - $stat1[$i]['user'];
$dif['nice'] = $stat2[$i]['nice'] - $stat1[$i]['nice'];
$dif['sys'] = $stat2[$i]['sys'] - $stat1[$i]['sys'];
$dif['idle'] = $stat2[$i]['idle'] - $stat1[$i]['idle'];
$total = array_sum($dif);
$cpu = array();
foreach ($dif as $x=>$y) {
$cpu[$x] = round($y / $total * 100, 1);
}
$cpus['cpu' . $i] = $cpu;
}
foreach($dif as $x=>$y) $cpu[$x] = round($y / $total * 100, 1);
$cpus['cpu' . $i] = $cpu;
}
return $cpus;
}
return $cpus;
}
}

View File

@ -2,35 +2,35 @@ registerController('Status_Controller', ['$api', '$scope', '$rootScope', '$inter
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'Status',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'Status',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
registerController('Status_SystemController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
machine : "Loading...",
currentTime : "Loading...",
uptime : "Loading...",
hostname : "Loading..."
machine: "Loading...",
currentTime: "Loading...",
uptime: "Loading...",
hostname: "Loading..."
};
$scope.getInfo = function() {
$api.request({
module: 'Status',
action: 'getSystem'
}, function(response) {
$scope.info = response.info;
});
$api.request({
module: 'Status',
action: 'getSystem'
}, function(response) {
$scope.info = response.info;
});
};
$scope.getInfo();
@ -39,29 +39,29 @@ registerController('Status_SystemController', ['$api', '$scope', '$rootScope', '
registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$filter', '$sce', function($api, $scope, $rootScope, $filter, $sce) {
$scope.info = {
cpuModel : "Loading...",
bogoMIPS : "Loading...",
type : "Loading...",
loadAveragePourcentage : "0",
loadAverageAll : "Loading..."
cpuModel: "Loading...",
bogoMIPS: "Loading...",
type: "Loading...",
loadAveragePourcentage: "0",
loadAverageAll: "Loading..."
};
$scope.getInfo = function() {
$api.request({
module: 'Status',
action: 'getCPU'
}, function(response) {
$scope.info = response.info;
});
$api.request({
module: 'Status',
action: 'getCPU'
}, function(response) {
$scope.info = response.info;
});
};
$scope.getSrc = (function() {
$scope.src = $sce.trustAsResourceUrl('/modules/Status/svg/graph_cpu.svg');
});
$scope.src = $sce.trustAsResourceUrl('/modules/Status/svg/graph_cpu.svg');
});
$scope.setSrc = (function() {
$scope.src = $sce.trustAsResourceUrl('about:blank');
});
$scope.src = $sce.trustAsResourceUrl('about:blank');
});
$scope.setSrc();
$scope.getInfo();
@ -70,7 +70,7 @@ registerController('Status_CPUController', ['$api', '$scope', '$rootScope', '$fi
registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
clientsList : []
clientsList: []
};
$scope.title = "Loading...";
@ -79,43 +79,43 @@ registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$f
$scope.loading = false;
$scope.getInfo = function() {
$scope.loading = true;
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getDHCP'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
$api.request({
module: 'Status',
action: 'getDHCP'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
};
$scope.getMACInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getPingInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getInfo();
@ -124,20 +124,20 @@ registerController('Status_DHCPController', ['$api', '$scope', '$rootScope', '$f
registerController('Status_MemoryController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
memoryTotal : "Loading...",
memoryFree : "Loading...",
memoryFreePourcentage : "0",
memoryUsed : "Loading...",
memoryUsedPourcentage : "0"
memoryTotal: "Loading...",
memoryFree: "Loading...",
memoryFreePourcentage: "0",
memoryUsed: "Loading...",
memoryUsedPourcentage: "0"
};
$scope.getInfo = function() {
$api.request({
module: 'Status',
action: 'getMemory'
}, function(response) {
$scope.info = response.info;
});
$api.request({
module: 'Status',
action: 'getMemory'
}, function(response) {
$scope.info = response.info;
});
};
$scope.getInfo();
@ -146,50 +146,50 @@ registerController('Status_MemoryController', ['$api', '$scope', '$rootScope', '
registerController('Status_WiFiController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
wifiClientsList : []
wifiClientsList: []
};
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.loading = false;
$scope.getInfo = function() {
$scope.loading = true;
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getWiFi'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
$api.request({
module: 'Status',
action: 'getWiFi'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
};
$scope.getMACInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getPingInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getInfo();
@ -198,21 +198,21 @@ registerController('Status_WiFiController', ['$api', '$scope', '$rootScope', '$f
registerController('Status_SwapController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
swapAvailable : false,
swapTotal : "Loading...",
swapFree : "Loading...",
swapFreePourcentage : "0",
swapUsed : "Loading...",
swapUsedPourcentage : "0"
swapAvailable: false,
swapTotal: "Loading...",
swapFree: "Loading...",
swapFreePourcentage: "0",
swapUsed: "Loading...",
swapUsedPourcentage: "0"
};
$scope.getInfo = function() {
$api.request({
module: 'Status',
action: 'getSwap'
}, function(response) {
$scope.info = response.info;
});
$api.request({
module: 'Status',
action: 'getSwap'
}, function(response) {
$scope.info = response.info;
});
};
$scope.getInfo();
@ -221,21 +221,21 @@ registerController('Status_SwapController', ['$api', '$scope', '$rootScope', '$f
registerController('Status_StorageController', ['$api', '$scope', '$rootScope', '$filter', function($api, $scope, $rootScope, $filter) {
$scope.info = {
storagesList : []
storagesList: []
};
$scope.loading = false;
$scope.getInfo = function() {
$scope.loading = true;
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getStorage'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
$api.request({
module: 'Status',
action: 'getStorage'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
};
$scope.getInfo();
@ -244,10 +244,10 @@ registerController('Status_StorageController', ['$api', '$scope', '$rootScope',
registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope', '$filter', '$sce', function($api, $scope, $rootScope, $filter, $sce) {
$scope.info = {
wanIpAddress : "Loading...",
wanGateway : "Loading...",
dnsList : [],
interfacesList : []
wanIpAddress: "Loading...",
wanGateway: "Loading...",
dnsList: [],
interfacesList: []
};
$scope.title = "Loading...";
@ -256,53 +256,53 @@ registerController('Status_InterfaceController', ['$api', '$scope', '$rootScope'
$scope.loading = false;
$scope.getMACInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getMACInfo',
mac: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getPingInfo = function(param) {
$scope.title = "Loading...";
$scope.output = "Loading...";
$scope.title = "Loading...";
$scope.output = "Loading...";
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
$api.request({
module: 'Status',
action: 'getPingInfo',
ip: param
}, function(response) {
$scope.title = response.title;
$scope.output = response.output;
});
};
$scope.getInfo = function() {
$scope.loading = true;
$scope.loading = true;
$api.request({
module: 'Status',
action: 'getInterfaces'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
$api.request({
module: 'Status',
action: 'getInterfaces'
}, function(response) {
$scope.info = response.info;
$scope.loading = false;
});
};
$scope.getSrc = (function(param) {
$scope.src = $sce.trustAsResourceUrl('/modules/Status/svg/graph_if.svg?'+param);
$scope.interfaceName = param;
});
$scope.src = $sce.trustAsResourceUrl('/modules/Status/svg/graph_if.svg?' + param);
$scope.interfaceName = param;
});
$scope.setSrc = (function() {
$scope.src = $sce.trustAsResourceUrl('about:blank');
});
$scope.src = $sce.trustAsResourceUrl('about:blank');
});
$scope.setSrc();
$scope.getInfo();

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "Status",
"version": "1.2"
"version": "1.3"
}

View File

@ -1,5 +1,9 @@
<?php namespace pineapple;
/*
* Author: trashbo4t (github.com/trashbo4t)
*/
class Themes extends Module
{
// CONSTANTS
@ -26,7 +30,6 @@ class Themes extends Module
private $ALL_MODULES = array(
"Dashboard",
"Recon",
"Profiling",
"Clients",
"ModuleManager",
"Filters",
@ -37,6 +40,7 @@ class Themes extends Module
"Networking",
"Configuration",
"Advanced",
"Notes",
"Help",
);
/*
@ -200,6 +204,9 @@ class Themes extends Module
* $moduleName -> String name of module, can be any format (nEtWoRkIng) because it gets formatted
* $color -> string name of the color, used for index of mapping
* $brightness -> string name of brightness, used for map selection
*
* This is a neat little technique to change image colors, since the images are SVG we search and
* replace the original RBG colors in the image file with the new RBG hex values.
*/
public function replaceModuleImage($moduleName, $color, $brightness)
{

View File

@ -1,5 +1,8 @@
registerController("ThemesController", ['$api', '$scope','$window','$route', '$http', function ($api, $scope, $window, $route, $http) {
/*
* Author: trashbo4t (github.com/trashbo4t)
*/
getThemes();
getCurrentTheme();
backupFiles();
@ -36,8 +39,8 @@ registerController("ThemesController", ['$api', '$scope','$window','$route', '$h
$scope.dashboardcontrastBrightness = 'normal';
$scope.reconcontrastText = 'light';
$scope.reconcontrastBrightness = 'normal';
$scope.profilingcontrastText = 'light';
$scope.profilingcontrastBrightness = 'normal';
$scope.notescontrastText = 'light';
$scope.notescontrastBrightness = 'normal';
$scope.clientscontrastText = 'light';
$scope.clientscontrastBrightness = 'normal';
$scope.modulescontrastText = 'light';
@ -196,15 +199,15 @@ registerController("ThemesController", ['$api', '$scope','$window','$route', '$h
}
});
};
$scope.changeProfiling = function(){
$scope.changeNotes = function(){
$api.request({
module: "Themes",
action: "replaceImage",
img: 'Profiling',
color: $scope.profilingcontrastText,
brightness: $scope.profilingcontrastBrightness
img: 'Notes',
color: $scope.notescontrastText,
brightness: $scope.notescontrastBrightness
}, function(response) {
$scope.sendMessage("Profiling Icon", "set to " + $scope.profilingcontrastText + " (" + $scope.profilingcontrastBrightness + ")");
$scope.sendMessage("Notes Icon", "set to " + $scope.notescontrastText + " (" + $scope.notescontrastBrightness + ")");
log("changeDashboard", "Success? " + response.success + " " + response.message);
if ($scope.autoRefresh) {
$window.location.reload();
@ -405,8 +408,8 @@ registerController("ThemesController", ['$api', '$scope','$window','$route', '$h
$scope.dashboardcontrastBrightness = response.dashboardbrightness;
$scope.reconcontrastText = response.recon;
$scope.reconcontrastBrightness = response.reconbrightness;
$scope.profilingcontrastText = response.profiling;
$scope.profilingcontrastBrightness = response.profilingbrightness;
$scope.notescontrastText = response.notes;
$scope.notescontrastBrightness = response.notesbrightness;
$scope.clientscontrastText = response.clients;
$scope.clientscontrastBrightness = response.clientsbrightness;
$scope.modulescontrastText = response.modulemanager;

View File

@ -1,3 +1,7 @@
<!-- Author: -->
<!-- trashbo4t -->
<!-- (github.com/trashbo4t) -->
<div class="row" ng-controller="ThemesController">
<div class="col-md-3">
@ -78,7 +82,6 @@
<tr><td>Favicon</td><td> {{ faviconcontrastText }}</td><td> N/A </td> </tr>
<tr><td>Dashboard</td><td> {{ dashboardcontrastText }}</td><td> {{ dashboardcontrastBrightness }}</td> </tr>
<tr><td>Recon</td><td> {{ reconcontrastText }}</td><td> {{ reconcontrastBrightness }}</td> </tr>
<tr><td>Profiling</td><td> {{ profilingcontrastText }}</td><td> {{ profilingcontrastBrightness }}</td> </tr>
<tr><td>Clients</td><td> {{ clientscontrastText }}</td><td> {{ clientscontrastBrightness }}</td> </tr>
<tr><td>Modules</td><td> {{ modulescontrastText }}</td><td> {{ modulescontrastBrightness }}</td> </tr>
<tr><td>Filters</td><td> {{ filterscontrastText }}</td><td> {{ filterscontrastBrightness }}</td> </tr>
@ -89,6 +92,7 @@
<tr><td>Networking</td><td> {{ networkingcontrastText }}</td><td> {{ networkingcontrastBrightness }}</td> </tr>
<tr><td>Configuration</td><td> {{ configurationcontrastText }}</td><td> {{ configurationcontrastBrightness }}</td> </tr>
<tr><td>Advanced</td><td> {{ advancedcontrastText }}</td><td> {{ advancedcontrastBrightness }}</td> </tr>
<tr><td>Notes</td><td> {{ notescontrastText }}</td><td> {{ notescontrastBrightness }}</td> </tr>
<tr><td>Help</td><td> {{ helpcontrastText }}</td><td> {{ helpcontrastBrightness }}</td> </tr>
</tbody>
</table>
@ -376,26 +380,27 @@
</button>
</td>
</tr>
<td><b>Profiling</b></td>
<td><img src="/modules/Profiling/module_icon.svg" width="30" height="30" /></td>
<td><select ng-model="profilingcontrastText"
<td><b>Notes</b></td>
<td><img src="/modules/Notes/module_icon.svg" width="30" height="30" /></td>
<td><select ng-model="notescontrastText"
ng-style="selectOptions"
ng-options="x for x in colors"
ng-value="{{ profilingcontrastText }}"
ng-value="{{ notescontrastText }}"
>
</select>
</td>
<td><select ng-model="profilingcontrastBrightness"
<td><select ng-model="notescontrastBrightness"
ng-style="selectOptions"
ng-options="x for x in brightness"
ng-value="{{ profilingcontrastBrightness }}"
ng-value="{{ notescontrastBrightness }}"
>
</select>
</td>
<td><button class="btn btn-default"
type="button"
ng-click="changeProfiling()">
ng-click="changeNotes()">
Apply
</button>
</td>
@ -755,6 +760,13 @@
</div>
<div id="collapseChangelog" class="panel-collapse collapse">
<div class="panel-body">
<ul>
<li><b>1.1</b></li>
<ul>
<li class="text-muted">Removed profiling icon options</li>
<li class="text-muted">Added "Notes" icon options</li>
</ul>
</ul>
<ul>
<li><b>1.0</b></li>
<ul>

View File

@ -6,5 +6,7 @@
"tetra"
],
"title": "Themes",
"version": "1.0"
"description": "Create, download, and share custom themes",
"version": "1.1",
"author": "trashbo4t"
}

View File

@ -1,21 +1,22 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class dump1090 extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'clearOutput':
$this->clearOutput();
break;
case 'clearOutput':
$this->clearOutput();
break;
case 'refreshStatus':
$this->refreshStatus();
break;
@ -34,234 +35,229 @@ class dump1090 extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'viewHistory':
$this->viewHistory();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'refreshList':
$this->refreshList();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'viewHistory':
$this->viewHistory();
break;
case 'getSettings':
$this->getSettings();
break;
case 'setSettings':
$this->setSettings();
break;
case 'refreshList':
$this->refreshList();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dump1090.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("dump1090.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/dump1090/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/dump1090/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("dump1090"))
{
$this->execBackground("/pineapple/modules/dump1090/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/dump1090/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("dump1090")) {
$this->execBackground("/pineapple/modules/dump1090/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/dump1090/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/dump1090.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/dump1090.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function toggledump1090()
{
if(!$this->checkRunning("dump1090"))
{
$this->execBackground("/pineapple/modules/dump1090/scripts/dump1090.sh start");
}
else
{
$this->execBackground("/pineapple/modules/dump1090/scripts/dump1090.sh stop");
}
}
if (!$this->checkRunning("dump1090")) {
$this->execBackground("/pineapple/modules/dump1090/scripts/dump1090.sh start");
} else {
$this->execBackground("/pineapple/modules/dump1090/scripts/dump1090.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/dump1090.progress'))
{
if (!$this->checkDependency("dump1090"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/dump1090.progress')) {
if (!$this->checkDependency("dump1090")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$running = false;
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
$running = false;
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("dump1090"))
{
$status = "Stop";
$statusLabel = "danger";
$running = true;
}
else
{
$status = "Start";
$statusLabel = "success";
$running = false;
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if ($this->checkRunning("dump1090")) {
$status = "Stop";
$statusLabel = "danger";
$running = true;
} else {
$status = "Start";
$statusLabel = "success";
$running = false;
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$running = false;
$status = "Start";
$statusLabel = "success";
$running = false;
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing, "running" => $running);
}
private function refreshOutput()
{
if ($this->checkDependency("dump1090"))
{
if (file_exists("/tmp/dump1090_capture.log"))
{
$output = file_get_contents("/tmp/dump1090_capture.log");
if(!empty($output))
$this->response = $output;
else
$this->response = "dump1090 is running...";
}
else
{
$this->response = "dump1090 is not running...";
}
}
else
{
$this->response = "dump1090 is not installed...";
}
}
private function clearOutput()
{
exec("rm -rf /tmp/dump1090_capture.log");
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/dump1090/log/*.log"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i],".log");
if(file_exists("/pineapple/modules/dump1090/log/".$entryName.".csv"))
echo json_encode(array($entryDate, $entryName.".log", $entryName.".csv"));
else
echo json_encode(array($entryDate, $entryName.".log", ''));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/dump1090/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/dump1090/log/".$this->request->file));
exec ("strings /pineapple/modules/dump1090/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
private function deleteHistory()
{
$file = basename($this->request->file,".log");
exec("rm -rf /pineapple/modules/dump1090/log/".$file.".*");
}
private function getSettings()
{
$settings = array(
'csv' => $this->uciGet("dump1090.settings.csv"),
'gain' => $this->uciGet("dump1090.settings.gain"),
'frequency' => $this->uciGet("dump1090.settings.frequency"),
'metrics' => $this->uciGet("dump1090.settings.metrics"),
'agc' => $this->uciGet("dump1090.settings.agc"),
'aggressive' => $this->uciGet("dump1090.settings.aggressive")
);
$this->response = array('settings' => $settings);
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("dump1090.settings.gain", $settings->gain);
$this->uciSet("dump1090.settings.frequency", $settings->frequency);
if ($settings->csv) $this->uciSet("dump1090.settings.csv", 1); else $this->uciSet("dump1090.settings.csv", 0);
if ($settings->metrics) $this->uciSet("dump1090.settings.metrics", 1); else $this->uciSet("dump1090.settings.metrics", 0);
if ($settings->agc) $this->uciSet("dump1090.settings.agc", 1); else $this->uciSet("dump1090.settings.agc", 0);
if ($settings->aggressive) $this->uciSet("dump1090.settings.aggressive", 1); else $this->uciSet("dump1090.settings.aggressive", 0);
}
private function refreshList()
{
$this->streamFunction = function () {
echo file_get_contents("http://127.0.0.1:9090/data.json");
};
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing, "running" => $running);
}
private function refreshOutput()
{
if ($this->checkDependency("dump1090")) {
if (file_exists("/tmp/dump1090_capture.log")) {
$output = file_get_contents("/tmp/dump1090_capture.log");
if (!empty($output)) {
$this->response = $output;
} else {
$this->response = "dump1090 is running...";
}
} else {
$this->response = "dump1090 is not running...";
}
} else {
$this->response = "dump1090 is not installed...";
}
}
private function clearOutput()
{
exec("rm -rf /tmp/dump1090_capture.log");
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/dump1090/log/*.log"));
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i], ".log");
if (file_exists("/pineapple/modules/dump1090/log/".$entryName.".csv")) {
echo json_encode(array($entryDate, $entryName.".log", $entryName.".csv"));
} else {
echo json_encode(array($entryDate, $entryName.".log", ''));
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/dump1090/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/dump1090/log/".$this->request->file));
exec("strings /pineapple/modules/dump1090/log/".$this->request->file, $output);
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
$file = basename($this->request->file, ".log");
exec("rm -rf /pineapple/modules/dump1090/log/".$file.".*");
}
private function getSettings()
{
$settings = array(
'csv' => $this->uciGet("dump1090.settings.csv"),
'gain' => $this->uciGet("dump1090.settings.gain"),
'frequency' => $this->uciGet("dump1090.settings.frequency"),
'metrics' => $this->uciGet("dump1090.settings.metrics"),
'agc' => $this->uciGet("dump1090.settings.agc"),
'aggressive' => $this->uciGet("dump1090.settings.aggressive")
);
$this->response = array('settings' => $settings);
}
private function setSettings()
{
$settings = $this->request->settings;
$this->uciSet("dump1090.settings.gain", $settings->gain);
$this->uciSet("dump1090.settings.frequency", $settings->frequency);
if ($settings->csv) {
$this->uciSet("dump1090.settings.csv", 1);
} else {
$this->uciSet("dump1090.settings.csv", 0);
}
if ($settings->metrics) {
$this->uciSet("dump1090.settings.metrics", 1);
} else {
$this->uciSet("dump1090.settings.metrics", 0);
}
if ($settings->agc) {
$this->uciSet("dump1090.settings.agc", 1);
} else {
$this->uciSet("dump1090.settings.agc", 0);
}
if ($settings->aggressive) {
$this->uciSet("dump1090.settings.aggressive", 1);
} else {
$this->uciSet("dump1090.settings.aggressive", 0);
}
}
private function refreshList()
{
$this->streamFunction = function () {
echo file_get_contents("http://127.0.0.1:9090/data.json");
};
}
}

View File

@ -2,17 +2,17 @@ registerController('dump1090_Controller', ['$api', '$scope', '$rootScope', '$int
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'dump1090',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'dump1090',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -29,32 +29,32 @@ registerController('dump1090_ControlsController', ['$api', '$scope', '$rootScope
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
running : false,
refreshOutput : false,
refreshHistory : false
installed: false,
running: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "dump1090",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "dump1090",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.running = response.running;
})
});
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.running = response.running;
})
});
$scope.toggledump1090 = (function() {
if($scope.status != "Stop")
$scope.toggledump1090 = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -66,105 +66,102 @@ registerController('dump1090_ControlsController', ['$api', '$scope', '$rootScope
$rootScope.status.refreshHistory = false;
$api.request({
module: 'dump1090',
action: 'toggledump1090',
command: $rootScope.command
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'dump1090',
action: 'toggledump1090',
command: $rootScope.command
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
}, 2000);
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'dump1090',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'dump1090',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'dump1090',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'dump1090',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
$scope.refreshStatus();
}]);
registerController('dump1090_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "dump1090",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
module: "dump1090",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
$scope.clearOutput = (function() {
$api.request({
module: "dump1090",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
module: "dump1090",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -173,52 +170,52 @@ registerController('dump1090_HistoryController', ['$api', '$scope', '$rootScope'
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "dump1090",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$scope.refreshHistory = (function() {
$api.request({
module: "dump1090",
action: "viewHistory",
module: "dump1090",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "dump1090",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
})
});
$scope.deleteHistory = (function(param) {
$scope.deleteHistory = (function(param) {
$api.request({
module: "dump1090",
action: "deleteHistory",
module: "dump1090",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'dump1090',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'dump1090',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -228,15 +225,15 @@ registerController('dump1090_HistoryController', ['$api', '$scope', '$rootScope'
registerController('dump1090_MapController', ['$api', '$scope', '$rootScope', '$timeout', '$location', '$sce', function($api, $scope, $rootScope, $timeout, $location, $sce) {
$scope.getMapSrc = (function(param) {
return $sce.trustAsResourceUrl('http://' + $location.host() + ':9090/');
});
return $sce.trustAsResourceUrl('http://' + $location.host() + ':9090/');
});
$scope.refreshMap = (function(param) {
document.getElementById('map').src += '';
});
document.getElementById('map').src += '';
});
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
if (param) {
$scope.refreshMap();
}
});
@ -250,37 +247,34 @@ registerController('dump1090_ListController', ['$api', '$scope', '$rootScope', '
$scope.refreshLabelOFF = "danger";
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshList();
}, 5000);
}, 5000);
}
});
});
$scope.refreshList = (function() {
$api.request({
module: "dump1090",
action: "refreshList"
}, function(response) {
$scope.list = response;
})
});
$scope.refreshList = (function() {
$api.request({
module: "dump1090",
action: "refreshList"
}, function(response) {
$scope.list = response;
})
});
$scope.refreshList();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
if (param) {
$scope.refreshList();
}
});
@ -288,51 +282,51 @@ registerController('dump1090_ListController', ['$api', '$scope', '$rootScope', '
}]);
registerController('dump1090_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
$scope.settings = {
csv : false,
gain : "",
frequency : "",
metrics : false,
agc : false,
aggressive : false
};
$scope.settings = {
csv: false,
gain: "",
frequency: "",
metrics: false,
agc: false,
aggressive: false
};
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
$scope.getSettings = function() {
$api.request({
module: 'dump1090',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.getSettings = function() {
$api.request({
module: 'dump1090',
action: 'getSettings'
}, function(response) {
$scope.settings = response.settings;
});
};
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$scope.setSettings = function() {
$scope.saveSettingsLabel = "warning";
$scope.saveSettings = "Saving...";
$scope.saving = true;
$api.request({
module: 'dump1090',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$api.request({
module: 'dump1090',
action: 'setSettings',
settings: $scope.settings
}, function(response) {
$scope.getSettings();
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$scope.saveSettingsLabel = "success";
$scope.saveSettings = "Saved";
$timeout(function(){
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$timeout(function() {
$scope.saveSettingsLabel = "primary";
$scope.saveSettings = "Save";
$scope.saving = false;
}, 2000);
});
};
$scope.getSettings();
$scope.getSettings();
}]);

1
dump1090/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -12,14 +12,13 @@ touch /tmp/dump1090.progress
if [ "$1" = "install" ]; then
if [ "$2" = "internal" ]; then
opkg update
opkg install dump1090
opkg update
opkg install dump1090
elif [ "$2" = "sd" ]; then
opkg update
opkg install dump1090 --dest sd
ln -s /sd/usr/share/dump1090/ /usr/share/dump1090
fi
touch /etc/config/dump1090
@ -30,8 +29,8 @@ if [ "$1" = "install" ]; then
uci commit dump1090.module.installed
elif [ "$1" = "remove" ]; then
opkg remove dump1090
rm -rf /etc/config/dump1090
opkg remove dump1090
rm -rf /etc/config/dump1090
fi
rm /tmp/dump1090.progress

View File

@ -38,6 +38,6 @@ if [ "$1" = "start" ]; then
fi
elif [ "$1" = "stop" ]; then
killall -9 dump1090
killall -9 dump1090
killall -9 nc
fi

View File

@ -1,19 +1,20 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class ettercap extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'clearOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'clearOutput':
$this->clearOutput();
break;
case 'refreshStatus':
@ -37,290 +38,264 @@ class ettercap extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getFilters':
$this->getFilters();
break;
case 'showFilter':
$this->showFilter();
break;
case 'deleteFilter':
$this->deleteFilter();
break;
case 'saveFilterData':
$this->saveFilterData();
break;
case 'compileFilterData':
$this->compileFilterData();
break;
case 'getFilters':
$this->getFilters();
break;
case 'showFilter':
$this->showFilter();
break;
case 'deleteFilter':
$this->deleteFilter();
break;
case 'saveFilterData':
$this->saveFilterData();
break;
case 'compileFilterData':
$this->compileFilterData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("ettercap.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("ettercap.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/ettercap/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/ettercap/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("ettercap"))
{
$this->execBackground("/pineapple/modules/ettercap/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/ettercap/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("ettercap")) {
$this->execBackground("/pineapple/modules/ettercap/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/ettercap/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/ettercap.progress'))
{
if (!file_exists('/tmp/ettercap.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleettercap()
{
if(!$this->checkRunning("ettercap"))
{
$full_cmd = $this->request->command . " -T -w /pineapple/modules/ettercap/log/log_".time().".pcap -m /pineapple/modules/ettercap/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/ettercap.run");
if (!$this->checkRunning("ettercap")) {
$full_cmd = $this->request->command . " -T -w /pineapple/modules/ettercap/log/log_".time().".pcap -m /pineapple/modules/ettercap/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/ettercap.run");
$this->execBackground("/pineapple/modules/ettercap/scripts/ettercap.sh start");
}
else
{
$this->execBackground("/pineapple/modules/ettercap/scripts/ettercap.sh stop");
}
}
$this->execBackground("/pineapple/modules/ettercap/scripts/ettercap.sh start");
} else {
$this->execBackground("/pineapple/modules/ettercap/scripts/ettercap.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/ettercap.progress'))
{
if(!$this->checkDependency("ettercap"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/ettercap.progress')) {
if (!$this->checkDependency("ettercap")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("ettercap"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if ($this->checkRunning("ettercap")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function refreshOutput()
{
if($this->checkDependency("ettercap"))
{
if ($this->checkRunning("ettercap"))
{
$path = "/pineapple/modules/ettercap/log";
if ($this->checkDependency("ettercap")) {
if ($this->checkRunning("ettercap")) {
$path = "/pineapple/modules/ettercap/log";
$latest_ctime = 0;
$latest_filename = '';
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime && substr_compare($filepath, ".log", -4, 4) == 0) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime && substr_compare($filepath, ".log", -4, 4) == 0) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ettercap/log/".$latest_filename));
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ettercap/log/".$latest_filename));
if ($this->request->filter != "")
{
$filter = $this->request->filter;
if ($this->request->filter != "") {
$filter = $this->request->filter;
$cmd = "cat /pineapple/modules/ettercap/log/".$latest_filename." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/ettercap/log/".$latest_filename;
}
$cmd = "cat /pineapple/modules/ettercap/log/".$latest_filename." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/ettercap/log/".$latest_filename;
}
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "ettercap is not running...";
}
}
else
{
$this->response = "ettercap is not installed...";
}
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "ettercap is not running...";
}
} else {
$this->response = "ettercap is not installed...";
}
}
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/ettercap/log/*.pcap"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/ettercap/log/*.pcap"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i],".pcap");
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i], ".pcap");
echo json_encode(array($entryDate, $entryName.".log", $entryName.".pcap"));
echo json_encode(array($entryDate, $entryName.".log", $entryName.".pcap"));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/ettercap/log/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/ettercap/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ettercap/log/".$this->request->file));
exec ("cat /pineapple/modules/ettercap/log/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ettercap/log/".$this->request->file));
exec("cat /pineapple/modules/ettercap/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
$file = basename($this->request->file,".pcap");
exec("rm -rf /pineapple/modules/ettercap/log/".$file.".*");
}
private function deleteHistory()
{
$file = basename($this->request->file, ".pcap");
exec("rm -rf /pineapple/modules/ettercap/log/".$file.".*");
}
private function getFilters()
{
$this->response = array();
if($this->request->compiled) {
$filterList = array_reverse(glob("/pineapple/modules/ettercap/filters/*.ef"));
array_push($this->response, "--");
foreach ($filterList as $filter) {
array_push($this->response, basename($filter));
}
}
else {
$filterList = array_reverse(glob("/pineapple/modules/ettercap/filters/*.filter"));
array_push($this->response, "--");
foreach ($filterList as $filter) {
array_push($this->response, basename($filter));
}
}
}
private function getFilters()
{
$this->response = array();
if ($this->request->compiled) {
$filterList = array_reverse(glob("/pineapple/modules/ettercap/filters/*.ef"));
array_push($this->response, "--");
foreach ($filterList as $filter) {
array_push($this->response, basename($filter));
}
} else {
$filterList = array_reverse(glob("/pineapple/modules/ettercap/filters/*.filter"));
array_push($this->response, "--");
foreach ($filterList as $filter) {
array_push($this->response, basename($filter));
}
}
}
private function showFilter()
{
$filterData = file_get_contents('/pineapple/modules/ettercap/filters/'.$this->request->filter);
$this->response = array("filterData" => $filterData);
}
private function showFilter()
{
$filterData = file_get_contents('/pineapple/modules/ettercap/filters/'.$this->request->filter);
$this->response = array("filterData" => $filterData);
}
private function deleteFilter()
{
exec("rm -rf /pineapple/modules/ettercap/filters/".basename($this->request->filter, '.filter').".*");
}
private function deleteFilter()
{
exec("rm -rf /pineapple/modules/ettercap/filters/".basename($this->request->filter, '.filter').".*");
}
private function compileFilterData()
{
$filename = "/pineapple/modules/ettercap/filters/".$this->request->filter;
$filename_ef = "/pineapple/modules/ettercap/filters/".basename($this->request->filter, '.filter').".ef";
private function compileFilterData()
{
$filename = "/pineapple/modules/ettercap/filters/".$this->request->filter;
$filename_ef = "/pineapple/modules/ettercap/filters/".basename($this->request->filter, '.filter').".ef";
$cmd = "etterfilter -o ".$filename_ef." ".$filename." 2>&1";
$cmd = "etterfilter -o ".$filename_ef." ".$filename." 2>&1";
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", $output);
else
$this->response = "Empty log...";
}
private function saveFilterData()
{
$filename = "/pineapple/modules/ettercap/filters/".$this->request->filter;
file_put_contents($filename, $this->request->filterData);
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", $output);
} else {
$this->response = "Empty log...";
}
}
private function saveFilterData()
{
$filename = "/pineapple/modules/ettercap/filters/".$this->request->filter;
file_put_contents($filename, $this->request->filterData);
}
}

View File

@ -2,17 +2,17 @@ registerController('ettercap_Controller', ['$api', '$scope', '$rootScope', '$int
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'ettercap',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'ettercap',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -30,31 +30,31 @@ registerController('ettercap_ControlsController', ['$api', '$scope', '$rootScope
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false,
refreshFilters : false
installed: false,
refreshOutput: false,
refreshHistory: false,
refreshFilters: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "ettercap",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
module: "ettercap",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
})
});
})
});
$scope.toggleettercap = (function() {
if($scope.status != "Stop")
$scope.toggleettercap = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -66,103 +66,100 @@ registerController('ettercap_ControlsController', ['$api', '$scope', '$rootScope
$rootScope.status.refreshHistory = false;
$api.request({
module: 'ettercap',
action: 'toggleettercap',
command: $rootScope.command
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'ettercap',
action: 'toggleettercap',
command: $rootScope.command
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
}, 2000);
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'ettercap',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'ettercap',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'ettercap',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'ettercap',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
$scope.refreshStatus();
}]);
registerController('ettercap_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "ettercap",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
module: "ettercap",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -171,52 +168,52 @@ registerController('ettercap_HistoryController', ['$api', '$scope', '$rootScope'
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "ettercap",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$scope.refreshHistory = (function() {
$api.request({
module: "ettercap",
action: "viewHistory",
module: "ettercap",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "ettercap",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
})
});
$scope.deleteHistory = (function(param) {
$scope.deleteHistory = (function(param) {
$api.request({
module: "ettercap",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
module: "ettercap",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'ettercap',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'ettercap',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -224,153 +221,154 @@ registerController('ettercap_HistoryController', ['$api', '$scope', '$rootScope'
}]);
registerController('ettercap_OptionsController', ['$api', '$scope', '$rootScope', function($api, $scope, $rootScope) {
$scope.command = "ettercap ";
$scope.command = "ettercap ";
$scope.target1 = "";
$scope.target2 = "";
$scope.target1 = "";
$scope.target2 = "";
$scope.filters = [];
$scope.selectedFilter = "--";
$scope.filters = [];
$scope.selectedFilter = "--";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.mitm = "--";
$scope.arpParameters = "--";
$scope.portParameters = "--";
$scope.visualization = "--";
$scope.proto = "--";
$scope.mitm = "--";
$scope.arpParameters = "--";
$scope.portParameters = "--";
$scope.visualization = "--";
$scope.proto = "--";
$scope.visualizationOptions = {
option1 : false,
option2 : false,
option3 : false
};
$scope.visualizationOptions = {
option1: false,
option2: false,
option3: false
};
$scope.protoOptions = {
option1 : false,
option2 : false,
option3 : false,
option4 : false,
option5 : false,
option6 : false
};
$scope.protoOptions = {
option1: false,
option2: false,
option3: false,
option4: false,
option5: false,
option6: false
};
$scope.update = (function(param) {
$scope.command = "ettercap " + updateInterface() + updateOptions() + updateProto() + updateVisualization() + updateFilter() + updateMITM() + updateTarget1() + updateTarget2()
$rootScope.command = $scope.command;
$scope.update = (function(param) {
$scope.command = "ettercap " + updateInterface() + updateOptions() + updateProto() + updateVisualization() + updateFilter() + updateMITM() + updateTarget1() + updateTarget2()
$rootScope.command = $scope.command;
});
$scope.getFilters = (function() {
$api.request({
module: 'ettercap',
action: 'getFilters',
compiled: true
}, function(response) {
$scope.filters = response;
$scope.selectedFilter = "--";
$rootScope.status.refreshFilters = false;
});
});
function updateInterface() {
var return_value = "";
if ($scope.selectedInterface != "--")
return_value = "-i " + $scope.selectedInterface + " ";
return return_value;
}
function updateOptions() {
var return_value = "";
angular.forEach($scope.visualizationOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
$scope.getFilters = (function() {
$api.request({
module: 'ettercap',
action: 'getFilters',
compiled: true
}, function(response) {
$scope.filters = response;
$scope.selectedFilter = "--";
$rootScope.status.refreshFilters = false;
});
});
angular.forEach($scope.protoOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
function updateInterface() {
var return_value = "";
return return_value;
}
if($scope.selectedInterface != "--")
return_value = "-i " + $scope.selectedInterface + " ";
function updateTarget1() {
var return_value = "";
return return_value;
}
if ($scope.target1 != "")
return_value = "/" + $scope.target1 + "/ ";
function updateOptions() {
var return_value = "";
return return_value;
}
angular.forEach($scope.visualizationOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
function updateTarget2() {
var return_value = "";
angular.forEach($scope.protoOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
if ($scope.target2 != "")
return_value = "/" + $scope.target2 + "/ ";
return return_value;
}
return return_value;
}
function updateTarget1() {
var return_value = "";
function updateMITM() {
var return_value = "";
if($scope.target1 != "")
return_value = "/" + $scope.target1 + "/ ";
if ($scope.mitm != "--")
if ($scope.mitm == "-M arp" && $scope.arpParameters != "--")
return_value = $scope.mitm + ":" + $scope.arpParameters + " ";
else if ($scope.mitm == "-M port" && $scope.portParameters != "--")
return_value = $scope.mitm + ":" + $scope.portParameters + " ";
else
return_value = $scope.mitm + " ";
return return_value;
}
return return_value;
}
function updateTarget2() {
var return_value = "";
function updateFilter() {
var return_value = "";
if($scope.target2 != "")
return_value = "/" + $scope.target2 + "/ ";
if ($scope.selectedFilter != "--")
return_value = "-F /pineapple/modules/ettercap/filters/" + $scope.selectedFilter + " ";
return return_value;
}
return return_value;
}
function updateMITM() {
var return_value = "";
function updateVisualization() {
var return_value = "";
if($scope.mitm != "--")
if($scope.mitm == "-M arp" && $scope.arpParameters != "--")
return_value = $scope.mitm + ":" + $scope.arpParameters + " ";
else if($scope.mitm == "-M port" && $scope.portParameters != "--")
return_value = $scope.mitm + ":" + $scope.portParameters + " ";
else
return_value = $scope.mitm + " ";
if ($scope.visualization != "--")
return_value = $scope.visualization + " ";
return return_value;
}
return return_value;
}
function updateFilter() {
var return_value = "";
function updateProto() {
var return_value = "";
if($scope.selectedFilter != "--")
return_value = "-F /pineapple/modules/ettercap/filters/" + $scope.selectedFilter + " ";
if ($scope.proto != "--")
return_value = $scope.proto + " ";
return return_value;
}
return return_value;
}
function updateVisualization() {
var return_value = "";
if($scope.visualization != "--")
return_value = $scope.visualization + " ";
return return_value;
}
function updateProto() {
var return_value = "";
if($scope.proto != "--")
return_value = $scope.proto + " ";
return return_value;
}
$scope.getInterfaces = (function() {
$api.request({
module: 'ettercap',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'ettercap',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
});
});
$scope.getInterfaces();
$scope.getFilters();
$scope.update();
$rootScope.$watch('status.refreshFilters', function(param) {
if(param) {
if (param) {
$scope.getFilters();
}
});
@ -398,30 +396,29 @@ registerController('ettercap_EditorController', ['$api', '$scope', '$rootScope',
$scope.getFilters = (function() {
$api.request({
module: 'ettercap',
action: 'getFilters',
compiled: false
}, function(response) {
$scope.filters = response;
});
module: 'ettercap',
action: 'getFilters',
compiled: false
}, function(response) {
$scope.filters = response;
});
});
$scope.showFilter = (function() {
$scope.output = "";
if($scope.selectedFilter != "--") {
if ($scope.selectedFilter != "--") {
$scope.filterName = $scope.selectedFilter;
$scope.saveFilter = "Save Filter";
$api.request({
module: 'ettercap',
action: 'showFilter',
filter: $scope.selectedFilter
}, function(response) {
$scope.filterData = response.filterData;
});
}
else {
module: 'ettercap',
action: 'showFilter',
filter: $scope.selectedFilter
}, function(response) {
$scope.filterData = response.filterData;
});
} else {
$scope.filterName = "";
$scope.filterData = "";
$scope.saveFilter = "New Filter";
@ -438,108 +435,104 @@ registerController('ettercap_EditorController', ['$api', '$scope', '$rootScope',
action: 'deleteFilter',
filter: $scope.selectedFilter
}, function(response) {
$scope.deleteFilterLabel = "success";
$scope.deleteFilter = "Deleted";
$scope.deleteFilterLabel = "success";
$scope.deleteFilter = "Deleted";
$timeout(function(){
$scope.deleteFilterLabel = "danger";
$scope.deleteFilter = "Delete Filter";
$scope.deleting = false;
}, 2000);
$timeout(function() {
$scope.deleteFilterLabel = "danger";
$scope.deleteFilter = "Delete Filter";
$scope.deleting = false;
}, 2000);
$scope.getFilters();
$scope.selectedFilter = '--';
$scope.filterName = "";
$scope.filterData = "";
$scope.getFilters();
$scope.selectedFilter = '--';
$scope.filterName = "";
$scope.filterData = "";
$scope.saveFilter = "New Filter";
$scope.saveFilter = "New Filter";
$rootScope.status.refreshFilters = true;
$rootScope.status.refreshFilters = true;
});
});
$scope.compileFilterData = (function() {
if($scope.selectedFilter != "--" && $scope.filterName != "")
{
$scope.compileFilterLabel = "warning";
$scope.compileFilter = "Compiling...";
$scope.compiling = true;
if ($scope.selectedFilter != "--" && $scope.filterName != "") {
$scope.compileFilterLabel = "warning";
$scope.compileFilter = "Compiling...";
$scope.compiling = true;
$api.request({
module: 'ettercap',
action: 'compileFilterData',
filterData: $scope.filterData,
filter: $scope.selectedFilter
}, function(response) {
$scope.compileFilterLabel = "success";
$scope.compileFilter = "Compiled";
$api.request({
module: 'ettercap',
action: 'compileFilterData',
filterData: $scope.filterData,
filter: $scope.selectedFilter
}, function(response) {
$scope.compileFilterLabel = "success";
$scope.compileFilter = "Compiled";
$timeout(function(){
$scope.compileFilterLabel = "primary";
$scope.compileFilter = "Compile Filter";
$scope.compiling = false;
}, 2000);
$timeout(function() {
$scope.compileFilterLabel = "primary";
$scope.compileFilter = "Compile Filter";
$scope.compiling = false;
}, 2000);
$rootScope.status.refreshFilters = true;
$rootScope.status.refreshFilters = true;
$scope.output = response;
});
$scope.output = response;
});
}
});
$scope.saveFilterData = (function() {
if($scope.selectedFilter != "--" && $scope.filterName != "")
{
$scope.saveFilterLabel = "warning";
$scope.saveFilter = "Saving...";
$scope.saving = true;
if ($scope.selectedFilter != "--" && $scope.filterName != "") {
$scope.saveFilterLabel = "warning";
$scope.saveFilter = "Saving...";
$scope.saving = true;
$api.request({
module: 'ettercap',
action: 'saveFilterData',
filterData: $scope.filterData,
filter: $scope.selectedFilter
}, function(response) {
$scope.saveFilterLabel = "success";
$scope.saveFilter = "Saved";
$api.request({
module: 'ettercap',
action: 'saveFilterData',
filterData: $scope.filterData,
filter: $scope.selectedFilter
}, function(response) {
$scope.saveFilterLabel = "success";
$scope.saveFilter = "Saved";
$timeout(function(){
$scope.saveFilterLabel = "primary";
$scope.saveFilter = "Save Filter";
$scope.saving = false;
}, 2000);
});
}
else if($scope.selectedFilter == "--" && $scope.filterName != "")
{
$scope.saveFilterLabel = "warning";
$scope.saveFilter = "Saving...";
$scope.saving = true;
$timeout(function() {
$scope.saveFilterLabel = "primary";
$scope.saveFilter = "Save Filter";
$scope.saving = false;
}, 2000);
});
} else if ($scope.selectedFilter == "--" && $scope.filterName != "") {
$scope.saveFilterLabel = "warning";
$scope.saveFilter = "Saving...";
$scope.saving = true;
if($scope.filterName.search(".filter") == -1)
$scope.filterName = $scope.filterName + ".filter";
if ($scope.filterName.search(".filter") == -1)
$scope.filterName = $scope.filterName + ".filter";
$api.request({
module: 'ettercap',
action: 'saveFilterData',
filterData: $scope.filterData,
filter: $scope.filterName
}, function(response) {
$scope.saveFilterLabel = "success";
$scope.saveFilter = "Saved";
$api.request({
module: 'ettercap',
action: 'saveFilterData',
filterData: $scope.filterData,
filter: $scope.filterName
}, function(response) {
$scope.saveFilterLabel = "success";
$scope.saveFilter = "Saved";
$timeout(function(){
$scope.saveFilterLabel = "primary";
$scope.saveFilter = "Save Filter";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveFilterLabel = "primary";
$scope.saveFilter = "Save Filter";
$scope.saving = false;
}, 2000);
$scope.getFilters();
$scope.selectedFilter = $scope.filterName;
$scope.getFilters();
$scope.selectedFilter = $scope.filterName;
$rootScope.status.refreshFIlters = true;
});
}
$rootScope.status.refreshFIlters = true;
});
}
});
$scope.getFilters();

1
ettercap/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "ettercap",
"version": "1.5"
"version": "1.6"
}

View File

@ -46,8 +46,8 @@ if [ "$1" = "install" ]; then
uci commit ettercap.module.installed
elif [ "$1" = "remove" ]; then
opkg remove ettercap
rm -rf /etc/config/ettercap
opkg remove ettercap
rm -rf /etc/config/ettercap
fi
rm /tmp/ettercap.progress

View File

@ -11,6 +11,6 @@ if [ "$1" = "start" ]; then
eval ${MYCMD}
rm -rf /tmp/ettercap.run
elif [ "$1" = "stop" ]; then
killall -9 ettercap
killall -9 ettercap
rm -rf /tmp/ettercap.run
fi

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class ngrep extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,265 +35,239 @@ class ngrep extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getProfiles':
$this->getProfiles();
break;
case 'showProfile':
$this->showProfile();
break;
case 'deleteProfile':
$this->deleteProfile();
break;
case 'saveProfileData':
$this->saveProfileData();
break;
case 'getProfiles':
$this->getProfiles();
break;
case 'showProfile':
$this->showProfile();
break;
case 'deleteProfile':
$this->deleteProfile();
break;
case 'saveProfileData':
$this->saveProfileData();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("ngrep.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("ngrep.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/ngrep/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/ngrep/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("ngrep"))
{
$this->execBackground("/pineapple/modules/ngrep/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/ngrep/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("ngrep")) {
$this->execBackground("/pineapple/modules/ngrep/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/ngrep/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/ngrep.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/ngrep.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function togglengrep()
{
if(!$this->checkRunning("ngrep"))
{
$full_cmd = $this->request->command . " -O /pineapple/modules/ngrep/log/log_".time().".pcap >> /pineapple/modules/ngrep/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/ngrep.run");
if (!$this->checkRunning("ngrep")) {
$full_cmd = $this->request->command . " -O /pineapple/modules/ngrep/log/log_".time().".pcap >> /pineapple/modules/ngrep/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/ngrep.run");
$this->execBackground("/pineapple/modules/ngrep/scripts/ngrep.sh start");
}
else
{
$this->execBackground("/pineapple/modules/ngrep/scripts/ngrep.sh stop");
}
}
$this->execBackground("/pineapple/modules/ngrep/scripts/ngrep.sh start");
} else {
$this->execBackground("/pineapple/modules/ngrep/scripts/ngrep.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/ngrep.progress'))
{
if (!$this->checkDependency("ngrep"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/ngrep.progress')) {
if (!$this->checkDependency("ngrep")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("ngrep"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if ($this->checkRunning("ngrep")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function refreshOutput()
{
if ($this->checkDependency("ngrep"))
{
if ($this->checkRunning("ngrep"))
{
$path = "/pineapple/modules/ngrep/log";
private function refreshOutput()
{
if ($this->checkDependency("ngrep")) {
if ($this->checkRunning("ngrep")) {
$path = "/pineapple/modules/ngrep/log";
$latest_ctime = 0;
$latest_filename = '';
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ngrep/log/".$latest_filename));
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ngrep/log/".$latest_filename));
if ($this->request->filter != "")
{
$filter = $this->request->filter;
if ($this->request->filter != "") {
$filter = $this->request->filter;
$cmd = "cat /pineapple/modules/ngrep/log/".$latest_filename." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/ngrep/log/".$latest_filename;
}
$cmd = "cat /pineapple/modules/ngrep/log/".$latest_filename." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/ngrep/log/".$latest_filename;
}
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "ngrep is not running...";
}
}
else
{
$this->response = "ngrep is not installed...";
}
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "ngrep is not running...";
}
} else {
$this->response = "ngrep is not installed...";
}
}
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/ngrep/log/*.pcap"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/ngrep/log/*.pcap"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i],".pcap");
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i], ".pcap");
echo json_encode(array($entryDate, $entryName.".log", $entryName.".pcap"));
echo json_encode(array($entryDate, $entryName.".log", $entryName.".pcap"));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/ngrep/log/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/ngrep/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ngrep/log/".$this->request->file));
exec ("strings /pineapple/modules/ngrep/log/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/ngrep/log/".$this->request->file));
exec("strings /pineapple/modules/ngrep/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
$file = basename($this->request->file,".pcap");
exec("rm -rf /pineapple/modules/ngrep/log/".$file.".*");
}
private function deleteHistory()
{
$file = basename($this->request->file, ".pcap");
exec("rm -rf /pineapple/modules/ngrep/log/".$file.".*");
}
private function getProfiles()
{
$this->response = array();
$profileList = array_reverse(glob("/pineapple/modules/ngrep/profiles/*"));
array_push($this->response, array("text" => "--", "value" => "--"));
foreach ($profileList as $profile) {
$profileData = file_get_contents('/pineapple/modules/ngrep/profiles/'.basename($profile));
array_push($this->response, array("text" => basename($profile), "value" => $profileData));
}
}
private function getProfiles()
{
$this->response = array();
$profileList = array_reverse(glob("/pineapple/modules/ngrep/profiles/*"));
array_push($this->response, array("text" => "--", "value" => "--"));
foreach ($profileList as $profile) {
$profileData = file_get_contents('/pineapple/modules/ngrep/profiles/'.basename($profile));
array_push($this->response, array("text" => basename($profile), "value" => $profileData));
}
}
private function showProfile()
{
$profileData = file_get_contents('/pineapple/modules/ngrep/profiles/'.$this->request->profile);
$this->response = array("profileData" => $profileData);
}
private function showProfile()
{
$profileData = file_get_contents('/pineapple/modules/ngrep/profiles/'.$this->request->profile);
$this->response = array("profileData" => $profileData);
}
private function deleteProfile()
{
exec("rm -rf /pineapple/modules/ngrep/profiles/".$this->request->profile);
}
private function saveProfileData()
{
$filename = "/pineapple/modules/ngrep/profiles/".$this->request->profile;
file_put_contents($filename, $this->request->profileData);
}
private function deleteProfile()
{
exec("rm -rf /pineapple/modules/ngrep/profiles/".$this->request->profile);
}
private function saveProfileData()
{
$filename = "/pineapple/modules/ngrep/profiles/".$this->request->profile;
file_put_contents($filename, $this->request->profileData);
}
}

View File

@ -2,17 +2,17 @@ registerController('ngrep_Controller', ['$api', '$scope', '$rootScope', '$interv
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'ngrep',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'ngrep',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -29,31 +29,31 @@ registerController('ngrep_ControlsController', ['$api', '$scope', '$rootScope',
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false,
refreshProfiles : false
installed: false,
refreshOutput: false,
refreshHistory: false,
refreshProfiles: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "ngrep",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
module: "ngrep",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
})
});
})
});
$scope.togglengrep = (function() {
if($scope.status != "Stop")
$scope.togglengrep = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -65,103 +65,100 @@ registerController('ngrep_ControlsController', ['$api', '$scope', '$rootScope',
$rootScope.status.refreshHistory = false;
$api.request({
module: 'ngrep',
action: 'togglengrep',
command: $rootScope.command
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'ngrep',
action: 'togglengrep',
command: $rootScope.command
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
}, 2000);
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'ngrep',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'ngrep',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'ngrep',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'ngrep',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
$scope.refreshStatus();
}]);
registerController('ngrep_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "ngrep",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
module: "ngrep",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -170,52 +167,52 @@ registerController('ngrep_HistoryController', ['$api', '$scope', '$rootScope', f
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "ngrep",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$scope.refreshHistory = (function() {
$api.request({
module: "ngrep",
action: "viewHistory",
module: "ngrep",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "ngrep",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
})
});
$scope.deleteHistory = (function(param) {
$scope.deleteHistory = (function(param) {
$api.request({
module: "ngrep",
action: "deleteHistory",
module: "ngrep",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'ngrep',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'ngrep',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -223,127 +220,128 @@ registerController('ngrep_HistoryController', ['$api', '$scope', '$rootScope', f
}]);
registerController('ngrep_OptionsController', ['$api', '$scope', '$rootScope', function($api, $scope, $rootScope) {
$scope.command = "ngrep ";
$scope.command = "ngrep ";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.profiles = [];
$scope.selectedProfile = "--";
$scope.profiles = [];
$scope.selectedProfile = "--";
$scope.filter = "";
$scope.expression = "";
$scope.format = "--";
$scope.filter = "";
$scope.expression = "";
$scope.format = "--";
$scope.options = {
option1 : false,
option2 : false,
option3 : false,
option4 : false,
option5 : false,
option6 : false,
option7 : false,
option8 : false,
option9 : false,
option10 : false,
option11 : false,
option12 : false,
option13 : false
};
$scope.options = {
option1: false,
option2: false,
option3: false,
option4: false,
option5: false,
option6: false,
option7: false,
option8: false,
option9: false,
option10: false,
option11: false,
option12: false,
option13: false
};
$scope.update = (function(param) {
if(updateProfile() != "")
$scope.command = "ngrep " + updateInterface() + updateOptions() + updateFormat() + updateProfile();
else
$scope.command = "ngrep " + updateInterface() + updateOptions() + updateFormat() + updateExpression() + updateFilter();
$scope.update = (function(param) {
if (updateProfile() != "")
$scope.command = "ngrep " + updateInterface() + updateOptions() + updateFormat() + updateProfile();
else
$scope.command = "ngrep " + updateInterface() + updateOptions() + updateFormat() + updateExpression() + updateFilter();
$rootScope.command = $scope.command;
$rootScope.command = $scope.command;
});
function updateInterface() {
var return_value = "";
if ($scope.selectedInterface != "--")
return_value = "-d " + $scope.selectedInterface + " ";
return return_value;
}
function updateProfile() {
var return_value = "";
if ($scope.selectedProfile != "--")
return_value = $scope.selectedProfile + " ";
return return_value;
}
function updateOptions() {
var return_value = "";
angular.forEach($scope.options, function(value, key) {
if (value != false)
return_value += value + " ";
});
function updateInterface() {
var return_value = "";
return return_value;
}
if($scope.selectedInterface != "--")
return_value = "-d " + $scope.selectedInterface + " ";
function updateFormat() {
var return_value = "";
return return_value;
}
if ($scope.format != "--")
return_value = $scope.format + " ";
function updateProfile() {
var return_value = "";
return return_value;
}
if($scope.selectedProfile != "--")
return_value = $scope.selectedProfile + " ";
function updateExpression() {
var return_value = "";
return return_value;
}
if ($scope.expression != "")
return_value = "'" + $scope.expression + "' ";
function updateOptions() {
var return_value = "";
return return_value;
}
angular.forEach($scope.options, function(value, key) {
if(value != false)
return_value += value + " ";
});
function updateFilter() {
var return_value = "";
return return_value;
}
if ($scope.filter != "")
return_value = "'" + $scope.filter + "' ";
function updateFormat() {
var return_value = "";
return return_value;
}
if($scope.format != "--")
return_value = $scope.format + " ";
return return_value;
}
function updateExpression() {
var return_value = "";
if($scope.expression != "")
return_value = "'" + $scope.expression + "' ";
return return_value;
}
function updateFilter() {
var return_value = "";
if($scope.filter != "")
return_value = "'" + $scope.filter + "' ";
return return_value;
}
$scope.getInterfaces = (function() {
$api.request({
module: 'ngrep',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
});
});
$scope.getProfiles = (function() {
$api.request({
module: 'ngrep',
action: 'getProfiles'
}, function(response) {
$scope.profiles = response;
$scope.selectedProfile = "--";
$rootScope.status.refreshProfiles = false;
});
});
$scope.getInterfaces();
$scope.getProfiles();
$rootScope.$watch('status.refreshProfiles', function(param) {
if(param) {
$scope.getProfiles();
}
$scope.getInterfaces = (function() {
$api.request({
module: 'ngrep',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
});
});
$scope.getProfiles = (function() {
$api.request({
module: 'ngrep',
action: 'getProfiles'
}, function(response) {
$scope.profiles = response;
$scope.selectedProfile = "--";
$rootScope.status.refreshProfiles = false;
});
});
$scope.getInterfaces();
$scope.getProfiles();
$scope.update();
$rootScope.$watch('status.refreshProfiles', function(param) {
if (param) {
$scope.getProfiles();
}
});
}]);
@ -364,29 +362,28 @@ registerController('ngrep_EditorController', ['$api', '$scope', '$rootScope', '$
$scope.getProfiles = (function(param) {
$api.request({
module: 'ngrep',
action: 'getProfiles'
}, function(response) {
$scope.profiles = response;
});
module: 'ngrep',
action: 'getProfiles'
}, function(response) {
$scope.profiles = response;
});
});
$scope.showProfile = (function() {
$scope.output = "";
if($scope.selectedProfile != "--") {
if ($scope.selectedProfile != "--") {
$scope.profileName = $scope.selectedProfile;
$scope.saveProfile = "Save Profile";
$api.request({
module: 'ngrep',
action: 'showProfile',
profile: $scope.selectedProfile
}, function(response) {
$scope.profileData = response.profileData;
});
}
else {
module: 'ngrep',
action: 'showProfile',
profile: $scope.selectedProfile
}, function(response) {
$scope.profileData = response.profileData;
});
} else {
$scope.profileName = "";
$scope.profileData = "";
$scope.saveProfile = "New Profile";
@ -403,76 +400,73 @@ registerController('ngrep_EditorController', ['$api', '$scope', '$rootScope', '$
action: 'deleteProfile',
profile: $scope.selectedProfile
}, function(response) {
$scope.deleteProfileLabel = "success";
$scope.deleteProfile = "Deleted";
$scope.deleteProfileLabel = "success";
$scope.deleteProfile = "Deleted";
$timeout(function(){
$scope.deleteProfileLabel = "danger";
$scope.deleteProfile = "Delete Profile";
$scope.deleting = false;
}, 2000);
$timeout(function() {
$scope.deleteProfileLabel = "danger";
$scope.deleteProfile = "Delete Profile";
$scope.deleting = false;
}, 2000);
$scope.getProfiles();
$scope.selectedProfile = '--';
$scope.profileName = "";
$scope.profileData = "";
$scope.getProfiles();
$scope.selectedProfile = '--';
$scope.profileName = "";
$scope.profileData = "";
$scope.saveProfile = "New Profile";
$scope.saveProfile = "New Profile";
$rootScope.status.refreshProfiles = true;
$rootScope.status.refreshProfiles = true;
});
});
$scope.saveProfileData = (function() {
if($scope.selectedProfile != "--" && $scope.profileName != "")
{
$scope.saveProfileLabel = "warning";
$scope.saveProfile = "Saving...";
$scope.saving = true;
if ($scope.selectedProfile != "--" && $scope.profileName != "") {
$scope.saveProfileLabel = "warning";
$scope.saveProfile = "Saving...";
$scope.saving = true;
$api.request({
module: 'ngrep',
action: 'saveProfileData',
profileData: $scope.profileData,
profile: $scope.selectedProfile
}, function(response) {
$scope.saveProfileLabel = "success";
$scope.saveProfile = "Saved";
$api.request({
module: 'ngrep',
action: 'saveProfileData',
profileData: $scope.profileData,
profile: $scope.selectedProfile
}, function(response) {
$scope.saveProfileLabel = "success";
$scope.saveProfile = "Saved";
$timeout(function(){
$scope.saveProfileLabel = "primary";
$scope.saveProfile = "Save Profile";
$scope.saving = false;
}, 2000);
});
}
else if($scope.selectedProfile == "--" && $scope.profileName != "")
{
$scope.saveProfileLabel = "warning";
$scope.saveProfile = "Saving...";
$scope.saving = true;
$timeout(function() {
$scope.saveProfileLabel = "primary";
$scope.saveProfile = "Save Profile";
$scope.saving = false;
}, 2000);
});
} else if ($scope.selectedProfile == "--" && $scope.profileName != "") {
$scope.saveProfileLabel = "warning";
$scope.saveProfile = "Saving...";
$scope.saving = true;
$api.request({
module: 'ngrep',
action: 'saveProfileData',
profileData: $scope.profileData,
profile: $scope.profileName
}, function(response) {
$scope.saveProfileLabel = "success";
$scope.saveProfile = "Saved";
$api.request({
module: 'ngrep',
action: 'saveProfileData',
profileData: $scope.profileData,
profile: $scope.profileName
}, function(response) {
$scope.saveProfileLabel = "success";
$scope.saveProfile = "Saved";
$timeout(function(){
$scope.saveProfileLabel = "primary";
$scope.saveProfile = "Save Profile";
$scope.saving = false;
}, 2000);
$timeout(function() {
$scope.saveProfileLabel = "primary";
$scope.saveProfile = "Save Profile";
$scope.saving = false;
}, 2000);
$scope.getProfiles();
$scope.selectedProfile = $scope.profileName;
$scope.getProfiles();
$scope.selectedProfile = $scope.profileName;
$rootScope.status.refreshProfiles = true;
});
}
$rootScope.status.refreshProfiles = true;
});
}
});
$scope.getProfileData = (function() {

1
ngrep/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "ngrep",
"version": "1.5"
"version": "1.6"
}

View File

@ -9,17 +9,14 @@ export PATH=$PATH:/sd/usr/bin:/sd/usr/sbin
}
touch /tmp/ngrep.progress
mkdir -p /tmp/ngrep
wget https://github.com/adde88/openwrt-useful-tools/tree/master -P /tmp/ngrep
NGREP=`grep -F "ngrep_" /tmp/ngrep/master | awk {'print $5'} | awk -F'"' {'print $2'}`
if [ "$1" = "install" ]; then
if [ "$2" = "internal" ]; then
opkg update
opkg install "$NGREP"
opkg update
opkg install ngrep
elif [ "$2" = "sd" ]; then
opkg update
opkg install "$NGREP" --dest sd
opkg install ngrep --dest sd
fi
if [ ! -f /usr/lib/libpcap.so ] && [ -f /usr/lib/libpcap.so.1.3 ]; then
@ -38,4 +35,3 @@ elif [ "$1" = "remove" ]; then
fi
rm /tmp/ngrep.progress
rm -rf /tmp/ngrep

View File

@ -11,6 +11,6 @@ if [ "$1" = "start" ]; then
eval ${MYCMD}
rm -rf /tmp/ngrep.run
elif [ "$1" = "stop" ]; then
killall ngrep
killall -9 ngrep
rm -rf /tmp/ngrep.run
fi

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class nmap extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -19,7 +20,7 @@ class nmap extends Module
case 'togglenmap':
$this->togglenmap();
break;
case 'scanStatus':
case 'scanStatus':
$this->scanStatus();
break;
case 'handleDependencies':
@ -37,193 +38,168 @@ class nmap extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("nmap.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("nmap.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/nmap/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/nmap/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("nmap"))
{
$this->execBackground("/pineapple/modules/nmap/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/nmap/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("nmap")) {
$this->execBackground("/pineapple/modules/nmap/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/nmap/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/nmap.progress'))
{
if (!file_exists('/tmp/nmap.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function scanStatus()
{
if (!$this->checkRunning("nmap"))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
}
}
private function scanStatus()
{
if (!$this->checkRunning("nmap")) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function togglenmap()
{
if(!$this->checkRunning("nmap"))
{
$full_cmd = $this->request->command . " -oN /tmp/nmap.scan 2>&1";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/nmap.run");
if (!$this->checkRunning("nmap")) {
$full_cmd = $this->request->command . " -oN /tmp/nmap.scan 2>&1";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/nmap.run");
$this->execBackground("/pineapple/modules/nmap/scripts/nmap.sh start");
}
else
{
$this->execBackground("/pineapple/modules/nmap/scripts/nmap.sh stop");
}
}
$this->execBackground("/pineapple/modules/nmap/scripts/nmap.sh start");
} else {
$this->execBackground("/pineapple/modules/nmap/scripts/nmap.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/nmap.progress'))
{
if (!$this->checkDependency("nmap"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/nmap.progress')) {
if (!$this->checkDependency("nmap")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("nmap"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if ($this->checkRunning("nmap")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
}
$status = "Start";
$statusLabel = "success";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function refreshOutput()
{
if ($this->checkDependency("nmap"))
{
if ($this->checkRunning("nmap") && file_exists("/tmp/nmap.scan"))
{
$output = file_get_contents("/tmp/nmap.scan");
if(!empty($output))
$this->response = $output;
else
$this->response = "Empty log...";
}
else
{
$this->response = "nmap is not running...";
}
}
else
{
$this->response = "nmap is not installed...";
}
if ($this->checkDependency("nmap")) {
if ($this->checkRunning("nmap") && file_exists("/tmp/nmap.scan")) {
$output = file_get_contents("/tmp/nmap.scan");
if (!empty($output)) {
$this->response = $output;
} else {
$this->response = "Empty log...";
}
} else {
$this->response = "nmap is not running...";
}
} else {
$this->response = "nmap is not installed...";
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/nmap/scan/*"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/nmap/scan/*"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/nmap/scan/".$this->request->file));
exec ("cat /pineapple/modules/nmap/scan/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/nmap/scan/".$this->request->file));
exec("cat /pineapple/modules/nmap/scan/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty scan...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty scan...", "date" => $log_date);
}
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/nmap/scan/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/nmap/scan/".$this->request->file));
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/nmap/scan/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/nmap/scan/".$this->request->file));
}
}

View File

@ -2,17 +2,17 @@ registerController('nmap_Controller', ['$api', '$scope', '$rootScope', '$interva
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'nmap',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'nmap',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -29,30 +29,30 @@ registerController('nmap_ControlsController', ['$api', '$scope', '$rootScope', '
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "nmap",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
module: "nmap",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
})
});
})
});
$scope.togglenmap = (function() {
if($scope.status != "Stop")
$scope.togglenmap = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -61,111 +61,108 @@ registerController('nmap_ControlsController', ['$api', '$scope', '$rootScope', '
$scope.starting = true;
$api.request({
module: 'nmap',
action: 'togglenmap',
command: $rootScope.command
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = false;
module: 'nmap',
action: 'togglenmap',
command: $rootScope.command
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = false;
$scope.starting = false;
$scope.refreshStatus();
$scope.starting = false;
$scope.refreshStatus();
$scope.scanInterval = $interval(function(){
$api.request({
module: 'nmap',
action: 'scanStatus'
}, function(response) {
if (response.success === true){
$interval.cancel($scope.scanInterval);
$rootScope.status.refreshOutput = false;
$rootScope.status.refreshHistory = true;
}
$scope.refreshStatus();
});
}, 5000);
$scope.scanInterval = $interval(function() {
$api.request({
module: 'nmap',
action: 'scanStatus'
}, function(response) {
if (response.success === true) {
$interval.cancel($scope.scanInterval);
$rootScope.status.refreshOutput = false;
$rootScope.status.refreshHistory = true;
}
$scope.refreshStatus();
});
}, 5000);
}, 2000);
})
}, 2000);
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'nmap',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'nmap',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'nmap',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'nmap',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
}]);
registerController('nmap_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "nmap",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
module: "nmap",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -174,52 +171,52 @@ registerController('nmap_HistoryController', ['$api', '$scope', '$rootScope', fu
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "nmap",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$scope.refreshHistory = (function() {
$api.request({
module: "nmap",
action: "viewHistory",
module: "nmap",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "nmap",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
})
});
$scope.deleteHistory = (function(param) {
$scope.deleteHistory = (function(param) {
$api.request({
module: "nmap",
action: "deleteHistory",
module: "nmap",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'nmap',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'nmap',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -227,118 +224,118 @@ registerController('nmap_HistoryController', ['$api', '$scope', '$rootScope', fu
}]);
registerController('nmap_OptionsController', ['$api', '$scope', '$rootScope', function($api, $scope, $rootScope) {
$scope.command = "nmap ";
$scope.target = "";
$scope.command = "nmap ";
$scope.target = "";
$scope.profile = "--";
$scope.timing = "--";
$scope.tcp = "--";
$scope.nontcp = "--";
$scope.profile = "--";
$scope.timing = "--";
$scope.tcp = "--";
$scope.nontcp = "--";
$scope.scanOptions = {
option1 : false,
option2 : false,
option3 : false,
option4 : false,
option5 : false
};
$scope.scanOptions = {
option1: false,
option2: false,
option3: false,
option4: false,
option5: false
};
$scope.pingOptions = {
option1 : false,
option2 : false,
option3 : false,
option4 : false
};
$scope.pingOptions = {
option1: false,
option2: false,
option3: false,
option4: false
};
$scope.targetOptions = {
option1 : false
};
$scope.targetOptions = {
option1: false
};
$scope.otherOptions = {
option1 : false,
option2 : false,
option3 : false,
option4 : false
};
$scope.otherOptions = {
option1: false,
option2: false,
option3: false,
option4: false
};
$scope.update = (function(param) {
if (updateProfile() != "")
$scope.command = "nmap " + updateProfile() + updateTarget();
else
$scope.command = "nmap " + updateTiming() + updateTcp() + updateNontcp() + updateOptions() + updateTarget();
$rootScope.command = $scope.command;
});
$scope.update = (function(param) {
if(updateProfile() != "")
$scope.command = "nmap " + updateProfile() + updateTarget();
else
$scope.command = "nmap " + updateTiming() + updateTcp() + updateNontcp() + updateOptions() + updateTarget();
function updateOptions() {
var return_value = "";
$rootScope.command = $scope.command;
angular.forEach($scope.scanOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
function updateOptions() {
var return_value = "";
angular.forEach($scope.pingOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
angular.forEach($scope.scanOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
angular.forEach($scope.targetOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
angular.forEach($scope.pingOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
angular.forEach($scope.otherOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
angular.forEach($scope.targetOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
return return_value;
}
angular.forEach($scope.otherOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
function updateTarget() {
var return_value = "";
return return_value;
}
return_value = $scope.target;
function updateTarget() {
var return_value = "";
return return_value;
}
return_value = $scope.target;
function updateProfile() {
var return_value = "";
return return_value;
}
if ($scope.profile != "--")
return_value = $scope.profile + " ";
function updateProfile() {
var return_value = "";
return return_value;
}
if($scope.profile != "--")
return_value = $scope.profile + " ";
function updateTiming() {
var return_value = "";
return return_value;
}
if ($scope.timing != "--")
return_value = $scope.timing + " ";
function updateTiming() {
var return_value = "";
return return_value;
}
if($scope.timing != "--")
return_value = $scope.timing + " ";
function updateTcp() {
var return_value = "";
return return_value;
}
if ($scope.tcp != "--")
return_value = $scope.tcp + " ";
function updateTcp() {
var return_value = "";
return return_value;
}
if($scope.tcp != "--")
return_value = $scope.tcp + " ";
function updateNontcp() {
var return_value = "";
return return_value;
}
if ($scope.nontcp != "--")
return_value = $scope.nontcp + " ";
function updateNontcp() {
var return_value = "";
return return_value;
}
if($scope.nontcp != "--")
return_value = $scope.nontcp + " ";
return return_value;
}
$scope.update();
}]);

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "nmap",
"version": "1.6"
"version": "1.7"
}

1
nmap/scan/README.txt Normal file
View File

@ -0,0 +1 @@
Scan results will be saved here.

View File

@ -12,8 +12,8 @@ touch /tmp/nmap.progress
if [ "$1" = "install" ]; then
if [ "$2" = "internal" ]; then
opkg update
opkg install nmap
opkg update
opkg install nmap
elif [ "$2" = "sd" ]; then
opkg update
opkg install nmap --dest sd
@ -30,8 +30,8 @@ if [ "$1" = "install" ]; then
uci commit nmap.module.installed
elif [ "$1" = "remove" ]; then
opkg remove nmap
rm -rf /etc/config/nmap
opkg remove nmap
rm -rf /etc/config/nmap
fi
rm /tmp/nmap.progress

View File

@ -12,7 +12,7 @@ if [ "$1" = "start" ]; then
mv /tmp/nmap.scan /pineapple/modules/nmap/scan/scan_${MYTIME}
rm -rf /tmp/nmap.run
elif [ "$1" = "stop" ]; then
killall nmap
killall -9 nmap
rm -rf /tmp/nmap.run
rm -rf /tmp/nmap.scan
fi

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class p0f extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,265 +35,234 @@ class p0f extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'togglep0fOnBoot':
$this->togglep0fOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'togglep0fOnBoot':
$this->togglep0fOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("p0f.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("p0f.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/p0f/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/p0f/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("p0f"))
{
$this->execBackground("/pineapple/modules/p0f/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/p0f/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("p0f")) {
$this->execBackground("/pineapple/modules/p0f/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/p0f/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/p0f.progress'))
{
if (!file_exists('/tmp/p0f.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function togglep0fOnBoot()
{
if(exec("cat /etc/rc.local | grep p0f/scripts/autostart_p0f.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/p0f/scripts/autostart_p0f.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/p0f\/scripts\/autostart_p0f.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep p0f/scripts/autostart_p0f.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/p0f/scripts/autostart_p0f.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/p0f\/scripts\/autostart_p0f.sh/d' /etc/rc.local");
}
}
private function togglep0f()
{
if(!$this->checkRunning("p0f"))
{
$this->uciSet("p0f.run.interface", $this->request->interface);
if (!$this->checkRunning("p0f")) {
$this->uciSet("p0f.run.interface", $this->request->interface);
$this->execBackground("/pineapple/modules/p0f/scripts/p0f.sh start");
}
else
{
$this->uciSet("p0f.run.interface", '');
$this->execBackground("/pineapple/modules/p0f/scripts/p0f.sh start");
} else {
$this->uciSet("p0f.run.interface", '');
$this->execBackground("/pineapple/modules/p0f/scripts/p0f.sh stop");
}
}
$this->execBackground("/pineapple/modules/p0f/scripts/p0f.sh stop");
}
}
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("p0f.run.interface"));
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("p0f.run.interface"));
}
private function refreshStatus()
{
if (!file_exists('/tmp/p0f.progress'))
{
if (!$this->checkDependency("p0f"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/p0f.progress')) {
if (!$this->checkDependency("p0f")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if($this->checkRunning("p0f"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("p0f")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep p0f/scripts/autostart_p0f.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if (exec("cat /etc/rc.local | grep p0f/scripts/autostart_p0f.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$verbose = false;
$status = "Not running";
$statusLabel = "danger";
$verbose = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
private function refreshOutput()
{
if ($this->checkDependency("p0f"))
{
if ($this->checkRunning("p0f"))
{
$path = "/pineapple/modules/p0f/log";
if ($this->checkDependency("p0f")) {
if ($this->checkRunning("p0f")) {
$path = "/pineapple/modules/p0f/log";
$latest_ctime = 0;
$latest_filename = '';
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/p0f/log/".$latest_filename));
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/p0f/log/".$latest_filename));
if ($this->request->filter != "")
{
$filter = $this->request->filter;
if ($this->request->filter != "") {
$filter = $this->request->filter;
$cmd = "cat /pineapple/modules/p0f/log/".$latest_filename." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/p0f/log/".$latest_filename;
}
$cmd = "cat /pineapple/modules/p0f/log/".$latest_filename." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/p0f/log/".$latest_filename;
}
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "p0f is not running...";
}
}
else
{
$this->response = "p0f is not installed...";
}
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "p0f is not running...";
}
} else {
$this->response = "p0f is not installed...";
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/p0f/log/*"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/p0f/log/*"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/p0f/log/".$this->request->file));
exec ("cat /pineapple/modules/p0f/log/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/p0f/log/".$this->request->file));
exec("cat /pineapple/modules/p0f/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/p0f/log/".$this->request->file);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/p0f/log/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/p0f/log/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/p0f/log/".$this->request->file));
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("p0f.autostart.interface", $settings->interface);
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("p0f.autostart.interface", $settings->interface);
}
}

View File

@ -2,17 +2,17 @@ registerController('p0f_Controller', ['$api', '$scope', '$rootScope', '$interval
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'p0f',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'p0f',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,33 +37,33 @@ registerController('p0f_ControlsController', ['$api', '$scope', '$rootScope', '$
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "p0f",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "p0f",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.togglep0f = (function() {
if($scope.status != "Stop")
$scope.togglep0f = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -75,149 +75,145 @@ registerController('p0f_ControlsController', ['$api', '$scope', '$rootScope', '$
$rootScope.status.refreshHistory = false;
$api.request({
module: 'p0f',
action: 'togglep0f',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'p0f',
action: 'togglep0f',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
}, 2000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'p0f',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'p0f',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.togglep0fOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.togglep0fOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'p0f',
action: 'togglep0fOnBoot',
}, function(response) {
module: 'p0f',
action: 'togglep0fOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'p0f',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'p0f',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'p0f',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'p0f',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'p0f',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'p0f',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('p0f_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope,$interval) {
$scope.output = 'Loading...';
registerController('p0f_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "p0f",
action: "refreshOutput",
module: "p0f",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -226,52 +222,52 @@ registerController('p0f_HistoryController', ['$api', '$scope', '$rootScope', fun
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "p0f",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.refreshHistory = (function() {
$api.request({
module: "p0f",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "p0f",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "p0f",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "p0f",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "p0f",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'p0f',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
$api.request({
module: 'p0f',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});

1
p0f/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "p0f",
"version": "1.1"
"version": "1.2"
}

View File

@ -32,8 +32,8 @@ if [ "$1" = "install" ]; then
uci commit p0f.module.installed
elif [ "$1" = "remove" ]; then
opkg remove p0f
rm -rf /etc/config/p0f
opkg remove p0f
rm -rf /etc/config/p0f
fi
rm /tmp/p0f.progress

View File

@ -8,7 +8,7 @@ MYTIME=`date +%s`
MYINTERFACE=`uci get p0f.run.interface`
if [ "$1" = "start" ]; then
p0f -i ${MYINTERFACE} -o /pineapple/modules/p0f/log/output_${MYTIME}.log
p0f -i ${MYINTERFACE} -o /pineapple/modules/p0f/log/output_${MYTIME}.log
elif [ "$1" = "stop" ]; then
killall -9 p0f
fi

View File

@ -1,19 +1,20 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class tcpdump extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'clearOutput':
case 'clearOutput':
$this->clearOutput();
break;
case 'refreshStatus':
@ -37,199 +38,177 @@ class tcpdump extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
case 'downloadHistory':
$this->downloadHistory();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("tcpdump.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("tcpdump.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/tcpdump/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/tcpdump/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("tcpdump"))
{
$this->execBackground("/pineapple/modules/tcpdump/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/tcpdump/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("tcpdump")) {
$this->execBackground("/pineapple/modules/tcpdump/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/tcpdump/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/tcpdump.progress'))
{
if (!file_exists('/tmp/tcpdump.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggletcpdump()
{
if(!$this->checkRunning("tcpdump"))
{
$full_cmd = $this->request->command . " -w /pineapple/modules/tcpdump/dump/dump_".time().".pcap 2> /tmp/tcpdump_capture.log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/tcpdump.run");
if (!$this->checkRunning("tcpdump")) {
$full_cmd = $this->request->command . " -w /pineapple/modules/tcpdump/dump/dump_".time().".pcap 2> /tmp/tcpdump_capture.log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/tcpdump.run");
$this->execBackground("/pineapple/modules/tcpdump/scripts/tcpdump.sh start");
}
else
{
$this->execBackground("/pineapple/modules/tcpdump/scripts/tcpdump.sh stop");
}
}
$this->execBackground("/pineapple/modules/tcpdump/scripts/tcpdump.sh start");
} else {
$this->execBackground("/pineapple/modules/tcpdump/scripts/tcpdump.sh stop");
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/tcpdump.progress'))
{
if (!$this->checkDependency("tcpdump"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/tcpdump.progress')) {
if (!$this->checkDependency("tcpdump")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("tcpdump"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
if ($this->checkRunning("tcpdump")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function refreshOutput()
{
if ($this->checkDependency("tcpdump"))
{
if (file_exists("/tmp/tcpdump_capture.log"))
{
$output = file_get_contents("/tmp/tcpdump_capture.log");
if(!empty($output))
$this->response = $output;
else
$this->response = "tcpdump is running...";
}
else
{
$this->response = "tcpdump is not running...";
}
}
else
{
$this->response = "tcpdump is not installed...";
}
}
if ($this->checkDependency("tcpdump")) {
if (file_exists("/tmp/tcpdump_capture.log")) {
$output = file_get_contents("/tmp/tcpdump_capture.log");
if (!empty($output)) {
$this->response = $output;
} else {
$this->response = "tcpdump is running...";
}
} else {
$this->response = "tcpdump is not running...";
}
} else {
$this->response = "tcpdump is not installed...";
}
}
private function clearOutput()
{
exec("rm -rf /tmp/tcpdump_capture.log");
}
private function clearOutput()
{
exec("rm -rf /tmp/tcpdump_capture.log");
}
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
$this->response = array();
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
foreach ($interfaceArray as $interface) {
array_push($this->response, $interface);
}
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/tcpdump/dump/*.pcap"));
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/tcpdump/dump/*.pcap"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/tcpdump/dump/".$this->request->file));
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/tcpdump/dump/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/tcpdump/dump/".$this->request->file));
exec ("strings /pineapple/modules/tcpdump/dump/".$this->request->file, $output);
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/tcpdump/dump/".$this->request->file));
exec("strings /pineapple/modules/tcpdump/dump/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty dump...", "date" => $log_date);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/tcpdump/dump/".$this->request->file);
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty dump...", "date" => $log_date);
}
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/tcpdump/dump/".$this->request->file);
}
}

1
tcpdump/dump/README.txt Normal file
View File

@ -0,0 +1 @@
Dumps will be saved here.

View File

@ -2,17 +2,17 @@ registerController('tcpdump_Controller', ['$api', '$scope', '$rootScope', '$inte
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'tcpdump',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'tcpdump',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -29,30 +29,30 @@ registerController('tcpdump_ControlsController', ['$api', '$scope', '$rootScope'
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "tcpdump",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
module: "tcpdump",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
})
});
})
});
$scope.toggletcpdump = (function() {
if($scope.status != "Stop")
$scope.toggletcpdump = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -64,105 +64,102 @@ registerController('tcpdump_ControlsController', ['$api', '$scope', '$rootScope'
$rootScope.status.refreshHistory = false;
$api.request({
module: 'tcpdump',
action: 'toggletcpdump',
command: $rootScope.command
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'tcpdump',
action: 'toggletcpdump',
command: $rootScope.command
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
}, 2000);
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'tcpdump',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'tcpdump',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'tcpdump',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'tcpdump',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.refreshStatus();
$scope.refreshStatus();
}]);
registerController('tcpdump_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.output = 'Loading...';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "tcpdump",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
module: "tcpdump",
action: "refreshOutput"
}, function(response) {
$scope.output = response;
})
});
$scope.clearOutput = (function() {
$api.request({
module: "tcpdump",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
module: "tcpdump",
action: "clearOutput"
}, function(response) {
$scope.refreshOutput();
})
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -171,52 +168,52 @@ registerController('tcpdump_HistoryController', ['$api', '$scope', '$rootScope',
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "tcpdump",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$scope.refreshHistory = (function() {
$api.request({
module: "tcpdump",
action: "viewHistory",
module: "tcpdump",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "tcpdump",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
})
});
$scope.deleteHistory = (function(param) {
$scope.deleteHistory = (function(param) {
$api.request({
module: "tcpdump",
action: "deleteHistory",
module: "tcpdump",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'tcpdump',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$api.request({
module: 'tcpdump',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});
@ -224,108 +221,109 @@ registerController('tcpdump_HistoryController', ['$api', '$scope', '$rootScope',
}]);
registerController('tcpdump_OptionsController', ['$api', '$scope', '$rootScope', function($api, $scope, $rootScope) {
$scope.command = "tcpdump ";
$scope.command = "tcpdump ";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.interfaces = [];
$scope.selectedInterface = "--";
$scope.filter = "";
$scope.timestamp = "--";
$scope.resolve = "--";
$scope.verbose = "--";
$scope.filter = "";
$scope.timestamp = "--";
$scope.resolve = "--";
$scope.verbose = "--";
$scope.dumpOptions = {
option1 : false,
option2 : false,
option3 : false,
option4 : false,
option5 : false,
option6 : false
};
$scope.dumpOptions = {
option1: false,
option2: false,
option3: false,
option4: false,
option5: false,
option6: false
};
$scope.update = (function(param) {
if(updateFilter() != "")
$scope.command = "tcpdump " + updateInterface() + updateVerbose() + updateRevolve() + updateTimestamp() + updateOptions() + '\'' + updateFilter( )+ '\'';
else
$scope.command = "tcpdump " + updateInterface() + updateVerbose() + updateRevolve() + updateTimestamp() + updateOptions()
$scope.update = (function(param) {
if (updateFilter() != "")
$scope.command = "tcpdump " + updateInterface() + updateVerbose() + updateRevolve() + updateTimestamp() + updateOptions() + '\'' + updateFilter() + '\'';
else
$scope.command = "tcpdump " + updateInterface() + updateVerbose() + updateRevolve() + updateTimestamp() + updateOptions()
$rootScope.command = $scope.command;
$rootScope.command = $scope.command;
});
$scope.appendFilter = (function(param) {
if ($scope.filter.substr($scope.filter.length - 1) != ' ' && $scope.filter.length != 0)
$scope.filter = $scope.filter + ' ' + param;
else
$scope.filter = $scope.filter + param;
$scope.update();
});
function updateInterface() {
var return_value = "";
if ($scope.selectedInterface != "--")
return_value = "-i " + $scope.selectedInterface + " ";
return return_value;
}
function updateOptions() {
var return_value = "";
angular.forEach($scope.dumpOptions, function(value, key) {
if (value != false)
return_value += value + " ";
});
$scope.appendFilter = (function(param) {
if($scope.filter.substr($scope.filter.length-1) != ' ' && $scope.filter.length != 0)
$scope.filter = $scope.filter + ' ' + param;
else
$scope.filter = $scope.filter + param;
return return_value;
}
$scope.update();
function updateFilter() {
var return_value = "";
if ($scope.filter != "")
return_value = $scope.filter;
return return_value;
}
function updateVerbose() {
var return_value = "";
if ($scope.verbose != "--")
return_value = $scope.verbose + " ";
return return_value;
}
function updateRevolve() {
var return_value = "";
if ($scope.resolve != "--")
return_value = $scope.resolve + " ";
return return_value;
}
function updateTimestamp() {
var return_value = "";
if ($scope.timestamp != "--")
return_value = $scope.timestamp + " ";
return return_value;
}
$scope.getInterfaces = (function() {
$api.request({
module: 'tcpdump',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
$scope.selectedInterface = "--";
});
function updateInterface() {
var return_value = "";
if($scope.selectedInterface != "--")
return_value = "-i " + $scope.selectedInterface + " ";
return return_value;
}
function updateOptions() {
var return_value = "";
angular.forEach($scope.dumpOptions, function(value, key) {
if(value != false)
return_value += value + " ";
});
return return_value;
}
function updateFilter() {
var return_value = "";
if($scope.filter != "")
return_value = $scope.filter;
return return_value;
}
function updateVerbose() {
var return_value = "";
if($scope.verbose != "--")
return_value = $scope.verbose + " ";
return return_value;
}
function updateRevolve() {
var return_value = "";
if($scope.resolve != "--")
return_value = $scope.resolve + " ";
return return_value;
}
function updateTimestamp() {
var return_value = "";
if($scope.timestamp != "--")
return_value = $scope.timestamp + " ";
return return_value;
}
$scope.getInterfaces = (function() {
$api.request({
module: 'tcpdump',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response;
$scope.selectedInterface = "--";
});
});
});
$scope.getInterfaces();
$scope.update();
}]);

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "tcpdump",
"version": "1.5"
"version": "1.7"
}

View File

@ -11,6 +11,6 @@ if [ "$1" = "start" ]; then
eval ${MYCMD}
rm -rf /tmp/tcpdump.run
elif [ "$1" = "stop" ]; then
killall tcpdump
killall -9 tcpdump
rm -rf /tmp/tcpdump.run
fi

View File

@ -1,16 +1,17 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
class urlsnarf extends Module
{
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
case 'refreshInfo':
$this->refreshInfo();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshStatus':
@ -34,265 +35,233 @@ class urlsnarf extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleurlsnarfOnBoot':
$this->toggleurlsnarfOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'toggleurlsnarfOnBoot':
$this->toggleurlsnarfOnBoot();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'saveAutostartSettings':
$this->saveAutostartSettings();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("urlsnarf.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("urlsnarf.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/urlsnarf/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/urlsnarf/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("urlsnarf"))
{
$this->execBackground("/pineapple/modules/urlsnarf/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/urlsnarf/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("urlsnarf")) {
$this->execBackground("/pineapple/modules/urlsnarf/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/urlsnarf/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/urlsnarf.progress'))
{
if (!file_exists('/tmp/urlsnarf.progress')) {
$this->response = array('success' => true);
}
else
{
} else {
$this->response = array('success' => false);
}
}
private function toggleurlsnarfOnBoot()
{
if(exec("cat /etc/rc.local | grep urlsnarf/scripts/autostart_urlsnarf.sh") == "")
{
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/urlsnarf/scripts/autostart_urlsnarf.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
}
else
{
exec("sed -i '/urlsnarf\/scripts\/autostart_urlsnarf.sh/d' /etc/rc.local");
}
}
if (exec("cat /etc/rc.local | grep urlsnarf/scripts/autostart_urlsnarf.sh") == "") {
exec("sed -i '/exit 0/d' /etc/rc.local");
exec("echo /pineapple/modules/urlsnarf/scripts/autostart_urlsnarf.sh >> /etc/rc.local");
exec("echo exit 0 >> /etc/rc.local");
} else {
exec("sed -i '/urlsnarf\/scripts\/autostart_urlsnarf.sh/d' /etc/rc.local");
}
}
private function toggleurlsnarf()
{
if(!$this->checkRunning("urlsnarf"))
{
$this->uciSet("urlsnarf.run.interface", $this->request->interface);
if (!$this->checkRunning("urlsnarf")) {
$this->uciSet("urlsnarf.run.interface", $this->request->interface);
$this->execBackground("/pineapple/modules/urlsnarf/scripts/urlsnarf.sh start");
}
else
{
$this->uciSet("urlsnarf.run.interface", '');
$this->execBackground("/pineapple/modules/urlsnarf/scripts/urlsnarf.sh start");
} else {
$this->uciSet("urlsnarf.run.interface", '');
$this->execBackground("/pineapple/modules/urlsnarf/scripts/urlsnarf.sh stop");
}
}
$this->execBackground("/pineapple/modules/urlsnarf/scripts/urlsnarf.sh stop");
}
}
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
private function getInterfaces()
{
exec("cat /proc/net/dev | tail -n +3 | cut -f1 -d: | sed 's/ //g'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("urlsnarf.run.interface"));
}
$this->response = array("interfaces" => $interfaceArray, "selected" => $this->uciGet("urlsnarf.run.interface"));
}
private function refreshStatus()
{
if (!file_exists('/tmp/urlsnarf.progress'))
{
if (!$this->checkDependency("urlsnarf"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/urlsnarf.progress')) {
if (!$this->checkDependency("urlsnarf")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
$status = "Start";
$statusLabel = "success";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if($this->checkRunning("urlsnarf"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
if ($this->checkRunning("urlsnarf")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
if(exec("cat /etc/rc.local | grep urlsnarf/scripts/autostart_urlsnarf.sh") == "")
{
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
if (exec("cat /etc/rc.local | grep urlsnarf/scripts/autostart_urlsnarf.sh") == "") {
$bootLabelON = "default";
$bootLabelOFF = "danger";
} else {
$bootLabelON = "success";
$bootLabelOFF = "default";
}
}
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$bootLabelON = "default";
$bootLabelOFF = "danger";
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Not running";
$statusLabel = "danger";
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$bootLabelON = "default";
$bootLabelOFF = "danger";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
private function refreshOutput()
{
if ($this->checkDependency("urlsnarf")) {
if ($this->checkRunning("urlsnarf")) {
$path = "/pineapple/modules/urlsnarf/log";
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "bootLabelON" => $bootLabelON, "bootLabelOFF" => $bootLabelOFF, "processing" => $processing);
}
$latest_ctime = 0;
$latest_filename = '';
private function refreshOutput()
{
if ($this->checkDependency("urlsnarf"))
{
if ($this->checkRunning("urlsnarf"))
{
$path = "/pineapple/modules/urlsnarf/log";
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
$latest_ctime = 0;
$latest_filename = '';
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/urlsnarf/log/".$latest_filename));
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if ($this->request->filter != "") {
$filter = $this->request->filter;
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/urlsnarf/log/".$latest_filename));
$cmd = "cat /pineapple/modules/urlsnarf/log/".$latest_filename." | ".$filter;
} else {
$cmd = "cat /pineapple/modules/urlsnarf/log/".$latest_filename;
}
if ($this->request->filter != "")
{
$filter = $this->request->filter;
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "urlsnarf is not running...";
}
} else {
$this->response = "urlsnarf is not installed...";
}
}
$cmd = "cat /pineapple/modules/urlsnarf/log/".$latest_filename." | ".$filter;
}
else
{
$cmd = "cat /pineapple/modules/urlsnarf/log/".$latest_filename;
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/urlsnarf/log/*"));
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "urlsnarf is not running...";
}
}
else
{
$this->response = "urlsnarf is not installed...";
}
}
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/urlsnarf/log/*"));
echo json_encode(array($entryDate, $entryName));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
echo json_encode(array($entryDate, $entryName));
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/urlsnarf/log/".$this->request->file));
exec("cat /pineapple/modules/urlsnarf/log/".$this->request->file, $output);
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/urlsnarf/log/".$this->request->file));
exec ("cat /pineapple/modules/urlsnarf/log/".$this->request->file, $output);
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/urlsnarf/log/".$this->request->file);
}
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/urlsnarf/log/".$this->request->file);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/urlsnarf/log/".$this->request->file));
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("urlsnarf.autostart.interface", $settings->interface);
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/urlsnarf/log/".$this->request->file));
}
private function saveAutostartSettings()
{
$settings = $this->request->settings;
$this->uciSet("urlsnarf.autostart.interface", $settings->interface);
}
}

View File

@ -2,17 +2,17 @@ registerController('urlsnarf_Controller', ['$api', '$scope', '$rootScope', '$int
$scope.title = "Loading...";
$scope.version = "Loading...";
$scope.refreshInfo = (function() {
$scope.refreshInfo = (function() {
$api.request({
module: 'urlsnarf',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v"+response.version;
})
});
module: 'urlsnarf',
action: "refreshInfo"
}, function(response) {
$scope.title = response.title;
$scope.version = "v" + response.version;
})
});
$scope.refreshInfo();
$scope.refreshInfo();
}]);
@ -37,33 +37,33 @@ registerController('urlsnarf_ControlsController', ['$api', '$scope', '$rootScope
$scope.sdAvailable = false;
$rootScope.status = {
installed : false,
refreshOutput : false,
refreshHistory : false
installed: false,
refreshOutput: false,
refreshHistory: false
};
$scope.refreshStatus = (function() {
$scope.refreshStatus = (function() {
$api.request({
module: "urlsnarf",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
module: "urlsnarf",
action: "refreshStatus"
}, function(response) {
$scope.status = response.status;
$scope.statusLabel = response.statusLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if(response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$rootScope.status.installed = response.installed;
$scope.device = response.device;
$scope.sdAvailable = response.sdAvailable;
if (response.processing) $scope.processing = true;
$scope.install = response.install;
$scope.installLabel = response.installLabel;
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.bootLabelON = response.bootLabelON;
$scope.bootLabelOFF = response.bootLabelOFF;
})
});
$scope.toggleurlsnarf = (function() {
if($scope.status != "Stop")
$scope.toggleurlsnarf = (function() {
if ($scope.status != "Stop")
$scope.status = "Starting...";
else
$scope.status = "Stopping...";
@ -75,150 +75,146 @@ registerController('urlsnarf_ControlsController', ['$api', '$scope', '$rootScope
$rootScope.status.refreshHistory = false;
$api.request({
module: 'urlsnarf',
action: 'toggleurlsnarf',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function(){
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
module: 'urlsnarf',
action: 'toggleurlsnarf',
interface: $scope.selectedInterface
}, function(response) {
$timeout(function() {
$rootScope.status.refreshOutput = true;
$rootScope.status.refreshHistory = true;
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.starting = false;
$scope.refreshStatus();
}, 2000);
})
});
$scope.saveAutostartSettings = (function() {
$api.request({
module: 'urlsnarf',
action: 'saveAutostartSettings',
settings: { interface : $scope.selectedInterface }
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function(){
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
module: 'urlsnarf',
action: 'saveAutostartSettings',
settings: {
interface: $scope.selectedInterface
}
}, function(response) {
$scope.saveSettingsLabel = "success";
$timeout(function() {
$scope.saveSettingsLabel = "default";
}, 2000);
})
});
$scope.toggleurlsnarfOnBoot = (function() {
if($scope.bootLabelON == "default")
{
$scope.toggleurlsnarfOnBoot = (function() {
if ($scope.bootLabelON == "default") {
$scope.bootLabelON = "success";
$scope.bootLabelOFF = "default";
}
else
{
} else {
$scope.bootLabelON = "default";
$scope.bootLabelOFF = "danger";
}
$api.request({
module: 'urlsnarf',
action: 'toggleurlsnarfOnBoot',
}, function(response) {
module: 'urlsnarf',
action: 'toggleurlsnarfOnBoot',
}, function(response) {
$scope.refreshStatus();
})
});
})
});
$scope.handleDependencies = (function(param) {
if(!$rootScope.status.installed)
$scope.handleDependencies = (function(param) {
if (!$rootScope.status.installed)
$scope.install = "Installing...";
else
$scope.install = "Removing...";
$api.request({
module: 'urlsnarf',
action: 'handleDependencies',
destination: param
}, function(response){
if (response.success === true) {
module: 'urlsnarf',
action: 'handleDependencies',
destination: param
}, function(response) {
if (response.success === true) {
$scope.installLabel = "warning";
$scope.processing = true;
$scope.handleDependenciesInterval = $interval(function(){
$api.request({
module: 'urlsnarf',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true){
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.handleDependenciesInterval = $interval(function() {
$api.request({
module: 'urlsnarf',
action: 'handleDependenciesStatus'
}, function(response) {
if (response.success === true) {
$scope.processing = false;
$interval.cancel($scope.handleDependenciesInterval);
$scope.refreshStatus();
}
});
}, 5000);
}
});
});
$scope.getInterfaces = (function() {
$api.request({
module: 'urlsnarf',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if(response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
module: 'urlsnarf',
action: 'getInterfaces'
}, function(response) {
$scope.interfaces = response.interfaces;
if (response.selected != "")
$scope.selectedInterface = response.selected;
else
$scope.selectedInterface = $scope.interfaces[0];
});
});
$scope.refreshStatus();
$scope.getInterfaces();
}]);
registerController('urlsnarf_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope,$interval) {
$scope.output = 'Loading...';
registerController('urlsnarf_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
$scope.output = 'Loading...';
$scope.filter = '';
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
$scope.refreshOutput = (function() {
$scope.refreshOutput = (function() {
$api.request({
module: "urlsnarf",
action: "refreshOutput",
module: "urlsnarf",
action: "refreshOutput",
filter: $scope.filter
}, function(response) {
$scope.output = response;
})
});
}, function(response) {
$scope.output = response;
})
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.clearFilter = (function() {
$scope.filter = '';
$scope.refreshOutput();
});
$scope.toggleAutoRefresh = (function() {
if($scope.autoRefreshInterval)
{
$scope.toggleAutoRefresh = (function() {
if ($scope.autoRefreshInterval) {
$interval.cancel($scope.autoRefreshInterval);
$scope.autoRefreshInterval = null;
$scope.refreshLabelON = "default";
$scope.refreshLabelOFF = "danger";
}
else
{
} else {
$scope.refreshLabelON = "success";
$scope.refreshLabelOFF = "default";
$scope.autoRefreshInterval = $interval(function(){
$scope.autoRefreshInterval = $interval(function() {
$scope.refreshOutput();
}, 5000);
}, 5000);
}
});
});
$scope.refreshOutput();
$scope.refreshOutput();
$rootScope.$watch('status.refreshOutput', function(param) {
if(param) {
$scope.refreshOutput();
}
});
$rootScope.$watch('status.refreshOutput', function(param) {
if (param) {
$scope.refreshOutput();
}
});
}]);
@ -227,52 +223,52 @@ registerController('urlsnarf_HistoryController', ['$api', '$scope', '$rootScope'
$scope.historyOutput = 'Loading...';
$scope.historyDate = 'Loading...';
$scope.refreshHistory = (function() {
$api.request({
module: "urlsnarf",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.refreshHistory = (function() {
$api.request({
module: "urlsnarf",
action: "refreshHistory"
}, function(response) {
$scope.history = response;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "urlsnarf",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.viewHistory = (function(param) {
$api.request({
module: "urlsnarf",
action: "viewHistory",
file: param
}, function(response) {
$scope.historyOutput = response.output;
$scope.historyDate = response.date;
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "urlsnarf",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.deleteHistory = (function(param) {
$api.request({
module: "urlsnarf",
action: "deleteHistory",
file: param
}, function(response) {
$scope.refreshHistory();
})
});
$scope.downloadHistory = (function(param) {
$api.request({
module: 'urlsnarf',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$api.request({
module: 'urlsnarf',
action: 'downloadHistory',
file: param
}, function(response) {
if (response.error === undefined) {
window.location = '/api/?download=' + response.download;
}
});
});
$scope.refreshHistory();
$rootScope.$watch('status.refreshHistory', function(param) {
if(param) {
if (param) {
$scope.refreshHistory();
}
});

1
urlsnarf/log/README.txt Normal file
View File

@ -0,0 +1 @@
Logs will be saved here.

View File

@ -6,5 +6,5 @@
"tetra"
],
"title": "urlsnarf",
"version": "1.4"
"version": "1.5"
}

View File

@ -28,8 +28,8 @@ if [ "$1" = "install" ]; then
uci commit urlsnarf.module.installed
elif [ "$1" = "remove" ]; then
opkg remove urlsnarf
rm -rf /etc/config/urlsnarf
opkg remove urlsnarf
rm -rf /etc/config/urlsnarf
fi
rm /tmp/urlsnarf.progress

View File

@ -8,7 +8,7 @@ MYTIME=`date +%s`
MYINTERFACE=`uci get urlsnarf.run.interface`
if [ "$1" = "start" ]; then
urlsnarf -i ${MYINTERFACE} > /pineapple/modules/urlsnarf/log/output_${MYTIME}.log
urlsnarf -i ${MYINTERFACE} > /pineapple/modules/urlsnarf/log/output_${MYTIME}.log
elif [ "$1" = "stop" ]; then
killall urlsnarf
fi

View File

@ -1,67 +1,71 @@
<?php namespace pineapple;
class iwlist_parser{
function iwlist_parser(){
}
class iwlist_parser
{
public function iwlist_parser()
{
}
function parseString( $string ){
if(empty($string)) return false;
public function parseString($string)
{
if (empty($string)) {
return false;
}
// Rueckgabe dieser Funktion:
// $array[device][Cell#][Cell-Feld] = Wert
// z.b. $array[eth0][1][ESSID] = "MGees_WLan"
// Rueckgabe dieser Funktion:
// $array[device][Cell#][Cell-Feld] = Wert
// z.b. $array[eth0][1][ESSID] = "MGees_WLan"
$ergebnis = array();
$ergebnis = array();
$string = explode( "\n", $string );
$string = explode("\n", $string);
$device = $cell = "";
$device = $cell = "";
foreach($string as $zeile){
if(substr( $zeile, 0, 1 ) != ' '){
$device = substr($zeile, 0, strpos($zeile, ' '));
$ergebnis[$device] = array();
}
else{
$zeile = trim($zeile);
// Zeile kann sein:
// Cell ## - Address: Wert
// Feld:Wert
// Quality=bla Signal Level=bla2
if(substr($zeile, 0, 5) == 'Cell '){
$cell = (int)substr($zeile, 5, 2);
$ergebnis[$device][$cell] = array();
$doppelp_pos = strpos($zeile, ':');
$ergebnis[$device][$cell]['Address'] =
trim(substr($zeile, $doppelp_pos + 1));
}
elseif(substr($zeile, 0, 8) == 'Quality='){
$first_eq_pos = strpos($zeile, '=');
$last_eq_pos = strrpos($zeile, '=');
$slash_pos = strpos($zeile, '/') - $first_eq_pos;
//$ergebnis[$device][$cell]['Quality'] = trim(substr($zeile, $first_eq_pos + 1, $slash_pos - 1));
$ergebnis[$device][$cell]['Quality'] = trim(number_format (substr($zeile, $first_eq_pos + 1, $slash_pos - 1) * 100 / 70, 0));
$ergebnis[$device][$cell]['Signal level'] = trim(substr($zeile, $last_eq_pos + 1));
}
else{
$doppelp_pos = strpos($zeile, ':');
$feld = trim( substr( $zeile, 0, $doppelp_pos ) );
if(!empty($ergebnis[$device][$cell][$feld]))
$ergebnis[$device][$cell][$feld] .= "\n";
// Leer- und "-Zeichen rausschmeissen - ESSID steht immer in ""
@$ergebnis[$device][$cell][$feld] .= trim(str_replace('"', '', substr($zeile, $doppelp_pos + 1)));
}
}
}
return $ergebnis;
}
foreach ($string as $zeile) {
if (substr($zeile, 0, 1) != ' ') {
$device = substr($zeile, 0, strpos($zeile, ' '));
$ergebnis[$device] = array();
} else {
$zeile = trim($zeile);
// Zeile kann sein:
// Cell ## - Address: Wert
// Feld:Wert
// Quality=bla Signal Level=bla2
if (substr($zeile, 0, 5) == 'Cell ') {
$cell = (int)substr($zeile, 5, 2);
$ergebnis[$device][$cell] = array();
$doppelp_pos = strpos($zeile, ':');
$ergebnis[$device][$cell]['Address'] =
trim(substr($zeile, $doppelp_pos + 1));
} elseif (substr($zeile, 0, 8) == 'Quality=') {
$first_eq_pos = strpos($zeile, '=');
$last_eq_pos = strrpos($zeile, '=');
$slash_pos = strpos($zeile, '/') - $first_eq_pos;
//$ergebnis[$device][$cell]['Quality'] = trim(substr($zeile, $first_eq_pos + 1, $slash_pos - 1));
$ergebnis[$device][$cell]['Quality'] = trim(number_format(substr($zeile, $first_eq_pos + 1, $slash_pos - 1) * 100 / 70, 0));
$ergebnis[$device][$cell]['Signal level'] = trim(substr($zeile, $last_eq_pos + 1));
} else {
$doppelp_pos = strpos($zeile, ':');
$feld = trim(substr($zeile, 0, $doppelp_pos));
if (!empty($ergebnis[$device][$cell][$feld])) {
$ergebnis[$device][$cell][$feld] .= "\n";
}
// Leer- und "-Zeichen rausschmeissen - ESSID steht immer in ""
@$ergebnis[$device][$cell][$feld] .= trim(str_replace('"', '', substr($zeile, $doppelp_pos + 1)));
}
}
}
return $ergebnis;
}
function parseScanAll(){
return $this -> parseString( shell_exec( "iwlist scan 2> /dev/null" ));
}
public function parseScanAll()
{
return $this -> parseString(shell_exec("iwlist scan 2> /dev/null"));
}
function parseScanDev( $device ){
return $this -> parseString( shell_exec( "iwlist ".$device." scan 2> /dev/null" ));
}
public function parseScanDev($device)
{
return $this -> parseString(shell_exec("iwlist ".$device." scan 2> /dev/null"));
}
}
?>

View File

@ -1,4 +1,5 @@
<?php namespace pineapple;
putenv('LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH').':/sd/lib:/sd/usr/lib');
putenv('PATH='.getenv('PATH').':/sd/usr/bin:/sd/usr/sbin');
@ -6,13 +7,13 @@ require_once('/pineapple/modules/wps/api/iwlist_parser.php');
class wps extends Module
{
public function __construct($request)
{
parent::__construct($request, __CLASS__);
$this->iwlistparse = new iwlist_parser();
}
public function __construct($request)
{
parent::__construct($request, __CLASS__);
$this->iwlistparse = new iwlist_parser();
}
public function route()
public function route()
{
switch ($this->request->action) {
case 'refreshInfo':
@ -21,40 +22,40 @@ class wps extends Module
case 'refreshStatus':
$this->refreshStatus();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'refreshOutput':
$this->refreshOutput();
break;
case 'handleDependencies':
$this->handleDependencies();
break;
case 'handleDependenciesStatus':
$this->handleDependenciesStatus();
break;
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMonitors':
$this->getMonitors();
break;
case 'startMonitor':
$this->startMonitor();
break;
case 'stopMonitor':
$this->stopMonitor();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'togglewps':
$this->togglewps();
break;
case 'getProcesses':
$this->getProcesses();
break;
case 'refreshHistory':
case 'getInterfaces':
$this->getInterfaces();
break;
case 'getMonitors':
$this->getMonitors();
break;
case 'startMonitor':
$this->startMonitor();
break;
case 'stopMonitor':
$this->stopMonitor();
break;
case 'scanForNetworks':
$this->scanForNetworks();
break;
case 'getMACInfo':
$this->getMACInfo();
break;
case 'togglewps':
$this->togglewps();
break;
case 'getProcesses':
$this->getProcesses();
break;
case 'refreshHistory':
$this->refreshHistory();
break;
case 'viewHistory':
@ -63,410 +64,400 @@ class wps extends Module
case 'deleteHistory':
$this->deleteHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
case 'downloadHistory':
$this->downloadHistory();
break;
}
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("wps.module.installed")));
}
protected function checkDependency($dependencyName)
{
return ((exec("which {$dependencyName}") == '' ? false : true) && ($this->uciGet("wps.module.installed")));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function getDevice()
{
return trim(exec("cat /proc/cpuinfo | grep machine | awk -F: '{print $2}'"));
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function checkRunning($processName)
{
return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/wps/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
protected function refreshInfo()
{
$moduleInfo = @json_decode(file_get_contents("/pineapple/modules/wps/module.info"));
$this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version);
}
private function handleDependencies()
{
if(!$this->checkDependency("reaver"))
{
$this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
}
else
{
$this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
if (!$this->checkDependency("reaver")) {
$this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh install ".$this->request->destination);
$this->response = array('success' => true);
} else {
$this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh remove");
$this->response = array('success' => true);
}
}
private function handleDependenciesStatus()
{
if (!file_exists('/tmp/wps.progress'))
{
$this->response = array('success' => true);
}
else
{
$this->response = array('success' => false);
if (!file_exists('/tmp/wps.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
private function refreshStatus()
{
if (!file_exists('/tmp/wps.progress'))
{
if(!$this->checkDependency("iwlist"))
{
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
if (!file_exists('/tmp/wps.progress')) {
if (!$this->checkDependency("iwlist")) {
$installed = false;
$install = "Not installed";
$installLabel = "danger";
$processing = false;
$status = "Start";
$statusLabel = "success";
}
else
{
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
$status = "Start";
$statusLabel = "success";
} else {
$installed = true;
$install = "Installed";
$installLabel = "success";
$processing = false;
if ($this->checkRunning("reaver") || $this->checkRunning("bully"))
{
$status = "Stop";
$statusLabel = "danger";
}
else
{
$status = "Start";
$statusLabel = "success";
}
}
}
else
{
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
}
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function togglewps()
{
if(!($this->checkRunning("reaver") || $this->checkRunning("bully")))
{
$full_cmd = $this->request->command . " -o /pineapple/modules/wps/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/wps.run");
$this->execBackground("/pineapple/modules/wps/scripts/wps.sh start");
}
else
{
$this->execBackground("/pineapple/modules/wps/scripts/wps.sh stop");
}
}
private function refreshOutput()
{
if ($this->checkDependency("reaver") && $this->checkDependency("bully"))
{
if($this->checkRunning("reaver") || $this->checkRunning("bully"))
{
$path = "/pineapple/modules/wps/log";
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if($latest_filename != "")
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/wps/log/".$latest_filename));
$cmd = "cat /pineapple/modules/wps/log/".$latest_filename;
exec ($cmd, $output);
if(!empty($output))
$this->response = implode("\n", array_reverse($output));
else
$this->response = "Empty log...";
}
}
else
{
$this->response = "wps is not running...";
}
}
else
{
$this->response = "wps is not installed...";
}
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | grep -v \"mon*\" | awk '{print $1}'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray);
}
private function getMonitors()
{
exec("iwconfig 2> /dev/null | grep \"mon*\" | awk '{print $1}'", $monitorArray);
$this->response = array("monitors" => $monitorArray);
}
private function startMonitor()
{
exec("airmon-ng start ".$this->request->interface);
}
private function stopMonitor()
{
exec("airmon-ng stop ".$this->request->monitor);
}
private function scanForNetworks()
{
if($this->request->duration && $this->request->monitor != "")
{
exec("killall -9 airodump-ng && rm -rf /tmp/wps-*");
$this->execBackground("airodump-ng -a --output-format cap -w /tmp/wps ".$this->request->monitor." &> /dev/null");
sleep($this->request->duration);
exec("wash -f /tmp/wps-01.cap -o /tmp/wps-01.wash &> /dev/null");
exec("killall -9 airodump-ng");
}
$p = $this->iwlistparse->parseScanDev($this->request->interface);
$apArray = $p[$this->request->interface];
$returnArray = array();
foreach ($apArray as $apData) {
$accessPoint = array();
$accessPoint['mac'] = $apData["Address"];
$accessPoint['ssid'] = $apData["ESSID"];
$accessPoint['channel'] = intval($apData["Channel"]);
$frequencyData = explode(' ', $apData["Frequency"]);
$accessPoint['frequency'] = $frequencyData[0];
$accessPoint['signal'] = $apData["Signal level"];
$accessPoint['quality'] = intval($apData["Quality"]);
if($apData["Quality"] <= 25) $accessPoint['qualityLabel'] = "danger";
else if($apData["Quality"] <= 50) $accessPoint['qualityLabel'] = "warning";
else if($apData["Quality"] <= 100) $accessPoint['qualityLabel'] = "success";
if(exec("cat /tmp/wps_capture.lock") == $apData["Address"]) $accessPoint['captureOnSelected'] = 1;
else $accessPoint['captureOnSelected'] = 0;
if($this->checkRunning("airodump-ng")) $accessPoint['captureRunning'] = 1;
else $accessPoint['captureRunning'] = 0;
if(exec("cat /tmp/wps_deauth.lock") == $apData["Address"]) $accessPoint['deauthOnSelected'] = 1;
else $accessPoint['deauthOnSelected'] = 0;
if($this->checkRunning("aireplay-ng")) $accessPoint['deauthRunning'] = 1;
else $accessPoint['deauthRunning'] = 0;
if($apData["Encryption key"] == "on")
{
$WPA = strstr($apData["IE"], "WPA Version 1");
$WPA2 = strstr($apData["IE"], "802.11i/WPA2 Version 1");
$auth_type = str_replace("\n"," ",$apData["Authentication Suites (1)"]);
$auth_type = implode(' ',array_unique(explode(' ', $auth_type)));
$cipher = $apData["Pairwise Ciphers (2)"] ? $apData["Pairwise Ciphers (2)"] : $apData["Pairwise Ciphers (1)"];
$cipher = str_replace("\n"," ",$cipher);
$cipher = implode(', ',array_unique(explode(' ', $cipher)));
if($WPA2 != "" && $WPA != "") $accessPoint['encryption'] = 'Mixed WPA/WPA2';
else if($WPA2 != "") $accessPoint['encryption'] = 'WPA2';
else if($WPA != "") $accessPoint['encryption'] = 'WPA';
else $accessPoint['encryption'] = 'WEP';
$accessPoint['cipher'] = $cipher;
$accessPoint['auth'] = $auth_type;
}
else
{
$accessPoint['encryption'] = 'None';
$accessPoint['cipher'] = '';
$accessPoint['auth'] = '';
}
if($this->request->duration && $this->request->monitor != "")
{
$wps_enabled = trim(exec("cat /tmp/wps-01.wash | tail -n +3 | grep ".$accessPoint['mac']." | awk '{ print $5; }'"));
if($wps_enabled == "No" || $wps_enabled == "Yes")
{
$accessPoint['wps'] = "Yes";
$accessPoint['wpsLabel'] = "success";
}
else
{
$accessPoint['wps'] = "No";
$accessPoint['wpsLabel'] = "";
}
}
else
{
$accessPoint['wps'] = "--";
}
array_push($returnArray, $accessPoint);
}
exec("rm -rf /tmp/wps-*");
$this->response = $returnArray;
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getProcesses()
{
$returnArray = array();
$process = array();
if (file_exists("/tmp/wps.run") && ($this->checkRunning("reaver") || $this->checkRunning("bully")) )
{
$args = $this->parse_args(file_get_contents("/tmp/wps.run"));
$process['ssid'] = $args["e"];
$process['mac'] = $args["b"];
$process['channel'] = $args["c"];
if($args["reaver"]) $process['name'] = "reaver";
else if($args["bully"]) $process['name'] = "bully";
array_push($returnArray, $process);
}
$this->response = $returnArray;
}
private function parse_args($args) {
if(is_string($args)){
$args = str_replace(array('=', "\'", '\"'), array('= ', '&#39;', '&#34;'), $args);
$args = str_getcsv($args, ' ', '"');
$tmp = array();
foreach($args as $arg){
if(!empty($arg) && $arg != "&#39;" && $arg != "=" && $arg != " "){
$tmp[] = str_replace(array('= ', '&#39;', '&#34;'), array('=', "'", '"'), trim($arg));
}
}
$args = $tmp;
}
$out = array();
$args_size = count($args);
for($i = 0; $i < $args_size; $i++){
$value = false;
if( substr($args[$i], 0, 2) == '--' ){
$key = rtrim(substr($args[$i], 2), '=');
$out[$key] = true;
}else if( substr($args[$i], 0, 1) == '-' ){
$key = rtrim(substr($args[$i], 1), '=');
$opt = str_split($key);
$opt_size = count($opt);
if( $opt_size > 1){
for ($n=0; $n < $opt_size; $n++) {
$key = $opt[$n];
$out[$key] = true;
if ($this->checkRunning("reaver") || $this->checkRunning("bully")) {
$status = "Stop";
$statusLabel = "danger";
} else {
$status = "Start";
$statusLabel = "success";
}
}
}else{
$value = $args[$i];
} else {
$installed = false;
$install = "Installing...";
$installLabel = "warning";
$processing = true;
$status = "Start";
$statusLabel = "success";
}
if( isset($key) ){
if( isset($out[$key]) ){
if( is_bool($out[$key]) ){
$device = $this->getDevice();
$sdAvailable = $this->isSDAvailable();
$this->response = array("device" => $device, "sdAvailable" => $sdAvailable, "status" => $status, "statusLabel" => $statusLabel, "installed" => $installed, "install" => $install, "installLabel" => $installLabel, "processing" => $processing);
}
private function togglewps()
{
if (!($this->checkRunning("reaver") || $this->checkRunning("bully"))) {
$full_cmd = $this->request->command . " -o /pineapple/modules/wps/log/log_".time().".log";
shell_exec("echo -e \"{$full_cmd}\" > /tmp/wps.run");
$this->execBackground("/pineapple/modules/wps/scripts/wps.sh start");
} else {
$this->execBackground("/pineapple/modules/wps/scripts/wps.sh stop");
}
}
private function refreshOutput()
{
if ($this->checkDependency("reaver") && $this->checkDependency("bully")) {
if ($this->checkRunning("reaver") || $this->checkRunning("bully")) {
$path = "/pineapple/modules/wps/log";
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
if ($latest_filename != "") {
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/wps/log/".$latest_filename));
$cmd = "cat /pineapple/modules/wps/log/".$latest_filename;
exec($cmd, $output);
if (!empty($output)) {
$this->response = implode("\n", array_reverse($output));
} else {
$this->response = "Empty log...";
}
}
} else {
$this->response = "wps is not running...";
}
} else {
$this->response = "wps is not installed...";
}
}
private function getInterfaces()
{
exec("iwconfig 2> /dev/null | grep \"wlan*\" | grep -v \"mon*\" | awk '{print $1}'", $interfaceArray);
$this->response = array("interfaces" => $interfaceArray);
}
private function getMonitors()
{
exec("iwconfig 2> /dev/null | grep \"mon*\" | awk '{print $1}'", $monitorArray);
$this->response = array("monitors" => $monitorArray);
}
private function startMonitor()
{
exec("airmon-ng start ".$this->request->interface);
}
private function stopMonitor()
{
exec("airmon-ng stop ".$this->request->monitor);
}
private function scanForNetworks()
{
if ($this->request->duration && $this->request->monitor != "") {
exec("killall -9 airodump-ng && rm -rf /tmp/wps-*");
$this->execBackground("airodump-ng -a --output-format cap -w /tmp/wps ".$this->request->monitor." &> /dev/null");
sleep($this->request->duration);
exec("wash -f /tmp/wps-01.cap -o /tmp/wps-01.wash &> /dev/null");
exec("killall -9 airodump-ng");
}
$p = $this->iwlistparse->parseScanDev($this->request->interface);
$apArray = $p[$this->request->interface];
$returnArray = array();
foreach ($apArray as $apData) {
$accessPoint = array();
$accessPoint['mac'] = $apData["Address"];
$accessPoint['ssid'] = $apData["ESSID"];
$accessPoint['channel'] = intval($apData["Channel"]);
$frequencyData = explode(' ', $apData["Frequency"]);
$accessPoint['frequency'] = $frequencyData[0];
$accessPoint['signal'] = $apData["Signal level"];
$accessPoint['quality'] = intval($apData["Quality"]);
if ($apData["Quality"] <= 25) {
$accessPoint['qualityLabel'] = "danger";
} elseif ($apData["Quality"] <= 50) {
$accessPoint['qualityLabel'] = "warning";
} elseif ($apData["Quality"] <= 100) {
$accessPoint['qualityLabel'] = "success";
}
if (exec("cat /tmp/wps_capture.lock") == $apData["Address"]) {
$accessPoint['captureOnSelected'] = 1;
} else {
$accessPoint['captureOnSelected'] = 0;
}
if ($this->checkRunning("airodump-ng")) {
$accessPoint['captureRunning'] = 1;
} else {
$accessPoint['captureRunning'] = 0;
}
if (exec("cat /tmp/wps_deauth.lock") == $apData["Address"]) {
$accessPoint['deauthOnSelected'] = 1;
} else {
$accessPoint['deauthOnSelected'] = 0;
}
if ($this->checkRunning("aireplay-ng")) {
$accessPoint['deauthRunning'] = 1;
} else {
$accessPoint['deauthRunning'] = 0;
}
if ($apData["Encryption key"] == "on") {
$WPA = strstr($apData["IE"], "WPA Version 1");
$WPA2 = strstr($apData["IE"], "802.11i/WPA2 Version 1");
$auth_type = str_replace("\n", " ", $apData["Authentication Suites (1)"]);
$auth_type = implode(' ', array_unique(explode(' ', $auth_type)));
$cipher = $apData["Pairwise Ciphers (2)"] ? $apData["Pairwise Ciphers (2)"] : $apData["Pairwise Ciphers (1)"];
$cipher = str_replace("\n", " ", $cipher);
$cipher = implode(', ', array_unique(explode(' ', $cipher)));
if ($WPA2 != "" && $WPA != "") {
$accessPoint['encryption'] = 'Mixed WPA/WPA2';
} elseif ($WPA2 != "") {
$accessPoint['encryption'] = 'WPA2';
} elseif ($WPA != "") {
$accessPoint['encryption'] = 'WPA';
} else {
$accessPoint['encryption'] = 'WEP';
}
$accessPoint['cipher'] = $cipher;
$accessPoint['auth'] = $auth_type;
} else {
$accessPoint['encryption'] = 'None';
$accessPoint['cipher'] = '';
$accessPoint['auth'] = '';
}
if ($this->request->duration && $this->request->monitor != "") {
$wps_enabled = trim(exec("cat /tmp/wps-01.wash | tail -n +3 | grep ".$accessPoint['mac']." | awk '{ print $5; }'"));
if ($wps_enabled == "No" || $wps_enabled == "Yes") {
$accessPoint['wps'] = "Yes";
$accessPoint['wpsLabel'] = "success";
} else {
$accessPoint['wps'] = "No";
$accessPoint['wpsLabel'] = "";
}
} else {
$accessPoint['wps'] = "--";
}
array_push($returnArray, $accessPoint);
}
exec("rm -rf /tmp/wps-*");
$this->response = $returnArray;
}
private function getMACInfo()
{
$content = file_get_contents("https://api.macvendors.com/".$this->request->mac);
$this->response = array('title' => $this->request->mac, "output" => $content);
}
private function getProcesses()
{
$returnArray = array();
$process = array();
if (file_exists("/tmp/wps.run") && ($this->checkRunning("reaver") || $this->checkRunning("bully"))) {
$args = $this->parse_args(file_get_contents("/tmp/wps.run"));
$process['ssid'] = $args["e"];
$process['mac'] = $args["b"];
$process['channel'] = $args["c"];
if ($args["reaver"]) {
$process['name'] = "reaver";
} elseif ($args["bully"]) {
$process['name'] = "bully";
}
array_push($returnArray, $process);
}
$this->response = $returnArray;
}
private function parse_args($args)
{
if (is_string($args)) {
$args = str_replace(array('=', "\'", '\"'), array('= ', '&#39;', '&#34;'), $args);
$args = str_getcsv($args, ' ', '"');
$tmp = array();
foreach ($args as $arg) {
if (!empty($arg) && $arg != "&#39;" && $arg != "=" && $arg != " ") {
$tmp[] = str_replace(array('= ', '&#39;', '&#34;'), array('=', "'", '"'), trim($arg));
}
}
$args = $tmp;
}
$out = array();
$args_size = count($args);
for ($i = 0; $i < $args_size; $i++) {
$value = false;
if (substr($args[$i], 0, 2) == '--') {
$key = rtrim(substr($args[$i], 2), '=');
$out[$key] = true;
} elseif (substr($args[$i], 0, 1) == '-') {
$key = rtrim(substr($args[$i], 1), '=');
$opt = str_split($key);
$opt_size = count($opt);
if ($opt_size > 1) {
for ($n=0; $n < $opt_size; $n++) {
$key = $opt[$n];
$out[$key] = true;
}
}
} else {
$value = $args[$i];
}
if (isset($key)) {
if (isset($out[$key])) {
if (is_bool($out[$key])) {
$out[$key] = $value;
} else {
$out[$key] = trim($out[$key].' '.$value);
}
} else {
$out[$key] = $value;
}else{
$out[$key] = trim($out[$key].' '.$value);
}
}else{
$out[$key] = $value;
} elseif ($value) {
$out[$value] = true;
}
}else if($value){
$out[$value] = true;
}
return $out;
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/wps/log/*"));
echo '[';
for ($i=0;$i<count($log_list);$i++) {
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
if ($i!=count($log_list)-1) {
echo ',';
}
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/wps/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/wps/log/".$this->request->file));
exec("strings /pineapple/modules/wps/log/".$this->request->file, $output);
if (!empty($output)) {
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
} else {
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
}
return $out;
}
private function refreshHistory()
{
$this->streamFunction = function () {
$log_list = array_reverse(glob("/pineapple/modules/wps/log/*"));
echo '[';
for($i=0;$i<count($log_list);$i++)
{
$info = explode("_", basename($log_list[$i]));
$entryDate = gmdate('Y-m-d H-i-s', $info[1]);
$entryName = basename($log_list[$i]);
echo json_encode(array($entryDate, $entryName));
if($i!=count($log_list)-1) echo ',';
}
echo ']';
};
}
private function downloadHistory()
{
$this->response = array("download" => $this->downloadFile("/pineapple/modules/wps/log/".$this->request->file));
}
private function viewHistory()
{
$log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/wps/log/".$this->request->file));
exec ("strings /pineapple/modules/wps/log/".$this->request->file, $output);
if(!empty($output))
$this->response = array("output" => implode("\n", $output), "date" => $log_date);
else
$this->response = array("output" => "Empty log...", "date" => $log_date);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/wps/log/".$this->request->file);
}
private function deleteHistory()
{
exec("rm -rf /pineapple/modules/wps/log/".$this->request->file);
}
}

Some files were not shown because too many files have changed in this diff Show More