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

Panel - Add " Interface actions" and other changes

DSR! 3 жил өмнө
parent
commit
f57d737809

+ 2 - 2
src/pineapple/api/pineapple.php

@@ -57,11 +57,11 @@ function dgramUdsSend($path, $message)
 	return true;
 }
 
-function uciGet($uciString)
+function uciGet($uciString, $autoBool = true)
 {
 	$uciString = escapeshellarg($uciString);
 	$result = exec("uci get {$uciString}");
-	if ($result === "0" || $result === "1") {
+	if ($autoBool && ($result === "0" || $result === "1")) {
 		return $result === "1";
 	}
 

+ 9 - 3
src/pineapple/modules/Networking/api/AccessPoint.php

@@ -12,13 +12,16 @@ class AccessPoint
         }
 
         uciSet('wireless.@wifi-iface[0].ssid', $apConfig->openSSID);
+        uciSet('wireless.@wifi-iface[0].disabled', $apConfig->disableOpenAP);
         uciSet('wireless.@wifi-iface[0].hidden', $apConfig->hideOpenAP);
         uciSet('wireless.@wifi-iface[0].maxassoc', $apConfig->maxClients);
+
         uciSet('wireless.@wifi-iface[1].ssid', $apConfig->managementSSID);
         uciSet('wireless.@wifi-iface[1].key', $apConfig->managementKey);
         uciSet('wireless.@wifi-iface[1].disabled', $apConfig->disableManagementAP);
         uciSet('wireless.@wifi-iface[1].hidden', $apConfig->hideManagementAP);
         execBackground('wifi');
+
         return array("success" => true);
     }
 
@@ -30,17 +33,20 @@ class AccessPoint
         // Remove radar detection channels
         $channels = array();
         foreach ($channelList[1] as $channel) {
-            if ((int)$channel < 52 || (int)$channel > 140) {
+            //if ((int)$channel < 52 || (int)$channel > 140) {
                 $channels[] = $channel;
-            }
+            //}
         }
 
         return array(
             "selectedChannel" => uciGet("wireless.radio0.channel"),
             "availableChannels" => $channels,
+
             "openSSID" => uciGet("wireless.@wifi-iface[0].ssid"),
-            "maxClients" => uciGet("wireless.@wifi-iface[0].maxassoc"),
+            "maxClients" => uciGet("wireless.@wifi-iface[0].maxassoc", false),
+            "disableOpenAP" => uciGet("wireless.@wifi-iface[0].disabled"),
             "hideOpenAP" => uciGet("wireless.@wifi-iface[0].hidden"),
+
             "managementSSID" => uciGet("wireless.@wifi-iface[1].ssid"),
             "managementKey" => uciGet("wireless.@wifi-iface[1].key"),
             "disableManagementAP" => uciGet("wireless.@wifi-iface[1].disabled"),

+ 2 - 1
src/pineapple/modules/Networking/api/Interfaces.php

@@ -97,6 +97,7 @@ class Interfaces
             array_push($clientInterfaces, $interface);
         }
 
-        return array_reverse($clientInterfaces);
+        //return array_reverse($clientInterfaces);
+        return $clientInterfaces;
     }
 }

+ 26 - 3
src/pineapple/modules/Networking/api/module.php

@@ -100,6 +100,10 @@ class Networking extends SystemModule
             case 'getInfoData':
                 $this->getInfoData();
                 break;
+
+            case 'interfaceActions':
+                $this->interfaceActions();
+                break;
         }
     }
 
