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

Panel - Recon: Show pineapd service errors

DSR! 4 жил өмнө
parent
commit
1afbba1c70

+ 1 - 0
README.md

@@ -28,6 +28,7 @@ The following functionalities are modified looking for a better user experience
 
 ## PineAP:
  - Configure used interface
+ - Show pineapd service errors
 
 ## Logging:
  - Fire data loading on open accordion

+ 8 - 0
src/etc/init.d/pineapd

@@ -41,6 +41,14 @@ start() {
     ifconfig ${interface_mon} &>/dev/null || airmon-ng start ${interface} &>/dev/null
     /usr/sbin/pineapd /tmp/pineap.conf &>/dev/null & 
     sleep 1
+
+    if [[ $(/usr/bin/pgrep pineapd) ]]; then
+        echo "Status: OK"
+    elif [[ ! $(ifconfig -a ${interface_mon} | grep HWaddr | awk '{print $5}') ]]; then
+        echo "Status: Monitor interface won't start! Try to run manually airmon-ng start ${interface}"
+    else
+        echo "There is a problem with pineapd. Try to run it manually"
+    fi
 }
 
 stop() {

+ 10 - 3
src/pineapple/modules/Recon/api/module.php

@@ -110,10 +110,17 @@ class Recon extends SystemModule
 
     private function startPineAPDaemon()
     {
-        if(!$this->checkPineAPDaemon()) {
-            exec("/etc/init.d/pineapd start");
+        if ($this->checkPineAPDaemon()) {
+            $this->response = array("success" => true);
+            return;
+        }
+
+        exec("/etc/init.d/pineapd start", $status_output);
+        if ($status_output[0] === "Status: OK") {
+            $this->response = array("success" => true);
+        } else {
+            $this->response = array("message" => implode("\n", $status_output));
         }
-        $this->response = array("success" => true);
     }
 
     private function checkPineAPDaemon()

+ 4 - 3
src/pineapple/modules/Recon/js/module.js

@@ -27,6 +27,7 @@ registerController('ReconController', ['$api', '$scope', '$rootScope', '$interva
     $scope.running = false;
     $scope.pineAPDRunning = true;
     $scope.pineAPDStarting = false;
+    $scope.pineAPDStatus = null;
     $scope.paused = false;
     $scope.reverseSort = false;
     $scope.loading = false;
@@ -111,12 +112,12 @@ registerController('ReconController', ['$api', '$scope', '$rootScope', '$interva
             action: 'startPineAPDaemon'
         }, function(response){
             $scope.pineAPDStarting = false;
-            if (response.error === undefined) {
+            if (response.message === undefined) {
                 $scope.pineAPDRunning = true;
                 $scope.startScan();
-                $scope.error = null;
+                $scope.pineAPDStatus = null;
             } else {
-                $scope.error = response.error;
+                $scope.pineAPDStatus = response.message;
             }
         });
     };

+ 5 - 2
src/pineapple/modules/Recon/module.html

@@ -49,14 +49,17 @@
                         </div>
                     </div>
                 </div>
-                <div class="panel-footer" ng-show="!pineAPDRunning">
-                    <div class="alert alert-info">
+                <div class="panel-footer" ng-show="!pineAPDRunning || pineAPDStatus">
+                    <div class="alert alert-info" ng-show="!pineAPDRunning && !pineAPDStatus">
                         <strong>Notice:</strong> In order to use Recon, PineAP must first be enabled.<br/>
                         <button class="btn btn-default" ng-click="startPineAP()" ng-disabled="pineAPDStarting">
                             <span ng-hide="pineAPDStarting">Start PineAP</span>
                             <img class="button-throbber" ng-show="pineAPDStarting" src="img/throbber.gif">
                         </button>
                     </div>
+                    <div class="alert alert-danger" ng-show="pineAPDStatus">
+                        <strong>{{ pineAPDStatus }}</strong>
+                    </div>
                 </div>
             </div>
         </div>