š 3.5 Cisco Security Platforms and APIs
Overview
Cisco provides a comprehensive security portfolio with API-enabled platforms for threat detection, prevention, and response across the extended network.
1. Cisco XDR (Extended Detection and Response)
XDR Unified Security Analytics
Cisco XDR integrates telemetry from network, endpoint, cloud, and email to provide unified threat detection and automated response.
Key Capabilities
- Unified Visibility: Correlate data across security products
- Threat Detection: AI/ML-powered threat identification
- Automated Response: Orchestrated remediation actions
- Investigation: Incident timeline and root cause analysis
- Integration: SecureX platform for orchestration
2. Cisco Firepower (FMC & FTD)
Firepower Next-Generation Firewall
Firepower Management Center (FMC) manages Firepower Threat Defense (FTD) devices providing NGFW, IPS, malware protection, and URL filtering.
Key Capabilities
- NGFW: Application awareness and control
- IPS: Intrusion prevention with Snort rules
- Advanced Malware Protection (AMP): File analysis and blocking
- URL Filtering: Category-based web filtering
- VPN: Site-to-site and remote access VPN
- SSL Decryption: Inspect encrypted traffic
Firepower Management Center REST API
#!/usr/bin/env python3
"""
Firepower Management Center (FMC) API Example
"""
import requests
import json
class FirepowerAPI:
def __init__(self, server, username, password):
self.server = server
self.base_url = f"https://{server}/api/fmc_platform/v1"
self.username = username
self.password = password
self.token = None
self.domain_uuid = None
def authenticate(self):
"""Get authentication token"""
url = f"https://{self.server}/api/fmc_platform/v1/auth/generatetoken"
response = requests.post(
url,
auth=(self.username, self.password),
verify=False
)
if response.status_code == 204:
self.token = response.headers.get('X-auth-access-token')
self.domain_uuid = response.headers.get('DOMAIN_UUID')
print("ā
Authentication successful")
return True
else:
print(f"ā Authentication failed: {response.status_code}")
return False
def get_headers(self):
"""Get request headers"""
return {
'X-auth-access-token': self.token,
'Content-Type': 'application/json'
}
def get_devices(self):
"""Get all managed devices"""
url = f"{self.base_url}/domain/{self.domain_uuid}/devices/devicerecords"
response = requests.get(
url,
headers=self.get_headers(),
verify=False
)
if response.status_code == 200:
devices = response.json()['items']
print(f"\nā
Found {len(devices)} device(s)")
for dev in devices:
print(f" Name: {dev['name']}")
print(f" Model: {dev['model']}")
print(f" Type: {dev['type']}")
return devices
return []
def get_access_policies(self):
"""Get access control policies"""
url = f"{self.base_url}/domain/{self.domain_uuid}/policy/accesspolicies"
response = requests.get(
url,
headers=self.get_headers(),
verify=False
)
if response.status_code == 200:
policies = response.json()['items']
print(f"\nā
Access Policies:")
for policy in policies:
print(f" - {policy['name']}")
return policies
return []
# Usage
fmc = FirepowerAPI('fmc.example.com', 'admin', 'password')
if fmc.authenticate():
fmc.get_devices()
fmc.get_access_policies()
3. Cisco Umbrella
Umbrella Cloud-Delivered Security
Cisco Umbrella is a cloud security platform providing DNS-layer security, secure web gateway, firewall, and CASB.
Key Capabilities
- DNS Security: Block malicious domains before connection
- Secure Web Gateway (SWG): URL filtering and inspection
- Cloud Firewall: Layer 3/4 firewall in the cloud
- CASB: Cloud application security broker
- Threat Intelligence: Real-time global threat data
- Reporting: Comprehensive security analytics
Umbrella APIs
| API | Purpose |
|---|---|
| Reporting API | Security activity, top destinations, blocked requests |
| Management API | Manage policies, destinations, networks |
| Investigate API | Domain reputation, threat intelligence |
| Enforcement API | Dynamic block/allow lists |
https://api.umbrella.comAuthentication: API Key & Secret
4. Cisco Secure Endpoint (formerly AMP for Endpoints)
Secure Endpoint Endpoint Protection
Cisco Secure Endpoint provides advanced malware protection, detection, and response for endpoints.
Key Capabilities
- Malware Protection: Prevent, detect, and respond to threats
- Behavioral Analysis: Identify suspicious activities
- Retrospective Security: Continuous file analysis
- Threat Hunting: Search for IOCs across endpoints
- Outbreak Control: Application blocking policies
https://api.amp.cisco.com/v1
5. Cisco ISE (Identity Services Engine)
ISE Network Access Control
Cisco ISE provides secure network access control, device profiling, guest management, and BYOD support.
Key Capabilities
- 802.1X Authentication: Network access control
- TrustSec: Software-defined segmentation
- Device Profiling: Automatic device identification
- Guest Access: Self-service portal and sponsor approval
- BYOD: Secure personal device onboarding
- pxGrid: Share context with other security products
ISE APIs
| API | Purpose |
|---|---|
| ERS (External RESTful Services) | CRUD operations on ISE objects |
| pxGrid | Context sharing with security ecosystem |
| Guest API | Manage guest accounts programmatically |
#!/usr/bin/env python3
"""
Cisco ISE ERS API Example
"""
import requests
from requests.auth import HTTPBasicAuth
class ISEAPI:
def __init__(self, host, username, password):
self.base_url = f"https://{host}:9060/ers/config"
self.auth = HTTPBasicAuth(username, password)
self.headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
def get_endpoints(self):
"""Get all endpoints"""
url = f"{self.base_url}/endpoint"
response = requests.get(url, auth=self.auth, headers=self.headers, verify=False)
if response.status_code == 200:
endpoints = response.json()['SearchResult']['resources']
print(f"ā
Found {len(endpoints)} endpoints")
for ep in endpoints:
print(f" - {ep['name']}")
return endpoints
return []
def get_network_devices(self):
"""Get network devices (NAD)"""
url = f"{self.base_url}/networkdevice"
response = requests.get(url, auth=self.auth, headers=self.headers, verify=False)
if response.status_code == 200:
devices = response.json()['SearchResult']['resources']
print(f"ā
Network devices: {len(devices)}")
return devices
return []
# Usage
ise = ISEAPI('ise.example.com', 'admin', 'password')
ise.get_endpoints()
6. Cisco Secure Malware Analytics (Threat Grid)
Threat Grid Malware Sandboxing
Threat Grid provides advanced malware analysis and threat intelligence through automated sandboxing.
Key Capabilities
- File Analysis: Automated malware sandboxing
- Behavioral Analysis: Observe malware behavior
- Threat Intelligence: IOCs and threat feeds
- Integration: Share intelligence with security products
https://panacea.threatgrid.com/api/v2
Security Platform Comparison
| Platform | Primary Function | Deployment | API Type |
|---|---|---|---|
| XDR | Unified threat detection | Cloud | REST |
| Firepower | NGFW/IPS | On-prem/Cloud | REST |
| Umbrella | DNS/Web security | Cloud | REST |
| Secure Endpoint | Endpoint protection | Cloud-managed | REST |
| ISE | Network access control | On-premises | REST (ERS), pxGrid |
| Threat Grid | Malware analysis | Cloud | REST |
āļø 3.6 Device-Level APIs and Dynamic Interfaces
Overview
Modern Cisco network operating systems (IOS XE and NX-OS) provide multiple programmable interfaces for automation, configuration management, and monitoring.
IOS XE Programmable Interfaces
IOS XE Catalyst and ASR Platforms
Cisco IOS XE is the modern network OS running on Catalyst switches and ASR routers, offering extensive programmability.
Available APIs and Interfaces
| Interface | Protocol | Description |
|---|---|---|
| NETCONF | XML over SSH (port 830) | Configuration management using YANG models |
| RESTCONF | REST over HTTPS (port 443) | RESTful interface to YANG models |
| gNMI | gRPC | Google Network Management Interface |
| Guest Shell | Linux container | Run Python scripts directly on device |
| CLI (SSH/Telnet) | Text-based | Traditional command-line interface |
| SNMP | UDP | Monitoring and basic configuration |
NETCONF Example (IOS XE)
#!/usr/bin/env python3
"""
IOS XE NETCONF Example
Configuration management using ncclient
"""
from ncclient import manager
import xmltodict
# Connect to IOS XE device
def connect_netconf(host, port, username, password):
"""Establish NETCONF session"""
device = {
'host': host,
'port': port,
'username': username,
'password': password,
'hostkey_verify': False,
'device_params': {'name': 'iosxe'}
}
conn = manager.connect(**device)
print(f"ā
NETCONF session established with {host}")
return conn
# Get running configuration
def get_config(conn):
"""Retrieve running configuration"""
config = conn.get_config(source='running')
print("ā
Retrieved running configuration")
return config
# Get specific interface configuration
def get_interface(conn, interface_name):
"""Get interface configuration using filter"""
# NETCONF filter (XML)
interface_filter = f"""
{interface_name}
"""
result = conn.get(interface_filter)
print(f"ā
Retrieved configuration for {interface_name}")
return result
# Configure interface
def configure_interface(conn, interface_name, description):
"""Configure interface description"""
# NETCONF edit-config payload
config_data = f"""
{interface_name}
{description}
"""
response = conn.edit_config(target='running', config=config_data)
print(f"ā
Interface {interface_name} configured")
return response
# Main execution
if __name__ == "__main__":
# Connection details
HOST = "ios-xe-device.example.com"
PORT = 830
USERNAME = "admin"
PASSWORD = "cisco"
# Connect
conn = connect_netconf(HOST, PORT, USERNAME, PASSWORD)
# Get interface info
get_interface(conn, "GigabitEthernet1")
# Configure interface
configure_interface(conn, "GigabitEthernet1", "Configured via NETCONF")
# Close connection
conn.close_session()
print("ā
NETCONF session closed")
RESTCONF Example (IOS XE)
#!/usr/bin/env python3
"""
IOS XE RESTCONF Example
RESTful interface to YANG models
"""
import requests
import json
from requests.auth import HTTPBasicAuth
# Disable SSL warnings for lab
import urllib3
urllib3.disable_warnings()
class IOSXERestconf:
"""IOS XE RESTCONF API Client"""
def __init__(self, host, username, password):
self.base_url = f"https://{host}/restconf/data"
self.auth = HTTPBasicAuth(username, password)
self.headers = {
'Accept': 'application/yang-data+json',
'Content-Type': 'application/yang-data+json'
}
def get_interfaces(self):
"""Get all interfaces"""
url = f"{self.base_url}/ietf-interfaces:interfaces"
response = requests.get(
url,
auth=self.auth,
headers=self.headers,
verify=False
)
if response.status_code == 200:
interfaces = response.json()['ietf-interfaces:interfaces']['interface']
print(f"ā
Found {len(interfaces)} interfaces")
for intf in interfaces[:5]:
print(f" {intf['name']}: {intf.get('description', 'No description')}")
return interfaces
else:
print(f"ā Error: {response.status_code}")
return []
def get_interface(self, name):
"""Get specific interface"""
url = f"{self.base_url}/ietf-interfaces:interfaces/interface={name}"
response = requests.get(
url,
auth=self.auth,
headers=self.headers,
verify=False
)
if response.status_code == 200:
intf = response.json()['ietf-interfaces:interface']
print(f"\nInterface: {intf['name']}")
print(f" Type: {intf['type']}")
print(f" Enabled: {intf.get('enabled', False)}")
print(f" Description: {intf.get('description', 'N/A')}")
return intf
return None
def configure_interface(self, name, description, enabled=True):
"""Configure interface via RESTCONF"""
url = f"{self.base_url}/ietf-interfaces:interfaces/interface={name}"
data = {
"ietf-interfaces:interface": {
"name": name,
"description": description,
"enabled": enabled
}
}
response = requests.patch(
url,
auth=self.auth,
headers=self.headers,
json=data,
verify=False
)
if response.status_code in [200, 204]:
print(f"ā
Interface {name} configured")
return True
else:
print(f"ā Error: {response.status_code} - {response.text}")
return False
# Usage
device = IOSXERestconf('cat9k.example.com', 'admin', 'cisco')
device.get_interfaces()
device.configure_interface('GigabitEthernet1/0/1', 'Uplink to Core', enabled=True)
NX-OS Programmable Interfaces
NX-OS Nexus Data Center Switches
Cisco NX-OS powers Nexus switches in the data center, offering rich programmability and automation features.
Available APIs and Interfaces
| Interface | Protocol | Description |
|---|---|---|
| NX-API CLI | HTTP/HTTPS | Convert CLI commands to API calls (JSON/XML) |
| NX-API REST | REST over HTTPS | RESTful access to device management |
| NETCONF | XML over SSH | YANG model-based configuration |
| gNMI | gRPC | Streaming telemetry and configuration |
| Python (On-box) | Direct | Run Python scripts on switch |
| Bash Shell | Direct | Linux shell access for automation |
NX-API CLI Example (JSON-RPC)
#!/usr/bin/env python3
"""
NX-OS NX-API CLI Example
Execute CLI commands programmatically
"""
import requests
import json
from requests.auth import HTTPBasicAuth
class NXOSDevice:
"""NX-OS NX-API Client"""
def __init__(self, host, username, password):
self.url = f"https://{host}/ins"
self.auth = HTTPBasicAuth(username, password)
self.headers = {'Content-Type': 'application/json'}
def execute_command(self, command):
"""Execute single CLI command"""
payload = {
"ins_api": {
"version": "1.0",
"type": "cli_show",
"chunk": "0",
"sid": "1",
"input": command,
"output_format": "json"
}
}
response = requests.post(
self.url,
auth=self.auth,
headers=self.headers,
json=payload,
verify=False
)
if response.status_code == 200:
result = response.json()['ins_api']['outputs']['output']
return result['body']
else:
print(f"ā Error: {response.status_code}")
return None
def execute_config(self, commands):
"""Execute configuration commands"""
payload = {
"ins_api": {
"version": "1.0",
"type": "cli_conf",
"chunk": "0",
"sid": "1",
"input": commands,
"output_format": "json"
}
}
response = requests.post(
self.url,
auth=self.auth,
headers=self.headers,
json=payload,
verify=False
)
if response.status_code == 200:
print("ā
Configuration applied")
return True
else:
print(f"ā Error: {response.status_code}")
return False
def show_version(self):
"""Get device version information"""
result = self.execute_command("show version")
if result:
print(f"\nHostname: {result.get('host_name', 'N/A')}")
print(f"Software: {result.get('nxos_ver_str', 'N/A')}")
print(f"Uptime: {result.get('kern_uptm_days', 'N/A')} days")
return result
def show_interfaces(self):
"""Get interface status"""
result = self.execute_command("show interface brief")
if result:
interfaces = result['TABLE_interface']['ROW_interface']
print(f"\nā
Interfaces ({len(interfaces)}):")
for intf in interfaces[:5]:
print(f" {intf['interface']}: {intf['state']}")
return result
def configure_interface_description(self, interface, description):
"""Configure interface description"""
commands = f"""
interface {interface}
description {description}
"""
return self.execute_config(commands)
# Usage Example
device = NXOSDevice('nxos-switch.example.com', 'admin', 'admin')
device.show_version()
device.show_interfaces()
device.configure_interface_description('Ethernet1/1', 'Uplink via API')
YANG Data Models
YANG (Yet Another Next Generation) is a data modeling language used to model configuration and state data. It provides a standardized way to represent network device capabilities.
Common YANG Model Types
| Model Type | Description | Examples |
|---|---|---|
| IETF Models | Industry-standard models | ietf-interfaces, ietf-ip, ietf-routing |
| OpenConfig Models | Vendor-neutral models | openconfig-interfaces, openconfig-bgp |
| Cisco Native Models | Cisco-specific features | Cisco-IOS-XE-native, Cisco-NX-OS-device |
Guest Shell (On-Box Python)
Guest Shell - Python Directly on Device
Guest Shell is a virtualized Linux-based environment running on IOS XE and NX-OS devices, allowing you to run Python scripts directly on the switch or router.
Enabling Guest Shell (IOS XE)
# Enable IOx (application hosting)
configure terminal
iox
exit
# Enable Guest Shell
guestshell enable
# Access Guest Shell
guestshell
# Inside Guest Shell - run Python
python3
>>> import cli
>>> output = cli.execute('show version')
>>> print(output)
Python CLI Module Example
#!/usr/bin/env python3
"""
IOS XE Guest Shell Python Example
Using CLI module for device interaction
"""
# Import CLI module (available in Guest Shell)
import cli
# Execute show command
def show_command(command):
"""Execute show command and return output"""
output = cli.execute(command)
print(f"Executing: {command}")
print(output)
return output
# Configure device
def configure_device(config_commands):
"""Apply configuration commands"""
output = cli.configure(config_commands)
print("ā
Configuration applied")
print(output)
return output
# Example usage
if __name__ == "__main__":
# Show commands
show_command("show version")
show_command("show ip interface brief")
# Configuration
config = """
interface GigabitEthernet1
description Configured from Python
"""
configure_device(config)
API Comparison: IOS XE vs NX-OS
| Feature | IOS XE | NX-OS |
|---|---|---|
| NETCONF | ā Full support | ā Full support |
| RESTCONF | ā Native support | ā ļø Limited |
| NX-API | ā Not available | ā CLI to API conversion |
| Guest Shell | ā Available | ā Available |
| Python On-Box | ā Via Guest Shell | ā Native Python |
| YANG Models | Cisco-IOS-XE-* | Cisco-NX-OS-* |
| Telemetry | Model-driven telemetry | DME (NX-API), gNMI |
- Use Model-Driven APIs: NETCONF/RESTCONF over CLI scraping
- YANG Models: Leverage standardized data models
- Error Handling: Always handle connection and command errors
- Transaction Support: Use NETCONF for atomic operations
- Telemetry: Use streaming telemetry for real-time monitoring
- Version Check: Verify API support in device OS version
š Interactive Python Interpreter
- Write Python code in the editor below
- Click "ā¶ Run Code" to execute
- Experiment with security platforms and device API patterns