Skip to content

Commit

Permalink
PMKIDAttack v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
n3d-b0y authored Mar 2, 2019
1 parent b2ce2a1 commit 3448786
Show file tree
Hide file tree
Showing 8 changed files with 423 additions and 327 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ The module automates PMKID attack

**Device:** Tetra

[![Demo video](https://i.ibb.co/wMf1BGg/PMKIDAttack-You-Tube.png)](https://youtu.be/AU2kAd3PUz8)

**Official topics for discussions:**
```
https://codeby.net/threads/6-wifi-pineapple-pmkidattack.66709
https://forums.hak5.org/topic/45365-module-pmkidattack/
```

[![Watch the video](https://i.ibb.co/wMf1BGg/PMKIDAttack-You-Tube.png)](https://youtu.be/AU2kAd3PUz8)

**Install module:**

**Module installation:**
```
opkg update && opkg install git git-http
cd /pineapple/modules/
Expand Down
83 changes: 58 additions & 25 deletions api/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
class PMKIDAttack extends Module
{
const PATH_MODULE = '/pineapple/modules/PMKIDAttack';
const PATH_LOG_FILE = '/var/log/pmkidattack.log';

public function route()
{
switch ($this->request->action) {
case 'isConnected':
$this->isConnected();
case 'clearLog':
$this->clearLog();
break;
case 'getInfo':
$this->getInfo();
case 'getLog':
$this->getLog();
break;
case 'getDependenciesStatus':
$this->getDependenciesStatus();
Expand Down Expand Up @@ -55,18 +56,33 @@ public function route()
}
}

public function isConnected()
protected function clearLog()
{
$connected = @fsockopen("google.com", 80);
if (!file_exists(self::PATH_LOG_FILE)) {
touch(self::PATH_LOG_FILE);
}

if ($connected) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
exec('rm ' . self::PATH_LOG_FILE);
touch(self::PATH_LOG_FILE);
}

protected function getLog()
{
if (!file_exists(self::PATH_LOG_FILE)) {
touch(self::PATH_LOG_FILE);
}

$file = file_get_contents(self::PATH_LOG_FILE);

$this->response = array("pmkidlog" => $file);
}

protected function formatLog($massage)
{
return '[' . date("Y-m-d H:i:s") . '] ' . $massage . PHP_EOL;
}

private function getDependenciesStatus()
protected function getDependenciesStatus()
{
if (!file_exists('/tmp/PMKIDAttack.progress')) {
if ($this->checkDependency()) {
Expand All @@ -93,7 +109,7 @@ protected function checkDependency()
return ((trim(exec("which hcxdumptool")) == '' ? false : true) && $this->uciGet("pmkidattack.module.installed"));
}

private function managerDependencies()
protected function managerDependencies()
{
if (!$this->checkDependency()) {
$this->execBackground(self::PATH_MODULE . "/scripts/dependencies.sh install");
Expand All @@ -104,26 +120,31 @@ private function managerDependencies()
}
}

private function statusDependencies()
protected function statusDependencies()
{
if (!file_exists('/tmp/HandshakeCrack.progress')) {
if (!file_exists('/tmp/PMKIDAttack.progress')) {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}

private function startAttack()
protected function startAttack()
{
$this->uciSet('pmkidattack.attack.bssid', $this->request->bssid);

$this->uciSet('pmkidattack.attack.run', '1');
exec("echo " . $this->getFormatBSSID() . " > " . self::PATH_MODULE . "/filter.txt");
exec(self::PATH_MODULE . "/scripts/PMKIDAttack.sh start " . $this->getFormatBSSID());

$massageLog = 'Start attack ' . $this->request->bssid;

file_put_contents(self::PATH_LOG_FILE, $this->formatLog($massageLog), FILE_APPEND);

$this->response = array('success' => true);
}

private function stopAttack()
protected function stopAttack()
{
$this->uciSet('pmkidattack.attack.run', '0');

Expand All @@ -136,28 +157,40 @@ private function stopAttack()
exec("rm -rf /tmp/" . $this->getFormatBSSID() . '.pcapng');
exec("rm -rf " . self::PATH_MODULE . "/log/output.txt");

$massageLog = 'Stop attack ' . $this->getBSSID();

file_put_contents(self::PATH_LOG_FILE, $this->formatLog($massageLog), FILE_APPEND);

$this->response = array('success' => true);
}


private function catchPMKID()
protected function catchPMKID()
{
if ($this->checkPMKID()) {
$massageLog = 'PMKID ' . $this->getBSSID() . ' intercepted!';

file_put_contents(self::PATH_LOG_FILE, $this->formatLog($massageLog), FILE_APPEND);
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}

private function getFormatBSSID()
protected function getFormatBSSID()
{
$bssid = $this->uciGet('pmkidattack.attack.bssid');
$bssidFormat = str_replace(':', '', $bssid);

return $bssidFormat;
}

private function checkPMKID()
protected function getBSSID()
{
return $this->uciGet('pmkidattack.attack.bssid');
}

protected function checkPMKID()
{
$searchLine = 'PMKIDs';

Expand All @@ -168,7 +201,7 @@ private function checkPMKID()
return strpos($file, $searchLine) !== false;
}

private function getPMKIDFiles()
protected function getPMKIDFiles()
{
$pmkids = [];
exec("find -L " . self::PATH_MODULE . "/pcapng/ -type f -name \"*.**pcapng\" 2>&1", $files);
Expand All @@ -187,7 +220,7 @@ private function getPMKIDFiles()
$this->response = array("pmkids" => $pmkids);
}

private function downloadPMKID()
protected function downloadPMKID()
{
$fileName = basename($this->request->file, '.pcapng');

Expand All @@ -200,12 +233,12 @@ private function downloadPMKID()
$this->response = array("download" => $this->downloadFile("/tmp/". $fileName .".tar.gz"));
}

private function deletePMKID()
protected function deletePMKID()
{
exec("rm -rf " . $this->request->file);
}

private function getOutput()
protected function getOutput()
{
if (!empty($this->request->pathPMKID)) {
exec('hcxpcaptool -z /tmp/pmkid.txt ' . $this->request->pathPMKID . ' &> ' . self::PATH_MODULE . '/log/output2.txt');
Expand All @@ -218,12 +251,12 @@ private function getOutput()
$this->response = array("output" => $output);
}

private function getStatusAttack()
protected function getStatusAttack()
{
if ($this->uciGet('pmkidattack.attack.run') == '1') {
$this->response = array('success' => true);
} else {
$this->response = array('success' => false);
}
}
}
}
Loading

0 comments on commit 3448786

Please sign in to comment.