-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_cve.py
61 lines (49 loc) · 1.95 KB
/
check_cve.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
import sys
from netmiko import ConnectHandler
from netmiko.exceptions import NetmikoTimeoutException, NetmikoAuthenticationException
from tqdm import tqdm
import logging
def execute_command_on_firewall(host, username, password, command):
cli_pattern = r"\)>\s"
ssh_parameters = {
"device_type": "paloalto_panos",
"host": host,
"username": username,
"password": password,
}
try:
ssh = ConnectHandler(**ssh_parameters)
output = ssh.send_command(command, expect_string=cli_pattern, read_timeout=30)
ssh.disconnect()
return output
except NetmikoTimeoutException:
print(f"Cannot connect to {host}. Please check if the network is communicating properly.")
except NetmikoAuthenticationException:
logging.warning(f"Logon Failure for {host}: Incorrect username or password.")
print(f"Logon Failure for {host}: Incorrect username or password.")
except Exception as e:
print(f"Failed to execute command on {host}: {e}")
# Example usage
if __name__ == "__main__":
# Replace these values with your actual firewall credentials
firewall_hosts = ["firewalls"] # List of firewall IPs
firewall_username = "username"
firewall_password = "password"
command_to_run = "grep pattern 'failed to unmarshal session(.\+\/' mp-log gpsvc.log"
# Max number of concurrent SSH connections
max_concurrent_connections = 10
#Header
header = (f"{'*' * 51}\n CHECKING FOR CVE-2024-3400 PAN-OS EXPLOIT EVIDENCE\n"
f"https://security.paloaltonetworks.com/CVE-2024-3400\n"
f"{'*' * 51}")
print(header)
with tqdm(total=len(firewall_hosts), desc="Checking...", colour='blue', file=sys.stdout, position=0, leave=True) as progress_bar:
for host in firewall_hosts:
output = execute_command_on_firewall(host, firewall_username, firewall_password, command_to_run)
if output:
tqdm.write(f"Output from {host}:"
f"{output}")
else:
tqdm.write(f"No evidence returned from {host.upper()}")
progress_bar.update(1)
progress_bar.close()