-
Notifications
You must be signed in to change notification settings - Fork 10
/
iosdump.py
135 lines (106 loc) · 4.05 KB
/
iosdump.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/python
import sys
import shutil
import os
import os.path
from os.path import expanduser
import glob
import json
import sqlite3
import tempfile
import datetime
from ios import ios
# Global Variables
selected = -1
# List iTunes Backups
def selectBackup():
'List all the iOS Backups and prompt for selection'
global selected
for i in range(len(iosBackup.backups)):
iosBackup.select(i)
print ( str(i) + ":\t" + iosBackup.deviceName + " (" + str(iosBackup.lastBackupDate) + ")" )
print
selected = input("Select Backup to Dump: ")
if len(selected) > 0:
selected = int(selected)
else:
selected = 0
if selected < 0 or selected > len(iosBackup.backups) - 1:
print ( "Invalid Selection!" )
else:
iosBackup.select(selected)
print ( "You selected: " + str(selected) + " - " + iosBackup.deviceName + " (" + str(iosBackup.lastBackupDate) + ")" )
iosDumpData(selected)
def cleanFolder(folder):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
else:
shutil.rmtree(file_path)
except Exception as e:
print ( e )
def iosDumpData(selection):
iosBackup.index = selection
# Clean Up Previous Dump
if not os.path.exists(outputFolder):
os.mkdir(outputFolder, 0o755)
else:
cleanFolder(outputFolder)
os.mkdir(outputFolder + "contacts", 0o755)
os.mkdir(outputFolder + "db", 0o755)
os.mkdir(outputFolder + "roll", 0o755)
os.mkdir(outputFolder + "rec", 0o755)
os.mkdir(outputFolder + "sms", 0o755)
os.mkdir(outputFolder + "vm", 0o755)
#print ( ios.dbRecordings
#print ( iosBackup.deviceName(0) + " (" + iosBackup.backups[0] + ")"
print ( outputFolder )
print ( iosBackup.path() )
# Copy Database Files to Output Folder
if os.path.exists(iosBackup.path() + ios.dbAddressBook):
shutil.copyfile(iosBackup.path() + ios.dbAddressBook, outputFolder + "db/AddressBook.sqlite")
if os.path.exists(iosBackup.path() + ios.dbAddressBookImages):
shutil.copyfile(iosBackup.path() + ios.dbAddressBookImages, outputFolder + "db/AddressBookImages.sqlite")
if os.path.exists(iosBackup.path() + ios.dbCalendar):
shutil.copyfile(iosBackup.path() + ios.dbCalendar, outputFolder + "db/Calendar.sqlite")
if os.path.exists(iosBackup.path() + ios.dbCallHistory):
shutil.copyfile(iosBackup.path() + ios.dbCallHistory, outputFolder + "db/call_history.sqlite")
if os.path.exists(iosBackup.path() + ios.dbNotes):
shutil.copyfile(iosBackup.path() + ios.dbNotes, outputFolder + "db/notes.sqlite")
if os.path.exists(iosBackup.path() + ios.dbPhotos):
shutil.copyfile(iosBackup.path() + ios.dbPhotos, outputFolder + "db/Photos.sqlite")
if os.path.exists(iosBackup.path() + ios.dbRecordings):
shutil.copyfile(iosBackup.path() + ios.dbRecordings, outputFolder + "db/Recordings.sqlite")
if os.path.exists(iosBackup.path() + ios.dbSMS):
shutil.copyfile(iosBackup.path() + ios.dbSMS, outputFolder + "db/sms.sqlite")
if os.path.exists(iosBackup.path() + ios.dbVoicemail):
shutil.copyfile(iosBackup.path() + ios.dbVoicemail, outputFolder + "db/voicemail.sqlite")
print ( "Dumping SMS Messages" )
iosBackup.dumpSMS(outputFolder, "sms.json")
print ( "Dumping Call History" )
iosBackup.dumpCallHistory(outputFolder + "callhistory.json")
print ( "Dumping Address Book" )
iosBackup.dumpAddressBook(outputFolder)
print ( "Dumping Voicemail" )
iosBackup.dumpVoicemail(outputFolder, "voicemail.json")
print ( "Dumping Voice Memos" )
iosBackup.dumpMemos(outputFolder, "recordings.json")
print ( "Dumping Camera Roll" )
iosBackup.dumpCameraRoll(outputFolder, "cameraroll.json")
print ( "Dumping Notes" )
iosBackup.dumpNotes(outputFolder + "notes.json")
print ( "Dump Complete!" )
os.system("open " + outputFolder)
iosBackup = ios()
#outputFolder = expanduser("~") + "/Desktop/iOSDump/"
outputFolder = expanduser(".") + "/dump/"
if __name__ == "__main__":
# Initialize Objects & Set Output Folder
if not os.path.exists(outputFolder):
os.mkdir(outputFolder, 0o755)
else:
cleanFolder(outputFolder)
print ( "\nWhich iTunes Backup would you like to dump?\n" )
selectBackup()