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 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);
|
||||
}
|
||||
}
|
||||
|
||||
312
p0f/js/module.js
312
p0f/js/module.js
@@ -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
1
p0f/log/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
Logs will be saved here.
|
||||
@@ -6,5 +6,5 @@
|
||||
"tetra"
|
||||
],
|
||||
"title": "p0f",
|
||||
"version": "1.1"
|
||||
"version": "1.2"
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user