AI Malware Scanner GUI – Python App to Detect Suspicious Files | FuzzuTech
Demo :
Click Video πππ
πΉ Intro :
Want to build your own AI-powered malware scanner? π» This Python GUI project uses a machine learning model to classify files based on their hash and size. With a hacker-style dark GUI and real-time detection, this project is perfect for ethical hacking and cybersecurity enthusiasts.
- π‘ Uses AI (Random Forest) to scan .exe, .pdf, .zip files
- ⚙️ Built with Python, customtkinter, and hashlib
- π Classifies files as Safe or Suspicious
- π§ Smart feature extraction from file size & SHA256 hash
- π Modern dark-mode GUI (desktop style)
- π― Ideal for cybersecurity learners & ethical hackers
Code :
import os
import customtkinter as ctk
from tkinter import filedialog
from sklearn.ensemble import RandomForestClassifier
import joblib
import hashlib
# 1. Create Dummy Model (if not exists)
MODEL_PATH = "model/malware_classifier.joblib"
def create_dummy_model():
os.makedirs("model", exist_ok=True)
X = [[10000, 12345678], [20000, 87654321], [15000, 23456789], [50000, 99999999]]
y = [0, 1, 0, 1] # 0 = Safe, 1 = Suspicious
model = RandomForestClassifier()
model.fit(X, y)
joblib.dump(model, MODEL_PATH)
print("✅ Dummy model created successfully.")
if not os.path.exists(MODEL_PATH):
create_dummy_model()
# 2. Load Model
model = joblib.load(MODEL_PATH)
# 3. Feature Extractor
def extract_features(file_path):
try:
file_size = os.path.getsize(file_path)
with open(file_path, 'rb') as f:
file_hash = hashlib.sha256(f.read()).hexdigest()
hash_int = int(file_hash[:8], 16)
return [[file_size, hash_int]]
except:
return [[0, 0]]
# 4. GUI App
class MalwareScannerGUI(ctk.CTk):
def __init__(self):
super().__init__()
self.title("AI Malware Scanner")
self.geometry("500x400")
self.configure(fg_color="#1e1e1e")
ctk.set_appearance_mode("dark")
self.label_title = ctk.CTkLabel(self, text="π Malware Classifier", font=("Arial", 24, "bold"))
self.label_title.pack(pady=20)
self.upload_btn = ctk.CTkButton(self, text="Upload File (exe/pdf/zip)", command=self.upload_file)
self.upload_btn.pack(pady=20)
self.status_label = ctk.CTkLabel(self, text="No file selected.", font=("Arial", 16))
self.status_label.pack(pady=10)
self.result_label = ctk.CTkLabel(self, text="", font=("Arial", 18, "bold"))
self.result_label.pack(pady=10)
def upload_file(self):
file_path = filedialog.askopenfilename(filetypes=[("All Files", "*.*")])
if file_path:
self.status_label.configure(text="Scanning: " + os.path.basename(file_path))
features = extract_features(file_path)
prediction = model.predict(features)[0]
result = "✅ Safe" if prediction == 0 else "⚠️ Suspicious"
self.result_label.configure(text=f"Result: {result}")
if __name__ == "__main__":
app = MalwareScannerGUI()
app.mainloop()
Comments
Post a Comment