Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out the proxy type (http, socks 4/5) in Python?

I'm trying to make a program that gets a proxy list from Charon, which looks like

202.43.178.31:3128
202.109.80.106:8080
193.165.79.13:3128
222.177.13.25:3128
125.40.181.247:8080
222.134.33.146:8080

and make it into one that can work with proxychains

http 141.219.252.132 68664
http 118.174.0.155 8080
http 91.194.246.169 8080
http 91.194.246.81 8080
http 201.245.110.138 8888

I did this, but I need some way to determine the proxy type. Right now my program puts 'http' in front of everything, at most checks if the proxy works and if it does not comments it out. Any suggestions to find the proxy type in Python (and make it as portable as possible, as in not using any linux-specific tools)?

like image 508
Gringoire Avatar asked Nov 14 '22 18:11

Gringoire


1 Answers

One way to do it would be to connect to an external server and retrieve the HTTP header and get the information from that. You could also find some site that checks the proxy type when you connect to it and scrape the page for the answer.

I don't think it's possible without some kind of server you connect to, as the headers aren't passed back to the client, only the server.

Another, less appropriate way to do it might be to try connecting as each type of proxy and see which one works.

I hope this can help you in the right direction.

like image 128
tobloef Avatar answered Dec 15 '22 14:12

tobloef