2012-12-31 22:11:37 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
#
|
|
|
|
# Simple proxy for SET, note will show up in history
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import getpass
|
2016-07-22 16:52:36 +00:00
|
|
|
import os
|
2016-07-28 20:19:04 +00:00
|
|
|
import subprocess
|
|
|
|
import re
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-07-22 16:52:36 +00:00
|
|
|
import src.core.setcore as core
|
|
|
|
|
|
|
|
# Py2/3 compatibility
|
|
|
|
# Python3 renamed raw_input to input
|
|
|
|
try:
|
|
|
|
input = raw_input
|
|
|
|
except NameError:
|
|
|
|
pass
|
2012-12-31 22:11:37 +00:00
|
|
|
|
|
|
|
# grab the operating system
|
2016-07-22 16:52:36 +00:00
|
|
|
operating_system = core.check_os()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
|
|
|
# if windows then do some stuff
|
|
|
|
if operating_system == "posix":
|
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
definepath = os.getcwd()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-01-14 20:50:06 +00:00
|
|
|
print("\n[*] Welcome to the SET-Proxy Configuration Utility")
|
2016-07-28 20:19:04 +00:00
|
|
|
print("\nEnter the proxy setting information below.\n\nExample: http://10.3.1.1:8080\n")
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
try:
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-07-22 16:52:36 +00:00
|
|
|
proxy = input("Enter the proxy server: ")
|
2016-07-28 20:19:04 +00:00
|
|
|
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): ")
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
except KeyboardInterrupt:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("\n[!] Exiting the Social-Engineer Toolkit.")
|
2013-03-16 19:47:25 +00:00
|
|
|
sys.exit()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
if username != "":
|
2016-07-28 20:19:04 +00:00
|
|
|
proxy_string = "export http_proxy='http://{}:{}@{}'".format(username, password, proxy)
|
|
|
|
else:
|
|
|
|
proxy_string = "export http_proxy='http://{}'".format(proxy)
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-07-28 20:19:04 +00:00
|
|
|
with open(os.path.join(core.setdir, "/proxy.config"), "w") as filewrite:
|
|
|
|
filewrite.write(proxy_string)
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2016-01-14 20:50:06 +00:00
|
|
|
def kill_proc(port, flag):
|
2016-07-28 20:19:04 +00:00
|
|
|
proc = subprocess.Popen("netstat -antp | grep '{}'".format(port), shell=True, stdout=subprocess.PIPE)
|
2016-01-14 20:50:06 +00:00
|
|
|
stdout_value = proc.communicate()[0]
|
2016-07-28 20:19:04 +00:00
|
|
|
a = re.search("\d+/{}".format(flag), stdout_value)
|
2013-03-16 19:47:25 +00:00
|
|
|
if a:
|
2016-01-14 20:50:06 +00:00
|
|
|
b = a.group()
|
2016-07-28 20:19:04 +00:00
|
|
|
b = b.replace("/{}".format(flag), "")
|
|
|
|
subprocess.Popen("kill -9 {} 1> /dev/null 2> /dev/null".format(b), shell=True).wait()
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
# cleans up stale processes from SET
|
|
|
|
try:
|
|
|
|
# kill anything python running on 80
|
2016-01-14 20:50:06 +00:00
|
|
|
kill_proc("80", "python")
|
2013-03-16 19:47:25 +00:00
|
|
|
# kill anything on 443 ruby which is generally a rogue listener
|
|
|
|
kill_proc("443", "ruby")
|
2012-12-31 22:11:37 +00:00
|
|
|
|
2013-03-16 19:47:25 +00:00
|
|
|
# handle errors
|
2016-01-14 20:50:06 +00:00
|
|
|
except Exception as error:
|
2016-07-28 20:19:04 +00:00
|
|
|
core.log(error)
|
2016-07-22 16:52:36 +00:00
|
|
|
|
2012-12-31 22:11:37 +00:00
|
|
|
else:
|
2016-01-14 20:50:06 +00:00
|
|
|
print("[!] Sorry, this only works on posix (nix) based systems and is not compatible with this operating system.")
|