Skip to content

Commit

Permalink
client: add screen_capture
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Mar 24, 2022
1 parent dace09f commit 35f0e2d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
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.screen_capture import ScreenCapture
from rpcclient.ios.telephony import Telephony
from rpcclient.protocol import arch_t

Expand All @@ -19,6 +20,7 @@ def __init__(self, sock, sysname: str, arch: arch_t, hostname: str, port: int =
self.mobile_gestalt = MobileGestalt(self)
self.lockdown = Lockdown(self)
self.telephony = Telephony(self)
self.screen_capture = ScreenCapture(self)

@property
def roots(self) -> typing.List[str]:
Expand Down
25 changes: 25 additions & 0 deletions src/rpcclient/rpcclient/ios/screen_capture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from collections import namedtuple

from rpcclient.darwin.symbol import DarwinSymbol

CGRect = namedtuple('CGRect', 'x0 y0 x1 y1')


class ScreenCapture:
""" monitor screen events """

def __init__(self, client):
self._client = client

@property
def main_display(self) -> DarwinSymbol:
return self._client.symbols.objc_getClass('CADisplay').objc_call('mainDisplay')

@property
def bounds(self) -> CGRect:
d = self.main_display.objc_call('bounds', return_raw=True).d
return CGRect(x0=d[0], y0=d[1], x1=d[2], y1=d[3])

@property
def screenshot(self) -> bytes:
return self._client.symbols.UIImagePNGRepresentation(self._client.symbols._UICreateScreenUIImage()).py
11 changes: 11 additions & 0 deletions src/rpcserver/ents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<string>kTCCServiceCamera</string>
<string>kTCCServiceLocation</string>
<string>kTCCServiceBluetoothPeripheral</string>
<string>kTCCServiceScreenCapture</string>
</array>
<key>com.apple.private.icfcallserver</key>
<true/>
Expand All @@ -63,5 +64,15 @@
<string>voice</string>
<string>spi</string>
</array>
<key>com.apple.QuartzCore.global-capture</key>
<true/>
<key>com.apple.QuartzCore.get-client-port</key>
<true/>
<key>com.apple.accessibility.api</key>
<true/>
<key>com.apple.security.iokit-user-client-class</key>
<array>
<string>IOSurfaceRootUserClient</string>
</array>
</dict>
</plist>

0 comments on commit 35f0e2d

Please sign in to comment.