Sample script for calling and consuming ASDM from a Cisco ASA
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

This is a sample of how one might call and consume ASDM from an ASA in python.
This is a very simple script by design. It makes the assumption that Gig 0/0 is UP/UP and that nameif is "outside"

Packages required:
- bs4
- beautifulsoup4
- colorama

  1. pip install bs4 beautifulsoup4 colorama
  2. edit with your ASA IP, credentials, and IPs/Ports
  3. python

Python Script ASDM HTTP Request

POST /admin/config HTTP/1.1
Accept-Encoding: identity
Content-Length: 196
User-Agent: Python-urllib/2.7
Connection: close
Content-Type: text/xml
Authorization: Basic Y2lzY286c2FuZnJhbg==
<?xml version="1.0" encoding="ISO-8859-1"?>
<config-data config-action="merge" errors="continue">
  <cli id="0">packet-tracer input outside tcp 35290 21 xml</cli>

HTTP Server Response

Date: Fri, 25 May 2018 01:27:33 UTC
Connection: close
Content-Type: text/xml  

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ErrorList SYSTEM "urn:com-cisco-nm-callhome:ErrorList">
    <error-info id="0" type="info">
      &lt;subtype&gt;Resolve Egress Interface&lt;/subtype&gt;
      found next-hop using egress ifc  inside
      Implicit Rule
      &lt;drop-reason&gt;(acl-drop) Flow is denied by configured rule&lt;/drop-reason&gt;