social-engineer-toolkit/setoolkit

284 lines
9.7 KiB
Text
Raw Normal View History

2016-01-25 01:23:04 +00:00
#!/usr/bin/env python
# coding=utf-8
2016-01-25 01:23:04 +00:00
import os
2016-07-22 16:52:36 +00:00
import re
2016-01-25 01:23:04 +00:00
import shutil
import subprocess
2016-07-22 16:52:36 +00:00
import sys
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
2016-01-25 01:23:04 +00:00
# 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()
2016-08-02 22:28:39 +00:00
if "CONFIG_VERSION=7.3.9" not in data:
2016-07-22 16:52:36 +00:00
print("[*] Overwriting old config for updates to SET. Backing up your old one in /etc/setoolkit/")
2016-01-25 01:23:04 +00:00
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
2016-07-22 16:52:36 +00:00
import src.core.setcore as core
from src.core.menu import text
from src.core.update_config import update_config
2016-01-25 01:23:04 +00:00
if os.path.isfile(os.path.join(core.setdir, "version.lock")):
os.remove(os.path.join(core.setdir, "version.lock"))
2016-07-21 11:23:56 +00:00
2016-01-25 01:23:04 +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
with open("src/logs/set_logfile.log", "w") as filewrite:
filewrite.write("")
2016-01-25 01:23:04 +00:00
# check which operating system
2016-07-22 16:52:36 +00:00
operating_system = core.check_os()
2016-01-25 01:23:04 +00:00
# use ~/.set
if operating_system == "posix":
2016-07-22 16:52:36 +00:00
if not os.path.isdir(core.setdir):
2016-01-25 01:23:04 +00:00
# create the set variables
2016-07-22 16:52:36 +00:00
os.makedirs(core.setdir)
2016-01-25 01:23:04 +00:00
# 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.setdir, "reports")):
os.makedirs(os.path.join(core.setdir, "reports"))
2016-01-25 01:23:04 +00:00
# check to see if we have python-pycrypto
try:
from Crypto.Cipher import AES
except ImportError:
2016-07-22 16:52:36 +00:00
print("[!] The python-pycrypto python module not installed. You will lose the ability to use multi-pyinjector.")
2016-01-25 01:23:04 +00:00
pass
#
2016-01-25 01:23:04 +00:00
# The Social-Engineer Toolkit (SET) #
# Written by: David Kennedy (ReL1K) #
#
2016-01-25 01:23:04 +00:00
#
# 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)
2016-01-25 01:23:04 +00:00
2016-07-22 16:52:36 +00:00
dns = core.check_config("DNS_SERVER=")
2016-01-25 01:23:04 +00:00
if dns.lower() == "on":
2016-07-22 16:52:36 +00:00
core.start_dns()
2016-01-25 01:23:04 +00:00
# remove old files
2016-07-22 16:52:36 +00:00
for root, dirs, files in os.walk(core.setdir):
2016-01-25 01:23:04 +00:00
for f in files:
try:
match = re.search(".svn|entries|all-wcprops|props|text-base|prop-base|tmp", f)
2016-01-25 01:23:04 +00:00
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)
2016-01-25 01:23:04 +00:00
if not match:
shutil.rmtree(os.path.join(root, d))
except:
pass
# if windows then do some stuff
if operating_system == "posix":
#
# ROOT CHECK
#
2016-01-25 01:23:04 +00:00
if os.geteuid() != 0:
2016-07-22 16:52:36 +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")
core.exit_set()
2016-01-25 01:23:04 +00:00
# if there isn't a set_config.py file yet, create one
if not os.path.isfile("/etc/setoolkit/set_config.py"):
update_config()
2016-07-22 16:52:36 +00:00
define_version = core.get_version()
core.cleanup_routine()
2016-01-25 01:23:04 +00:00
# create the set.options routine
with open(os.path.join(core.setdir, "/set.options"), "w") as filewrite:
filewrite.write("{This is the main SET configuration file for all options used in SET}\n")
2016-01-25 01:23:04 +00:00
try:
# Remove old Signed_Updates
if os.path.isfile(os.path.join(core.setdir, "/Signed_Update.jar")):
os.remove(os.path.join(core.setdir, "/Signed_Update.jar"))
2016-01-25 01:23:04 +00:00
# initial user menu
2016-01-25 01:23:04 +00:00
if not os.path.isfile("src/agreement4"):
with open("readme/LICENSE") as fileopen:
for line in fileopen:
print((line.rstrip()))
2016-07-28 23:16:24 +00:00
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 "
2016-07-28 23:16:24 +00:00
"lawful purposes only.{1}".format(core.bcolors.RED, core.bcolors.ENDC))
print(core.bcolors.GREEN)
2016-07-22 16:52:36 +00:00
choice = input("\nDo you agree to the terms of service [y/n]: ")
2016-01-25 01:23:04 +00:00
choice += " " # b/c method below
if choice[0].lower() == "y":
with open("src/agreement4", "w") as filewrite:
filewrite.write("user accepted")
2016-07-22 16:52:36 +00:00
print(core.bcolors.ENDC)
2016-01-25 01:23:04 +00:00
else:
print(core.bcolors.ENDC + "[!] Exiting the Social-Engineer Toolkit, have a nice day." + core.bcolors.ENDC)
2016-01-25 01:23:04 +00:00
sys.exit()
while True:
2016-07-22 16:52:36 +00:00
core.show_banner(define_version, '1')
show_main_menu = core.create_menu(text.main_text, text.main_menu)
2016-01-25 01:23:04 +00:00
# special case of list item 99
2016-07-22 16:52:36 +00:00
print('\n 99) Exit the Social-Engineer Toolkit\n')
2016-01-25 01:23:04 +00:00
# main core menu
2016-07-22 16:52:36 +00:00
main_menu_choice = (input(core.setprompt("0", "")))
2016-01-25 01:23:04 +00:00
# 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.")
2016-01-25 01:23:04 +00:00
# funny2
if main_menu_choice == "freehugs":
2016-07-22 16:52:36 +00:00
core.print_warning("HUGS ARE ALWAYS FREE! NEVER CHARGE! ALWAYS HUG.")
pause = input("\nDo not press return until giving someone a hug.")
2016-01-25 01:23:04 +00:00
# funny3
if main_menu_choice == "derbycon":
core.print_warning(core.bcolors.BOLD + "YAYYYYYYYYYYYYYYYYYYYYYY DerbyCon.\n\nDerbyCon 6.0 'Recharge' -- September 23th - 25th 2016" + core.bcolors.ENDC)
pause = input(core.bcolors.BOLD + "\nDon't miss it! Sep 23 - Sep 25th! Press {return} to continue." + core.bcolors.ENDC)
2016-01-25 01:23:04 +00:00
# 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)
2016-07-22 16:52:36 +00:00
pause = input("Press {return} to continue.")
2016-01-25 01:23:04 +00:00
2016-06-25 21:16:27 +00:00
# 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)
2016-07-22 16:52:36 +00:00
pause = input("Press {return} to continue.")
2016-06-25 21:16:27 +00:00
2016-01-25 01:23:04 +00:00
# quit out
if main_menu_choice == 'exit' or main_menu_choice == "99" or main_menu_choice == "quit":
2016-07-22 16:52:36 +00:00
core.exit_set()
2016-01-25 01:23:04 +00:00
# cleans up stale processes from SET
try:
# kill anything python running on 80
2016-07-22 16:52:36 +00:00
core.kill_proc("80", "python")
2016-01-25 01:23:04 +00:00
# kill anything on 443 ruby which is generally a rogue listener
2016-07-22 16:52:36 +00:00
core.kill_proc("443", "ruby")
2016-01-25 01:23:04 +00:00
except:
pass
# load set
if main_menu_choice == '1':
2016-02-15 14:16:19 +00:00
try:
2016-07-22 16:52:36 +00:00
core.module_reload(src.core.set)
2016-02-15 14:24:31 +00:00
except:
2016-02-15 14:16:19 +00:00
import src.core.set
2016-01-25 01:23:04 +00:00
# load fasttrack
if main_menu_choice == '2':
2016-02-15 14:16:19 +00:00
try:
2016-07-22 16:52:36 +00:00
core.module_reload(src.core.fasttrack)
2016-02-15 14:24:31 +00:00
except:
2016-02-15 14:16:19 +00:00
import src.core.fasttrack
2016-01-25 01:23:04 +00:00
# third party modules
if main_menu_choice == '3':
2016-02-15 14:16:19 +00:00
try:
2016-07-22 16:52:36 +00:00
core.module_reload(src.core.module_handler)
2016-02-15 14:24:31 +00:00
except:
2016-02-15 14:16:19 +00:00
import src.core.module_handler
2016-01-25 01:23:04 +00:00
# update set
if main_menu_choice == '4':
2016-07-22 16:52:36 +00:00
core.update_set()
2016-01-25 01:23:04 +00:00
# credits
if main_menu_choice == '5':
update_config()
# update config
if main_menu_choice == '6':
2016-07-22 16:52:36 +00:00
core.help_menu()
2016-01-25 01:23:04 +00:00
# handle keyboard interrupts
except KeyboardInterrupt:
2016-07-28 23:16:24 +00:00
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)))
2016-01-25 01:23:04 +00:00
# handle exceptions
2016-07-21 09:35:25 +00:00
except Exception as error:
core.log(error)
print("\n\n[!] Something went wrong, printing the error: " + str(error))
2016-01-25 01:23:04 +00:00
# cleanup routine
2016-07-22 16:52:36 +00:00
core.cleanup_routine()