mirror of
https://github.com/hak5/nano-tetra-modules.git
synced 2025-10-29 16:58:09 +00:00
Maintenance for a few modules (#42)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
if($scope.nontcp != "--")
|
||||
return_value = $scope.nontcp + " ";
|
||||
|
||||
return return_value;
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
$scope.update();
|
||||
}]);
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"tetra"
|
||||
],
|
||||
"title": "nmap",
|
||||
"version": "1.6"
|
||||
"version": "1.7"
|
||||
}
|
||||
1
nmap/scan/README.txt
Normal file
1
nmap/scan/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
Scan results will be saved here.
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user