pull/52/head
n3d.b0y 2019-02-22 03:16:39 +03:00
parent 8eb6bbc8f0
commit 5476bb3140
8 changed files with 725 additions and 0 deletions

View File

@ -0,0 +1,171 @@
<?php
/**
* User: n3d.b0y
* Email: n3d.b0y@gmail.com
*/
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);
}
}
}

244
HandshakeCrack/js/module.js Normal file
View File

@ -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);
});
}]);

179
HandshakeCrack/module.html Normal file
View File

@ -0,0 +1,179 @@
<div ng-controller="HandshakeCrack_IsConnected">
<div class="alert alert-danger" role="alert" ng-show="$root.isConnected">
Internet connection required for this module to work!
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-default" ng-controller="HandshakeCrack_Dependencies">
<div class="panel-heading">
<h3 class="panel-title">Controls</h3>
</div>
<div class="panel-body">
<table style="width:100%">
<tr>
<td style="padding-bottom: .5em;" class="text-muted">Dependencies</td>
<td style="text-align:right;padding-bottom: .5em;">
<button type="button" style="width: 90px;" class="btn btn-{{installLabel}} btn-xs"
ng-click="managerDependencies()" ng-disabled="processing || $root.noDependencies">{{install}}
</button>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-8" ng-show="!$root.status.installed">
<div class="panel panel-default" ng-controller="HandshakeCrack_Settings">
<div class="panel-heading">
<h3 class="panel-title">Setting</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-10">
<div class="input-group">
<span class="input-group-addon input-sm">Email</span>
<input type="text" class="form-control input-sm" ng-model="settings.email">
</div>
</div>
<div class="col-md-2">
<button class="btn btn-{{saveSettingsLabel}} btn-sm btn-block" ng-disabled="saving"
ng-click="setSettings()">{{saveSettings}}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" ng-show="!$root.status.installed" ng-controller="HandshakeCrack_Files">
<div class="col-md-6">
<div class="panel panel-default" ng-controller="HandshakeCrack_Crack">
<div class="panel-heading">
<h4 class="panel-title">Upload your WPA(2) capture file
<span class="badge ng-binding pull-right">{{countHandshake}}</span>
<div class="clearfix"></div>
</h4>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group">
<div class="col-md-10">
<div class="input-group">
<span class="input-group-addon">File</span>
<select class="form-control input-sm handshake-select"
ng-change="refreshHandshakeInfo()"
ng-model="fileHandshake">
<option ng-repeat="file in files">{{ file }}</option>
</select>
</div>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-{{btnClass}} btn-sm btn-block"
ng-disabled="countHandshake == 0 || working || $root.isConnected"
ng-click="send()">
{{btnText}}
</button>
</div>
</div>
</div>
<div style="margin-top: 15px;" class="info" ng-show="$root.handshakeInfo">
<div class="form-group">
<label style="padding-left: 0;" class="col-sm-2 control-label">BSSID:</label>
<div class="col-sm-10">
<p style="margin: 0 0 5px;">{{bssid}}</p>
</div>
</div>
<div class="form-group">
<label style="padding-left: 0;" class="col-sm-2 control-label">ESSID:</label>
<div class="col-sm-10">
<p style="margin: 0 0 5px;">{{essid}}</p>
</div>
</div>
</div>
<div style="margin-top: 15px;">
<strong class="pull-right">Log</strong>
<div class="clearfix"></div>
<pre class="scrollable-pre log-pre">{{output}}</pre>
</div>
<a href="https://www.onlinehashcrack.com/wpa" target="_blank" class="btn btn-default">Dashboard</a>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default" ng-controller="HandshakeCrack_Convert">
<div class="panel-heading">
<h4 class="panel-title">Cap to hccapx Converter</h4>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div ng-show="massages.length > 0" class="alert alert-success" role="alert">
{{massages}}
</div>
</div>
<div class="form-group">
<div class="col-md-10">
<div class="input-group">
<span class="input-group-addon">File</span>
<select class="form-control input-sm handshake-select"
ng-change="refreshHandshakeInfo()"
ng-model="fileHandshake">
<option ng-repeat="file in files">{{ file }}</option>
</select>
</div>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-{{btnClass}} btn-sm btn-block"
ng-disabled="countHandshake == 0 || working || $root.isConnected"
ng-click="send()">
{{btnText}}
</button>
</div>
</div>
<div class="col-md-12" style="margin-top: 15px;">
<a ng-click="btnDownload()" href="{{link}}" ng-show="link.length > 0" class="btn btn-success">Download</a>
</div>
</div>
<div style="margin-top: 10px">
<fieldset>
<legend>Notes</legend>
<ul>
<li>Uploaded files (.cap) will be deleted immediately. We do NOT store your .cap files</li>
<li>Converted files (.hccapx) will be stored for 2 days before being deleted</li>
<li>This site is using the best-in-class tool <a href="https://github.com/ZerBea/hcxtools">hcxtools</a>
to onvert cap files
</li>
<li>The goal of this page is to make it very easy to convert .cap files to .hccapx</li>
</ul>
</fieldset>
<fieldset>
<legend>How to use?</legend>
<p>More than easy, just select and upload your .(p)cap file. If valid, the file will be
converted
into a .hccapx file, which is readable by Hashcat.</p>
</fieldset>
<fieldset>
<legend>Explanation of the format</legend>
<p>hccapx is a custom format, specifically developed for Hashcat, to be used for hash type -m
2500 =
WPA/WPA2
A nexhaustive description of this custom format can be found on their <a
href="https://hashcat.net/wiki/doku.php?id=hccapx">official wiki</a>.</p>
</fieldset>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,9 @@
{
"author": "n3d.b0y",
"description": "Web service www.onlinehashcrack.com in your pineapple",
"devices": [
"tetra"
],
"title": "Handshake Crack",
"version": "1.0"
}

