-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
66 lines (63 loc) · 2.83 KB
/
setup.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
# WheresPy? sPyWhere - setup
import os.path
import configparser
from cryptography.fernet import Fernet
# import IPy
print("-----------------")
print("WheresPy? config setup")
print("-----------------")
print()
# read wp.conf
if not os.path.isfile('wp.conf'):
print("wp.conf file does not exist! check host folder.")
print("aborting.")
exit()
# start initial setup
config = configparser.ConfigParser()
config.read(r'wp.conf')
if ((config.get('general', 'runsetup'))=="y"):
input('press ENTER to begin client setup.')
print("note: previously edited values will not be changed.")
print()
sudevicename = input('enter a name to be used for this device (client): ')
suserverip = input('enter ip of server: ')
suserverport = input('enter port of server: ')
sufreq = input('how often should client send reports? (seconds): ')
susendip = input('should client send ip address? (y/n): ')
susendnetworks = input('should client send log of local internet networks? (y/n): ')
suscreenshot = input('should client send screenshots? (y/n): ')
input('press ENTER to write new values to wp.conf... ')
# write into wp.conf
with open('wp.conf', 'r') as conffile :
confdata = conffile.read()
confdata = confdata.replace('runsetup=y', 'runsetup=n')
confdata = confdata.replace('devicename=X', 'devicename=' + sudevicename)
confdata = confdata.replace('serverip=X', 'serverip=' + suserverip)
confdata = confdata.replace('serverport=X', 'serverport=' + suserverport)
confdata = confdata.replace('sendnetworks=X', 'sendnetworks=' + susendnetworks)
confdata = confdata.replace('freq=X', 'freq=' + sufreq)
confdata = confdata.replace('sendip=X', 'sendip=' + susendip)
confdata = confdata.replace('screenshot=X', 'screenshot=' + suscreenshot)
print("new values have been written.")
with open('wp.conf', 'w') as conffile:
conffile.write(confdata)
else:
print("runsetup has been set to N. skipping setup questions.")
print()
print("press ENTER to generate a cryptography key.")
print("you may exit if you are going to use your own.")
input("make sure to create it yourself (filekey.key) and add to host folder for encryption to work!")
key = Fernet.generate_key()
# string the key in a file
with open('filekey.key', 'wb') as filekey:
filekey.write(key)
print()
print("keyfile.key has been created and setup is finished.")
print("you may now exit and delete setup.py")
print("note: you may also delete filekey.key on the server files to keep them secure.")
print("if filekey.key is not found on client, encryption will be skipped.")
print("there are further settings you can explore in wp.conf, check them out.")
print("i assume no responsibility for the outcomes of what you may use this software for.")
print("glhf!")
print(" -yoav33 on GitHub")
exit()