forked from trustedsec/social-engineer-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setoolkit
executable file
·285 lines (233 loc) · 9.75 KB
/
setoolkit
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env python
# coding=utf-8
import os
import re
import shutil
import subprocess
import sys
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
# import main core functionality into SET
import src.core.setcore as core
# check which operating system
operating_system = core.check_os()
if operating_system == "posix":
#
# ROOT CHECK
#
if os.geteuid() != 0:
print("\n The Social-Engineer Toolkit (SET) - by David Kennedy (ReL1K)")
print("\n Not running as root. \n\nExiting the Social-Engineer Toolkit (SET).\n")
core.exit_set()
# if we are running in the path no need to change
if os.path.isfile("setoolkit"):
pass
# check where we are and load default directory
elif os.path.isdir("/usr/share/setoolkit"):
if not os.path.isfile("setoolkit"):
os.chdir("/usr/share/setoolkit")
sys.path.append("/usr/share/setoolkit")
# check where we are and load default directory
elif os.path.isdir("/usr/share/set"):
if not os.path.isfile("setoolkit"):
os.chdir("/usr/share/set")
sys.path.append("/usr/share/set")
# make sure the config file is located in /etc/setoolkit
if not os.path.isdir("/etc/setoolkit/"):
os.makedirs("/etc/setoolkit/")
shutil.copyfile("src/core/config.baseline", "/etc/setoolkit/set.config")
if not os.path.isfile("/etc/setoolkit/set.config"):
shutil.copyfile("src/core/config.baseline", "/etc/setoolkit/set.config")
# here we check to ensure we have the latest version
with open("/etc/setoolkit/set.config") as fileopen:
data = fileopen.read()
if "CONFIG_VERSION=7.7.9" not in data:
print("[*] Overwriting old config for updates to SET. Backing up your old one in /etc/setoolkit/")
shutil.move("/etc/setoolkit/set.config", "/etc/setoolkit/set.config.bak")
shutil.copyfile("src/core/config.baseline", "/etc/setoolkit/set.config")
# import after config checks have been properly created
from src.core.menu import text
from src.core.update_config import update_config
if os.path.isfile(os.path.join(core.userconfigpath, "version.lock")):
os.remove(os.path.join(core.userconfigpath, "version.lock"))
# check directory and make it
if not os.path.isdir("src/logs/"):
os.makedirs("src/logs/")
# check set logfile
if not os.path.isfile("src/logs/set_logfile.log"):
# create new log
with open("src/logs/set_logfile.log", "w") as filewrite:
filewrite.write("")
# use ~/.set
if operating_system == "posix":
if not os.path.isdir(core.userconfigpath):
# create the set variables
os.makedirs(core.userconfigpath)
# if for some reason it failed to pull the path
userdir = os.path.join(os.path.expanduser('~'), '.set')
if not os.path.isdir(userdir):
os.makedirs(userdir)
if not os.path.isdir(os.path.join(core.userconfigpath, "reports")):
os.makedirs(os.path.join(core.userconfigpath, "reports"))
# check to see if we have python-pycrypto
try:
from Crypto.Cipher import AES
except ImportError:
print("[!] The python-pycrypto python module not installed. You will lose the ability to use multi-pyinjector.")
pass
#
# The Social-Engineer Toolkit (SET) #
# Written by: David Kennedy (ReL1K) #
#
#
# this is the main menu structure for SET
# main menu
# update the main config per load
update_config()
# chmod routine
if operating_system == "posix":
# change permissions if nix
subprocess.Popen("chmod +x seautomate;"
"chmod +x set-update;"
"chmod +x setup.py;"
"chmod +x set-proxy;"
"chmod +x src/payloads/ratte/ratteserver;"
"chmod +x src/payloads/set_payloads/listener.py",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
dns = core.check_config("DNS_SERVER=")
if dns.lower() == "on":
core.start_dns()
# remove old files
for root, dirs, files in os.walk(core.userconfigpath):
for f in files:
try:
match = re.search(".svn|entries|all-wcprops|props|text-base|prop-base|tmp", f)
if not match:
os.unlink(os.path.join(root, f))
# if they are being used then ignore
except:
pass
# loop through all the directories
for d in dirs:
try:
match = re.search(".svn|entries|all-wcprops|props|text-base|prop-base|tmp", d)
if not match:
shutil.rmtree(os.path.join(root, d))
except:
pass
# if there isn't a set_config.py file yet, create one
if not os.path.isfile("/etc/setoolkit/set_config.py"):
update_config()
define_version = core.get_version()
core.cleanup_routine()
# create the set.options routine
with open(os.path.join(core.userconfigpath, "set.options"), "w") as filewrite:
filewrite.write("{This is the main SET configuration file for all options used in SET}\n")
try:
# Remove old Signed_Updates
if os.path.isfile(os.path.join(core.userconfigpath, "Signed_Update.jar")):
os.remove(os.path.join(core.userconfigpath, "Signed_Update.jar"))
# initial user menu
if not os.path.isfile("src/agreement4"):
with open("readme/LICENSE") as fileopen:
for line in fileopen:
print((line.rstrip()))
print("{0}The Social-Engineer Toolkit is designed purely"
" for good and not evil. If you are planning on "
"using this tool for malicious purposes that are "
"not authorized by the company you are performing "
"assessments for, you are violating the terms of "
"service and license of this toolset. By hitting "
"yes (only one time), you agree to the terms of "
"service and that you will only use this tool for "
"lawful purposes only.{1}".format(core.bcolors.RED, core.bcolors.ENDC))
print(core.bcolors.GREEN)
choice = input("\nDo you agree to the terms of service [y/n]: ")
choice += " " # b/c method below
if choice[0].lower() == "y":
with open("src/agreement4", "w") as filewrite:
filewrite.write("user accepted")
print(core.bcolors.ENDC)
else:
print(core.bcolors.ENDC + "[!] Exiting the Social-Engineer Toolkit, have a nice day." + core.bcolors.ENDC)
sys.exit()
while True:
core.show_banner(define_version, '1')
show_main_menu = core.create_menu(text.main_text, text.main_menu)
# special case of list item 99
print('\n 99) Exit the Social-Engineer Toolkit\n')
# main core menu
main_menu_choice = (input(core.setprompt("0", "")))
# funny
if main_menu_choice == "hugs":
core.print_warning("Have you given someone a hug today? Remember a hug can change the world.")
pause = input("\nPlease give someone a hug then press {return} to continue.")
# funny2
if main_menu_choice == "freehugs":
core.print_warning("HUGS ARE ALWAYS FREE! NEVER CHARGE! ALWAYS HUG.")
pause = input("\nDo not press return until giving someone a hug.")
# funny3
if main_menu_choice == "derbycon":
core.print_warning(core.bcolors.BOLD + "YAYYYYYYYYYYYYYYYYYYYYYY DerbyCon.\n\nDerbyCon 7.0 'Legacy' -- September 22th - 24th 2017" + core.bcolors.ENDC)
pause = input(core.bcolors.BOLD + "\nDon't miss it! Sep 23 - Sep 25th! Press {return} to continue." + core.bcolors.ENDC)
# rance
if main_menu_choice == "rance":
core.print_warning(core.bcolors.BOLD + "We miss you buddy. David Jones (Rance) changed a lot of us and you'll always be apart of our lives (and SET). Fuck Cancer." + core.bcolors.ENDC)
pause = input("Press {return} to continue.")
# cavs
if main_menu_choice == "cavs":
core.print_warning(core.bcolors.BOLD + "2015-2016 CHAMPS BABY!!! C l e e e e e e v eeee l a a n n d d d d d d d d d d d " + core.bcolors.ENDC)
pause = input("Press {return} to continue.")
# quit out
if main_menu_choice == 'exit' or main_menu_choice == "99" or main_menu_choice == "quit":
core.exit_set()
# cleans up stale processes from SET
try:
# kill anything python running on 80
core.kill_proc("80", "python")
# kill anything on 443 ruby which is generally a rogue listener
core.kill_proc("443", "ruby")
except:
pass
# load set
if main_menu_choice == '1':
try:
core.module_reload(src.core.set)
except:
import src.core.set
# load fasttrack
if main_menu_choice == '2':
try:
core.module_reload(src.core.fasttrack)
except:
import src.core.fasttrack
# third party modules
if main_menu_choice == '3':
try:
core.module_reload(src.core.module_handler)
except:
import src.core.module_handler
# update set
if main_menu_choice == '4':
core.update_set()
# credits
if main_menu_choice == '5':
update_config()
# update config
if main_menu_choice == '6':
core.help_menu()
# handle keyboard interrupts
except KeyboardInterrupt:
print(("\n\nThank you for {0}shopping{1} with the Social-Engineer Toolkit."
"\n\nHack the Gibson...and remember...hugs are worth more "
"than handshakes.\n".format(core.bcolors.RED, core.bcolors.ENDC)))
# handle exceptions
except Exception as error:
core.log(error)
print("\n\n[!] Something went wrong, printing the error: " + str(error))
# cleanup routine
core.cleanup_routine()