Advertisement
Guest User

Untitled

a guest
Nov 15th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.23 KB | None | 0 0
  1. require 'open-uri'
  2. require 'tempfile'
  3.  
  4. require File.dirname(__FILE__) + '/regex_helpers'
  5.  
  6. #http://spys.ru/free-proxy-list/GB/
  7. url = ARGV[0] || "http://spys.ru/free-proxy-list/GB/"
  8.  
  9. OBFUS_JS_REGEX = />(eval.*?)<\/script>/m
  10. PROXY_REGEX = /<tr class=spy1xx?[^>]*><td[^>]*><font[^>]*>(?<number>[^<]*)<\/font>\s*<font[^>]*>(?<ip_address>[^<]+)<script type="text\/javascript">document\.write\("<font[^>]*>[^<]*<\\\/font>"[+](?<port_obfus>.*?)\)<\/script>.*?<\/td><td[^>]*>(?<type>[^<]*)<\/td><td[^>]*><font[^>]*>(?<anonymity>[^<]*)</m
  11.  
  12. source = ""
  13. open(url).each { |l| source += l }
  14.  
  15. obfus_match = OBFUS_JS_REGEX.match source
  16. proxy_matches = PROXY_REGEX.find_all_matches source
  17.  
  18. if obfus_match and proxy_matches.length > 0
  19.   file = Tempfile.new('proxies')
  20.   file.write "#{obfus_match[1]};\n"
  21.  
  22.   proxies = {}
  23.  
  24.   proxy_matches.each do |proxy|
  25.     file.write "console.log(''+#{proxy[:number]}+','+#{proxy[:port_obfus]});\n"
  26.     proxies[proxy[:number]] = proxy
  27.   end
  28.  
  29.   file.close
  30.  
  31.   `node #{file.path}`.split(/\n/).each do |line|
  32.     parts = line.split /,/
  33.     proxy = proxies[parts[0]]
  34.  
  35.     puts "#{parts[0]},#{proxy[:ip_address]},#{parts[1]},#{proxy[:type]},#{proxy[:anonymity]}"
  36.   end
  37. else
  38.   puts "Couldn't parse!"
  39.   exit 1
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement