-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_kml_from_data.py
201 lines (173 loc) · 5.65 KB
/
create_kml_from_data.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# !/usr/bin/env python3
import argparse
from argparse import RawDescriptionHelpFormatter
import time
from pathlib import Path
from rich.console import Console
__author__ = '@mikespon'
__dlu__ = '2024-05-12'
# Create the console object.
c = Console()
def main() -> None:
# Set up the argument parser syntax for the command line.
parser = argparse.ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
prog='create_kml_from_data.py',
usage='%(prog)s [options]',
description=f"""
===========================
create_kml_from_data.py
===========================\n
[-] Create a .kml file by reading the location records from
the database specified by the user.
[-] The '--btime' and '--etime' values should be given in 'Apple
Absolute Time' (a/k/a 'Cocoa Core Data') format. To convert
time values to/from the required input, see:
https://www.gaijin.at/en/tools/time-converter.
[-] For the '--database' argument, enter the corresponding
number for the database/table containing the records you want
to examine:\n
1 = Cache.sqlite (Location History),
2 = cache_encryptedB.db (WiFi locations),
3 = cache_encryptedB.db (LTE locations),
4 = Cloud-V2.sqlite (Significant Locations),
5 = Local.sqlite (Significant Location Visits), or
6 = Local.sqlite (Vehicle Locations)\n
[-] Example Syntax:\n
python .\create_kml_from_data.py --source [SOURCE] --dest [DEST] --destf [DESTF] --csv y --db 3 --btime [START_TIME] --etime [END_TIME]\n
[-] NOTE: If the directory paths contain spaces, enclose the full path in
double quotes.""",
epilog=f""" [-] DEVELOPED BY: {__author__} | LAST UPDATED: {__dlu__}"""
)
parser.add_argument(
'--source',
type=Path,
required=True,
help='[str] REQUIRED Path of database file to query.'
)
parser.add_argument(
'--dest',
type=Path,
required=True,
help='[str] REQUIRED Path to save the resulting .kml file.'
)
parser.add_argument(
'--destf',
type=str,
required=True,
help='[str] REQUIRED Name to use for the created .kml file.'
)
parser.add_argument(
'--csv',
type=str,
choices=['y','n'],
required=True,
help='[str] REQUIRED Create a .csv file with the results of the query.'
)
parser.add_argument(
'--db',
type=int,
choices=[1,2,3,4,5,6],
required=True,
help='[int] REQUIRED Number of the database file you want to examine.'
)
parser.add_argument(
'--btime',
type=int,
required=True,
help='[int] REQUIRED Timestamp of the first record to return.'
)
parser.add_argument(
'--etime',
type=int,
required=True,
help='[int] REQUIRED Timestamp of the last record to return.'
)
args = parser.parse_args()
argv = vars(args)
source = argv['source']
dest = argv['dest']
destf = argv['destf']
make_csv = argv['csv']
db_type = argv['db']
begin_time = argv['btime']
end_time = argv['etime']
# Get local time to print to screen when program begins.
t = time.localtime()
c.print(f"""[grey66]
=================================
Program started : [dodger_blue1] \
{time.strftime("%m-%d-%Y at %H:%M:%S", t)} ET
[grey66]=================================""")
# Format the local time to append to the beginning of the output file name.
file_time = time.strftime('%Y-%m-%d_%H%M%S', t)
if db_type == 1:
from cacheSqlite.cacheSqliteToKml import cacheSqliteToKml
cacheSqliteToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
elif db_type == 2:
from cacheEncBWifi.cacheEncBWifiToKml import cacheEncBWifiToKml
cacheEncBWifiToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
elif db_type == 3:
from cacheEncBLte.cacheEncBLteToKml import cacheEncBLteToKml
cacheEncBLteToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
elif db_type == 4:
from cloudV2SigLoc.cloudV2SigLocToKml import cacheV2SigLocToKml
cacheV2SigLocToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
elif db_type == 5:
from localSigLocVisits.localSigLocVisitsToKml import localSigLocVisitToKml
localSigLocVisitToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
elif db_type == 6:
from localVehicleLoc.localVehicleLocToKml import localVehicleLocToKml
localVehicleLocToKml(
source=source,
dest=dest,
destf=destf,
make_csv=make_csv,
begin_time=begin_time,
end_time=end_time,
file_time=file_time
)
else:
c.print('The code to examine the database you entered is not complete.')
if __name__ == '__main__':
main()