forked from noobscode/kalel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·194 lines (161 loc) · 7.17 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
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
#!/usr/bin/env python
import os
import time
import subprocess
import sys
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
# Make sure Tool is run via sudo or by root
if not os.geteuid() == 0:
sys.exit(bcolors.FAIL + "\nOnly root can run this script\nTry with $ sudo kalel" + bcolors.ENDC)
def install():
print("Setting up KalEl For You...")
# Create and Copy files to installdir /opt/KalEl
if os.path.isfile('/opt/KalEl/run.py'):
reinstall = raw_input('KalEl is allready installed!\nDo you want to reinstall? (y/n): ')
if reinstall == ('y'):
print('After removal is complete you have to run $ python setup.py again')
raw_input('Press [ENTER] to continue...')
reinstall()
else:
exit(1)
print("[*] Copying KalEl into the /opt/KalEl directory...")
cwdpath = os.getcwd()
subprocess.Popen("cp -rf %s /opt/KalEl" % cwdpath, shell=True).wait()
subprocess.Popen("mkdir /opt/KalEl/.kal", shell=True).wait()
# Create a symbolic link for performing actions via /usr/bin
subprocess.Popen("ln -s /opt/KalEl/run.py /opt/KalEl/kalel", shell=True).wait()
subprocess.Popen("ln -s /opt/KalEl/module/tor/tor.py /opt/KalEl/kalelvpn", shell=True).wait()
print("[*] Installing KalEl installer to /usr/bin/kalel...")
if os.path.isfile("/usr/bin/kalel"):
subprocess.Popen("rm /usr/bin/kalel", shell=True).wait()
else:
pass
# Link for main program
subprocess.Popen("echo #!/bin/bash > /usr/bin/kalel", shell=True).wait()
subprocess.Popen("echo cd /opt/KalEl >> /usr/bin/kalel", shell=True).wait()
subprocess.Popen("echo exec python2 kalel $@ >> /usr/bin/kalel", shell=True).wait()
subprocess.Popen("chmod +x /usr/bin/kalel", shell=True).wait()
# Link for TOR TOR VPN
subprocess.Popen("echo #!/bin/bash > /usr/bin/kalelvpn", shell=True).wait()
subprocess.Popen("echo cd /opt/KalEl >> /usr/bin/kalelvpn", shell=True).wait()
subprocess.Popen("echo exec python2 kalelvpn $@ >> /usr/bin/kalelvpn", shell=True).wait()
subprocess.Popen("chmod +x /usr/bin/kalelvpn", shell=True).wait()
fixpermissions()
# Check if config files is present, if they are we will remove them
if os.path.isfile("/opt/KalEl/src/setupOK"):
subprocess.call(['rm', '/opt/KalEl/src/setupOK'])
if os.path.isfile("/opt/KalEl/src/config.py"):
subprocess.call(['rm', '/opt/KalEl/src/config.py'])
# CHECK REQUIRED DEPENDENCIES
FNULL = open(os.devnull, 'w')
# Install sendemail for mail spoofing
try:
subprocess.call(["sendemail"], stdout=FNULL, stderr=subprocess.STDOUT)
except OSError as e:
if e.errno == os.errno.ENOENT:
print('sendemail not install, installing now')
subprocess.call(['sudo', 'apt-get', 'install', '-y', 'sendemail'])
else:
print("something else went wrong, try again")
raise
# Check if ettercap is installed or present
try:
subprocess.call(["ettercap"], stdout=FNULL, stderr=subprocess.STDOUT)
except OSError as e:
if e.errno == os.errno.ENOENT:
print("We cant seem to find ettercap-ng")
installettercap = raw_input('Would you like KalEl to try and install it?\n y/n: ')
if installettercap == ('y'):
subprocess.call(['sudo', 'apt-get', 'install', '-y', 'ettercap-text-only'])
print('Done')
else:
print("Please install ettercap or define it's install directory")
etterdir = raw_input("Define ettercap installation directory\nexample (default): /usr/bin/ettercap\nDir: ")
with open("/opt/KalEl/src/config.py", "w") as filewrite:
filewrite.write("\n#[ETTERCAP DIR]\n")
filewrite.write("etterdir")
filewrite.write(" = ")
filewrite.write("'%s'\n" % etterdir)
else:
print("something else went wrong, try again")
raise
# Install Tor bundle
subprocess.call(['apt-get', 'install', 'tor', '-y', '-qq'])
print('TOR Installed')
# Install dependencies for TOR
try:
import pip
except ImportError:
print('we could not find pip, trying to install pip now')
# Install PIP
subprocess.call(['apt-get', 'install', 'python3-pip', '-y'])
subprocess.call(['apt-get', 'install', 'python-pip', '-y'])
except Exception:
print("KalEl's VPN Module might not work because of missing pip")
else:
print('PIP install OK!')
pip.main(['install', 'stem'])
pip.main(['install', 'requests'])
pass
# Write setup to src/setupOK to let the tool know setup is complete
with open("/opt/KalEl/src/setupOK", "w") as filewrite:
filewrite.write("Installed")
print(bcolors.OKGREEN + "[*] We are now finished! To run KalEl, type kalel..." + bcolors.ENDC)
exit(1)
def fixpermissions():
# Write permission to run
subprocess.Popen(['chmod', '+x', '/opt/KalEl/run.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/tor/tor.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/trafficgen/getheader.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/ettercap/spoof.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/harvester/prep.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/harvester/engine.py'])
subprocess.Popen(['chmod', '+x', '/opt/KalEl/module/spoofmail/spoofmail.py'])
def uninstall():
print('KalEl Uninstaller...')
# Check if KalEl is installed
if not os.path.isfile('/opt/KalEl/run.py'):
if not os.path.isfile('/usr/bin/kalel'):
print('KaleEl Is not installed')
exit(1)
# If KalEl is installed we'll remove it
if os.path.isdir('/opt/KalEl'):
print('Found KalEl...')
print('Removing')
subprocess.Popen("rm /usr/bin/kalel*", shell=True).wait()
subprocess.Popen("rm -fr /root/.kal", shell=True).wait()
subprocess.Popen("cd ..;rm -fr /opt/KalEl", shell=True).wait()
print('Done! Bye KalEl :()')
time.sleep(2)
exit(1)
def reinstall():
if not os.path.isfile('/tmp/setup.py'):
subprocess.Popen('cp /opt/KalEl/setup.py /tmp/setup.py', shell=True).wait()
os.chdir('/tmp/')
subprocess.call(['setup.py', 'reinstall'], shell=True).wait()
subprocess.call(['git', 'clone', 'https://github.com/noobscode/kalel'], shell=True).wait()
subprocess.call('cd kalel/', shell=True).wait()
subprocess.call(['setup.py', 'uninstall'], shell=True).wait()
subprocess.call(['setup.py', 'install'], shell=True).wait()
arg = sys.argv[1:]
if len(arg) != 1:
print(bcolors.FAIL + '\n!!! Missing argument !!!' + bcolors.ENDC)
print(bcolors.OKGREEN + 'Choose argument: install/reinstall/uninstall' + bcolors.ENDC)
sys.exit(1)
elif sys.argv[1] == "install":
install()
elif sys.argv[1] == "reinstall":
reinstall()
elif sys.argv[1] == "uninstall":
uninstall()
else:
print('Choose argument: install/uninstall')
sys.exit(1)