فهرست منبع

Panel - PineAP: Configure used source interface (pineapd source_mac grabber)

DSR! 4 سال پیش
والد
کامیت
c33a2e6732

+ 4 - 3
README.md

@@ -1,7 +1,7 @@
 # Wifi Pineapple Panel
 
-The idea of this project is to have a **better panel** for the pineapple NANO/TETRA  
-To install it, you just have to copy the src folder to / of the pineapple.
+The idea of this project is to have a better panel for the pineapple NANO/TETRA  
+To install it, you just have to copy the src folder to / of the pineapple and reboot.
 
 
 # Changes
@@ -27,7 +27,8 @@ The following functionalities are modified looking for a better user experience
  - Change default text logic
 
 ## PineAP:
- - Configure used interface
+ - Configure used monitor interface (pineapd pineap_interface)
+ - Configure used source interface (pineapd source_mac grabber)
  - Show pineapd service errors
 
 ## Logging:

+ 9 - 9
src/etc/init.d/pineapd

@@ -17,7 +17,7 @@ logging = $(uci get pineap.@config[0].logging)
 mac_filter = $(uci get pineap.@config[0].mac_filter)
 ssid_filter = $(uci get pineap.@config[0].ssid_filter)
 ap_channel = $(uci get pineap.@config[0].ap_channel)
-pineap_mac = $(ifconfig -a wlan0 | grep HWaddr | awk '{print $5}')
+pineap_mac = $(ifconfig -a $(uci get pineap.@config[0].pineap_source_interface) | grep HWaddr | awk '{print $5}')
 target_mac = $(uci get pineap.@config[0].target_mac)
 pineap_interface = $(uci get pineap.@config[0].pineap_interface)
 recon_db_path = $(uci get pineap.@config[0].recon_db_path)
@@ -31,21 +31,21 @@ EOF
 }
 
 start() {
-    interface_mon=$(uci get pineap.@config[0].pineap_interface)
-    interface=${interface_mon/mon/''}
-
     mkdir -p /tmp/handshakes
     gen_config
-    
+
+    pineap_interface=$(uci -q get pineap.@config[0].pineap_interface)
+    pineap_interface_original=${pineap_interface/mon/''}
+
     #ifconfig wlan1mon &>/dev/null || airmon-ng start wlan1 &>/dev/null
-    ifconfig ${interface_mon} &>/dev/null || airmon-ng start ${interface} &>/dev/null
+    ifconfig ${pineap_interface} &>/dev/null || airmon-ng start ${pineap_interface_original} &>/dev/null
     /usr/sbin/pineapd /tmp/pineap.conf &>/dev/null & 
-    sleep 1
 
+    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}"
+    elif [[ ! $(ifconfig -a ${pineap_interface} | grep HWaddr | awk '{print $5}') ]]; then
+        echo "Status: Monitor interface won't start! Try to run manually airmon-ng start ${pineap_interface_original}"
     else
         echo "There is a problem with pineapd. Try to run it manually"
     fi

+ 31 - 0
src/etc/uci-defaults/93-pineap.sh

@@ -0,0 +1,31 @@
+# -- Set up PineAP configuration
+
+touch /etc/config/pineap
+uci add pineap config
+uci set pineap.@config[0].autostart=0
+uci set pineap.@config[0].karma='off'
+uci set pineap.@config[0].beacon_interval='NORMAL'
+uci set pineap.@config[0].beacon_response_interval='NORMAL'
+uci set pineap.@config[0].beacon_responses='off'
+uci set pineap.@config[0].capture_ssids='off'
+uci set pineap.@config[0].broadcast_ssid_pool='off'
+uci set pineap.@config[0].logging='off'
+uci set pineap.@config[0].mac_filter='black'
+uci set pineap.@config[0].ssid_filter='black'
+uci set pineap.@config[0].connect_notifications='off'
+uci set pineap.@config[0].disconnect_notifications='off'
+uci set pineap.@config[0].ap_channel=11
+uci set pineap.@config[0].pineap_interface='wlan1mon'
+uci set pineap.@config[0].pineap_source_interface='wlan0'
+
+uci set pineap.@config[0].pineap_mac='00:11:22:33:44:55'
+uci set pineap.@config[0].target_mac='FF:FF:FF:FF:FF:FF'
+uci set pineap.@config[0].recon_db_path='/tmp/recon.db'
+uci set pineap.@config[0].hostapd_db_path='/tmp/log.db'
+uci set pineap.@config[0].ssid_db_path='/etc/pineapple/pineapple.db'
+
+uci set pineap.@config[0].pineape_passthrough='off'
+
+uci commit pineap
+
+exit 0

+ 21 - 15
src/pineapple/modules/PineAP/api/PineAPHelper.php

