tags:

views:

44

answers:

1

I have a list of proxy ip's that I want to use in one of my python scripts, but how do I verify that I am using one of the ip addresses from the list and not my own? I'm using mechanize, but any general explanation of how to do this would be helpful.

This is the first time I have worked with proxies, so anything you can tell me will be be really appreciated.

Thanks

+1  A: 

Running wireshark / tshark would be one way.

Many proxies run on port 3128, but substitute this for the proxy you're using. Make you request and if you get traffic to the host and port of your configured proxy, it's probably working. If it goes to the host for the website, then it's not.

E.g. First without a proxy:

$ tshark -i eth0 -n -Nn tcp port 3128 or tcp port 80

from mechanize import Browser
br = Browser()
br.open('http://news.bbc.co.uk')
0.000000 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk TCP 51088 > 80 [SYN]
0.003296 nol-vip05.cwwtf.bbc.co.uk -> mylocalhost TCP 80 > 51088 [SYN, ACK]
0.003318 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk TCP 51088 > 80 [ACK]
0.003375 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk HTTP GET / HTTP/1.1

With a proxy:

br.set_proxies({'http':'some.proxy:3128'})
br.open('http://news.bbc.co.uk')
0.000000 mylocalhost -> some.proxy TCP 57556 > 3128 [SYN]
0.011529 some.proxy -> mylocalhost TCP 3128 > 57556 [SYN, ACK]
0.011571 mylocalhost -> some.proxy TCP 57556 > 3128 [ACK]
0.011636 mylocalhost -> some.proxy HTTP GET / HTTP/1.1
MattH
+1 because wireshark is so very useful for network programming, here and in general
THC4k
Do you have any idea what the tshark command would be on windows?
Joe
I figured out that you have to use tshark.exe and it works, but I don't know what to use instead of etho0, any ideas?
Joe
Ahh, you're running on windows. Well you can always use the GUI instead. But perhaps `tshark.exe -D` might give you a list of interfaces you can capture on. There's a chance it may do the right thing if you left out the `-i <interface>` argument.
MattH