Ledger Nano X - The secure hardware wallet
SHARE
TWEET

How to Update Your ProxyChains Config File with Python Auto

a guest Jan 21st, 2016 964 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from bs4 import BeautifulSoup
  2. import urllib2, base64
  3. import os, sys
  4. from urlparse import urljoin
  5.  
  6.  
  7. ips = []
  8. ports = []
  9. both = []
  10.  
  11. if os.geteuid() != 0: #test for root or superuser
  12.     print "[*] You must run this program as root!!"
  13.     sys.exit()
  14.  
  15.  
  16. if len(sys.argv) != 2:
  17.     print "Usage: %s <location of configuration file>" %str(sys.argv[0])
  18.     sys.exit()
  19.  
  20. #open link...parse data with bs(...lol) and return it
  21. def getSoup(url):
  22.     headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"}
  23.  
  24.     try:
  25.         req = urllib2.Request(url, None, headers)
  26.         html = urllib2.urlopen(req).read()
  27.     except urllib2.URLError as e:
  28.         print str(e)
  29.         sys.exit()
  30.  
  31.     soup = BeautifulSoup(html, "html.parser") #parsing html
  32.  
  33.     return soup
  34.  
  35.  
  36. #first we get the link from with the raw proxies...
  37. first_soup = getSoup("http://www.samair.ru/proxy/ip-port/")
  38.  
  39. #now we gonna search for the raw proxy ports link
  40. for pports in first_soup.findAll('a', href=True):
  41.     if pports.getText() == "You can do it there":
  42.         new_link = urljoin("http://www.samair.ru",pports['href'])
  43.         break
  44.     else:
  45.         pass
  46.  
  47.  
  48. #now we can get the raw proxies
  49. second_soup = getSoup(new_link)
  50.  
  51. #parsing it to get the proxies from the pre tag
  52. #and also splitting it to make sure it comes in the list
  53. both = str(second_soup.find('pre')).split("\n")
  54.  
  55. for singles in both:
  56.     try:
  57.         #this is a lazy way to get rid of the pre tags because it comes with it
  58.         if singles.startswith("<pre>"):
  59.             singles = singles[5:]
  60.         if singles.startswith("</pre>"):
  61.             singles = singles[6:]
  62.  
  63.         ip_addr, port_num = singles.split(":") #separating ip addresses and ports
  64.         ips.append(ip_addr)
  65.         ports.append(port_num)
  66.     except:
  67.         pass       
  68.    
  69.  
  70. f = open(sys.argv[1], "a")
  71.  
  72. #write proxy settings to proxychains file
  73. for i in range(0,len(ports)):
  74.     f.write("http\t%s\t%s\n" %(ips[i], ports[i]))
  75.  
  76.  
  77. f.close()
  78.  
  79. print "[+] Done!!"
  80. print "[*] Now you can browse anonymously with proxychains"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top