106 lines
3.9 KiB
Python
106 lines
3.9 KiB
Python
import tkinter as tk
|
|
from tkinter import filedialog, ttk, scrolledtext, messagebox
|
|
import re
|
|
import json
|
|
|
|
class PatternFinderGUI:
|
|
def __init__(self, root):
|
|
self.root = root
|
|
self.root.title("PSA EDC17 PIN Finder")
|
|
self.root.geometry("680x300")
|
|
|
|
# File Selection Frame
|
|
file_frame = ttk.LabelFrame(root, text="File Selection", padding=10)
|
|
file_frame.pack(fill=tk.X, padx=5, pady=5)
|
|
|
|
self.file_path = tk.StringVar()
|
|
ttk.Entry(file_frame, textvariable=self.file_path, width=60).pack(side=tk.LEFT, padx=5)
|
|
ttk.Button(file_frame, text="Browse", command=self.browse_file).pack(side=tk.LEFT, padx=5)
|
|
ttk.Button(file_frame, text="About", command=self.show_about).pack(side=tk.RIGHT, padx=5)
|
|
ttk.Button(file_frame, text="Search PIN", command=self.search_patterns).pack(side=tk.RIGHT, padx=5)
|
|
|
|
|
|
# Results Frame
|
|
results_frame = ttk.LabelFrame(root, text="Results", padding=10)
|
|
results_frame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
|
|
|
self.results_text = scrolledtext.ScrolledText(results_frame, width=80, height=10)
|
|
self.results_text.pack(fill=tk.BOTH, expand=True)
|
|
|
|
def find_repeated_patterns(self, filepath):
|
|
try:
|
|
target_content = ""
|
|
bytes_per_line = 16
|
|
|
|
# Define search ranges
|
|
ranges = [
|
|
(0x50, 0x150), # First range
|
|
(0x10050, 0x10150) # Second range (10050-10150)
|
|
]
|
|
|
|
with open(filepath, 'rb') as file:
|
|
# Search in both ranges
|
|
for start_offset, end_offset in ranges:
|
|
file.seek(start_offset)
|
|
data = file.read(end_offset - start_offset)
|
|
|
|
for i in range(0, len(data), bytes_per_line):
|
|
line = data[i:i + bytes_per_line]
|
|
ascii_line = ''.join(chr(b) if 32 <= b <= 126 else '.' for b in line)
|
|
target_content += ascii_line.upper()
|
|
|
|
pattern = r'[A-Z0-9]{4}'
|
|
matches = re.findall(pattern, target_content)
|
|
|
|
results = {}
|
|
for match in matches:
|
|
count = target_content.count(match)
|
|
if count == 2:
|
|
results[match] = count
|
|
|
|
return results
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
return None
|
|
|
|
def browse_file(self):
|
|
filepath = filedialog.askopenfilename(
|
|
title="Select file",
|
|
filetypes=[("Binary files", "*.bin"), ("All files", "*.*")]
|
|
)
|
|
if filepath:
|
|
self.file_path.set(filepath)
|
|
|
|
def search_patterns(self):
|
|
filepath = self.file_path.get()
|
|
if not filepath:
|
|
self.results_text.insert(tk.END, "Please select a file first\n")
|
|
return
|
|
|
|
results = self.find_repeated_patterns(filepath)
|
|
self.results_text.delete(1.0, tk.END)
|
|
|
|
if results:
|
|
self.results_text.insert(tk.END, "Found PIN that appear exactly twice:\n\n")
|
|
for pattern, count in results.items():
|
|
self.results_text.insert(tk.END, f"Pattern: {pattern}\n")
|
|
else:
|
|
self.results_text.insert(tk.END, "No matching PIN found or error occurred\n")
|
|
|
|
def show_about(self):
|
|
messagebox.showinfo(
|
|
"Sobre",
|
|
"EDC17C10 PIN Decoder\n"
|
|
"Versão 1.0\n\n"
|
|
"Programa para decodificar PINs de EDC17C10 E2PROM\n"
|
|
"Created by: @Godax"
|
|
)
|
|
|
|
def main():
|
|
root = tk.Tk()
|
|
app = PatternFinderGUI(root)
|
|
root.mainloop()
|
|
|
|
if __name__ == "__main__":
|
|
main() |