Эх сурвалжийг харах

Fix wps module (#2)

Fix wps module
Scan now works properly and shows wps version
m5kro 2 жил өмнө
parent
commit
9237142390

BIN
modules/build/wps.tar.gz


+ 33 - 22
modules/src/wps/api/module.php

@@ -1,5 +1,6 @@
 <?php namespace pineapple;
 
+
 require_once('/pineapple/modules/wps/api/iwlist_parser.php');
 
 class wps extends Module
@@ -79,7 +80,7 @@ class wps extends Module
 
     protected function checkRunning($processName)
     {
-        return exec("ps w | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
+        return exec("ps -A | grep {$processName} | grep -v grep") !== '' ? 1 : 0;
     }
 
     protected function refreshInfo()
@@ -91,11 +92,21 @@ class wps extends Module
     private function handleDependencies()
     {
         if (!$this->checkDeps("reaver")) {
-            $this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh install ".$this->request->destination);
-            $this->response = array('success' => true);
+            if (file_exists('/sd/modules/wps/scripts/dependencies.sh')) {
+                $this->execBackground("bash /sd/modules/wps/scripts/dependencies.sh install ".$this->request->destination);
+                $this->response = array('success' => true);
+            } else {
+                $this->execBackground("bash /pineapple/modules/wps/scripts/dependencies.sh install ".$this->request->destination);
+                $this->response = array('success' => true);
+            }
         } else {
-            $this->execBackground("/pineapple/modules/wps/scripts/dependencies.sh remove");
-            $this->response = array('success' => true);
+            if (file_exists('/sd/modules/wps/scripts/dependencies.sh')) {
+                $this->execBackground("bash /sd/modules/wps/scripts/dependencies.sh remove");
+                $this->response = array('success' => true);
+            } else {
+                $this->execBackground("bash /pineapple/modules/wps/scripts/dependencies.sh remove");
+                $this->response = array('success' => true);
+            }
         }
     }
 
@@ -152,8 +163,10 @@ class wps extends Module
     private function togglewps()
     {
         if (!($this->checkRunning("reaver") || $this->checkRunning("bully"))) {
-            $full_cmd = $this->request->command . " -o /pineapple/modules/wps/log/log_".time().".log";
+            $full_cmd = $this->request->command . " &> /pineapple/modules/wps/log/log_".time().".log";
+            $lazy = $this->request->command;
             shell_exec("echo -e \"{$full_cmd}\" > /tmp/wps.run");
+            shell_exec("echo -e \"{$lazy}\" > /tmp/lazy.read");
 
             $this->execBackground("/pineapple/modules/wps/scripts/wps.sh start");
         } else {
@@ -186,7 +199,7 @@ class wps extends Module
 
                     exec($cmd, $output);
                     if (!empty($output)) {
-                        $this->response = implode("\n", array_reverse($output));
+                        $this->response = implode("\n", $output);
                     } else {
                         $this->response = "Empty log...";
                     }
@@ -227,11 +240,11 @@ class wps extends Module
     {
         if ($this->request->duration && $this->request->monitor != "") {
             exec("killall -9 airodump-ng && rm -rf /tmp/wps-*");
-            $this->execBackground("airodump-ng -a --output-format cap -w /tmp/wps ".$this->request->monitor." &> /dev/null");
+            $this->execBackground("airodump-ng -a --wps --output-format cap -w /tmp/wps ".$this->request->monitor." &> /dev/null");
             sleep($this->request->duration);
-            exec("wash -f /tmp/wps-01.cap -o /tmp/wps-01.wash &> /dev/null");
-
             exec("killall -9 airodump-ng");
+
+            exec("wash -f /tmp/wps-01.cap > /tmp/wps-01.wash");
         }
 
         $p = $this->iwlistparse->parseScanDev($this->request->interface);
@@ -312,16 +325,14 @@ class wps extends Module
             }
 
             if ($this->request->duration && $this->request->monitor != "") {
-                $wps_enabled = trim(exec("cat /tmp/wps-01.wash | tail -n +3 | grep ".$accessPoint['mac']." | awk '{ print $5; }'"));
-                if ($wps_enabled == "No" || $wps_enabled == "Yes") {
-                    $accessPoint['wps'] = "Yes";
-                    $accessPoint['wpsLabel'] = "success";
-                } else {
-                    $accessPoint['wps'] = "No";
-                    $accessPoint['wpsLabel'] = "";
-                }
-            } else {
-                $accessPoint['wps'] = "--";
+                $accessPoint['wps'] = trim(exec("cat /tmp/wps-01.wash | tail -n +3 | grep ".$accessPoint['mac']." | awk '{ print $4; }'"));
+                $accessPoint['wpsLabel'] = "success";
+                
+            } 
+            
+            if ($accessPoint['wps'] == "") {
+                $accessPoint['wps'] = "No";
+                $accessPoint['wpsLabel'] = "";
             }
 
             array_push($returnArray, $accessPoint);
@@ -344,7 +355,7 @@ class wps extends Module
 
         $process = array();
         if (file_exists("/tmp/wps.run") && ($this->checkRunning("reaver") || $this->checkRunning("bully"))) {
-            $args = $this->parse_args(file_get_contents("/tmp/wps.run"));
+            $args = $this->parse_args(file_get_contents("/tmp/lazy.read"));
 
             $process['ssid'] = $args["e"];
             $process['mac'] = $args["b"];
@@ -444,7 +455,7 @@ class wps extends Module
     private function viewHistory()
     {
         $log_date = gmdate("F d Y H:i:s", filemtime("/pineapple/modules/wps/log/".$this->request->file));
-        exec("strings /pineapple/modules/wps/log/".$this->request->file, $output);
+        exec("cat /pineapple/modules/wps/log/".$this->request->file, $output);
 
         if (!empty($output)) {
             $this->response = array("output" => implode("\n", $output), "date" => $log_date);

+ 3 - 2
modules/src/wps/module.html

@@ -167,7 +167,7 @@
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option12" ng-true-value="'-P'"> Set into PixieLoop mode (doesn't send M4, and loops through to M3) [False]</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option13" ng-true-value="'-H'"> Enables logging of sequence completed PixieHashes</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option14" ng-true-value="'-Z'"> Do NOT run reaver to auto retrieve WPA password if pixiewps attack is successful</label></div>
-                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option15" ng-true-value="'-K 1'"> [1] Run pixiewps with PKE, PKR, E-Hash1, E-Hash2, E-Nonce and Authkey (Ralink, Broadcom & Realtek)</label></div>
+                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option15" ng-true-value="'-K'"> Run pixiewps</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option16" ng-true-value="'-vv'"> Display non-critical warnings</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option17" ng-true-value="'-vvv'"> Display PixieHashes / enable pixiedust modes</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="reaverOptions.option18" ng-true-value="'-q'"> Only display critical messages</label></div>
@@ -256,6 +256,7 @@
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="bullyOptions.option13" ng-true-value="'-R'"> Assume radiotap headers are present</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="bullyOptions.option14" ng-true-value="'-W'"> Masquerade as a Windows 7 registrar</label></div>
                         <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="bullyOptions.option15" ng-true-value="'-Z'"> Suppress packet throttling algorithm</label></div>
+ <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="bullyOptions.option16" ng-true-value="'-d'"> Enable Pixiewps</label></div>
                       </div>
                   </div>
                 </div>
@@ -570,4 +571,4 @@
 	  </div>
 	</div>
 
-</div>
+</div>

+ 2 - 2
modules/src/wps/module.info

@@ -1,10 +1,10 @@
 {
     "author": "Whistle Master",
-    "description": "WPS brute force attack using Reaver, Bully and Pixiewps",
+    "description": "WPS brute force attack using Reaver, Bully, and Pixiewps. Edited by m5kro to support new firmwares.",
     "devices": [
         "nano",
         "tetra"
     ],
     "title": "wps",
-    "version": "1.7"
+    "version": "1.8"
 }

+ 13 - 7
modules/src/wps/scripts/dependencies.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
-#2015 - Whistle Master
+#2022 - m5kro aka kraken5
 
 [[ -f /tmp/wps.progress ]] && {
   exit 0
@@ -9,16 +9,21 @@ touch /tmp/wps.progress
 
 if [ "$1" = "install" ]; then
   if [ "$2" = "internal" ]; then
-	 opkg update
-
+     opkg update
      opkg install reaver
      opkg install bully
+     opkg install pixiewps
+     opkg install libpcap
+     chmod +x /pineapple/modules/wps/scripts/wps.sh
 
   elif [ "$2" = "sd" ]; then
-    opkg update
-
-    opkg install reaver --dest sd
-    opkg install bully --dest sd
+     opkg update
+     ln -s /sd/modules/wps /pineapple/modules/
+     opkg -d sd install reaver
+     opkg -d sd install bully
+     opkg -d sd install pixiewps
+     opkg -d sd install libpcap
+     chmod +x /sd/modules/wps/scripts/wps.sh
 
   fi
   
@@ -35,6 +40,7 @@ if [ "$1" = "install" ]; then
 elif [ "$1" = "remove" ]; then
     opkg remove reaver
     opkg remove bully
+    opkg remove pixiewps
     rm -rf /etc/config/wps
 fi
 

+ 3 - 1
modules/src/wps/scripts/wps.sh

@@ -9,9 +9,11 @@ MYCMD=`cat /tmp/wps.run`
 if [ "$1" = "start" ]; then
 	eval ${MYCMD}
 	rm -rf /tmp/wps.run
+        rm -rf /tmp/lazy.read
 elif [ "$1" = "stop" ]; then
  	killall -9 reaver
 	killall -9 bully
 
 	rm -rf /tmp/wps.run
-fi
+        rm -rf /tmp/lazy.read
+fi