-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add module HandshakeCrack v1.0 to repository #52
Open
n3d-b0y
wants to merge
1
commit into
hak5:master
Choose a base branch
from
n3d-b0y:HandshakeCrack
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<?php | ||
/** | ||
* User: n3d.b0y | ||
* Email: [email protected] | ||
*/ | ||
namespace pineapple; | ||
|
||
class HandshakeCrack extends Module | ||
{ | ||
const LOG_FILE_SEND_HANDSHAKE = '/tmp/handshakesend.log'; | ||
const BASH_SCRIP_SEND_HANDSHAKE = '/pineapple/modules/HandshakeCrack/scripts/handshake.sh'; | ||
const BASH_SCRIP_CONVERTER = '/pineapple/modules/HandshakeCrack/scripts/converter.sh'; | ||
const PYTHON_SCRIPT_PARSEG_PCAP = '/pineapple/modules/HandshakeCrack/scripts/parser_pcap.py'; | ||
|
||
public function route() | ||
{ | ||
switch ($this->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); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential typo: this and BASH_SCRIP_CONVERTER say SCRIPT rather than SCRIP