1 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
根據(jù)您的帖子,目標(biāo)是交叉加入用戶和密碼文件。為此,在 pwd 文件中加載一次,然后處理每個(gè)用戶(每個(gè)線程一個(gè))。
請(qǐng)注意,我使用 Python 3.8 對(duì)此進(jìn)行了測(cè)試。
試試這個(gè)代碼:
import threading
# create files for testing
user = "user1\nuser2\nuser3\nuser4\nuser5\nuser6\nuser7\nuser8\nuser9"
pwd = "pwd1\npwd2\npwd3\npwd4\npwd5\npwd6\npwd7\npwd8\npwd9"
with open("user.txt",'w') as f: f.write(user)
with open("pwd.txt",'w') as f: f.write(pwd)
##### main script #####
# load all pwds
f2 = open("pwd.txt", "r")
lstpwd = f2.readlines()
f1 = open("user.txt", "r")
threads = []
def brute():
for letter in f1.readlines():
print ("\n[+]First Value: {}".format(letter.strip()))
for second_letter in lstpwd:
print ("[++]Second Value: {}".format(second_letter.strip()))
threads.append(threading.Thread(target=runner, args=(letter,second_letter,)))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
def runner(word1,word2):
print("[+]I am just a worker class: {0}:{1}".format(word1.strip(),word2.strip()))
brute()
輸出
[+]First Value: user1
[++]Second Value: pwd1
[++]Second Value: pwd2
[++]Second Value: pwd3
.......
[+]First Value: user2
[++]Second Value: pwd1
[++]Second Value: pwd2
[++]Second Value: pwd3
.......
[+]I am just a worker class: user1:pwd1
[+]I am just a worker class: user1:pwd2
[+]I am just a worker class: user1:pwd3
.......
[+]I am just a worker class: user2:pwd1
[+]I am just a worker class: user2:pwd2
[+]I am just a worker class: user2:pwd3
.......
添加回答
舉報(bào)