@@ -274,9 +278,7 @@ class Networking extends SystemModule
 
     private function getInfoData()
     {
-        $type = (int)$this->request->type;
-        $command = '';
-        switch ($type) {
+        switch ((int)$this->request->type) {
             case 2:
                 $command = 'iw dev';
                 break;
@@ -290,4 +292,25 @@ class Networking extends SystemModule
         exec($command, $info);
         $this->response = implode("\n", $info);
     }
+
+    private function interfaceActions()
+    {
+        $interface = escapeshellarg($this->request->interface);
+        switch ((int)$this->request->type) {
+            case 2:
+                $command = "ifconfig {$interface} down";
+                break;
+            case 3:
+                $command = "airmon-ng start {$interface}";
+                break;
+            case 4:
+                $command = "airmon-ng stop {$interface}";
+                break;
+            default:
+                $command = "ifconfig {$interface} up";
+        }
+
+        exec($command, $info);
+        $this->response = implode("\n", $info);
+    }
 }

+ 42 - 6
src/pineapple/modules/Networking/js/module.js

@@ -59,6 +59,7 @@ registerController('NetworkingAccessPointsController', ['$api', '$scope', '$time
         selectedChannel: "1",
         openSSID: "",
         hideOpenAP: false,
+        disableOpenAP: false,
         managementSSID: "",
         managementKey: "",
         disableManagementAP: false,
@@ -248,7 +249,7 @@ registerController('NetworkingFirewallController', ['$api', '$scope', '$timeout'
 
 registerController('NetworkingMACAddressesController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
     $scope.interfaces = [];
-    $scope.selectedInterface = "wlan0";
+    $scope.selectedInterface = "";
     $scope.newMac = "";
     $scope.modifyingMAC = false;
     $scope.forceReload = false;
@@ -263,6 +264,7 @@ registerController('NetworkingMACAddressesController', ['$api', '$scope', '$time
             if (response.error === undefined) {
                 $scope.loading = false;
                 $scope.interfaces = response;
+                $scope.selectedInterface = Object.keys(response)[0];
             }
         });
     });
@@ -499,21 +501,55 @@ registerController("OUILookupController", ['$api', '$scope', '$timeout', '$http'
 }]);
 
 registerController('NetworkingInfoController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
-    $scope.info = 'Use buttons for load info';
-    $scope.loading = false;
+    $scope.interfaces = [];
+    $scope.info = '';
+    $scope.actions = '';
+
+    $scope.getInterfaces = (function() {
+        $scope.interfaces = [];
+        $scope.actions = 'loading';
+        $api.request({
+            module: 'Networking',
+            action: 'getClientInterfaces'
+        }, function(response) {
+            if (response.error === undefined) {
+                $scope.actions = '';
+                $scope.interfaces = response;
+            }
+        });
+    });
+
+    $scope.interfaceActions = (function(type, wlan) {
+        $scope.actions = 'loading';
+        $api.request({
+            module: 'Networking',
+            action: 'interfaceActions',
+            type: type,
+            interface: wlan
+        }, function(response) {
+            if (response.error === undefined) {
+                $scope.actions = response;
+
+                // reload interfaces in monitor command cases
+                if (type === 3 || type === 4) {
+                    $scope.getInterfaces();
+                }
+            }
+        });
+    });
 
     $scope.getInfoData = (function(type) {
-        $scope.info = 'Loading...';
-        $scope.loading = true;
+        $scope.info = 'loading';
         $api.request({
             module: 'Networking',
             action: 'getInfoData',
             type: type
         }, function(response) {
             if (response.error === undefined) {
-                $scope.loading = false;
                 $scope.info = response;
             }
         });
     });
+
+    $scope.getInterfaces();
 }]);

+ 46 - 7
src/pineapple/modules/Networking/module.html

@@ -226,18 +226,52 @@
             <div class="col-md-6 controller" ng-controller="NetworkingInfoController">
                 <div class="panel panel-default">
                     <div class="panel-heading">
-                        <h3 class="panel-title">Info</h3>
+                        <h3 class="panel-title">
+                            Interface actions
+                            <span class="pull-right">
+                                <button class="btn btn-default btn-xs btn-fixed-length" ng-disabled="loading" ng-click="getInterfaces();">
+                                    Refresh
+                                </button>
+                            </span>
+                        </h3>
                     </div>
                     <div class="panel-body">
                         <div class="col-md-12">
                             <div class="row">
-                                <button class="btn btn-default" ng-click="getInfoData(1)" ng-disabled="loading">ifconfig</button>
-                                <button class="btn btn-default" ng-click="getInfoData(2)" ng-disabled="loading">iw dev</button>
-                                <button class="btn btn-default" ng-click="getInfoData(3)" ng-disabled="loading">airmon-ng</button>
-                                <img src="img/throbber.gif" ng-hide="!loading">
+                                <div class="form-group" ng-repeat="interface in interfaces">
+                                    <div class="input-group">
+                                        <span class="input-group-addon">{{ interface }}</span>
+                                        <div class="btn-group" role="group">
+                                            <button type="button" class="btn btn-default" ng-click="interfaceActions(1, interface)" ng-disabled="actions == 'loading'">Up</button>
+                                            <button type="button" class="btn btn-default" ng-click="interfaceActions(2, interface)" ng-disabled="actions == 'loading'">Down</button>
+                                            <button type="button" class="btn btn-default" ng-click="interfaceActions(3, interface)" ng-disabled="actions == 'loading'">Monitor ON</button>
+                                            <button type="button" class="btn btn-default" ng-click="interfaceActions(4, interface)" ng-disabled="actions == 'loading'">Monitor OFF</button>
+                                        </div>
+                                    </div>
+                                </div>
+                                <img src="img/throbber.gif" ng-show="actions == 'loading'">
                             </div>
-                            <br/>
+                            <div class="row" ng-hide="actions == '' || actions == 'loading'">
+                                <br/>
+                                <pre class="scrollable-pre">{{ actions }}</pre>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="panel panel-default">
+                    <div class="panel-heading">
+                        <h3 class="panel-title">Info</h3>
+                    </div>
+                    <div class="panel-body">
+                        <div class="col-md-12">
                             <div class="row">
+                                <button class="btn btn-default" ng-click="getInfoData(1)" ng-disabled="info == 'loading'">ifconfig</button>
+                                <button class="btn btn-default" ng-click="getInfoData(2)" ng-disabled="info == 'loading'">iw dev</button>
+                                <button class="btn btn-default" ng-click="getInfoData(3)" ng-disabled="info == 'loading'">airmon-ng</button>
+                                <img src="img/throbber.gif" ng-show="info == 'loading'">
+                            </div>
+                            <div class="row" ng-hide="info == '' || info == 'loading'">
+                                <br/>
                                 <pre class="scrollable-pre">{{ info }}</pre>
                             </div>
                         </div>
@@ -356,11 +390,16 @@
                                 </div>
                                 <br/>
                                 <div class="input-group">
-                                    <div class="col-md-12">
+                                    <div class="col-md-5">
                                        <div class="checkbox">
                                             <label for="hideOpenAP"><input id="hideOpenAP" type="checkbox" value="" ng-model="apConfig['hideOpenAP']">Hide Open SSID</label>
                                         </div>
                                     </div>
+                                    <div class="col-md-5">
+                                        <div class="checkbox">
+                                            <label for="disableOpenAP"><input id="disableOpenAP" type="checkbox" value="" ng-model="apConfig['disableOpenAP']">Disable Open SSID</label>
+                                        </div>
+                                    </div>
                                 </div>
                                 <br/>
                                 <div class="input-group">

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

@@ -42,10 +42,11 @@
                         <div class="row">
                             <br/>
                             <div class="progress" ng-show="running && scanSettings.scanDuration > 0">
-                                <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="{{ percent }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ percent }}%">{{ percent | roundCeil }}%
+                                <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="{{ percent }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ percent }}%">
+                                    {{ percent | roundCeil }}%
                                 </div>
-                                <div class="alert well-sm alert-danger" ng-show="error">{{ error }}</div>
                             </div>
+                            <div class="alert well-sm alert-danger" ng-show="pineAPDRunning && pineAPDStatus && error">{{ error }}</div>
                         </div>
                     </div>
                 </div>