Update main.py
This commit is contained in:
parent
29f2242e02
commit
1b09287c9c
1 changed files with 21 additions and 10 deletions
19
main.py
19
main.py
|
@ -321,6 +321,7 @@ def monitor_browser(browser='chrome'):
|
||||||
driver = setup_firefox_driver()
|
driver = setup_firefox_driver()
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unsupported browser!")
|
raise ValueError("Unsupported browser!")
|
||||||
|
bypassed_processes = load_bypassed_processes() # Load bypassed processes
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -332,21 +333,28 @@ def monitor_browser(browser='chrome'):
|
||||||
|
|
||||||
# Kill process involved in suspicious browser activity
|
# Kill process involved in suspicious browser activity
|
||||||
for proc in psutil.process_iter(['pid', 'name', 'connections']):
|
for proc in psutil.process_iter(['pid', 'name', 'connections']):
|
||||||
|
try:
|
||||||
if any(url in conn.raddr for conn in proc.info['connections']):
|
if any(url in conn.raddr for conn in proc.info['connections']):
|
||||||
bypassed_processes = load_bypassed_processes()
|
if proc.info['name'].lower() not in bypassed_processes and proc.info['name'].lower() not in critical_processes:
|
||||||
if proc.info['name'].lower() not in bypassed_processes and proc_name not in critical_processes:
|
|
||||||
print(f'Alert: Killing suspicious process {proc.info["name"]} (PID: {proc.info["pid"]})')
|
print(f'Alert: Killing suspicious process {proc.info["name"]} (PID: {proc.info["pid"]})')
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
proc.wait()
|
proc.wait()
|
||||||
except (Exception) as e:
|
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
||||||
print(f"Exception while monitoring browser behavior - ${e}")
|
# Handle the case where process info is not accessible
|
||||||
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception while monitoring browser behavior - {e}")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
# Setup Chrome and Firefox Drivers
|
# Setup Chrome and Firefox Drivers
|
||||||
def setup_chrome_driver():
|
def setup_chrome_driver():
|
||||||
options = webdriver.ChromeOptions()
|
options = webdriver.ChromeOptions()
|
||||||
options.add_argument("--headless") # Run in headless mode
|
options.add_argument("--headless") # Run in headless mode
|
||||||
|
chrome_options.add_argument("--enable-logging") # Enable logging
|
||||||
|
chrome_options.add_argument("--v=1") # Adjust verbosity level if needed
|
||||||
|
chrome_options.add_argument("--auto-open-devtools-for-tabs") # Open Dev Tools
|
||||||
service = ChromeService()
|
service = ChromeService()
|
||||||
return webdriver.Chrome(service=service, options=options)
|
return webdriver.Chrome(service=service, options=options)
|
||||||
|
|
||||||
|
@ -359,7 +367,10 @@ def setup_firefox_driver():
|
||||||
def realtimeAV():
|
def realtimeAV():
|
||||||
while True:
|
while True:
|
||||||
print(f"Realtime AntiMalware active")
|
print(f"Realtime AntiMalware active")
|
||||||
|
try:
|
||||||
kill_suspicious_processes()
|
kill_suspicious_processes()
|
||||||
|
except:
|
||||||
|
print("Realtime AntiMalware error. :()")
|
||||||
time.sleep(1) # check for malware every second
|
time.sleep(1) # check for malware every second
|
||||||
|
|
||||||
def threadCounter():
|
def threadCounter():
|
||||||
|
|
Loading…
Reference in a new issue