Skip to content

Commit

Permalink
Merge pull request #62 from doronz88/feature/ios_airplane_mode
Browse files Browse the repository at this point in the history
Feature/ios airplane mode
  • Loading branch information
doronz88 authored Feb 15, 2022
2 parents d12a848 + c45bc3d commit 708e478
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
38 changes: 23 additions & 15 deletions src/ents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,44 @@
<dict>
<key>application-identifier</key>
<string>com.cyber.rpcserver</string>
<key>platform-application</key>
<true/>
<key>platform-application</key>
<true/>
<key>com.apple.private.security.no-container</key>
<true/>
<key>com.apple.wlan.authentication</key>
<true/>
<true/>
<key>com.apple.wifi.manager-access</key>
<true/>
<true/>
<key>task_for_pid-allow</key>
<true/>
<true/>
<key>com.apple.private.tcc.allow</key>
<array>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
</array>
<key>com.apple.security.device.audio-input</key>
<true/>
<true/>
<key>com.apple.security.device.microphone</key>
<true/>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<true/>
<key>com.apple.security.personal-information.addressbook</key>
<true/>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<true/>
<key>com.apple.SystemConfiguration.SCDynamicStore-write-access</key>
<true/>
<key>com.apple.SystemConfiguration.SCPreferences-write-access</key>
<array>
<string>com.apple.AutoWake.xml</string>
<string>preferences.plist</string>
<string>com.apple.radios.plist</string>
</array>
</dict>
</plist>
5 changes: 5 additions & 0 deletions src/rpcclient/rpcclient/darwin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def uname(self):
def is_idevice(self):
return self.uname.machine.startswith('i')

def set_airplane_mode(self, mode: bool):
preferences = self.symbols.objc_getClass('RadiosPreferences').objc_call('new')
preferences.objc_call('setAirplaneMode:', mode)
preferences.objc_call('synchronize')

def symbol(self, symbol: int):
""" at a symbol object from a given address """
return DarwinSymbol.create(symbol, self)
Expand Down
40 changes: 18 additions & 22 deletions src/rpcclient/rpcclient/darwin/network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ctypes
import logging
import time
from typing import List

from rpcclient.exceptions import BadReturnValueError, RpcClientException
Expand Down Expand Up @@ -84,10 +83,6 @@ def _set(self, is_on: bool):
if self._client.symbols.WiFiDeviceClientSetPower(self._device, is_on):
raise BadReturnValueError(f'WiFiDeviceClientSetPower failed ({self._client.last_error})')

# bugfix: this is an async operation, so we need to wait some time
while self.is_on() != is_on:
time.sleep(.1)

if is_on:
if self._client.symbols.WiFiManagerClientEnable(self._wifi_manager_client):
raise BadReturnValueError(f'WiFiManagerClientEnable failed ({self._client.last_error})')
Expand Down Expand Up @@ -138,28 +133,29 @@ def wifi_interfaces(self) -> List[str]:

def get_wifi_interface(self, interface_name: str = None) -> WifiInterface:
""" get a specific wifi interface object for remote controlling """
with self._client.safe_malloc(8) as p_interface:
if self._client.symbols.Apple80211Open(p_interface):
with self._client.safe_malloc(8) as p_handle:
if self._client.symbols.Apple80211Open(p_handle):
raise BadReturnValueError(f'Apple80211Open failed ({self._client.last_error})')
handle = p_handle[0]

if interface_name is None:
wifi_interfaces = self.wifi_interfaces
if interface_name is None:
wifi_interfaces = self.wifi_interfaces

if not wifi_interfaces:
raise RpcClientException('no available wifi interfaces were found')
if not wifi_interfaces:
raise RpcClientException('no available wifi interfaces were found')

interface_name = wifi_interfaces[0]
interface_name = wifi_interfaces[0]

if self._client.symbols.Apple80211BindToInterface(p_interface[0], self._client.cf(interface_name)):
raise BadReturnValueError(f'Apple80211BindToInterface failed ({self._client.last_error})')
if self._client.symbols.Apple80211BindToInterface(handle, self._client.cf(interface_name)):
raise BadReturnValueError(f'Apple80211BindToInterface failed ({self._client.last_error})')

wifi_manager_client = self._client.symbols.WiFiManagerClientCreate(0, 0)
if not wifi_manager_client:
raise BadReturnValueError('WiFiManagerClientCreate failed')
wifi_manager_client = self._client.symbols.WiFiManagerClientCreate(0, 0)
if not wifi_manager_client:
raise BadReturnValueError('WiFiManagerClientCreate failed')

device = self._client.symbols.WiFiManagerClientGetDevice(wifi_manager_client,
self._client.cf(interface_name))
if not device:
raise BadReturnValueError('WiFiManagerClientGetDevice failed')
device = self._client.symbols.WiFiManagerClientGetDevice(wifi_manager_client,
self._client.cf(interface_name))
if not device:
raise BadReturnValueError('WiFiManagerClientGetDevice failed')

return WifiInterface(self._client, p_interface[0], wifi_manager_client, device)
return WifiInterface(self._client, handle, wifi_manager_client, device)

0 comments on commit 708e478

Please sign in to comment.