fix the fix to hopefully finally fix the bug
This commit is contained in:
parent
3ef41a249a
commit
be22f55358
1 changed files with 24 additions and 9 deletions
33
main.py
33
main.py
|
@ -174,15 +174,6 @@ def monitor_cpu_gpu_usage():
|
||||||
|
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
def realtime_av():
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
print("Realtime AntiMalware active")
|
|
||||||
kill_suspicious_processes()
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error in realtimeAV: {e}")
|
|
||||||
time.sleep(1) # Check for malware every second
|
|
||||||
|
|
||||||
def get_gpu_usage():
|
def get_gpu_usage():
|
||||||
gpus = tf.config.list_physical_devices('GPU')
|
gpus = tf.config.list_physical_devices('GPU')
|
||||||
if gpus:
|
if gpus:
|
||||||
|
@ -304,6 +295,30 @@ def thread_counter():
|
||||||
print(f"Active anti-malware threads: {threading.active_count()}")
|
print(f"Active anti-malware threads: {threading.active_count()}")
|
||||||
time.sleep(10) # Prints active count of Anti-Malware threads every 10 seconds.
|
time.sleep(10) # Prints active count of Anti-Malware threads every 10 seconds.
|
||||||
|
|
||||||
|
# Similar to "kill_suspicious_processes" but just the essentials (for optimization.)
|
||||||
|
def realtime_av():
|
||||||
|
while True:
|
||||||
|
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||||
|
try:
|
||||||
|
proc_name = proc.info['name'].lower()
|
||||||
|
cmdline = " ".join(proc.info['cmdline']).lower()
|
||||||
|
|
||||||
|
if proc_name in mining_processes and proc_name not in bypassed_processes:
|
||||||
|
print(f"Terminating suspicious mining process: {proc.info['name']} (PID: {proc.info['pid']})")
|
||||||
|
proc.terminate()
|
||||||
|
proc.wait()
|
||||||
|
|
||||||
|
# Scan files for malware as they launch and kill if potentially malicious.
|
||||||
|
for file_path in proc.info.get('cmdline', []):
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
if scan_for_malware(file_path):
|
||||||
|
print(f"Terminating potentially malicious process {proc.info['name']} (PID: {proc.info['pid']} NOW...")
|
||||||
|
proc.terminate()
|
||||||
|
proc.wait()
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied) as e:
|
||||||
|
print(f"Error terminating process: {e}")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# Start Monitoring in Threads
|
# Start Monitoring in Threads
|
||||||
threads = [
|
threads = [
|
||||||
threading.Thread(target=start_file_system_monitor),
|
threading.Thread(target=start_file_system_monitor),
|
||||||
|
|
Loading…
Reference in a new issue