如何使用readlines()或read()读取大文件,破解

时间:2017-03-11 00:30:46

标签: python-2.7 loops cracking

import mechanize
import cookielib 
def check():

            global browser
            global passwords
            try:
                    browser = mechanize.Browser()
                    cj = cookielib.LWPCookieJar()
                    browser.set_handle_robots(False)
                    browser.set_handle_equiv(True)
                    browser.set_handle_referer(True)
                    browser.set_handle_redirect(True)
                    browser.set_cookiejar(cj)
                    browser.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),max_time=1)
            except KeyboardInterrupt:
                    fwx=str(raw_input("\n[*] Exiting program .."))
                    sys.exit(1)

            try:
                    list = open(passwordlist, "r")
                    passwords = list.read()

                    while True:
                            k = 0
                            passwords = list.readlines()
                            if not passwords:
                                    break
                            while k < len(passwords):
                                    passwords[k] = passwords[k].strip()
                                    k += 1

                            search()
                            attack(password)
            except IOError:
                    fe=str(raw_input("\n [*] Error: check your passsword list path!! \n"))
                    sys.exit(1)
            except KeyboardInterrupt:
                    fdd=str(raw_input("\n [*] Exiting program .."))
                    sys.exit(1)

            try:

                    search()
                    attack(password)
            except KeyboardInterrupt:
                    fp=str(raw_input("\n [*] Exit program .."))
                    sys.exit(1)

我试图读取.lst assoc中的长列表或者说.csv列表。 当我读取()或readlines()时,该循环中的文件没有任何反应:

while True:                                
    k = 0
    passwords = list.readlines()
       if not passwords:
           break
       while k < len(passwords):
           passwords[k] = passwords[k].strip()
           k += 1

       search()
       attack(password)

我不知道我在做什么..什么会使文件条纹和处理? 它的工作是一个短名单(不到1gb),但它无法读取比这更大的所有比赛。

list = open(passwordlist, "r")
passwords = list.readlines()
k = 0
while k < len(passwords):
    passwords[k] = passwords[k].strip()
    k += 1

我想阅读完整的文件。

0 个答案:

没有答案