-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
39 lines (29 loc) · 1.04 KB
/
test.py
File metadata and controls
39 lines (29 loc) · 1.04 KB
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
import urlfetch
import socket
import pyChainedProxy as socks #import pyChainedProxy
# Enable debugging
def DEBUG(msg):
print (msg)
#socks.DEBUG = DEBUG
print ("Hell: ",urlfetch.get('http://ip-api.com/json').content)
# Configure a default chain
chain = [
'socks5://localhost:9050/', # First hop is Tor,
'http://user1:pass@example.com/' # ...and then auth to an HTTP proxy
]
socks.setdefaultproxy() # Clear the default chain
#adding hops with proxies
for hop in chain:
socks.adddefaultproxy(*socks.parseproxy(hop))
#wrap a single module
#socks.wrapmodule(urlfetch)
# Configure alternate routes (No proxy for localhost)
socks.setproxy('localhost', socks.PROXY_TYPE_NONE)
socks.setproxy('127.0.0.1', socks.PROXY_TYPE_NONE)
# This would have set proxies using the standard environment variables:
#socks.usesystemdefaults()
# Monkey Patching whole socket class (everything will be proxified)
rawsocket = socket.socket
socket.socket = socks.socksocket
# Everything will be proxied!
print ("Hell: ",urlfetch.get('http://ip-api.com/json').content)