-
Notifications
You must be signed in to change notification settings - Fork 0
/
obdfuscator.py
82 lines (60 loc) · 2.8 KB
/
obdfuscator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
import tkinter as tk
from tkinter import filedialog, messagebox
# Key for XOR encryption (you can customize this key)
xor_encryption_key = 0x42
# Key for Caesar cipher encryption (you can customize this key)
caesar_cipher_key = 3
def obfuscate_executable():
input_exe_file = input_file_entry.get()
try:
# Get the directory of the input .exe file
input_dir = os.path.dirname(input_exe_file)
# Determine the output .exe file path in the same directory
input_filename = os.path.basename(input_exe_file)
output_exe_path = os.path.join(input_dir, "obfuscated_" + input_filename)
# Read the binary data from the input .exe file
with open(input_exe_file, 'rb') as input_file:
binary_data = input_file.read()
# XOR encrypt the binary data
xor_encrypted_data = bytes([byte ^ xor_encryption_key for byte in binary_data])
# Caesar cipher encrypt the XOR encrypted data
caesar_encrypted_data = bytes([(byte + caesar_cipher_key) % 256 for byte in xor_encrypted_data])
# Write the obfuscated data to the output .exe file
with open(output_exe_path, 'wb') as output_file:
output_file.write(caesar_encrypted_data)
messagebox.showinfo("Obfuscation Complete", "Obfuscated executable saved to:\n" + output_exe_path)
except Exception as e:
messagebox.showerror("Error", "Error obfuscating the executable:\n" + str(e))
def browse_input_file():
input_file_path = filedialog.askopenfilename(filetypes=[("Executable Files", "*.exe")])
input_file_entry.delete(0, tk.END)
input_file_entry.insert(0, input_file_path)
def browse_output_file():
output_file_path = filedialog.asksaveasfilename(defaultextension=".exe")
output_file_entry.delete(0, tk.END)
output_file_entry.insert(0, output_file_path)
# Create a GUI window
root = tk.Tk()
root.title("Executable Obfuscation")
# Create and configure GUI components
frame = tk.Frame(root)
frame.pack(padx=10, pady=10)
matrix_label = tk.Label(frame, text="Welcome to Matrix", font=("Courier", 16))
matrix_label.pack()
input_file_label = tk.Label(frame, text="Select the input .exe file:")
input_file_label.pack()
input_file_entry = tk.Entry(frame, width=50)
input_file_entry.pack()
browse_input_button = tk.Button(frame, text="Browse", command=browse_input_file)
browse_input_button.pack()
obfuscate_button = tk.Button(frame, text="Obfuscate", command=obfuscate_executable)
obfuscate_button.pack()
output_file_label = tk.Label(frame, text="Save obfuscated file as:")
output_file_label.pack()
output_file_entry = tk.Entry(frame, width=50)
output_file_entry.pack()
browse_output_button = tk.Button(frame, text="Browse", command=browse_output_file)
browse_output_button.pack()
# Start the GUI
root.mainloop()