A Python tool for extracting and analyzing Cisco FMC (Firewall Management Center) access control rules containing specific IP addresses. This tool connects to your FMC via REST API and generates detailed Excel reports of firewall rules.
git clone <your-repo-url> cd get_filtered
pip install -r requirements.txt
fmcip = '192.168.1.100 # Replace with your FMC IP
python get_filtered_rules.py <ClusterName> <IP_Address> <OutputFile.xlsx>
ClusterName: Name of the firewall cluster/device in FMCIP_Address: IP address to search for in firewall rulesOutputFile.xlsx: Output Excel file name (must have .xlsx extension)python get_filtered_rules.py "DC-Firewall-Cluster" "192.168.1.100" "firewall_rules_report.xlsx"
The script will prompt for FMC credentials:
The tool generates:
Excel Report (OutputFile.xlsx): Contains filtered rules with:
Log File (GetFilteredRules.log): Detailed execution log for troubleshooting
| Column | Description |
|---|---|
| rule_index | Order/index of the rule in the policy |
| name | Rule name/identifier |
| action | Rule action (ALLOW, BLOCK, etc.) |
| enabled | Whether the rule is enabled |
| sourceNetworks | Source IP addresses/networks |
| destinationNetworks | Destination IP addresses/networks |
| destinationPorts | Destination ports and protocols |
| sourceZones | Source security zones |
Update the fmcip variable in the script:
fmcip = 'your.fmc.ip.address'
The script disables SSL verification by default for lab environments. For production:
session.verify = True # Enable SSL verification
The tool includes comprehensive error handling for:
Detailed logs are written to GetFilteredRules.log including:
Authentication Error (401)
Cluster Not Found
No Rules Found
Connection Errors
Enable verbose logging by modifying the logging level:
level=logging.DEBUG
requests: HTTP library for API callspandas: Data manipulation and analysisopenpyxl: Excel file creationbase64: Authentication encodingSee requirements.txt for specific versions.
Artur Pinto - arturj.pinto@gmail.com
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is provided as-is for educational and administrative purposes. Always test in a lab environment before using in production. The author is not responsible for any network disruptions or policy changes resulting from the use of this tool.
Owner
Contributors
Categories
Products
Secure FirewallProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community