Advertisement
parkdream1

vnh_v2.py

Jun 21st, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.91 KB | None | 0 0
  1. import sys
  2. import urllib
  3. import urllib2
  4. import httplib
  5. import re
  6. import random
  7. import lxml.html
  8. import cookielib
  9. import os
  10.  
  11. from random import randrange
  12. from PIL import Image
  13.  
  14. def recapcha():
  15.     try:
  16.         global traloi
  17.         global c_src
  18.         headers = ({"Host": "api.recaptcha.net",
  19.                 "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0",
  20.                 "Connection": "keep-alive"})
  21.         request = urllib2.Request('http://api.recaptcha.net/noscript?k=6LfHsgMAAAAAAMVjkB1nC_nI5qfAjVk0qxz4VtPV', None,headers)
  22.         connect = urllib2.urlopen(request)
  23.         r_data = connect.read()
  24.         print "[*] Lay Link ReCapCha"
  25.         tree = lxml.html.fromstring(r_data)
  26.         src = tree.xpath(".//img[@alt='']")[0].get('src')
  27.         c_src = src.replace("image?c=", "")
  28.         img_src = "http://www.google.com/recaptcha/api/" + src
  29.         print "[*] Link ReCapCha La: %s" % img_src
  30.         request_1 = urllib2.Request(img_src, None, headers)
  31.         f1 = urllib2.urlopen(request_1)
  32.         img_wb = f1.read()
  33.         open('temp.jpg', 'wb').write(img_wb)
  34.         showimg = Image.open('temp.jpg')
  35.         showimg.show()
  36.         traloi = raw_input("[*] Nhap Capcha:\n")
  37.     except urllib2.HTTPError, e:
  38.         print e.code
  39.         main()
  40.     except urllib2.URLError, e:
  41.         print e.args
  42.         main()
  43.     except(KeyboardInterrupt):
  44.         print "[*] Tai Lai ReCapCha"
  45.         main()
  46.    
  47. def d_recapcha():
  48.     try:
  49.         global key
  50.         params = urllib.urlencode({'recaptcha_challenge_field':'%s'%c_src,
  51.                 'recaptcha_response_field': '%s'%traloi,
  52.                 'submit':'T%EF%BF%BDi+l%EF%BF%BD+ng%3F%3Fi'})
  53.  
  54.         lenth = len(params)
  55.        
  56.         headers = ({"Host": "api.recaptcha.net",
  57.                 "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0",
  58.                 "Referer": "http://api.recaptcha.net/noscript?k=6LfHsgMAAAAAAMVjkB1nC_nI5qfAjVk0qxz4VtPV",
  59.                 "Connection": "keep-alive",
  60.                 "Content-Type": "application/x-www-form-urlencoded",
  61.                 "Content-Length": "%s"%lenth})
  62.         print "[*] Get Key"    
  63.         request = urllib2.Request('http://api.recaptcha.net/noscript?k=6LfHsgMAAAAAAMVjkB1nC_nI5qfAjVk0qxz4VtPV', params, headers)
  64.         connect = urllib2.urlopen(request)
  65.         r_data = connect.read()
  66.         r_key = re.search('cols="100">(.*)</textarea>',r_data)
  67.         if r_key:
  68.             key = r_key.group(1)
  69.             print "Key is : %s " % key
  70.         else:
  71.             print "[-] Nhap sai capcha roi"
  72.             print "[*] Reload"
  73.             main()
  74.     except urllib2.HTTPError, e:
  75.         print e.code
  76.         main()
  77.     except urllib2.URLError, e:
  78.         print e.args
  79.         main()
  80.     except(KeyboardInterrupt):
  81.         print "[*] Reload ReCapCha"
  82.         main()
  83.        
  84. def Hash():
  85.     try:
  86.         global hash
  87.         params = urllib.urlencode({'s':'',
  88.                 'securitytoken': 'guest',
  89.                 'do': 'register',
  90.                 'url':'http://vnhfamily.us/forum/',
  91.                 'month':'',
  92.                 'day':'',
  93.                 'year':'',
  94.                 'who':'adult',
  95.                 'agree':'1'})
  96.                
  97.         lenth = len(params)
  98.            
  99.         headers =  ({"Host": "vnhfamily.us",
  100.                     "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0",
  101.                     "Referer": "http://vnhfamily.us/forum/register.php?do=signup",
  102.                     "Cookie": "PHPSESSID=%s"%sid,
  103.                     "Authorization": "Basic Vk5IOlZOSA==",
  104.                     "Connection": "keep-alive",
  105.                     "Content-type": "application/x-www-form-urlencoded",
  106.                     "Content-Length": "%s"%lenth})
  107.                    
  108.         print "[*] Lay Ma Hash"            
  109.         request = urllib2.Request('http://vnhfamily.us/forum/register.php?do=register', params,headers)
  110.         connect = urllib2.urlopen(request)
  111.         r_data = connect.read()
  112.         tree = lxml.html.fromstring(r_data)
  113.         hash = tree.xpath(".//input[@id='hash']")[0].get('value')
  114.         print "[*] Hash La: %s" % (hash)
  115.     except urllib2.HTTPError, e:
  116.         print e.code
  117.         main()
  118.     except urllib2.URLError, e:
  119.         print e.args
  120.         main()
  121.     except(KeyboardInterrupt):
  122.         main()
  123. def reg():
  124.     global user
  125.     kytu1 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  126.     kytu2 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  127.     kytu3 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  128.     kytu4 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  129.     kytu5 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  130.     kytu6 =  random.choice('qwertyuiopasdfghjklzxcvbnm')
  131.    
  132.     t_user = '%s%s%s%s%s%s'%(kytu1,kytu2,kytu3,kytu4,kytu5,kytu6)
  133.    
  134.     i = randrange(9999)
  135.     user = '%s%s' % (t_user,i)
  136.     email = '%s%s@gmail.com' % (t_user,i)
  137.     c_email = '%s%s@gmail.com' % (t_user,i)
  138.  
  139.     print "UserName: %s" % user
  140.     print "Email: %s" % email
  141.     try:
  142.         params = urllib.urlencode({'s':'',
  143.                 'securitytoken': 'guest',
  144.                 'do': 'addmember',
  145.                 'url':'http://vnhfamily.us/forum/index.php',
  146.                 'agree':'1',
  147.                 'password_md5':'',
  148.                 'passwordconfirm_md5':'',
  149.                 'day':'0',
  150.                 'month':'0',
  151.                 'year':'0',
  152.                 'username':'%s'%(user),
  153.                 'password':'manhmanh',
  154.                 'passwordconfirm':'manhmanh',
  155.                 'email':'%s'%(email),
  156.                 'emailconfirm':'%s'%(c_email),
  157.                 'humanverify[hash]':'%s'%(hash),
  158.                 'recaptcha_challenge_field':'%s'%(key),
  159.                 'recaptcha_response_field':'manual_challenge',
  160.                 'referrername':'',
  161.                 'timezoneoffset':'7',
  162.                 'dst':'2',
  163.                 'options[adminemail]':'1'})
  164.         lenth = len(params)
  165.            
  166.         headers =   ({
  167.                         "Host": "vnhfamily.us",
  168.                         "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0",
  169.                         "Referer": "http://vnhfamily.us/forum/register.php?do=register",
  170.                         "Cookie": "PHPSESSID=%s"%sid,
  171.                         "Authorization": "Basic Vk5IOlZOSA==",
  172.                         "Connection": "keep-alive",
  173.                         "Content-type": "application/x-www-form-urlencoded",
  174.                         "Content-Length": "%s"%lenth})
  175.         print "Dang Ky User %s" % user
  176.         print "Please Wait ..."
  177.         request = urllib2.Request('http://vnhfamily.us/forum/register.php?do=add', params,headers)
  178.         connect = urllib2.urlopen(request)
  179.         r_data = connect.read()
  180.         print "Dang Ky Thanh Cong User: %s" % user
  181.         print "================================================================================"
  182.     except urllib2.HTTPError, e:
  183.         print e.code
  184.         main()
  185.     except urllib2.URLError, e:
  186.         print e.args
  187.         main()
  188.     except(KeyboardInterrupt):
  189.         main()
  190.  
  191. def ReceivedCookie():
  192.     print "Dang Nhap http://vnhfamily.us/forum"
  193.     COOKIEFILE = 'temp'
  194.  
  195.     urlopen = urllib2.urlopen
  196.     cj = cookielib.LWPCookieJar()
  197.     Request = urllib2.Request
  198.     opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  199.     urllib2.install_opener(opener)
  200.        
  201.     if cj != None:
  202.         if os.path.isfile(COOKIEFILE):
  203.             cj.load(COOKIEFILE)
  204.  
  205.     params = urllib.urlencode({'do':'login',
  206.         'url': '/forum/index.php',
  207.         'vb_login_md5password': '1f5d020ac0ce982f5846897871b6b5ec',
  208.         'vb_login_md5password_utf':'1f5d020ac0ce982f5846897871b6b5ec',
  209.         's':'',            
  210.         'securitytoken':'guest',
  211.         'vb_login_username':'%s'%(user),
  212.         'vvb_login_password':'',
  213.         'cookieuser':'1'})
  214.        
  215.     length =  len(params)
  216.     print "Length is %s" % length
  217.        
  218.     headers = ({"Host": "vnhfamily.us",
  219.         "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0",
  220.         "Referer": "http://vnhfamily.us/forum/index.php",
  221.         "Cookie": "PHPSESSID=%s"%(sid),
  222.         "Connection": "keep-alive",
  223.         "Authorization": "Basic Vk5IOlZOSA==",
  224.         "Connection": "keep-alive",
  225.         "Content-type": "application/x-www-form-urlencoded",
  226.         "Content-Length": "%s"%length})
  227.        
  228.     theurl = 'http://vnhfamily.us/forum/login.php?do=login'
  229.    
  230.     try:
  231.         req = Request(theurl, params, headers)
  232.         handle = urlopen(req)
  233.         the_page = handle.read()
  234.     except IOError, e:
  235.         print 'We failed to open "%s".' % theurl
  236.         if hasattr(e, 'code'):
  237.             print 'We failed with error code - %s.' % e.code
  238.                        
  239.     if cj == None:
  240.         print "We don't have a cookie library available - sorry."
  241.         print "I can't show you any cookies."
  242.     else:
  243.         print '[*] Cookies we have Received:'
  244.         for index, cookie in enumerate(cj):
  245.             print "%s:%s" % (cookie.name,cookie.value)
  246.             cj.save(COOKIEFILE)  
  247.  
  248. def Login():
  249.     data = open('temp','r').read()
  250.     userid = re.search('bbuserid=(.*); path=',data)    
  251.     password = re.search('bbpassword=(.*); path=',data)
  252.        
  253.     print "[*] Login with ID = %s and Password_Hash = %s" % (userid.group(1),password.group(1))
  254.  
  255.     headers =       ({"Host": "vnhfamily.us",
  256.         "User-Agent": "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0",
  257.         "Referer": "http://vnhfamily.us/forum/login.php?do=login",
  258.         "Cookie": "PHPSESSID=%s; bbuserid=%s; bbpassword=%s"%(sid,userid.group(1),password.group(1)),
  259.         "Authorization": "Basic Vk5IOlZOSA==",
  260.         "Connection": "keep-alive"})
  261.                                        
  262.     theurl = 'http://vnhfamily.us/forum/index.php'
  263.     topurl = 'http://vnhfamily.us/forum/ajax.php?do=allforum&result=20'
  264.     try:
  265.         req = urllib2.Request(theurl, None, headers)
  266.         top = urllib2.Request(topurl, None, headers)
  267.         response = urllib2.urlopen(req)
  268.         response1 = urllib2.urlopen(top)
  269.         the_page = response.read()
  270.         the_page1 = response1.read()
  271.     except IOError, e:
  272.         print 'We failed to open "%s".' % theurl      
  273.     print "================================================================================"    
  274.        
  275. def main():
  276.     recapcha()
  277.     d_recapcha()
  278.     Hash()
  279.     reg()
  280.     ReceivedCookie()
  281.     Login()
  282. if __name__ == "__main__":
  283.     sid = raw_input("[*] Nhap PHPSESSID:\n")
  284.     while True:
  285.         main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement