# Path: app/NetProcess.py
# class NetProcess(object):
#     def __init__(self):
#         self.__proxy = ''
#         self.__cookies = {}
#         self.__usecookies = False
#         self.__headers = {}
#         self.__useheaders = False
#         self.__grequests = []
# 
#     def getCookies(self): return self.__cookies
#     def setCookies(self, value):self.__cookies = value
#     Cookies = property(getCookies, setCookies, "Property CookieList")
# 
#     def getProxy(self): return self.__proxy
#     def setProxy(self, value):self.__proxy = value
#     Proxy = property(getProxy, setProxy, "Property Proxy")
# 
#     def getHeaders(self): return self.__headers
#     def setHeaders(self, value):self.__headers = value
#     Headers = property(getHeaders, setHeaders, "Property Headers")
# 
# 
# 
#     def GetResFromRequest(self, method, requrl, encodemethod='utf-8', postDic={}, reqdata='', use_proxy=False, timeout=5):
#         res = None
#         requests.adapters.DEFAULT_RETRIES = 5
#         try:
#             if str(method).upper() == 'POST':
#                 if use_proxy:
#                     scp = 'http://' + self.__proxy
#                     proxy = {"http": scp, }
#                     res = requests.post(requrl, data=postDic, proxies=proxy, cookies=self.__cookies,  headers=self.__headers, timeout=timeout)
#                 else:
#                     res = requests.post(requrl, data=postDic, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#             elif str(method).upper() == 'GET':
#                 if use_proxy:
#                     scp = 'http://' + self.__proxy
#                     proxy = {"http": scp, }
#                     res = requests.get(requrl, proxies=proxy, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#                 else:
#                     res = requests.get(requrl, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#             self.__cookies = res.cookies
#             res.encoding = encodemethod
#             # print res.content
#             return res.content
#         except Exception, e:
#             #print e.message
#             # print e
#             return 'error: %s' % str(e)
#         finally:
#             pass
# 
# 
#     def coroutine_request(self, method, requrl, encodemethod='utf-8', postDic={}, reqdata='', use_proxy=False, timeout=5):
#         if use_proxy:
#             scp = 'http://' + self.__proxy
#             proxy = {"http": scp, }
#             g_req = AsyncRequest(str(method).upper(), requrl, data=postDic, timeout=timeout, proxies=proxy)
#         else:
#             g_req = AsyncRequest(str(method).upper(), requrl, data=postDic, timeout=timeout)
#         self.__grequests.append(g_req)
#         return g_req
# 
# 
#     def coroutine_response(self, size=None, stream=False, exception_handler=None, status_only=False):
#         g_requests = list(self.__grequests)
# 
#         pool = Pool(size) if size else None
#         jobs = [send(r, pool, stream=stream) for r in g_requests]
#         gevent.joinall(jobs)
# 
#         ret = []
#         if status_only:
#             for request in g_requests:
#                 if request.response:
#                     ret.append(copy.copy(True))
#                 else:
#                     ret.append(copy.copy(False))
#             return ret
# 
#         for request in g_requests:
#             if request.response:
#                 ret.append(request.response)
#             elif exception_handler:
#                 exception_handler(request, request.exception)
# 
# 
# 
#         return ret
# 
#     def OutPutCookie(self):
#         res = {}
#         for (itm, key) in self.__cookies.items():
#             res[itm] = key
#         return res
# 
#     def SetCookie(self, cookiestr):
#         cookielist = eval(cookiestr)
#         self.__cookies = cookielist
#         self.__usecookies = True
#         return True
# 
#     def SetHeaders(self, headerdic):
#         self.__headers = headerdic
#         self.__useheaders = True
#         return True


import base64
import re
from app.NetProcess import NetProcess
    #     return 0
    # res = res[:300]
    # a = re.findall(r'httpAutErrorArray=new Array[\(][\r\n](\d+)', res)
    # if len(a) == 0:
    #     with open('pass_result.txt', 'a+') as f1:
    #         f1.writelines('password: %s\r\n' % password)
    #         f1.close()
    # else:
    #     num = a[0]
    #     if num == '1' or num == '2':
    #         print 'password: %s checked' % password
    #         return 0
    #     else:
    #         with open('pass_result.txt', 'a+') as f1:
    #             f1.writelines('password: %s' % password)
    #             f1.close()


def read_and_do():
    with open('password_dict.txt', 'r') as f1:
        for line in f1.readlines():
            check_pass(line)


# read_and_do()

# check_pass('123456345')

# print build_pass('123456qq')


