-
Notifications
You must be signed in to change notification settings - Fork 5
/
gengeoinfo.py
90 lines (71 loc) · 2.62 KB
/
gengeoinfo.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
import math
import argparse
import struct
import binascii
#python gengeoinfo.py --password aaaaa --gps +40.73150390,-73.96328405 --radius 0.5 --unit mm --out geoinfo.txt
def main():
parser = argparse.ArgumentParser(description='Generate key.')
parser.add_argument('--password', type=str, help='a password')
parser.add_argument('--gps', type=str, help='gps coordinates to use')
parser.add_argument('--radius', type=float, help='search radius(m) to use')
parser.add_argument('--unit', type=str, help='search unit to use')
parser.add_argument('--out', type=str, help='search list file for brute force attack')
args = parser.parse_args()
password = args.password
outfilename = args.out
#here insert validation function
gps = args.gps
centlatlong = gps.split(",")
if len(centlatlong) != 2:
print("invalid gps argument")
return
cenlat = float(centlatlong[0])
cenlong = float(centlatlong[1])
searchredius = args.radius
scanunit = args.unit
#earth mean radius mm
#637813700
earthradius = 6371008800
#calculate real degree unit for argument unit
earthtotallen = math.pi * 2.0 * earthradius
#calc square step
stepdgreepermm = 360.0 / earthtotallen
stepdgree = 0.00000001
iterator = int(searchredius * 1000)
if scanunit == "mm":
#https://en.wikipedia.org/wiki/Decimal_degrees
stepdgree = 0.00000001
elif scanunit == "cm":
stepdgree = 0.00000010
iterator = int(iterator/10)
elif scanunit == "dm":
stepdgree = 0.00000100
iterator = int(iterator/100)
elif scanunit == "m":
stepdgree = 0.00001000
iterator = int(iterator/1000)
#calc left top and iterator round
k = 0
#open out file
try:
fout = open(outfilename, 'w')
for i in range(-iterator, iterator + 1):
for j in range(-iterator, iterator + 1):
lat = cenlat + i * stepdgree
long = cenlong + j * stepdgree
strlat = '%.08f' % lat
strlong = '%.08f' % long
if lat > 0.0:
strlat = "+" + strlat
if long > 0.0:
strlong = "+" + strlong
strlatlong = strlat + "," + strlong
#print(strlatlong)
strline = password + " " + strlatlong + '\n'
fout.write(strline)
fout.close()
except IOError:
print("Could not write file!")
print("Compete!")
if __name__== "__main__":
main()