Repository navigation
Expand file tree
/
Copy pathinstall.py
More file actions
92 lines (71 loc) · 2.25 KB
/
Copy pathinstall.py
File metadata and controls
92 lines (71 loc) · 2.25 KB
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
"""
This program 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 <https://www.gnu.org/licenses/>.
"""
import pyAesCrypt
import os
import json
from random import randint
if os.getuid() > 0:
print("Run as root :)")
exit()
CONFIG_FILE = open("config.json", "r")
CONFIG = json.load(CONFIG_FILE)
CMD_PATH = CONFIG["cmd_dir"] + CONFIG["name"]
BASE = CONFIG["install_dir"] + CONFIG["name"]
def create_dir():
print("creating {0}...".format(BASE), end="")
os.system("mkdir " + BASE)
print("done")
if not os.path.exists(BASE):
create_dir()
else:
print(BASE + " already exists")
choice = input("Delete and recreate? [Y/n] ")
if choice in "Yy":
print("deleting {0}...".format(BASE))
os.system("rm -rf " + BASE)
print("done")
create_dir()
print("copying this directory to {0}...".format(BASE), end="")
os.system("cp -rf . " + BASE)
print("done")
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,/+-*_-<>"
KEY = ""
print("generating key...", end="")
for i in range(len(chars)):
KEY += chars[randint(0, len(chars)-1)]
print("done")
key_file = open(BASE + "/.key", "w")
key_file.write(KEY)
key_file.close()
DATA_FILE = open(BASE + "/data.json", "w")
d = {
"email": 0,
"alias": 0,
"password": 0
}
json.dump(d, DATA_FILE)
DATA_FILE.close()
bufferSize = 64 * 1024
pyAesCrypt.encryptFile(BASE + "/data.json", BASE + "/data.json.aes", KEY, bufferSize)
os.system("rm -rf {0}".format(BASE + "/data.json"))
print("creating command {0}...".format(CMD_PATH), end="")
f = open(CMD_PATH, "w")
f.write("""
#! /bin/bash
python3 {0}
""".format(BASE))
f.close()
print("done")
print("executing: chmod ugo+x {0}...".format(CMD_PATH), end="")
os.system("chmod +x " + CMD_PATH)
print("done")