2015-07-29 02:24:53 +00:00
#!/usr/bin/env python
2016-01-07 18:31:38 +00:00
2013-07-25 12:46:13 +00:00
import os
import sys
2015-07-10 18:29:08 +00:00
import shutil
2015-10-15 10:13:18 +00:00
import subprocess
2013-10-30 20:50:24 +00:00
# if we are running in the path no need to change
if os.path.isfile("setoolkit"):
pass
2013-07-25 12:46:13 +00:00
# check where we are and load default directory
2013-10-30 20:50:24 +00:00
elif os.path.isdir("/usr/share/setoolkit"):
2016-01-13 03:29:04 +00:00
if not os.path.isfile("setoolkit"):
2016-01-14 20:52:38 +00:00
os.chdir("/usr/share/setoolkit")
2016-01-13 03:29:04 +00:00
sys.path.append("/usr/share/setoolkit")
2013-07-25 12:46:13 +00:00
# check where we are and load default directory
2013-10-30 20:50:24 +00:00
elif os.path.isdir("/usr/share/set"):
if not os.path.isfile("setoolkit"):
2013-07-25 12:46:13 +00:00
os.chdir("/usr/share/set")
sys.path.append("/usr/share/set")
2015-07-10 18:29:08 +00:00
# make sure the config file is located in /etc/setoolkit
if not os.path.isdir("/etc/setoolkit/"):
2016-01-14 20:52:38 +00:00
os.makedirs("/etc/setoolkit/")
shutil.copyfile("src/core/config.baseline", "/etc/setoolkit/set.config")
2015-07-10 18:29:08 +00:00
if not os.path.isfile("/etc/setoolkit/set.config"):
2016-01-14 20:52:38 +00:00
shutil.copyfile("src/core/config.baseline", "/etc/setoolkit/set.config")
2015-07-10 18:29:08 +00:00
2016-01-13 03:29:04 +00:00
# here we check to ensure we have the latest version
data = open("/etc/setoolkit/set.config", "r").read()
2016-01-07 18:31:38 +00:00
if not "CONFIG_VERSION=7.0" in data:
2016-01-14 20:52:38 +00:00
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")
2013-07-25 12:46:13 +00:00
2016-01-13 03:29:04 +00:00
2013-07-25 12:46:13 +00:00
from src.core.setcore import *
from src.core.menu import text
2015-07-10 18:29:08 +00:00
from src.core.update_config import update_config
2014-05-20 12:35:43 +00:00
import shutil
import re
2013-07-25 12:46:13 +00:00
2015-10-15 12:04:02 +00:00
if check_kali() == "Kali":
2016-01-13 03:29:04 +00:00
if check_config("BLEEDING_EDGE=").lower() != "on":
print_status("Kali bleeding edge was not detected to be on...")
2016-01-14 20:52:38 +00:00
print_status(
"Kali install detected. Note that if you are not using bleeding edge repositories, your version of SET will be roughly 4 months behind.")
print_status(
"It is recommended to switch to bleeding-edge repos to ensure you are running the latest version of SET and other tools.")
pause = raw_input(
"Press [enter] to accept that SET is several months out of date and probably contains bugs and issues.")
2016-01-13 03:29:04 +00:00
2013-07-25 12:46:13 +00:00
# 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
2016-01-13 23:17:55 +00:00
filewrite = open("src/logs/set_logfile.log", "w")
2013-07-25 12:46:13 +00:00
filewrite.write("")
filewrite.close()
2014-12-03 02:14:30 +00:00
# check which operating system
2013-07-25 12:46:13 +00:00
operating_system = check_os()
# use ~/.set
if operating_system == "posix":
if not os.path.isdir(setdir):
# create the set variables
os.makedirs(setdir)
# if for some reason it failed to pull the path
2014-02-12 06:38:51 +00:00
userdir = os.path.join(os.path.expanduser('~'), '.set')
if not os.path.isdir(userdir):
os.makedirs(userdir)
2013-07-25 12:46:13 +00:00
if not os.path.isdir(setdir + "/reports/"):
os.makedirs(setdir + "/reports")
2014-05-20 12:35:43 +00:00
# check bleeding edge
bleeding_edge()
2013-07-25 12:46:13 +00:00
# check to see if we have python-pycrypto
try:
from Crypto.Cipher import AES
except ImportError:
2016-01-13 03:29:04 +00:00
print ("[!] The python-pycrypto python module not installed. You will lose the ability to use multi-pyinjector.")
2013-07-25 12:46:13 +00:00
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
2016-01-14 20:52:38 +00:00
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)
2013-07-25 12:46:13 +00:00
dns = check_config("DNS_SERVER=")
2014-12-03 02:14:30 +00:00
if dns.lower() == "on":
2016-01-14 20:52:38 +00:00
start_dns()
2013-07-25 12:46:13 +00:00
# remove old files
for root, dirs, files in os.walk(setdir):
for f in files:
try:
2016-01-14 20:52:38 +00:00
match = re.search(
".svn|entries|all-wcprops|props|text-base|prop-base|tmp", f)
2013-07-25 12:46:13 +00:00
if not match:
os.unlink(os.path.join(root, f))
# if they are being used then ignore
2016-01-14 20:52:38 +00:00
except:
pass
2013-07-25 12:46:13 +00:00
# loop through all the directories
for d in dirs:
try:
2016-01-14 20:52:38 +00:00
match = re.search(
".svn|entries|all-wcprops|props|text-base|prop-base|tmp", d)
2013-07-25 12:46:13 +00:00
if not match:
shutil.rmtree(os.path.join(root, d))
2016-01-14 20:52:38 +00:00
except:
pass
2013-07-25 12:46:13 +00:00
# if windows then do some stuff
if operating_system == "posix":
################################################
# ROOT CHECK
################################################
if os.geteuid() != 0:
2016-01-13 03:29:04 +00:00
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")
2013-07-25 12:46:13 +00:00
exit_set()
# if there isn't a set_config.py file yet, create one
2015-07-10 18:29:08 +00:00
if not os.path.isfile("/etc/setoolkit/set_config.py"):
2013-07-25 12:46:13 +00:00
update_config()
define_version = get_version()
cleanup_routine()
# create the set.options routine
2016-01-13 23:17:55 +00:00
filewrite = open(setdir + "/set.options", "w")
2016-01-14 20:52:38 +00:00
filewrite.write(
"{This is the main SET configuration file for all options used in SET}\n")
2013-07-25 12:46:13 +00:00
filewrite.close()
try:
# Remove old Signed_Updates
if os.path.isfile(setdir + "/Signed_Update.jar"):
os.remove(setdir + "/Signed_Update.jar")
# intitial user menu
if not os.path.isfile("src/agreement4"):
2016-01-13 23:17:55 +00:00
fileopen = open("readme/LICENSE", "r")
2013-07-25 12:46:13 +00:00
for line in fileopen:
2016-01-14 20:52:38 +00:00
print((line.rstrip()))
2013-07-25 12:46:13 +00:00
2016-01-14 20:52:38 +00:00
print((bcolors.RED + """
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.""" + bcolors.GREEN))
2013-07-25 12:46:13 +00:00
choice = raw_input("\nDo you agree to the terms of service [y/n]: ")
2016-01-14 20:52:38 +00:00
choice += " " # b/c method below
2014-12-03 02:14:30 +00:00
if choice[0].lower() == "y":
2016-01-13 23:17:55 +00:00
filewrite = open("src/agreement4", "w")
2013-07-25 12:46:13 +00:00
filewrite.write("user accepted")
filewrite.close()
2016-01-14 20:52:38 +00:00
print((bcolors.ENDC))
2013-07-25 12:46:13 +00:00
else:
2016-01-14 20:52:38 +00:00
print((
bcolors.ENDC + "[!] Exiting the Social-Engineer Toolkit, have a nice day." + bcolors.ENDC))
2013-07-25 12:46:13 +00:00
sys.exit()
2014-12-03 02:14:30 +00:00
while True:
2016-01-14 20:52:38 +00:00
show_banner(define_version, '1')
2013-07-25 12:46:13 +00:00
show_main_menu = create_menu(text.main_text, text.main_menu)
# special case of list item 99
2016-01-13 03:29:04 +00:00
print ('\n 99) Exit the Social-Engineer Toolkit\n')
2013-07-25 12:46:13 +00:00
2016-01-14 20:52:38 +00:00
# main core menu
2013-07-25 12:46:13 +00:00
main_menu_choice = (raw_input(setprompt("0", "")))
# funny
if main_menu_choice == "hugs":
2016-01-14 20:52:38 +00:00
print_warning(
"Have you given someone a hug today? Remember a hug can change the world.")
pause = raw_input(
"\nPlease give someone a hug then press {return} to continue.")
2013-07-25 12:46:13 +00:00
2016-01-13 03:29:04 +00:00
# funny2
if main_menu_choice == "freehugs":
print_warning("HUGS ARE ALWAYS FREE! NEVER CHARGE! ALWAYS HUG.")
2016-01-14 20:52:38 +00:00
pause = raw_input(
"\nDo not press return until giving someone a hug.")
2015-04-23 22:51:23 +00:00
# funny3
2013-07-25 12:46:13 +00:00
if main_menu_choice == "derbycon":
2016-01-14 20:52:38 +00:00
print_warning(
bcolors.BOLD + "YAYYYYYYYYYYYYYYYYYYYYYY DerbyCon.\n\nDerbyCon 6.0 -- September 23th - 25th 2016" + bcolors.ENDC)
pause = raw_input(
bcolors.BOLD + "\nDon't miss it! Sep 23 - Sep 25th! Press {return} to continue." + bcolors.ENDC)
2013-07-25 12:46:13 +00:00
# quit out
if main_menu_choice == 'exit' or main_menu_choice == "99" or main_menu_choice == "quit":
exit_set()
# cleans up stale processes from SET
try:
# kill anything python running on 80
2016-01-14 20:52:38 +00:00
kill_proc("80", "python")
2013-07-25 12:46:13 +00:00
# kill anything on 443 ruby which is generally a rogue listener
kill_proc("443", "ruby")
2016-01-14 20:52:38 +00:00
except:
pass
2013-07-25 12:46:13 +00:00
# load set
if main_menu_choice == '1':
try:
reload(src.core.set)
except:
import src.core.set
# load fasttrack
if main_menu_choice == '2':
2016-01-14 20:52:38 +00:00
try:
reload(src.core.fasttrack)
except:
import src.core.fasttrack
2013-07-25 12:46:13 +00:00
# third party modules
if main_menu_choice == '3':
2016-01-14 20:52:38 +00:00
try:
reload(src.core.module_handler)
except:
import src.core.module_handler
2013-07-25 12:46:13 +00:00
# update set
2014-05-20 12:35:43 +00:00
if main_menu_choice == '4':
2013-07-25 12:46:13 +00:00
update_set()
# credits
2014-05-20 12:35:43 +00:00
if main_menu_choice == '5':
2013-07-25 12:46:13 +00:00
update_config()
# update config
2014-05-20 12:35:43 +00:00
if main_menu_choice == '6':
2013-07-25 12:46:13 +00:00
help_menu()
# handle keyboard interrupts
except KeyboardInterrupt:
2016-01-14 20:52:38 +00:00
print(("\n\nThank you for " + bcolors.RED + "shopping" + bcolors.ENDC +
" with the Social-Engineer Toolkit.\n\nHack the Gibson...and remember...hugs are worth more than handshakes.\n"))
2013-07-25 12:46:13 +00:00
# handle exceptions
2016-01-14 20:52:38 +00:00
# except Exception as error:
2016-01-14 20:50:06 +00:00
# log(error)
# print ("\n\n[!] Something went wrong, printing the error: "+ str(error))
2013-07-25 12:46:13 +00:00
# cleanup routine
cleanup_routine()