2013-12-18 06:06:29 +00:00
|
|
|
#!/usr/bin/env python
|
2016-07-28 20:19:04 +00:00
|
|
|
# coding=utf-8
|
2013-12-18 06:06:29 +00:00
|
|
|
|
2012-12-31 22:11:37 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
import re
|
2013-04-15 14:26:00 +00:00
|
|
|
|
2016-07-22 16:52:36 +00:00
|
|
|
# Py2/3 compatibility
|
|
|
|
# Python3 renamed raw_input to input
|
|
|
|
try:
|
|
|
|
input = raw_input
|
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
reload
|
2016-09-27 15:15:03 +00:00
|
|
|
|
2016-07-22 16:52:36 +00:00
|
|
|
except NameError:
|
|
|
|
from importlib import reload
|
|
|
|
|
|
|
|
|
2013-04-15 14:26:00 +00:00
|
|
|
# check where we are and load default directory
|
|
|
|
if os.path.isdir("/usr/share/setoolkit"):
|
2016-09-27 15:15:03 +00:00
|
|
|
if not os.path.isfile("setoolkit"):
|
2013-04-15 14:26:00 +00:00
|
|
|
os.chdir("/usr/share/setoolkit")
|
|
|
|
sys.path.append("/usr/share/setoolkit")
|
|
|
|
|
2016-07-22 16:52:36 +00:00
|
|
|
import src.core.setcore as core
|
|
|
|
|
2013-04-15 14:26:00 +00:00
|
|
|
# if we can't see our config then something didn't go good..
|
2015-07-13 21:29:42 +00:00
|
|
|
if not os.path.isfile("/etc/setoolkit/set.config"):
|
2016-07-22 16:52:36 +00:00
|
|
|
core.print_error("Cannot locate SET executable. Try running from the local directory.")
|
|
|
|
core.print_error("If this does not work, please run the setup.py install file.")
|
2013-04-15 14:26:00 +00:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
2012-12-31 22:11:37 +00:00
|
|
|
#
|
|
|
|
# Simple client mode for SET
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# try to import pexpect
|
2013-12-18 06:06:29 +00:00
|
|
|
try:
|
|
|
|
import pexpect
|
2016-09-27 15:49:48 +00:00
|
|
|
|
2012-12-31 22:11:37 +00:00
|
|
|
# if pexpect fails
|
|
|
|
except ImportError:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("\n[*] PEXPECT is required, please download and install before running this...")
|
|
|
|
print("[*] Exiting SEAUTOMATE mode...")
|
2013-03-16 19:47:25 +00:00
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
|
|
|
# try to define filename through argument specified during command line mode
|
|
|
|
try:
|
2013-12-18 06:06:29 +00:00
|
|
|
filename = sys.argv[1]
|
2012-12-31 22:11:37 +00:00
|
|
|
|
|
|
|
# if we through an exception spit out the command line syntax
|
|
|
|
except IndexError:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("\nThe Social-Engineer Toolkit Automate - Automatation for SET")
|
|
|
|
print("\nSimply create a file that has each option you want from menu mode.")
|
|
|
|
print("For example your file should look something like this:")
|
|
|
|
print("\n2\n2\n2\nhttps://gmail.com\n2\n2\n443\netc.\n")
|
|
|
|
print("Usage: ./seautomate <filename>")
|
2013-03-16 19:47:25 +00:00
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-12-18 06:06:29 +00:00
|
|
|
# if the filename doesnt exist, throw an error
|
2013-03-16 19:47:25 +00:00
|
|
|
if not os.path.isfile(filename):
|
2016-01-14 20:50:06 +00:00
|
|
|
print("\n[*] Sorry hoss, unable to locate that filename, try again.\n")
|
2013-03-16 19:47:25 +00:00
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-12-18 06:06:29 +00:00
|
|
|
password = False
|
2012-12-31 22:11:37 +00:00
|
|
|
# if the path is around
|
|
|
|
if os.path.isfile(filename):
|
2013-03-16 19:47:25 +00:00
|
|
|
try:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("[*] Spawning SET in a threaded process...")
|
2013-12-18 06:06:29 +00:00
|
|
|
child = pexpect.spawn("python setoolkit")
|
2016-09-27 15:49:48 +00:00
|
|
|
child.expect("99\) Exit the Social-Engineer Toolkit")
|
2016-07-28 20:19:04 +00:00
|
|
|
with open(filename) as fileopen:
|
|
|
|
for line in fileopen:
|
|
|
|
line = line.rstrip()
|
|
|
|
# if we just use enter send default
|
|
|
|
if line == "":
|
2016-09-27 15:49:48 +00:00
|
|
|
line = "blank line"
|
2016-07-28 20:19:04 +00:00
|
|
|
|
2016-09-27 15:49:48 +00:00
|
|
|
#match1 = re.search("OMGPASSWORDHERE", line)
|
|
|
|
#if match1:
|
|
|
|
# line = line.replace("OMGPASSWORDHERE", "")
|
|
|
|
# password = True
|
2016-07-28 20:19:04 +00:00
|
|
|
|
2016-09-27 15:49:48 +00:00
|
|
|
#if password is False:
|
|
|
|
print("[*] Sending command {0} to the interface...".format(line))
|
|
|
|
#if password is True:
|
|
|
|
# print("[*] Sending command [**********] (password masked) to the interface...")
|
|
|
|
# password = False
|
2016-07-28 20:19:04 +00:00
|
|
|
|
2016-09-27 15:49:48 +00:00
|
|
|
if line == "blank line":
|
|
|
|
line = "\n"
|
2016-07-28 20:19:04 +00:00
|
|
|
|
|
|
|
if line == "CONTROL-C-HERE":
|
|
|
|
try:
|
|
|
|
print("[*] This may take a few seconds while SET catches up...")
|
|
|
|
child.expect("Next line of the body:")
|
|
|
|
time.sleep(2)
|
|
|
|
child.sendline("\n")
|
|
|
|
child.sendcontrol('c')
|
|
|
|
|
|
|
|
# if the user is using pexpect < 2.3
|
|
|
|
except AttributeError:
|
|
|
|
print("[-] Error: You are running pexpect < 2.3 which is needed for this function")
|
|
|
|
choice = input("Would you like to install it now yes or no: ")
|
|
|
|
if choice == "yes" or choice == "y":
|
2016-09-27 15:49:48 +00:00
|
|
|
#subprocess.Popen("wget http://sourceforge.net/projects/pexpect/files/pexpect/Release%202.3/pexpect-2.3.tar.gz;"
|
|
|
|
# "tar -zxvf pexpect-2.3.tar.gz;"
|
|
|
|
# "cd pexpect-2.3;"
|
|
|
|
# "python setup.py install;"
|
|
|
|
# "cd ..;"
|
|
|
|
# "rm -rf pexpect-2*", shell=True).wait()
|
|
|
|
subprocess.Popen("pip install pexpect", shell=True).wait()
|
2016-07-28 20:19:04 +00:00
|
|
|
try:
|
|
|
|
reload(pexpect)
|
|
|
|
child.sendcontrol('c')
|
|
|
|
except:
|
|
|
|
print("[*] Relaunch the Social-Engineer Toolkit for changes to apply.")
|
|
|
|
sys.exit()
|
|
|
|
if line != "CONTROL-C-HERE":
|
|
|
|
child.sendline(line)
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-01-14 20:50:06 +00:00
|
|
|
print("[*] Finished sending commands, interacting with the interface..")
|
2013-03-16 19:47:25 +00:00
|
|
|
child.interact()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
# sometimes pexpect can throw errors upon exit this handles them
|
|
|
|
except OSError:
|
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
# handle keyboardinterrupts (controlc)
|
|
|
|
except KeyboardInterrupt:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("[*] Control-C detected, exiting the Social-Engineer Toolkit..")
|
2013-03-16 19:47:25 +00:00
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
# handle everything else
|
2013-12-18 06:06:29 +00:00
|
|
|
except Exception as e:
|
2016-07-28 23:16:24 +00:00
|
|
|
print("[*] Something went wrong, printing error: {0}".format(e))
|