wps=wps_match.group(1)ifwps_matchelseNone# Fix: Avoid "WPS is enabled (unknown)"
ifpmkid=="no":
print(Fore.RED+Style.BRIGHT+f"[!] ALERT: Wi-Fi security profile '{sec_name}' has insecure settings!")
print(Fore.RED+" - PMKID attack is possible (disable-pmkid=no)")
risks_found=True
ifwpsisnotNoneandwps!="disable":
print(Fore.RED+f"[!] ALERT: Wi-Fi security profile '{sec_name}' has WPS enabled ({wps}), Risk of PIN bruteforcing and Pixie Dust attacks.")
risks_found=True
else:
print(Fore.RED+"[-] ERROR: Unable to retrieve Wi-Fi security settings.")
else:
print(Fore.CYAN+"[*] Skipping `/interface wifi security print` (not supported in this version)")
exceptExceptionase:
print(Fore.RED+f"[-] ERROR: Failed to check Wi-Fi settings: {e}")
ifnotrisks_found:
print(Fore.GREEN+"[+] All Wi-Fi interfaces and security profiles have secure settings.")
print(Fore.YELLOW+"[*] If you use WPA-PSK or WPA2-PSK, take care of password strength. So that the handshake cannot be easily brute-forced.")
print(Fore.GREEN+"[+] No issues found.")
# Check if UPnP is enabled
defcheck_upnp_status(connection):
separator("Checking UPnP Status")
command="/ip upnp print"
output=connection.send_command(command)
if"enabled: yes"inoutput:
print(Fore.RED+Style.BRIGHT+"[!] ALERT: UPnP is ENABLED! This is a very insecure protocol that automatically pushes internal hosts to the Internet. This protocol is used for automatic port forwarding and may also indicate a potential router compromise. Did you enable UPnP yourself?")
else:
print(Fore.GREEN+"[+] UPnP is disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Check if the router is acting as a DNS server
defcheck_dns_status(connection):
separator("Checking DNS Settings")
command="/ip dns print"
output=connection.send_command(command)
if"allow-remote-requests: yes"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: Router is acting as a DNS server! This is just a warning. The DNS port on your RouterOS should not be on the external interface.")
else:
print(Fore.GREEN+"[+] DNS remote requests are disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Check DDNS Settings
defcheck_ddns_status(connection):
separator("Checking DDNS Settings")
command="/ip cloud print"
output=connection.send_command(command)
if"ddns-enabled: yes"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: Dynamic DNS is enabled! Are you sure you need it?")
else:
print(Fore.GREEN+"[+] DDNS is disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Detect active PoE interfaces that might pose a risk to connected devices
defcheck_poe_status(connection):
separator("Checking PoE Status")
command="/interface ethernet print detail"
output=connection.send_command(command)
risks_found=False
interfaces=output.split("\n\n")
forinterfaceininterfaces:
name_match=re.search(r'name="([^"]+)"',interface)
poe_match=re.search(r'poe-out=(\S+)',interface)
name=name_match.group(1)ifname_matchelse"Unknown"
poe=poe_match.group(1)ifpoe_matchelse"none"
ifpoein["auto-on","forced-on"]:
print(Fore.YELLOW+Style.BRIGHT+f"[!] CAUTION: PoE is enabled on {name}. Ensure that connected devices support PoE to prevent damage.")
risks_found=True
ifnotrisks_found:
print(Fore.GREEN+"[+] No PoE-enabled interfaces detected.")
print(Fore.GREEN+"[+] No issues found.")
# Checking RouterBOOT
defcheck_routerboot_protection(connection):
separator("Checking RouterBOOT Protection")
command="/system routerboard settings print"
output=connection.send_command(command)
if"protected-routerboot: disabled"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: RouterBOOT protection is disabled! This can allow unauthorized firmware changes and password resets via Netinstall.")
else:
print(Fore.GREEN+"[+] RouterBOOT protection is enabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
defcheck_socks_status(connection):
separator("Checking SOCKS Proxy Status")
command="/ip socks print"
output=connection.send_command(command)
if"enabled: yes"inoutput:
print(Fore.RED+Style.BRIGHT+"[!] ALERT: SOCKS proxy is enabled! This may indicate a possible compromise of the device, the entry point to the internal network.")
else:
print(Fore.GREEN+"[+] SOCKS proxy is disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Verify if RouterBOOT protection is enabled to prevent unauthorized firmware modifications
defcheck_bandwidth_server_status(connection):
separator("Checking Bandwidth Server Status")
command="/tool bandwidth-server print"
output=connection.send_command(command)
if"enabled: yes"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: Bandwidth server is enabled! Possible unwanted traffic, possible CPU load.")
else:
print(Fore.GREEN+"[+] Bandwidth server is disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Analyze discovery protocols (CDP, LLDP, MNDP) that might expose network information
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: RouterOS sends Discovery protocol packets to all interfaces. This can be used by an attacker to gather data about RouterOS.")
print(Fore.GREEN+"[+] No security risks found in Neighbor Discovery Protocol settings.")
print(Fore.GREEN+"[+] No issues found.")
# Ensure a minimum password length policy is enforced
defcheck_password_length_policy(connection):
separator("Checking Password Policy")
command="/user settings print"
output=connection.send_command(command)
if"minimum-password-length: 0"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: No minimum password length is enforced! The length of the created passwords must be taken into account.")
if"minimum-password-length: 0"notinoutput:
print(Fore.GREEN+"[+] Password policy is enforced. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Analyze SSH security settings, including strong encryption and port forwarding risks
defcheck_ssh_security(connection):
separator("Checking SSH Security")
command="/ip ssh print"
output=connection.send_command(command)
if"forwarding-enabled: both"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: SSH Dynamic Port Forwarding is enabled! This could indicate a RouterOS compromise, and SSH DPF could also be used by an attacker as a pivoting technique.")
if"strong-crypto: no"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: strong-crypto is disabled! It is recommended to enable it to enhance security. This will:")
print(Fore.YELLOW+" - Use stronger encryption, HMAC algorithms, and larger DH primes;")
print(Fore.GREEN+"[+] Connection Tracking is properly configured.")
print(Fore.GREEN+"[+] No issues found.")
# Verify if RoMON is enabled, which might expose Layer 2 management access
defcheck_romon_status(connection):
separator("Checking RoMON Status")
command="/tool romon print"
output=connection.send_command(command)
if"enabled: yes"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: RoMON is enabled! This allows Layer 2 management access, which may expose the router to unauthorized control.")
print(Fore.YELLOW+" - If RoMON is not required, disable it to reduce attack surface.")
if"enabled: yes"notinoutput:
print(Fore.GREEN+"[+] RoMON is disabled. No risk detected.")
print(Fore.GREEN+"[+] No issues found.")
# Analyze MAC-based Winbox access settings
defcheck_mac_winbox_security(connection):
separator("Checking Winbox MAC Server Settings")
# MAC-Winbox Server
command="tool mac-server mac-winbox print"
output=connection.send_command(command)
if"allowed-interface-list: all"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: MAC Winbox access is enabled on all interfaces. This compromises the security of the Winbox interface.")
else:
print(Fore.GREEN+"[+] MAC Winbox are properly restricted.")
# MAC-Server
command="tool mac-server print"
output=connection.send_command(command)
if"allowed-interface-list: all"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: MAC Telnet access is enabled on all interfaces. This compromises the security of the Winbox interface.")
else:
print(Fore.GREEN+"[+] MAC Telnet are properly restricted.")
# MAC Ping
command="tool mac-server ping print"
output=connection.send_command(command)
if"enabled: yes"inoutput:
print(Fore.YELLOW+Style.BRIGHT+"[!] CAUTION: MAC Ping is enabled. Possible unwanted traffic.")
else:
print(Fore.GREEN+"[+] MAC Ping are properly restricted.")
# Check for weak SNMP community strings that could be exploited
# Execute all implemented security checks in sequence
check_routeros_version(connection)
check_smb(connection)
check_rmi_services(connection)
check_default_users(connection)
checking_access_to_RMI(connection)
check_wifi_security(connection)
check_upnp_status(connection)
check_dns_status(connection)
check_ddns_status(connection)
check_poe_status(connection)
check_routerboot_protection(connection)
check_socks_status(connection)
check_bandwidth_server_status(connection)
check_neighbor_discovery(connection)
check_password_length_policy(connection)
check_ssh_security(connection)
check_connection_tracking(connection)
check_romon_status(connection)
check_mac_winbox_security(connection)
check_snmp(connection)
check_dst_nat_rules(connection)
detect_malicious_schedulers(connection)
check_static_dns_entries(connection)
get_router_uptime(connection)
# Print a blank line for better output formatting
print()
# Close the SSH connection to the router
connection.disconnect()
print(Fore.GREEN+Style.BRIGHT+f"[*] Disconnected from RouterOS ({args.ip}:{args.port})")
# Measure and display the total execution time
end_time=time.time()
total_time=round(end_time-start_time,2)
# Print a closing message emphasizing continuous security improvements
print(Fore.GREEN+Style.BRIGHT+f"[*] All checks have been completed. Security inspection completed in {total_time} seconds\n")
print(Fore.MAGENTA+Style.BRIGHT+"[*] "+Fore.WHITE+"Remember: "+Fore.RED+"Security"+Fore.WHITE+" is a "+Fore.GREEN+"process"+Fore.WHITE+", not a "+Fore.YELLOW+"state.")