@@ -2,6 +2,8 @@
 
 class PineAPHelper
 {
+    CONST CLI_PINEAPD = "/usr/sbin/pineapd";
+
     public function getSetting($settingKey)
     {
         $configFile = file_get_contents("/tmp/pineap.conf");
@@ -52,7 +54,7 @@ class PineAPHelper
 
     public function enableAssociations()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec("pineap /tmp/pineap.conf karma on");
         } else {
             $this->setSetting("karma", "on");
@@ -63,7 +65,7 @@ class PineAPHelper
 
     public function disableAssociations()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec("pineap /tmp/pineap.conf karma off");
         } else {
             $this->setSetting("karma", "off");
@@ -115,7 +117,7 @@ class PineAPHelper
 
     public function disableBeaconer()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf broadcast_pool off');
         } else {
             $this->setSetting("broadcast_ssid_pool", "off");
@@ -125,7 +127,7 @@ class PineAPHelper
 
     public function enableResponder()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf beacon_responses on');
         } else {
             $this->setSetting("beacon_responses", "on");
@@ -135,7 +137,7 @@ class PineAPHelper
 
     public function disableResponder()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf beacon_responses off');
         } else {
             $this->setSetting("beacon_responses", "off");
@@ -145,7 +147,7 @@ class PineAPHelper
 
     public function enableHarvester()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf capture_ssids on');
         } else {
             $this->setSetting("capture_ssids", "on");
@@ -155,7 +157,7 @@ class PineAPHelper
 
     public function disableHarvester()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf capture_ssids off');
         } else {
             $this->setSetting("capture_ssids", "off");
@@ -165,7 +167,7 @@ class PineAPHelper
 
     public function enableConnectNotifications()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf connect_notifications on');
         } else {
             $this->setSetting("connect_notifications", "on");
@@ -175,7 +177,7 @@ class PineAPHelper
 
     public function disableConnectNotifications()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf connect_notifications off');
         } else {
             $this->setSetting("connect_notifications", "off");
@@ -185,7 +187,7 @@ class PineAPHelper
 
     public function enableDisconnectNotifications()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf disconnect_notifications on');
         } else {
             $this->setSetting("disconnect_notifications", "on");
@@ -195,7 +197,7 @@ class PineAPHelper
 
     public function disableDisconnectNotifications()
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             exec('pineap /tmp/pineap.conf disconnect_notifications off');
         } else {
             $this->setSetting("disconnect_notifications", "off");
@@ -215,7 +217,7 @@ class PineAPHelper
 
     public function setBeaconInterval($interval)
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             $interval = escapeshellarg($interval);
             exec("pineap /tmp/pineap.conf beacon_interval {$interval}");
         } else {
@@ -227,7 +229,7 @@ class PineAPHelper
 
     public function setResponseInterval($interval)
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             $interval = escapeshellarg($interval);
             exec("pineap /tmp/pineap.conf beacon_response_interval {$interval}");
         } else {
@@ -239,7 +241,7 @@ class PineAPHelper
 
     public function setSource($mac)
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             $mac = escapeshellarg($mac);
             exec("pineap /tmp/pineap.conf set_source {$mac}");
         } else {
@@ -251,7 +253,7 @@ class PineAPHelper
 
     public function setTarget($mac)
     {
-        if (\helper\checkRunning("/usr/sbin/pineapd")) {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
             $mac = escapeshellarg($mac);
             exec("pineap /tmp/pineap.conf set_target {$mac}");
         } else {
@@ -274,6 +276,10 @@ class PineAPHelper
 
     public function setPineapInterface($interface)
     {
+        if (\helper\checkRunning(CLI_PINEAPD)) {
+            $this->disablePineAP();
+        }
+
         $this->setSetting("pineap_interface", "{$interface}");
         return true;
     }

+ 12 - 9
src/pineapple/modules/PineAP/api/module.php

@@ -436,15 +436,15 @@ class PineAP extends SystemModule
     {
         $sourceMAC = $this->pineAPHelper->getSource();
         $sourceMAC = $sourceMAC === false ? '00:00:00:00:00:00' : $sourceMAC;
-        $sourceMAC = strtoupper($sourceMAC);
+
         $targetMAC = $this->pineAPHelper->getTarget();
         $targetMAC = $targetMAC === false ? 'FF:FF:FF:FF:FF:FF' : $targetMAC;
-        $targetMAC = strtoupper($targetMAC);
+
         $settings = array(
-            'allowAssociations' => $this->pineAPHelper->getSetting("karma"),
-            'logEvents' => $this->pineAPHelper->getSetting("logging"),
             'pineAPDaemon' => $this->checkRunning("pineapd"),
             'autostartPineAP' => $this->uciGet("pineap.@config[0].autostart"),
+            'allowAssociations' => $this->pineAPHelper->getSetting("karma"),
+            'logEvents' => $this->pineAPHelper->getSetting("logging"),
             'beaconResponses' => $this->pineAPHelper->getSetting("beacon_responses"),
             'captureSSIDs' => $this->pineAPHelper->getSetting("capture_ssids"),
             'broadcastSSIDs' => $this->pineAPHelper->getSetting("broadcast_ssid_pool"),
@@ -452,10 +452,12 @@ class PineAP extends SystemModule
             'disconnectNotifications' => $this->pineAPHelper->getSetting("disconnect_notifications"),
             'broadcastInterval' => $this->pineAPHelper->getSetting("beacon_interval"),
             'responseInterval' => $this->pineAPHelper->getSetting("beacon_response_interval"),
-            'sourceMAC' => $sourceMAC,
-            'targetMAC' => $targetMAC,
-            'interface' => $this->pineAPHelper->getSetting("pineap_interface"),
+            'monitorInterface' => $this->pineAPHelper->getSetting("pineap_interface"),
+            'sourceInterface' => $this->uciGet("pineap.@config[0].pineap_source_interface"),
+            'sourceMAC' => strtoupper($sourceMAC),
+            'targetMAC' => strtoupper($targetMAC),
         );
+
         $this->response = array('settings' => $settings, 'success' => true);
         return $settings;
     }
@@ -520,8 +522,9 @@ class PineAP extends SystemModule
         $this->uciSet("pineap.@config[0].target_mac", $settings->targetMAC);
         $this->pineAPHelper->setSource($settings->sourceMAC);
         $this->uciSet("pineap.@config[0].pineap_mac", $settings->sourceMAC);
-        $this->pineAPHelper->setPineapInterface($settings->interface);
-        $this->uciSet("pineap.@config[0].pineap_interface", $settings->interface);
+        $this->uciSet("pineap.@config[0].pineap_source_interface", $settings->sourceInterface);
+        $this->pineAPHelper->setPineapInterface($settings->monitorInterface);
+        $this->uciSet("pineap.@config[0].pineap_interface", $settings->monitorInterface);
 
         $this->response = array("success" => true);
     }

+ 7 - 7
src/pineapple/modules/PineAP/js/module.js

@@ -153,13 +153,13 @@ registerController('PineAPSettingsController', ['$api', '$scope', function($api,
         disconnectNotifications: false,
         broadcastInterval: 'NORMAL',
         responseInterval: 'NORMAL',
+        monitorInterface: 'wlan1mon',
+        sourceInterface: 'wlan0',
         sourceMAC: '00:00:00:00:00:00',
-        targetMAC: 'FF:FF:FF:FF:FF:FF',
-        interface: 'wlan1mon'
+        targetMAC: 'FF:FF:FF:FF:FF:FF'
     };
-    $scope.interfaces = [];
 
-    $scope.togglePineAP = (function() {
+    $scope.togglePineAP = function() {
         $scope.pineAPenabling = true;
         var actionString = $scope.settings.pineAPDaemon ? "disable" : "enable";
         $api.request({
@@ -171,9 +171,9 @@ registerController('PineAPSettingsController', ['$api', '$scope', function($api,
                 $scope.getSettings();
             }
         });
-    });
+    };
 
-    $scope.toggleAutoStart = (function() {
+    $scope.toggleAutoStart = function() {
         var actionString = $scope.settings.autostartPineAP ? "disableAutoStart" : "enableAutoStart";
         $api.request({
             module: 'PineAP',
@@ -183,7 +183,7 @@ registerController('PineAPSettingsController', ['$api', '$scope', function($api,
                 $scope.getSettings();
             }
         });
-    });
+    };
 
     $scope.getSettings = function() {
         $api.request({

+ 8 - 4
src/pineapple/modules/PineAP/module.html

@@ -92,6 +92,14 @@
                             </select>
                         </div>
                         <br/>
+                       <div class="input-group margin-bottom">
+                            <span class="fixed-addon-width-3 input-group-addon">Monitor Interface</span>
+                            <input type="text" maxlength="8" class="form-control" ng-model="settings.monitorInterface">
+                        </div>
+                        <div class="input-group margin-bottom">
+                            <span class="fixed-addon-width-3 input-group-addon">Source Interface</span>
+                            <input type="text" maxlength="8" class="form-control" ng-model="settings.sourceInterface">
+                        </div>
                         <div class="input-group margin-bottom">
                             <span class="fixed-addon-width-3 input-group-addon">Source MAC</span>
                             <input type="text" maxlength="17" class="form-control" ng-model="settings.sourceMAC">
@@ -100,10 +108,6 @@
                             <span class="fixed-addon-width-3 input-group-addon">Target MAC</span>
                             <input type="text" maxlength="17" class="form-control" ng-model="settings.targetMAC">
                         </div>
-                        <div class="input-group margin-bottom">
-                            <span class="fixed-addon-width-3 input-group-addon">Interface</span>
-                            <input type="text" maxlength="8" class="form-control" ng-model="settings.interface">
-                        </div>
                         <br/>
                         <div class="input-group">
                             <button class="btn btn-default" ng-hide="disableButton" ng-click="updateSettings()">Save