-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77f451f
commit 4d3d580
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import smtplib | ||
from email.mime.text import MIMEText | ||
from email.mime.multipart import MIMEMultipart | ||
|
||
def send_email(subject, body): | ||
sender_email = "[email protected]" | ||
receiver_email = "[email protected]" | ||
password = "your_password" | ||
|
||
msg = MIMEMultipart() | ||
msg["From"] = sender_email | ||
msg["To"] = receiver_email | ||
msg["Subject"] = subject | ||
|
||
msg.attach(MIMEText(body, "plain")) | ||
|
||
try: | ||
server = smtplib.SMTP("smtp.example.com", 587) | ||
server.starttls() | ||
server.login(sender_email, password) | ||
text = msg.as_string() | ||
server.sendmail(sender_email, receiver_email, text) | ||
server.quit() | ||
print("Email sent successfully") | ||
except Exception as e: | ||
print(f"Failed to send email: {e}") | ||
|
||
def notify_suspicious_process(process_name): | ||
subject = "Suspicious Process Detected" | ||
body = f"A suspicious process was detected and terminated: {process_name}" | ||
send_email(subject, body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import tkinter as tk | ||
from tkinter import messagebox | ||
import threading | ||
from security_monitor import monitor_processes, stop_monitoring | ||
|
||
def start_monitoring(): | ||
thread = threading.Thread(target=monitor_processes) | ||
thread.start() | ||
messagebox.showinfo("Information", "Monitoring started") | ||
|
||
def stop_monitoring_gui(): | ||
stop_monitoring() | ||
messagebox.showinfo("Information", "Monitoring stopped") | ||
|
||
root = tk.Tk() | ||
root.title("SecureProcessMonitor") | ||
|
||
start_button = tk.Button(root, text="Start Monitoring", command=start_monitoring) | ||
start_button.pack(pady=10) | ||
|
||
stop_button = tk.Button(root, text="Stop Monitoring", command=stop_monitoring_gui) | ||
stop_button.pack(pady=10) | ||
|
||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import psutil | ||
import time | ||
from datetime import datetime | ||
from email_notifier import notify_suspicious_process | ||
|
||
suspicious_processes = ["powershell.exe", "ftp.exe"] | ||
log_file = "security_monitor.log" | ||
monitoring = True | ||
|
||
def log_event(event): | ||
with open(log_file, "a") as log: | ||
log.write(f"{datetime.now()} - {event}\n") | ||
|
||
def kill_process(process_name): | ||
for proc in psutil.process_iter(['pid', 'name']): | ||
if proc.info['name'].lower() == process_name: | ||
proc.kill() | ||
log_event(f"Killed process: {process_name}") | ||
notify_suspicious_process(process_name) | ||
|
||
def monitor_processes(): | ||
global monitoring | ||
while monitoring: | ||
for proc_name in suspicious_processes: | ||
kill_process(proc_name) | ||
time.sleep(1) | ||
|
||
def stop_monitoring(): | ||
global monitoring | ||
monitoring = False | ||
|
||
if __name__ == "__main__": | ||
try: | ||
log_event("Started monitoring suspicious processes.") | ||
monitor_processes() | ||
except KeyboardInterrupt: | ||
log_event("Stopped monitoring script.") | ||
print("Stopping the monitoring script.") |