這裡查閱許多資料,學習用python寫了乙個zip檔案暴力破解的程式。若有不足之處請大家多多指教!
本隨筆僅供學習交流,切勿拿去做違法之事!
import itertools as its
import threading
import zipfile
import sys
import time
from tqdm import tqdm
class product_doct(threading.thread):
def __init__(self):
threading.thread.__init__(self)
self.pd1=false
self.pd2 = false
if len(sys.ar**) >1:
self.words = sys.ar**[1].strip()
# self.word1 = input("請輸入前面的固定字元,若沒有直接enter:").strip()
# self.word2 = input("請輸入後面的固定字元,若沒有直接enter:").strip()
self.len = int(sys.ar**[2].strip())
self.filename= sys.ar**[3].strip()
else:
self.words = input('請輸入要密碼包含的字元:').strip()
# self.word1 = input("請輸入前面的固定字元,若沒有直接enter:").strip()
# self.word2 = input("請輸入後面的固定字元,若沒有直接enter:").strip()
self.len = int(input('請輸入要密碼長度:').strip())
self.filename = input('請輸入要破解的zip檔案目錄:').strip()
self.zfile =zipfile.zipfile(self.filename)#zipfile.zipfile(input('請輸入檔案路徑:').strip())
self.s = false
self.i = 0
self.threading_list =
def run(self):
print("開始")
self.produ_miam()
while true:
if self.pd1 and self.pd2:
if self.s:
break
else:
print('結束')
with open('passwoed.txt', 'w', encoding='utf-8') as fp:
fp.write(f'在【】字元中按1到位排列未找到密碼!')
fp.close()
break
def produ_miam(self):
words = set(self.words) # 去重
words = ''.join(words) # 拼接
for lon in range(1,self.len+1):
if not self.s:
l=threading.thread(target=self.start_pj, args=(words, lon))
l.start()
#print('執行緒數量:' + str(len(threading.enumerate())))
while true:
if (len(threading.enumerate()) < 600):
break
else:
break
self.pd1=true
def start_pj(self,words,lon):
r = its.product(words, repeat=lon)
for i in r:
password = "".join(i)
# password = self.word1 + password + self.word2
#print(password)
if not self.s:
t = threading.thread(target=self.crack_zip, args=(self.zfile, password))
t.start()
while true:
if (len(threading.enumerate()) < 600):
break
else:
break
if lon == self.len : self.pd2 = true
def crack_zip(self,zfile,password):
try:
if not self.s:
zfile.extractall(pwd=bytes(password, "utf8"))
print("檔案解壓密碼為: ", password)
self.s = true
with open('passwoed.txt','w',encoding='utf-8') as fp:
fp.write(password)
fp.close()
return password
else:
pass
except:
pass
if __name__ == '__main__':
p=product_doct()
p.run()
用java寫了乙個漢諾塔
package com.brzhang 漢諾塔 開始盤子全部都放在第一根柱子上 目的 將第一根柱子上的盤子全部移動到第三根柱子上,規則是不能編號較大的盤子放在編號交小的盤子上面。public class hanota else 移動盤子,從from移動到to借助assite param from p...
用Python寫乙個zip檔案的密碼破解程式
最近在讀 python絕技 運用python成為頂級黑客 一書,文中有如何運用python中zipfile自帶的方法破解zip檔案。短短的十幾行 就將乙個程式實現了。下面給出書中所用的 1 coding utf 8 2import zipfile 3import threading45 def ex...
用python寫了乙個文字版本的掃雷遊戲。
很簡單,注釋很詳細。附上。coding utf 8 import sys import random 地圖標記 map map blank 0 地圖空白 map mine 1 有雷存在 map used 2 已經排除 錯誤碼 error error ok 5 結果ok error fail 6 結果...