Skip to content

Commit

Permalink
Merge pull request #344 from doronz88/feature/network-proxy-settings
Browse files Browse the repository at this point in the history
network: add proxy settings management
  • Loading branch information
doronz88 authored Feb 18, 2024
2 parents 97b5faf + e40f46e commit f30018e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/rpcclient/rpcclient/darwin/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rpcclient.structs.consts import SIGKILL

PINNING_RULED_DB = '/private/var/protected/trustd/pinningrules.sqlite3'
SYSTEM_CONFIGURATION_PLIST = '/private/var/Managed Preferences/mobile/com.apple.SystemConfiguration.plist'


class DarwinNetwork(Network):
Expand All @@ -17,6 +18,23 @@ def __init__(self, client):
def proxy_settings(self) -> Mapping:
return self._client.symbols.CFNetworkCopySystemProxySettings().py()

def set_http_proxy(self, ip: str, port: int) -> None:
with self._client.preferences.sc.open(SYSTEM_CONFIGURATION_PLIST) as config:
config.set('Proxies', {'HTTPProxyType': 1,
'HTTPEnable': 1,
'HTTPPort': port,
'HTTPSProxy': ip,
'HTTPSPort': port,
'HTTPProxy': ip,
'HTTPSEnable': 1,
'BypassAllowed': 0})
self._client.processes.get_by_basename('configd').kill(SIGKILL)

def remove_http_proxy(self) -> None:
with self._client.preferences.sc.open(SYSTEM_CONFIGURATION_PLIST) as config:
config.remove('Proxies')
self._client.processes.get_by_basename('configd').kill(SIGKILL)

def remove_certificate_pinning(self) -> None:
with self._client.fs.remote_file(PINNING_RULED_DB) as local_db_file:
# truncate pinning rules
Expand Down

0 comments on commit f30018e

Please sign in to comment.