forked from iOSForensics/pymobiledevice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
house_arrest.py
executable file
·75 lines (58 loc) · 2.34 KB
/
house_arrest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf8 -*-
#
# $Id$
#
# Copyright (c) 2012-2014 "dark[-at-]gotohack.org"
#
# This file is part of pymobiledevice
#
# pymobiledevice is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
import os
from lockdown import LockdownClient
from pprint import pprint
from afc import AFCClient, AFCShell
from optparse import OptionParser
class HouseArrestClient(AFCClient):
def __init__(self, lockdown=None,serviceName="com.apple.mobile.house_arrest", service=None):
self.serviceName = serviceName
self.lockdown = lockdown if lockdown else LockdownClient()
self.service = service if service else self.lockdown.startService(self.serviceName)
def stop_session(self):
print "Disconecting..."
self.service.close()
def send_command(self, applicationId, cmd="VendDocuments"):
self.service.sendPlist({"Command": cmd, "Identifier": applicationId})
res = self.service.recvPlist()
if res.get("Error"):
print res["Error"]
return None
def shell(self,applicationId,cmd="VendDocuments"):
res = self.send_command(applicationId, cmd="VendDocuments")
if res:
AFCShell(client=self.service).cmdloop()
if __name__ == "__main__":
parser = OptionParser(usage="%prog -a applicationId")
parser.add_option("-a", "--application", dest="applicationId", default=False,
help="Application ID <com.apple.iBooks>", type="string")
parser.add_option("-c", "--command", dest="cmd", default=False,
help="House_Arrest commands: ", type="string")
(options, args) = parser.parse_args()
h = HouseArrestClient()
if options.cmd:
h.shell(options.applicationId)
else:
h.shell(options.applicationId, cmd=options.cmd)