# Path: app/NetProcess.py
# class NetProcess(object):
#     def __init__(self):
#         self.__proxy = ''
#         self.__cookies = {}
#         self.__usecookies = False
#         self.__headers = {}
#         self.__useheaders = False
#         self.__grequests = []
# 
#     def getCookies(self): return self.__cookies
#     def setCookies(self, value):self.__cookies = value
#     Cookies = property(getCookies, setCookies, "Property CookieList")
# 
#     def getProxy(self): return self.__proxy
#     def setProxy(self, value):self.__proxy = value
#     Proxy = property(getProxy, setProxy, "Property Proxy")
# 
#     def getHeaders(self): return self.__headers
#     def setHeaders(self, value):self.__headers = value
#     Headers = property(getHeaders, setHeaders, "Property Headers")
# 
# 
# 
#     def GetResFromRequest(self, method, requrl, encodemethod='utf-8', postDic={}, reqdata='', use_proxy=False, timeout=5):
#         res = None
#         requests.adapters.DEFAULT_RETRIES = 5
#         try:
#             if str(method).upper() == 'POST':
#                 if use_proxy:
#                     scp = 'http://' + self.__proxy
#                     proxy = {"http": scp, }
#                     res = requests.post(requrl, data=postDic, proxies=proxy, cookies=self.__cookies,  headers=self.__headers, timeout=timeout)
#                 else:
#                     res = requests.post(requrl, data=postDic, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#             elif str(method).upper() == 'GET':
#                 if use_proxy:
#                     scp = 'http://' + self.__proxy
#                     proxy = {"http": scp, }
#                     res = requests.get(requrl, proxies=proxy, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#                 else:
#                     res = requests.get(requrl, cookies=self.__cookies, headers=self.__headers, timeout=timeout)
#             self.__cookies = res.cookies
#             res.encoding = encodemethod
#             # print res.content
#             return res.content
#         except Exception, e:
#             #print e.message
#             # print e
#             return 'error: %s' % str(e)
#         finally:
#             pass
# 
# 
#     def coroutine_request(self, method, requrl, encodemethod='utf-8', postDic={}, reqdata='', use_proxy=False, timeout=5):
#         if use_proxy:
#             scp = 'http://' + self.__proxy
#             proxy = {"http": scp, }
#             g_req = AsyncRequest(str(method).upper(), requrl, data=postDic, timeout=timeout, proxies=proxy)
#         else:
#             g_req = AsyncRequest(str(method).upper(), requrl, data=postDic, timeout=timeout)
#         self.__grequests.append(g_req)
#         return g_req
# 
# 
#     def coroutine_response(self, size=None, stream=False, exception_handler=None, status_only=False):
#         g_requests = list(self.__grequests)
# 
#         pool = Pool(size) if size else None
#         jobs = [send(r, pool, stream=stream) for r in g_requests]
#         gevent.joinall(jobs)
# 
#         ret = []
#         if status_only:
#             for request in g_requests:
#                 if request.response:
#                     ret.append(copy.copy(True))
#                 else:
#                     ret.append(copy.copy(False))
#             return ret
# 
#         for request in g_requests:
#             if request.response:
#                 ret.append(request.response)
#             elif exception_handler:
#                 exception_handler(request, request.exception)
# 
# 
# 
#         return ret
# 
#     def OutPutCookie(self):
#         res = {}
#         for (itm, key) in self.__cookies.items():
#             res[itm] = key
#         return res
# 
#     def SetCookie(self, cookiestr):
#         cookielist = eval(cookiestr)
#         self.__cookies = cookielist
#         self.__usecookies = True
#         return True
# 
#     def SetHeaders(self, headerdic):
#         self.__headers = headerdic
#         self.__useheaders = True
#         return True


# Path: app/blog_lab/proxy/tplink.py
import base64
import re
from app.NetProcess import NetProcess

    #     return 0
    # res = res[:300]
    # a = re.findall(r'httpAutErrorArray=new Array[\(][\r\n](\d+)', res)
    # if len(a) == 0:
    #     with open('pass_result.txt', 'a+') as f1:
    #         f1.writelines('password: %s\r\n' % password)
    #         f1.close()
    # else:
    #     num = a[0]
    #     if num == '1' or num == '2':
    #         print 'password: %s checked' % password
    #         return 0
    #     else:
    #         with open('pass_result.txt', 'a+') as f1:
    #             f1.writelines('password: %s' % password)
    #             f1.close()


def read_and_do():
    with open('password_dict.txt', 'r') as f1:
        for line in f1.readlines():
            check_pass(line)


# read_and_do()

# check_pass('123456345')

# print build_pass('123456qq')


check_pass('123456qq')