social-engineer-toolkit/set-automate

102 lines
3.7 KiB
Text
Raw Normal View History

2012-12-31 22:11:37 +00:00
#!/usr/bin/env python
import pexpect
import sys
import os
import time
import subprocess
import re
#
# Simple client mode for SET
#
#
# try to import pexpect
try: import pexpect
# if pexpect fails
except ImportError:
print "\n[*] PEXPECT is required, please download and install before running this..."
print "[*] Exiting SET-AUTOMATE mode..."
sys.exit()
2012-12-31 22:11:37 +00:00
# try to define filename through argument specified during command line mode
try:
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:
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: ./set-automate <filename>"
sys.exit()
2012-12-31 22:11:37 +00:00
# if the filename doesnt exist throw an error
if not os.path.isfile(filename):
print "\n[*] Sorry hoss, unable to locate that filename, try again.\n"
sys.exit()
2012-12-31 22:11:37 +00:00
password="false"
# if the path is around
if os.path.isfile(filename):
try:
print "[*] Spawning SET in a threaded process..."
child=pexpect.spawn("python set")
#child.delaybeforesend = 0
fileopen=file(filename,"r")
for line in fileopen:
line=line.rstrip()
# if we just use enter send default
if line == "": line="default"
2012-12-31 22:11:37 +00:00
match1=re.search("OMGPASSWORDHERE", line)
if match1:
line=line.replace(" OMGPASSWORDHERE", "")
password="true"
2012-12-31 22:11:37 +00:00
if password == "false":
print "[*] Sending command %s to the interface..." % (line)
if password == "true":
print "[*] Sending command [**********] (password masked) to the interface..."
password="false"
2012-12-31 22:11:37 +00:00
if line == "default":
line=""
2012-12-31 22:11:37 +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')
2012-12-31 22:11:37 +00:00
# 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=raw_input("Would you like to install it now yes or no: ")
if choice == "yes" or choice == "y":
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()
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
print "[*] Finished sending commands, interacting with the interface.."
child.interact()
2012-12-31 22:11:37 +00:00
# sometimes pexpect can throw errors upon exit this handles them
except OSError:
sys.exit()
2012-12-31 22:11:37 +00:00
# handle keyboardinterrupts (controlc)
except KeyboardInterrupt:
print "[*] Control-C detected, exiting the Social-Engineer Toolkit.."
sys.exit()
2012-12-31 22:11:37 +00:00
# handle everything else
except Exception,e: print "[*] Something went wrong, printing error: %s" % str(e)