Python課堂實驗 字典攻擊

2021-10-13 23:59:11 字數 1899 閱讀 8321

python字典攻擊實驗報告

python**:

# 字典攻擊

import itertools # 迭代器

import datetime

import hashlib

import time

defgeneratelibary

(library, length=8)

: libararys = itertools.product(library,repeat=length)

dic =

open

("paswordlirbarys.txt"

,"w"

,encoding=

'utf-8'

)#寫模式開啟檔案

for i in libararys:

dic.writelines(i)

dic.writelines(

"\n"

) dic.close(

)#x = hashlib.md5("123".encode(encoding="utf-8")).hexdigest()#hash演算法儲存密碼

#202cb962ac59075b964b07152d234b70

#print(x)

defdict_attack

(path,password)

:file

=open

(path)

for passwords in

file

:#print(passwords)

passwords = passwords.split(

"\n")[

0]if password == hashlib.md5(passwords.encode(encoding=

"utf-8"))

.hexdigest():

print

("你的密碼是:{}"

.format

(passwords)

)file

.close(

)if __name__ ==

"__main__"

:#lowercase = 'abcdefghijklmnopqrstuvwxyz'#字元組合

#uppercase = 'abcdefghijklmnopqrs'

#digits = '0123456789'

word =

"xiaowng2067"

#special = """!"#$%&'( )*+,-./:;<=>?@^_`~"""

#word = lowercase + uppercase + digits + special

starttime = datetime.datetime.now(

)# 獲取當前時間

print

(time.strftime(

"%y%m%d%h%m%s"

, time.localtime(time.time())

))generatelibary(word,length=6)

#生成8位數字字典

#dict_attack("paswordlirbarys.txt","05213bc82bacf7312806baf095038402")

endtime = datetime.datetime.now(

)print

(time.strftime(

"%y%m%d%h%m%s"

, time.localtime(time.time())

))print

('the time cost: '

)print

(endtime - starttime)

#時間

本次python實驗是根據老師課堂上內容所做總結。

取字典的值 Python小課堂 字典

python3字典 字典是另一種可變容器模型,且可儲存任意型別物件。字典的每個鍵值 key value 對用冒號 分割,每個對之間用逗號 分割,整個字典包括在花括號 中 格式如下所示 d 鍵必須是唯一的,但值則不必。值可以取任何資料型別,但鍵必須是不可變的,如字串,數字或元組。乙個簡單的字典例項 d...

hashcat字典攻擊

2.輸出命令 3.總結 hashcat最常用的攻擊方式 直接攻擊模式就是直接利用字典進行密碼爆破,它可以使用單一字典檔案,或多個字典檔案進行解密。還可以通過將字典與規則檔案結合,讓密碼爆破效率更高。hashcat a 0 m 0 mima.txt o outfile dic.txt 圖 4.png ...

python字典實驗 列表 元組 集合與字典

in not in 判斷元素是否在其中 適用於列表 元組 集合 list使用手冊 len 查詢 list 長度 remove 刪除指定元素 count 查詢元素在 list中的位置 reverse 反轉list del list 刪除位置上的元素 insert 插入元素 第乙個值為 元素位置 第二值...