View File

@ -0,0 +1,17 @@
#!/bin/sh
[[ -f /tmp/HandshakeCrack.progress ]] && {
exit 0
}
FILE=$1
touch /tmp/HandshakeCrack.progress
if [[ ! -f ${FILE} ]]; then
echo -e "File ${FILE} does not exist."
else
curl -s -v -F 0="cap2hccapx" -F file_data=@${FILE} https://www.onlinehashcrack.com/tools-upload.php
fi
rm /tmp/HandshakeCrack.progress

View File

@ -0,0 +1,25 @@
#!/bin/sh
[[ -f /tmp/HandshakeCrack.progress ]] && {
exit 0
}
touch /tmp/HandshakeCrack.progress
if [[ "$1" = "install" ]]; then
opkg update
opkg install curl
touch /etc/config/handshakecrack
echo "config handshakecrack 'settings'" > /etc/config/handshakecrack
echo "config handshakecrack 'module'" >> /etc/config/handshakecrack
uci set handshakecrack.module.installed=1
uci commit handshakecrack.module.installed
elif [[ "$1" = "remove" ]]; then
opkg remove curl
rm -rf /etc/config/handshakecrack
fi
rm /tmp/HandshakeCrack.progress

View File

@ -0,0 +1,26 @@
#!/bin/sh
[[ -f /tmp/HandshakeCrack.progress ]] && {
exit 0
}
EMAIL=`uci get handshakecrack.settings.email`
FILE=$1
touch /tmp/HandshakeCrack.progress
if [[ -n "$EMAIL" ]]; then
if [[ ! -f ${FILE} ]]; then
echo -e "File ${FILE} does not exist."
else
echo -e "Sent to www.onlinehashcrack.com web service successfully."
echo -e "Notification will be sent to ${EMAIL}"
echo -e "The following has been sent: ${FILE}"
curl -s -v -F submit="Submit" -F emailTask="${EMAIL}" -F file=@${FILE} https://www.onlinehashcrack.com/addtask.php
fi
else
echo -e "Notification email not set in settings."
fi
rm /tmp/HandshakeCrack.progress

View File

@ -0,0 +1,54 @@
import sys, getopt
import subprocess
import re
def usage():
print "%s -i <capture-file>" % (__file__)
def main(argv):
try:
opts, args = getopt.getopt(argv, "hi:", ["ifile="])
if not opts:
print 'No input file supplied'
usage()
sys.exit(2)
except getopt.GetoptError, e:
print e
usage()
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
usage()
sys.exit()
elif opt in ("-i", "--ifile"):
filename = arg
return filename
if __name__ == "__main__":
filename = main(sys.argv[1:])
list = []
argv = ["-ennr", filename, "(type mgt subtype beacon) || (type mgt subtype probe-resp)"]
cmd = subprocess.Popen(["tcpdump"] + argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in cmd.stdout:
if 'Beacon' in line:
bssid = re.search(r'(BSSID:)(\w+\:\w+\:\w+\:\w+\:\w+\:\w+)', line)
if bssid.group(2) not in list:
list.append(bssid.group(2))
ssid = re.search(r'(Beacon\s\()(.+?(?=\)))', line)
if ssid:
print "%s %s" % (bssid.group(2), ssid.group(2))
else:
print "%s <hidden>" % (bssid.group(2))
elif 'Probe Response' in line:
bssid = re.search(r'(BSSID:)(\w+\:\w+\:\w+\:\w+\:\w+\:\w+)', line)
if bssid.group(2) not in list:
list.append(bssid.group(2))
ssid = re.search(r'(Probe Response\s\()(.+?(?=\)))', line)
if ssid:
print "%s %s" % (bssid.group(2), ssid.group(2))
else:
print "%s <hidden>" % (bssid.group(2))