-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
seproxy
executable file
·72 lines (55 loc) · 2.11 KB
/
seproxy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
#
# Simple proxy for SET, note will show up in history
#
import sys
import getpass
import os
import subprocess
import re
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 = core.check_os()
# if windows then do some stuff
if operating_system == "posix":
definepath = os.getcwd()
print("\n[*] Welcome to the SET-Proxy Configuration Utility")
print("\nEnter the proxy setting information below.\n\nExample: http://10.3.1.1:8080\n")
try:
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): ")
except KeyboardInterrupt:
print("\n[!] Exiting the Social-Engineer Toolkit.")
sys.exit()
if username != "":
proxy_string = "export http_proxy='http://{0}:{1}@{2}'".format(username, password, proxy)
else:
proxy_string = "export http_proxy='http://{0}'".format(proxy)
with open(os.path.join(core.userconfigpath, "proxy.config"), "w") as filewrite:
filewrite.write(proxy_string)
def kill_proc(port, flag):
proc = subprocess.Popen("netstat -antp | grep '{0}'".format(port), shell=True, stdout=subprocess.PIPE)
stdout_value = proc.communicate()[0]
a = re.search("\d+/{0}".format(flag), stdout_value)
if a:
b = a.group()
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:
# kill anything python running on 80
kill_proc("80", "python")
# kill anything on 443 ruby which is generally a rogue listener
kill_proc("443", "ruby")
# handle errors
except Exception as error:
core.log(error)
else:
print("[!] Sorry, this only works on posix (nix) based systems and is not compatible with this operating system.")