diff --git a/HandshakeCrack/api/module.php b/HandshakeCrack/api/module.php new file mode 100644 index 0000000..32cae4d --- /dev/null +++ b/HandshakeCrack/api/module.php @@ -0,0 +1,171 @@ +request->action) { + case 'getInfo': + $this->getInfo(); + break; + case 'getStatus': + $this->getStatus(); + break; + case 'managerDependencies': + $this->managerDependencies(); + break; + case 'statusDependencies': + $this->statusDependencies(); + break; + case 'getSettings': + $this->getSettings(); + break; + case 'setSettings': + $this->setSettings(); + break; + case 'getHandshakeFiles': + $this->getHandshakeFiles(); + break; + case 'getHandshakeInfo': + $this->getHandshakeInfo(); + break; + case 'sendHandshake': + $this->sendHandshake(); + break; + case 'converter': + $this->converter(); + break; + case 'isConnected': + $this->isConnected(); + break; + } + } + + protected function getInfo() + { + $moduleInfo = @json_decode(file_get_contents("/pineapple/modules/HandshakeCrack/module.info")); + $this->response = array('title' => $moduleInfo->title, 'version' => $moduleInfo->version); + } + + private function getStatus() + { + if (!file_exists('/tmp/HandshakeCrack.progress')) { + if ($this->checkDependencies()) { + $this->response = array( + "installed" => false, "install" => "Remove", + "installLabel" => "danger", "processing" => false + ); + } else { + $this->response = array( + "installed" => true, "install" => "Install", + "installLabel" => "success", "processing" => false + ); + } + } else { + $this->response = array( + "installed" => false, "install" => "Installing...", + "installLabel" => "warning", "processing" => true + ); + } + } + + protected function checkDependencies() + { + return ((exec("which curl") == '' ? false : true) && ($this->uciGet("handshakecrack.module.installed"))); + } + + private function managerDependencies() + { + if (!$this->checkDependencies()) { + $this->execBackground("/pineapple/modules/HandshakeCrack/scripts/dependencies.sh install"); + $this->response = array('success' => true); + } else { + $this->execBackground("/pineapple/modules/HandshakeCrack/scripts/dependencies.sh remove"); + $this->response = array('success' => true); + } + } + + private function statusDependencies() + { + if (!file_exists('/tmp/HandshakeCrack.progress')) { + $this->response = array('success' => true); + } else { + $this->response = array('success' => false); + } + } + + private function getSettings() + { + $settings = array( + 'email' => $this->uciGet("handshakecrack.settings.email") + ); + $this->response = array('settings' => $settings); + } + + private function setSettings() + { + $settings = $this->request->settings; + $this->uciSet("handshakecrack.settings.email", $settings->email); + } + + private function getHandshakeFiles() + { + exec("find -L /pineapple/modules/ -type f -name \"*.**cap\" 2>&1", $dir1); + exec("find -L /tmp/ -type f -name \"*.**cap\" 2>&1", $dir2); + + $this->response = array("files" => array_merge($dir1, $dir2)); + } + + private function getHandshakeInfo() + { + if (!empty($this->request->path)) { + exec('python ' . self::PYTHON_SCRIPT_PARSEG_PCAP . ' -i ' . $this->request->path, $output); + $outputArr = preg_split('/\s+/', $output[0]); + + if (!empty($outputArr)) { + $this->response = array( + 'success' => true, 'bssid' => strtoupper($outputArr[0]), + 'essid' => $outputArr[1] + ); + } else { + $this->response = array('success' => false); + } + } else { + $this->response = array('success' => false); + } + } + + private function sendHandshake() + { + exec(self::BASH_SCRIP_SEND_HANDSHAKE . " " . $this->request->file, $output); + $this->response = array('output' => $output); + } + + private function converter() + { + exec(self::BASH_SCRIP_CONVERTER . " " . $this->request->file, $output); + + $this->response = array('output' => $output[0]); + } + + public function isConnected() + { + $connected = @fsockopen("google.com", 80); + + if ($connected) { + $this->response = array('success' => true); + } else { + $this->response = array('success' => false); + } + } +} \ No newline at end of file diff --git a/HandshakeCrack/js/module.js b/HandshakeCrack/js/module.js new file mode 100644 index 0000000..dac079b --- /dev/null +++ b/HandshakeCrack/js/module.js @@ -0,0 +1,244 @@ +registerController('HandshakeCrack_IsConnected', ['$api', '$scope', '$rootScope', '$interval', function ($api, $scope, $rootScope, $interval) { + $rootScope.isConnected = false; + $rootScope.noDependencies = false; + + var isConnected = function () {$api.request({ + module: "HandshakeCrack", + action: "isConnected" + }, function (response) { + if (!response.success) { + $rootScope.isConnected = true; + } else { + $rootScope.isConnected = false; + $rootScope.noDependencies = false; + } + })}; + + $api.request({ + module: "HandshakeCrack", + action: "getStatus" + }, function (response) { + if (response.install === 'Install') { + $rootScope.noDependencies = true; + } + }); + + isConnected(); + + var interval = $interval(function () { + if (!$rootScope.isConnected) { + $interval.cancel(interval); + } else { + isConnected(); + } + }, 5000); +}]); + +registerController('HandshakeCrack_Dependencies', ['$api', '$scope', '$rootScope', '$interval', function ($api, $scope, $rootScope, $interval) { + $scope.install = "Loading..."; + $scope.installLabel = "default"; + $scope.processing = false; + $rootScope.handshakeInfo = false; + + $rootScope.status = { + installed: false, + generated: false, + refreshOutput: false, + refreshKnownHosts: false + }; + + $scope.refreshStatus = (function () { + $api.request({ + module: "HandshakeCrack", + action: "getStatus" + }, function (response) { + $scope.status.installed = response.installed; + $scope.processing = response.processing; + $scope.install = response.install; + $scope.installLabel = response.installLabel; + + if ($scope.processing) { + $scope.statusDependencies(); + } + }) + }); + + $scope.statusDependencies = (function () { + var statusDependenciesInterval = $interval(function () { + $api.request({ + module: 'HandshakeCrack', + action: 'statusDependencies' + }, function (response) { + if (response.success === true) { + $scope.processing = false; + $scope.refreshStatus(); + $interval.cancel(statusDependenciesInterval); + } + }); + }, 2000); + }); + + $scope.managerDependencies = (function () { + if ($scope.status.installed) { + $scope.install = "Installing..."; + } else { + $scope.install = "Removing..."; + } + + $api.request({ + module: 'HandshakeCrack', + action: 'managerDependencies' + }, function (response) { + if (response.success === true) { + $scope.installLabel = "warning"; + $scope.processing = true; + $scope.statusDependencies(); + } + }); + }); + + $scope.refreshStatus(); +}]); + + +registerController('HandshakeCrack_Settings', ['$api', '$scope', function ($api, $scope) { + $scope.settings = { + email: "" + }; + + $scope.saveSettingsLabel = "success"; + $scope.saveSettings = "Save"; + $scope.saving = false; + + $scope.getSettings = function () { + $api.request({ + module: 'HandshakeCrack', + action: 'getSettings' + }, function (response) { + $scope.settings = response.settings; + }); + }; + + $scope.setSettings = function () { + $scope.saveSettingsLabel = "warning"; + $scope.saveSettings = "Saving..."; + $scope.saving = true; + + $api.request({ + module: 'HandshakeCrack', + action: 'setSettings', + settings: $scope.settings + }, function (response) { + setTimeout(function () { + $scope.getSettings(); + $scope.saveSettingsLabel = "success"; + $scope.saveSettings = "Save"; + $scope.saving = false; + }, 1000); + }); + }; + + $scope.getSettings(); +}]); + +registerController('HandshakeCrack_Files', ['$api', '$scope', '$rootScope', function ($api, $scope, $rootScope) { + $scope.files = []; + + $scope.getHandshakeFiles = (function () { + $api.request({ + module: 'HandshakeCrack', + action: 'getHandshakeFiles' + }, function (response) { + $scope.files = response.files; + $scope.fileHandshake = response.files[0]; + $scope.countHandshake = response.files.length; + $scope.refreshHandshakeInfo(); + }); + }); + + $scope.refreshHandshakeInfo = (function () { + $api.request({ + module: 'HandshakeCrack', + action: 'getHandshakeInfo', + path: $scope.fileHandshake + }, function (response) { + if (response.success) { + $rootScope.handshakeInfo = true; + $scope.bssid = response.bssid; + $scope.essid = response.essid; + } + }); + }); + + $scope.getHandshakeFiles(); +}]); + +registerController('HandshakeCrack_Crack', ['$api', '$scope', '$controller', function ($api, $scope, $controller) { + $controller('HandshakeCrack_Files', {$scope: $scope}); + + $scope.working = false; + $scope.btnClass = "default"; + $scope.btnText = "Send"; + $scope.output = 'Nothing here yet...'; + + $scope.sendHandhake = (function () { + $api.request({ + module: 'HandshakeCrack', + action: 'sendHandshake', + file: $scope.fileHandshake + }, function (response) { + $scope.output = response.output.join("\n"); + $scope.btnClass = "default"; + $scope.btnText = "Send"; + $scope.working = false; + }); + }); + + $scope.send = (function () { + $scope.btnText = "Loading..."; + $scope.btnClass = "warning"; + $scope.output = 'Nothing here yet...'; + $scope.working = true; + $scope.sendHandhake(); + }); +}]); + +registerController('HandshakeCrack_Convert', ['$api', '$scope', '$controller', function ($api, $scope) { + $scope.btnClass = "default"; + $scope.btnText = "Convert"; + $scope.massages = ''; + $scope.working = false; + + $scope.converter = (function () { + $api.request({ + module: 'HandshakeCrack', + action: 'converter', + file: $scope.fileHandshake + }, function (response) { + var data = JSON.parse(response.output); + + $scope.link = data.link; + $scope.massages = data.uploaded; + $scope.btnClass = "default"; + $scope.btnText = "Convert"; + $scope.working = false; + + setTimeout(function () { + $scope.massages = ''; + }, 2000) + }); + }); + + $scope.send = (function () { + $scope.btnText = "Loading..."; + $scope.btnClass = "warning"; + $scope.working = true; + $scope.converter(); + }); + + $scope.btnDownload = (function () { + setTimeout(function () { + $scope.link = ''; + }, 1000); + }); +}]); \ No newline at end of file diff --git a/HandshakeCrack/module.html b/HandshakeCrack/module.html new file mode 100644 index 0000000..e82e0cc --- /dev/null +++ b/HandshakeCrack/module.html @@ -0,0 +1,179 @@ +
Dependencies | ++ + | +
{{bssid}}
+{{essid}}
+{{output}}+