事情是这样的,我的比特币钱包的密码忘记了,这个密码是可以无限尝试的,于是用python制作了一个简单的工具暴力破解,虽然还没有成功找回,但觉得挺好用,无偿分享给需要的朋友,仅供学习交流。已经打包好,直接下载打开就能使用。下面是源代码:
import itertools
import string
import pyautogui
import time
import tkinter as tk
from tkinter import messagebox
import random # 引入random模块
class PasswordCrackerApp:
def __init__(self, root):
self.root = root
self.root.title("密码穷举工具(MAKEY制作)")
# 界面布局
self.create_widgets()
def create_widgets(self):
tk.Label(self.root, text="密码长度范围:").grid(row=0, column=0, padx=10, pady=5, sticky="e")
tk.Label(self.root, text="最小长度:").grid(row=1, column=0, padx=10, pady=5, sticky="e")
self.entry_min_length = tk.Entry(self.root)
self.entry_min_length.grid(row=1, column=1, padx=10, pady=5)
self.entry_min_length.insert(0, "1") # 默认最小长度为1
tk.Label(self.root, text="最大长度:").grid(row=2, column=0, padx=10, pady=5, sticky="e")
self.entry_max_length = tk.Entry(self.root)
self.entry_max_length.grid(row=2, column=1, padx=10, pady=5)
self.entry_max_length.insert(0, "8") # 默认最大长度为8
tk.Label(self.root, text="部分已知密码:").grid(row=3, column=0, padx=10, pady=5, sticky="e")
self.entry_known = tk.Entry(self.root)
self.entry_known.grid(row=3, column=1, padx=10, pady=5)
tk.Label(self.root, text="部分已知密码位置:").grid(row=4, column=0, padx=10, pady=5, sticky="e")
self.var_position = tk.StringVar(value="start")
tk.Radiobutton(self.root, text="开头", variable=self.var_position, value="start").grid(row=4, column=1, sticky="w")
tk.Radiobutton(self.root, text="中间", variable=self.var_position, value="middle").grid(row=5, column=1, sticky="w")
tk.Radiobutton(self.root, text="末尾", variable=self.var_position, value="end").grid(row=6, column=1, sticky="w")
tk.Label(self.root, text="包含字符类型:").grid(row=7, column=0, padx=10, pady=5, sticky="ne")
self.var_lowercase = tk.BooleanVar(value=True)
self.var_uppercase = tk.BooleanVar(value=True)
self.var_digits = tk.BooleanVar(value=True)
self.var_special = tk.BooleanVar(value=False)
tk.Checkbutton(self.root, text="小写字母 (a-z)", variable=self.var_lowercase).grid(row=7, column=1, sticky="w")
tk.Checkbutton(self.root, text="大写字母 (A-Z)", variable=self.var_uppercase).grid(row=8, column=1, sticky="w")
tk.Checkbutton(self.root, text="数字 (0-9)", variable=self.var_digits).grid(row=9, column=1, sticky="w")
tk.Checkbutton(self.root, text="特殊字符 (!@#$)", variable=self.var_special).grid(row=10, column=1, sticky="w")
# 选择回车次数
tk.Label(self.root, text="密码输入后按键:").grid(row=11, column=0, padx=10, pady=5, sticky="e")
self.var_enter_count = tk.IntVar(value=2) # 默认两次回车
tk.Radiobutton(self.root, text="一次回车", variable=self.var_enter_count, value=1).grid(row=11, column=1, sticky="w")
tk.Radiobutton(self.root, text="两次回车", variable=self.var_enter_count, value=2).grid(row=12, column=1, sticky="w")
# 设置输入间隔(秒)
tk.Label(self.root, text="输入间隔(秒):").grid(row=13, column=0, padx=10, pady=5, sticky="e")
self.entry_delay = tk.Entry(self.root)
self.entry_delay.grid(row=13, column=1, padx=10, pady=5)
self.entry_delay.insert(0, "0.1") # 默认输入间隔为0.1秒
# 开始按钮
self.start_button = tk.Button(self.root, text="开始穷举", command=self.start_bruteforce)
self.start_button.grid(row=14, column=0, columnspan=2, pady=10)
def start_bruteforce(self):
try:
# 获取最小和最大密码长度
min_length = int(self.entry_min_length.get())
max_length = int(self.entry_max_length.get())
if min_length <= 0 or max_length <= 0 or min_length > max_length:
raise ValueError
except ValueError:
messagebox.showerror("错误", "请输入有效的密码长度范围!")
return
# 获取字符选择
include_lowercase = self.var_lowercase.get()
include_uppercase = self.var_uppercase.get()
include_digits = self.var_digits.get()
include_special = self.var_special.get()
known_part = self.entry_known.get()
known_position = self.var_position.get()
# 构建字符集合
characters = ""
if include_lowercase:
characters += string.ascii_lowercase
if include_uppercase:
characters += string.ascii_uppercase
if include_digits:
characters += string.digits
if include_special:
characters += string.punctuation
if not characters:
messagebox.showerror("错误", "请至少选择一种字符类型!")
return
# 验证部分已知密码长度是否合法
if len(known_part) > max_length:
messagebox.showerror("错误", "部分已知密码长度不能大于总密码长度!")
return
# 获取用户选择的回车次数
enter_count = self.var_enter_count.get()
# 获取输入间隔(延迟时间)
try:
delay = float(self.entry_delay.get())
if delay < 0.01 or delay > 100:
raise ValueError
except ValueError:
messagebox.showerror("错误", "请输入有效的输入间隔(0.01秒到100秒之间)!")
return
# 准备开始穷举
messagebox.showinfo("提示", "请切换到目标对话框,程序将在 5 秒后开始!")
time.sleep(5) # 给用户时间切换到目标窗口
try:
for length in range(min_length, max_length + 1):
unknown_length = length - len(known_part)
for attempt in itertools.product(characters, repeat=unknown_length):
unknown_part = ''.join(attempt)
# 拼接完整密码
if known_position == "start":
password = known_part + unknown_part
elif known_position == "end":
password = unknown_part + known_part
elif known_position == "middle":
mid_index = (length - len(known_part)) // 2
password = unknown_part[:mid_index] + known_part + unknown_part[mid_index:]
# 模拟输入和按键
pyautogui.typewrite(password, interval=0.01) # 减少输入间隔,加速
pyautogui.press('enter')
if enter_count == 2:
pyautogui.press('enter') # 如果需要两次回车,按第二次回车
print(f"尝试密码: {password}")
# 输入后等待指定的延迟时间
time.sleep(delay) # 调整速度,根据用户设置的输入间隔
except KeyboardInterrupt:
messagebox.showinfo("提示", "操作被用户中断。")
return
messagebox.showinfo("完成", "穷举已完成,未找到正确密码。")
# 创建 GUI 界面
root = tk.Tk()
app = PasswordCrackerApp(root)
# 启动 GUI 主循环
root.mainloop()
标签:column,自制,密码,grid,tk,穷举,root,self,row
From: https://blog.csdn.net/u011701632/article/details/144009995