banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

Pythonの暴力破解による暗号化された圧縮ファイルとソースコード

image

コマンドライン版:#

import argparse
import zipfile
import rarfile

def extract_zip(zip_file_path, password_dict_path):
    zip_file = zipfile.ZipFile(zip_file_path)
    with open(password_dict_path, 'r') as f:
        passwords = f.readlines()
    for password in passwords:
        password = password.strip()
        try:
            zip_file.extractall(pwd=bytes(password, 'utf-8'))
            print(f'解読成功、パスワードは:{password}')
            with open('パスワード.txt', 'w') as f:
                f.write(f'ファイル名:{zip_file_path}\nパスワード:{password}')
            input("解読成功、Enterキーを押して続ける...")
            break
        except zipfile.BadZipFile:
            print(f'ファイル形式エラー、解凍できません:{zip_file_path}')
            break
        except RuntimeError:
            print(f'解読失敗、試したパスワード:{password}')
    zip_file.close()

def extract_rar(rar_file_path, password_dict_path):
    rar_file = rarfile.RarFile(rar_file_path)
    with open(password_dict_path, 'r') as f:
        passwords = f.readlines()
    for password in passwords:
        password = password.strip()
        try:
            rar_file.extractall(pwd=bytes(password, 'utf-8'))
            print(f'解読成功、パスワードは:{password}')
            with open('パスワード.txt', 'w') as f:
                f.write(f'ファイル名:{rar_file_path}\nパスワード:{password}')
            input("解読成功、Enterキーを押して続ける...")
            break
        except rarfile.BadRarFile:
            print(f'ファイル形式エラー、解凍できません:{rar_file_path}')
            break
        except RuntimeError:
            print(f'解読失敗、試したパスワード:{password}')
    rar_file.close()

if __name__ == '__main__':
    zip_file_path = input("解読する圧縮ファイルのパスを入力してください(このディレクトリ内で名前を入力するだけでOK):")
    password_dict_path = input("パスワード辞書ファイルのパスを入力してください(このディレクトリ内で名前を入力するだけでOK):")

    if zip_file_path.endswith('.zip'):
        extract_zip(zip_file_path, password_dict_path)
    elif zip_file_path.endswith('.rar'):
        extract_rar(zip_file_path, password_dict_path)
    else:
        print('サポートされていないファイル形式')

GUI 版:#

import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
import zipfile
import rarfile

def extract_zip(zip_file_path, password_dict_path):
    zip_file = zipfile.ZipFile(zip_file_path)
    with open(password_dict_path, 'r') as f:
        passwords = f.readlines()
    for password in passwords:
        password = password.strip()
        try:
            zip_file.extractall(pwd=bytes(password, 'utf-8'))
            messagebox.showinfo('解読成功', f'解読成功、パスワードは:{password}')
            with open('パスワード.txt', 'w') as f:
                f.write(f'ファイル名:{zip_file_path}\nパスワード:{password}')
            break
        except zipfile.BadZipFile:
            lbl_result.config(text=f'ファイル形式エラー、解凍できません:{zip_file_path}')
            break
        except RuntimeError:
            lbl_result.config(text=f'解読失敗、試したパスワード:{password}')
    else:
        lbl_result.config(text='解読失敗、正しいパスワードが見つかりませんでした')
    zip_file.close()

def extract_rar(rar_file_path, password_dict_path):
    rar_file = rarfile.RarFile(rar_file_path)
    with open(password_dict_path, 'r') as f:
        passwords = f.readlines()
    for password in passwords:
        password = password.strip()
        try:
            rar_file.extractall(pwd=bytes(password, 'utf-8'))
            messagebox.showinfo('解読成功', f'解読成功、パスワードは:{password}')
            with open('パスワード.txt', 'w') as f:
                f.write(f'ファイル名:{rar_file_path}\nパスワード:{password}')
            break
        except rarfile.BadRarFile:
            lbl_result.config(text=f'ファイル形式エラー、解凍できません:{rar_file_path}')
            break
        except RuntimeError:
            lbl_result.config(text=f'解読失敗、試したパスワード:{password}')
    else:
        lbl_result.config(text='解読失敗、正しいパスワードが見つかりませんでした')
    rar_file.close()

def browse_zip_file():
    zip_file_path = filedialog.askopenfilename(filetypes=[('Zip Files', '.zip')])
    entry_zip_file.delete(0, tk.END)
    entry_zip_file.insert(tk.END, zip_file_path)

def browse_password_dict():
    password_dict_path = filedialog.askopenfilename(filetypes=[('Text Files', '.txt')])
    entry_password_dict.delete(0, tk.END)
    entry_password_dict.insert(tk.END, password_dict_path)
    
def crack_zip():
    zip_file_path = entry_zip_file.get()
    password_dict_path = entry_password_dict.get()
    if zip_file_path.endswith('.zip'):
        extract_zip(zip_file_path, password_dict_path)
    else:
        lbl_result.config(text='サポートされていないファイル形式')

def crack_rar():
    rar_file_path = entry_zip_file.get()
    password_dict_path = entry_password_dict.get()
    if rar_file_path.endswith('.rar'):
        extract_rar(rar_file_path, password_dict_path)
    else:
        lbl_result.config(text='サポートされていないファイル形式')

root = tk.Tk()
root.title("圧縮ファイルパスワード解読 - WeChat公式アカウント: ランパンズの家")
root.geometry("400x200")

lbl_zip_file = tk.Label(root, text="圧縮ファイルのパス:")
lbl_zip_file.pack()
entry_zip_file = tk.Entry(root)
entry_zip_file.pack()
btn_browse_zip_file= tk.Button(root, text="参照", command=browse_zip_file)
btn_browse_zip_file.pack()

lbl_password_dict = tk.Label(root, text="パスワード辞書のパス:")
lbl_password_dict.pack()
entry_password_dict = tk.Entry(root)
entry_password_dict.pack()
btn_browse_password_dict = tk.Button(root, text="参照", command=browse_password_dict)
btn_browse_password_dict.pack()

btn_crack_zip = tk.Button(root, text="Zipファイルを解読", command=crack_zip)
btn_crack_zip.pack()
btn_crack_rar = tk.Button(root, text="Rarファイルを解読", command=crack_rar)
btn_crack_rar.pack()

lbl_result = tk.Label(root, text="")
lbl_result.pack()

root.mainloop()

Screenshot_1

読み込み中...
文章は、創作者によって署名され、ブロックチェーンに安全に保存されています。