Beispiel #1
0
def redirector():
    """
    Redirects all incoming traffic through the proxy.
    """
    PROXY_HOST = environ.get("PROXY_HOST")
    PROXY_PORT = environ.get("PROXY_PORT", 1080)

    setdefaultproxy(PROXY_TYPE_SOCKS5, PROXY_HOST, PROXY_PORT)

    server = Socket(AF_INET, SOCK_STREAM)
    server.bind(("127.0.0.1", 42000))
    server.listen(5)

    while True:
        client_socket, (src_host, src_port) = server.accept()
        (dst_host, dst_port) = get_original_destination(client_socket)

        logger.info(
            f"Intercepted connection from {src_host}:{src_port} to {dst_host}:{dst_port}"
        )

        proxy_socket = SocksSocket()
        proxy_socket.connect((dst_host, dst_port))

        bidirectional_copy(client_socket, proxy_socket)
Beispiel #2
0
 def setup_conn(self):
     # Clear the default chain
     socks.setdefaultproxy()
     # add all proxies except last one.
     # we will connect on 'start' to the last proxy
     for hop in proxychain[:-1]:
         socks.adddefaultproxy(*hop)
     self.forward = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
def newIdentity(password):
	try:
		socks.setdefaultproxy()
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect(("127.0.0.1", 9151))
		s.send('AUTHENTICATE "' + password + '"\r\n')
		response = s.recv(128)
		if response.startswith("250"):
			s.send("SIGNAL NEWNYM\r\n")
		else:
			Log("Error: Could not Change Tor IP - "+response)
		s.close()
		connectTor()
	except:
		Log("Error: Enable Tor Network Proxy - No connection could be made because the target machine actively refused it")
Beispiel #4
0
def newIdentity(password):
	try:
		socks.setdefaultproxy()
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect(("127.0.0.1", 9151))
		s.send('AUTHENTICATE "' + password + '"\r\n')
		response = s.recv(128)
		if response.startswith("250"):
			s.send("SIGNAL NEWNYM\r\n")
		else:
			Log("Error: Could not Change Tor IP - "+response)
		s.close()
		connectTor()
	except:
		Log("Error: Enable Tor Network Proxy - No connection could be made because the target machine actively refused it")
def connectTor():
	socks.usesystemdefaults()
	socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9150, True)
	# patch the socket module
	socket.socket = socks.socksocket
	socket.create_connection = create_connection
Beispiel #6
0
 def get_tor_socket(self):
     if socks:
         socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
                               'localhost', 9050, True)
     return socks.socksocket
Beispiel #7
0
 def get_tor_socket(self):
     if socks:
         socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'localhost', 9050,
                               True)
     return socks.socksocket
Beispiel #8
0
def connectTor():
	socks.usesystemdefaults()
	socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9150, True)
	# patch the socket module
	socket.socket = socks.socksocket
	socket.create_connection = create_connection
Beispiel #9
0
import ftplib
import telnetlib

try:
    import urllib.request as urllib_request  # Python 3
except ImportError:
    import urllib2 as urllib_request  # Python 2

# Import SocksiPy
import sockschain as socks


def DEBUG(msg):
    print(msg)


socks.DEBUG = DEBUG

# Set the proxy information
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'localhost', 9050)

# Route an HTTP request through the SOCKS proxy
socks.wrapmodule(urllib_request)
print('\n%s\n' % urlopen('http://bot.whatismyipaddress.com/').read())

# Route a telnet connection through the SOCKS proxy
socks.wrapmodule(telnetlib)
tn = telnetlib.Telnet('india.colorado.edu', 13)
print(tn.read_all())
tn.close()
Beispiel #10
0
#!/usr/bin/python
import ftplib
import telnetlib
import urllib2

# Import SocksiPy
import sockschain as socks
def DEBUG(msg): print msg
socks.DEBUG = DEBUG

# Set the proxy information
#socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'localhost', 9050)
socks.setdefaultproxy(socks.PROXY_TYPE_HTTP, 'klaki.net', 18080)

# Route an HTTP request through the SOCKS proxy 
socks.wrapmodule(urllib2)
print urllib2.urlopen('http://automation.whatismyip.com/n09230945.asp').read()

# Route an FTP session through the SOCKS proxy 
#socks.wrapmodule(ftplib)
#ftp = ftplib.FTP('cdimage.ubuntu.com')
#ftp.login('anonymous', '*****@*****.**')
#print ftp.dir('cdimage')
#ftp.close()

# Route a telnet connection through the SOCKS proxy
socks.wrapmodule(telnetlib)
tn = telnetlib.Telnet('achaea.com')
print tn.read_very_eager()
tn.close()