Python script to extract multiple policy types from Cisco Firepower Management Center (FMC) via REST API and export them to CSV format.
The script automatically detects and handles FMC domain configurations:
The API user must have appropriate permissions in the target domain:
Scenario 1: MSP with Multiple Customers
1. Global (DOMAIN) - Management domain
2. Customer_A (DOMAIN) - Tenant A policies
3. Customer_B (DOMAIN) - Tenant B policies
4. Customer_C (DOMAIN) - Tenant C policies
Select: 2 → Export policies for Customer_A
Scenario 2: Large Enterprise with Regional Domains
1. Global (DOMAIN) - Corporate global policies
2. Americas (DOMAIN) - North/South America policies
3. EMEA (DOMAIN) - Europe/Middle East/Africa policies
4. APAC (DOMAIN) - Asia-Pacific policies
Select: 3 → Export policies for EMEA region
Scenario 3: Development/Production Separation
1. Global (DOMAIN) - Production policies
2. Development (DOMAIN) - Dev/Test policies
Select: 1 → Export production policies
# Install dependencies pip install -r requirements.txt # Or install manually pip install requests urllib3
python3 fmc_get_config.py
The script will prompt for:
fmc_access_policy_<POLICY_NAME>.csv================================================================================
FMC POLICY EXPORT TOOL
Cisco Firepower Management Center API v10.0
================================================================================
[*] Enter FMC connection details:
FMC IP Address or Hostname: 10.0.0.100
API Username: admin
API Password: ********
[*] Authenticating to FMC: 10.0.0.100
[✓] Authentication successful
[✓] Default Domain UUID: e276abec-e0f2-11e3-8169-6d9ed49b625f
[✓] Found 3 domain(s)
================================================================================
DOMAIN SELECTION
================================================================================
1. Global (DOMAIN)
2. Americas (DOMAIN)
3. EMEA (DOMAIN)
[*] Select domain (enter number):
Domain: 1
[✓] Selected domain UUID: e276abec-e0f2-11e3-8169-6d9ed49b625f
[✓] Selected domain: Global
================================================================================
POLICY TYPE SELECTION
================================================================================
1. Access Control Policies
2. NAT Policies
3. Prefilter Policies
4. SSL Policies
5. DNS Policies
[*] Select policy type (enter number):
Policy type: 1
[*] Fetching Access Control Policies...
[✓] Found 2 access control policies
================================================================================
AVAILABLE ACCESS CONTROL POLICIES
================================================================================
1. Corporate_Policy (ID: abc123...)
2. Guest_Policy (ID: def456...)
[*] Select policy to export (enter number):
Policy number: 1
[*] Selected policy: Corporate_Policy
[*] Fetching access control rules for policy ID: abc123...
[✓] Found 50 access control rules
[*] Exporting 50 rules to CSV: fmc_access_policy_Corporate_Policy.csv
[✓] CSV export complete
================================================================================
EXPORT COMPLETE
================================================================================
Policy Type: Access Control Policies
Policy Name: Corporate_Policy
Rules exported: 50
Output file: fmc_access_policy_Corporate_Policy.csv
================================================================================
[*] Authenticating to FMC: 10.0.0.100
[✓] Authentication successful
[✓] Default Domain UUID: e276abec-e0f2-11e3-8169-6d9ed49b625f
[✓] Found 1 domain(s)
[✓] Auto-selected domain: Global (UUID: e276abec-e0f2-11e3-8169-6d9ed49b625f)
[✓] Selected domain UUID: e276abec-e0f2-11e3-8169-6d9ed49b625f
================================================================================
POLICY TYPE SELECTION
================================================================================
The generated CSV format varies by policy type:
Policy, Rule ID, Rule Name, Enabled, Action, Source Zones, Source Networks, Source Ports, Destination Zones, Destination Networks, Destination Ports, Protocol, Applications, URLs, Users, IPS Policy, File Policy, Variable Set, Logging, Send Events To, Log Files, Log Connections, Comment, Section, Category
Policy, Rule ID, Rule Name, Enabled, NAT Type, Interface In, Interface Out, Original Source, Original Destination, Original Source Port, Original Destination Port, Translated Source, Translated Destination, Translated Source Port, Translated Destination Port, Comment
Policy, Rule ID, Rule Name, Enabled, Action, Source Zones, Source Networks, Source Ports, Destination Zones, Destination Networks, Destination Ports, Protocol, VLAN Tags, Logging, Comment
Policy, Rule ID, Rule Name, Enabled, Action, Source Zones, Source Networks, Destination Zones, Destination Networks, Destination Ports, Certificate, URL Categories, URLs, Logging, Comment
Policy, Rule ID, Rule Name, Enabled, Action, Source Zones, Source Networks, DNS Lists, URL Categories, Logging, Sinkhole, Comment
/api/fmc_platform/v1/auth/generatetoken - Authentication/api/fmc_platform/v1/info/domain - List available domains/api/fmc_platform/v1/domain/{uuid}/policy/accesspolicies - Access Control Policies/api/fmc_platform/v1/domain/{uuid}/policy/ftdnatpolicies - NAT Policies/api/fmc_platform/v1/domain/{uuid}/policy/prefilterpolicies - Prefilter Policies/api/fmc_platform/v1/domain/{uuid}/policy/sslpolicies - SSL Policies/api/fmc_platform/v1/domain/{uuid}/policy/dnspolicies - DNS Policies/api/fmc_platform/v1/domain/{uuid}/policy/accesspolicies/{id}/accessrules/api/fmc_platform/v1/domain/{uuid}/policy/ftdnatpolicies/{id}/natrules/api/fmc_platform/v1/domain/{uuid}/policy/prefilterpolicies/{id}/prefilterrules/api/fmc_platform/v1/domain/{uuid}/policy/sslpolicies/{id}/sslrules/api/fmc_platform/v1/domain/{uuid}/policy/dnspolicies/{id}/dnsrulesThe script disables SSL verification by default for self-signed certificates. For production, consider:
verify='/path/to/ca-bundle.crt' # Instead of verify=False
If you hit FMC API rate limits (429 errors), the script automatically waits 60 seconds and retries.
This script is designed for FMC API version 10.0 but should work with:
Check your FMC version:
curl -k -X POST https://<FMC-IP>/api/fmc_platform/v1/auth/generatetoken \ -u username:password -I | grep "X-auth-access-token"
getpass)This tool complements the NG-FMT ASA-to-FMC migration workflow:
Combined workflow:
Part of the NG-FMT (Next-Generation Firewall Migration Tool) project.
Owner
Contributors
Categories
SecurityProducts
Secure FirewallProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community