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 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
1
ngrep/log/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
Logs will be saved here.
|
||||
@@ -6,5 +6,5 @@
|
||||
"tetra"
|
||||
],
|
||||
"title": "ngrep",
|
||||
"version": "1.5"
|
||||
"version": "1.6"
|
||||
}
|
||||
@@ -12,8 +12,8 @@ touch /tmp/ngrep.progress
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user