SWAGGER API

After install and startup, you can access swagger URL http://127.0.0.1:5000/apidocs/.

ICMP

 curl -X POST \
     http://localhost:8001/ping \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{
         "timeout": 2,
         "prefix": "10.10.3.0/24"}'

output:

{
  "prefix": "10.10.3.0/24",
  "result": [
    {
      "ipv4": "10.10.3.103"
    },
    {
      "ipv4": "10.10.3.112"
    }
  ]
}

SNMP

 curl -X POST \
     http://localhost:8001/ping \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{
         "community": [
         "public",
         "public2"
         ],
         "prefix": "192.168.0.0/24",
         "timeout": 0.5
     }'

output:

{
  "community": [
    "public",
    "public2"
  ],
  "prefix": "172.31.254.0/24",
  "result": [
    {
      "descr": "pfSense my.compay.com 2.4.3-RELEASE pfSense FreeBSD 11.1-RELEASE-p7 amd64",
      "ip": "192.168.0.1"
    }
  ],
  "timeout": 0.5
}

NMAP

curl -X POST \
     http://localhost:8001/nmap \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{
        "hosts": ["scanme.nmap.org"],
        "arguments": " -A -T4 --host-timeout=5m"}'

# Example
# curl -X POST \
#      http://localhost:8001/nmap \
#      -H 'cache-control: no-cache' \
#      -H 'content-type: application/json' \
#      -d '{
#       "hosts": ["10.254.254.0/24"],
#         "arguments": "-P0 -p21,22,23,445,80,8080 --open -n --host-timeout=4s"}'

output:

$ ./shell_test_nmap-api.sh nmap
{
  "arguments": " -A -T4 -n --open --host-timeout=25",
  "hosts": [
    "scanme.nmap.org"
  ],
  "networks": "scanme.nmap.org",
  "result": [
    {
      "addresses": {
        "ipv4": "45.33.32.156"
      },
      "hostnames": [
        {
          "name": "scanme.nmap.org",
          "type": "user"
        }
      ],
      "status": {
        "reason": "syn-ack",
        "state": "up"
      },
      "tcp": {
        "22": {
          "conf": "10",
          "cpe": "cpe:/o:linux:linux_kernel",
          "extrainfo": "Ubuntu Linux; protocol 2.0",
          "name": "ssh",
          "product": "OpenSSH",
          "reason": "syn-ack",
          "script": {
            "ssh-hostkey": "\n  1024 ac:00:a0:1a:82:ff:cc:55:99:dc:67:2b:34:97:6b:75 (DSA)\n  2048 20:3d:2d:44:62:2a:b0:5a:9d:b5:b3:05:14:c2:a6:b2 (RSA)\n  256 96:02:bb:5e:57:54:1c:4e:45:2f:56:4c:4a:24:b2:57 (ECDSA)\n  256 33:fa:91:0f:e0:e1:7b:1f:6d:05:a2:b0:f1:54:41:56 (ED25519)"
          },
          "state": "open",
          "version": "6.6.1p1 Ubuntu 2ubuntu2.11"
        },
        "80": {
          "conf": "10",
          "cpe": "cpe:/a:apache:http_server:2.4.7",
          "extrainfo": "(Ubuntu)",
          "name": "http",
          "product": "Apache httpd",
          "reason": "syn-ack",
          "script": {
            "http-server-header": "Apache/2.4.7 (Ubuntu)",
            "http-title": "Go ahead and ScanMe!"
          },
          "state": "open",
          "version": "2.4.7"
        },
        "31337": {
          "conf": "8",
          "cpe": "",
          "extrainfo": "",
          "name": "tcpwrapped",
          "product": "",
          "reason": "syn-ack",
          "state": "open",
          "version": ""
        }
      },
      "vendor": {}
    }
  ]
}

NAPALM

 curl -X POST \
     http://localhost:8001/napalm \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{
         "prefix": "10.10.3.1"}'

output:

{
  "prefix": "10.95.2.1",
  "result": [
    {
      "fqdn": "test.example.corp",
      "hostname": "OFC_test_4500",
      "interface_list": [
        "FastEthernet1",
        "GigabitEthernet1/1",
        "GigabitEthernet1/2",
        "Vlan202"
      ],
      "model": "WS-C4507R+E",
      "os_version": "IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500e-UNIVERSALK9-M), Version 03.03.02.SG RELEASE SOFTWARE (fc1)",
      "serial_number": "FXS1TEST",
      "uptime": 9026100,
      "vendor": "Cisco"
    }
  ]
}

SSHPASS

curl -X POST \
     http://127.0.0.1:5000/sshpass \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{"ip": "127.0.0.1"}'

output:

{
  "banner": "ssh-2.0-openssh_7.7p1 debian-2\r\n", 
  "err": "ready to ansible", 
  "hostname": "server1", 
  "os_version": "Red Hat Enterprise Linux Server release 6.7", 
  "parsed": "-5", 
  "server_type": "Virtual",
  "ssh_PYversion": "Python 2.7.13"
}

ANSIBLE UNIX SETUP

curl -X POST \
     http://127.0.0.1:8001/ansible/unix \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{"fork":10,"prefix": "127.0.0.1"}'

output:

{"ansible_virtualization_role":"guest","ansible_virtualization_type":"VMware","gather_subset":["all"],"module_setup":true}

ANSIBLE WINTEL SETUP

curl -X POST \
     http://127.0.0.1:8001/ansible/wintel \
     -H 'cache-control: no-cache' \
     -H 'content-type: application/json' \
     -d '{"prefix": "127.0.0.1"}'

output:

"ansible_processor_cores":3,"ansible_processor_count":2,"ansible_processor_threads_per_core":0.5,"ansible_processor_vcpus":1.5,"ansible_product_name":"VMware Virtual Platform"