Skip to content

Commit

Permalink
Merge pull request #112 from doronz88/feature/telephony
Browse files Browse the repository at this point in the history
Feature/telephony
  • Loading branch information
doronz88 authored Mar 15, 2022
2 parents 79c26cf + 7145b28 commit 69119aa
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/rpcclient/rpcclient/ios/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rpcclient.ios.backlight import Backlight
from rpcclient.ios.lockdown import Lockdown
from rpcclient.ios.mobile_gestalt import MobileGestalt
from rpcclient.ios.telephony import Telephony

CRASH_REPORTS_DIR = 'Library/Logs/CrashReporter'

Expand All @@ -16,6 +17,7 @@ def __init__(self, sock, sysname: str, hostname: str, port: int = None):
self.reports = Reports(self, CRASH_REPORTS_DIR)
self.mobile_gestalt = MobileGestalt(self)
self.lockdown = Lockdown(self)
self.telephony = Telephony(self)

@property
def roots(self) -> typing.List[str]:
Expand Down
58 changes: 58 additions & 0 deletions src/rpcclient/rpcclient/ios/telephony.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
class Call:
def __init__(self, client, controller, call):
self._client = client
self._controller = controller
self._call = call

def disconnect(self):
"""
Disconnect the current call.
"""
self._send_action('CXEndCallAction')

def answer(self):
"""
Answer the current call.
"""
self._send_action('CXAnswerCallAction')

def _send_action(self, action_name):
action_class = self._client.symbols.objc_getClass(action_name)
action = action_class.objc_call('alloc').objc_call('initWithCallUUID:', self._uuid)
self._controller.objc_call('requestTransactionWithAction:completion:', action, self._client.get_dummy_block())

@property
def _uuid(self):
return self._call.objc_call('UUID')


class Telephony:
"""
Telephony utils.
In order to access the real telephony, the API requires the entitlement "application-identifier" to be set to
"com.apple.coretelephony".
"""

def __init__(self, client):
self._client = client
self.cx_call_controller = self._client.symbols.objc_getClass('CXCallController').objc_call('new')
self.cx_call_observer = self.cx_call_controller.objc_call('callObserver')

def dial(self, number: str):
"""
Start a call to a number. Use `current_call` to access the created call.
:param number: Phone address to call to.
"""
self._client.symbols.CTCallDial(self._client.cf(number))

@property
def current_call(self) -> Call:
"""
Return on object representing the current active call.
"""
calls = self.cx_call_observer.objc_call('calls')
for call_id in range(calls.objc_call('count')):
call = calls.objc_call('objectAtIndex:', call_id)
if call.objc_call('hasEnded'):
continue
return Call(self._client, self.cx_call_controller, call)
8 changes: 8 additions & 0 deletions src/rpcclient/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ def test_peek_invalid_address(client):
"""
with pytest.raises(ArgumentError):
client.peek(0, 0x10)


def test_calloc(client):
"""
:param rpcclient.client.Client client:
"""
with client.safe_calloc(0x100) as zeros:
assert client.peek(zeros, 0x100) == b'\x00' * 0x100
22 changes: 21 additions & 1 deletion src/rpcserver/ents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>com.cyber.rpcserver</string>
<string>com.apple.coretelephony</string>
<key>platform-application</key>
<true/>
<key>com.apple.private.security.no-container</key>
Expand Down Expand Up @@ -43,5 +43,25 @@
<string>kTCCServiceLocation</string>
<string>kTCCServiceBluetoothPeripheral</string>
</array>
<key>com.apple.private.icfcallserver</key>
<true/>
<key>com.apple.private.communicationsfilter</key>
<true/>
<key>com.apple.coretelephony.Calls.allow</key>
<true/>
<key>com.apple.CallKit.call-directory.extension-host</key>
<true/>
<key>com.apple.callkit</key>
<array>
<string>private-controller-api</string>
</array>
<key>com.apple.CallKit.call-directory</key>
<true/>
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>phone</string>
<string>voice</string>
<string>spi</string>
</array>
</dict>
</plist>

0 comments on commit 69119aa

Please sign in to comment.