• Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    Go
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

simple concurrent ssh server posing as cisco ios

cisshgo

Simple, small, fast, concurrent SSH server to emulate network equipment (i.e. Cisco IOS) for testing purposes.

Usage

  1. Clone the repository and change into that directory (All dependencies are included in the /vendor folder, so no installation step is necessary.)
  2. Execute go run cissh.go as shown below:
$ go run cissh.go 
2020/08/22 00:17:34 starting ssh server on port :10049
2020/08/22 00:17:34 starting ssh server on port :10023
2020/08/22 00:17:34 starting ssh server on port :10024
... <snip>

Alternatively you can compile and run in separate steps (useful for docker images, etc):

$ go build cisshgo cissh.go
$ ./cisshgo
2020/09/02 15:46:31 starting cissh.go ssh server on port :10008
2020/09/02 15:46:31 starting cissh.go ssh server on port :10005
2020/09/02 15:46:31 starting cissh.go ssh server on port :10000
2020/09/02 15:46:31 starting cissh.go ssh server on port :10006
... <snip>
  1. SSH into one of the open ports with admin as the password. By default, you can run "show version" or "show ip interface brief" or "show running-config". Other commands can be added by modifying the transcript_map.yaml file and supplying transcripts as needed.

Example output:

test_device#show version
Cisco IOS XE Software, Version 16.04.01
Cisco IOS Software [Everest], CSR1000V Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.4.1, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2016 by Cisco Systems, Inc.
Compiled Sun 27-Nov-16 13:02 by mcpre
Cisco IOS-XE software, Copyright (c) 2005-2016 by cisco Systems, Inc.
All rights reserved.  Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0.  The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0.  For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.
ROM: IOS-XE ROMMON

Advanced Usage

There are several options available to control the behavior of cisshgo see the below output of -help:

  -listeners int
    	How many listeners do you wish to spawn? (default 50)
  -startingPort int
    	What port do you want to start at? (default 10000)
  -transcriptMap string
    	What file contains the map of commands to transcribed output? (default "transcripts/transcript_map.yaml")

For example, if you only wish to launch with a single SSH listener for a testing process, you could simply apply -listeners 1 to the run command:

go run cissh.go -listeners 1
2020/09/03 19:41:04 Starting cissh.go ssh server on port :10000

Expanding Platform Support

cisshgo is built with modularity in mind to support easy expansion or customization. Potential options for enhancement are outlined below.

Customized Output in Command Transcripts

If you wish to modify elements of the transcript dynamically, for example the hostname, you can instantiate templated sections into your transcript.

For example, in the packaged output of show_version.txt the hostname is listed as:

ROM: IOS-XE ROMMON
{{.Hostname}} uptime is 4 hours, 55 minutes
Uptime for this control processor is 4 hours, 56 minutes

Any value in the fakedevices.FakeDevice struct can be referenced in this way, today these are:

type FakeDevice struct {
	Vendor            string            // Vendor of this fake device
	Platform          string            // Platform of this fake device
	Hostname          string            // Hostname of the fake device
	Password          string            // Password of the fake device
	SupportedCommands SupportedCommands // What commands this fake device supports
	ContextSearch     map[string]string // The available CLI prompt/contexts on this fake device
	ContextHierarchy  map[string]string // The hierarchy of the available contexts
}

If you wish to template additional/different values, they will need to be added to the FakeDevice struct and then instantiated in the transcript with a reference to {{.MyNewAttribute}}.

Adding Additional Command Transcripts

If you wish to add additional command transcripts, you simply need to include a plain text file in the appropriate vendor/platform folder, and create an entry in the transcript_map.yaml file under the appropriate vendor/platform:

---
platforms:
  - csr1000v:
      command_transcripts:
        "my new fancy command": "transcripts/cisco/csr1000v/my_new_fancy_command.txt"

On the next execution of cisshgo it will read this map and respond to my new fancy command

Adding Additional "Cisco-style" Platforms

If you wish to add a completely new Cisco-style device, that is one with configure terminal leading to a (config)# mode for example, you can simply supply additional device types and transcripts in the transcript_map.yaml file.

This however does not work if a device follows a different interaction pattern than the Cisco standard, for example a Juniper or F5 device, for that see the following section.

Adding Additional Non-"Cisco-style" Platforms

NOTE This feature is not fully implemented yet!

If you wish to add a platform that is not the "Cisco-style" of interaction, for example a Juniper or F5 device, you will need to implement a new handler module for it under ssh_server/handlers and add it to the device mapping in code in cissh.go where it chooses the SSH listener and handler.

The "handler" controls the basics of how we will emulate the SSH session, and provides a list of if...else if...else if... options to roughly simulate the device experience. Because many network devices vary in their CLI and interactions, the conditional tree that each requires will vary. This is implemented via the "handler" functionality.

Disclaimer

Cisco IOS is the property/trademark of Cisco.

More Repositories

1

netpalm

ReST based network device broker
Python
433
star
2

netbox_floorplan

JavaScript
81
star
3

ios-show-run-ttp

TTP template for Cisco IOS "show run"
Python
29
star
4

netpalm-admin

simple admin app for managing a netpalm cluster
JavaScript
27
star
5

RRDReST

Converts RRD Files to a easy to consume ReST API
Python
26
star
6

cmdboss

API driven, integrated configuration management
Python
22
star
7

netpalm-commandatron

simple web ui with async command running for network devices
JavaScript
13
star
8

OIDMAN

simple, on demand SNMP observability
Python
12
star
9

netpalm-flask-hello-command-runner-world

simple hello world command running webapp talking to network device via netpalm
HTML
8
star
10

netpalm-flask-hello-cdp-world

simple hello world CDP visualisation webapp leveraging netpalm
HTML
8
star
11

nautobot-dark-css

dark theme CSS for nautobot
CSS
8
star
12

netpalm-flow

UI based network automation platform built on node-red
CSS
6
star
13

flask-AdminLTE

AdminLTE 3 but ported to flask
JavaScript
6
star
14

streamiko

HTML
5
star
15

netpalm-flask-hello-arp-world

simple hello world app to pull arp table off multiple devices and render into a nice datatable
HTML
4
star
16

netpalm-servicenow-chronicles

random gifs of servicenow integration
Python
3
star
17

netpalm-flask-hello-cdp3d-world

simple hello world 3D CDP real time visualisation webapp leveraging netpalm
HTML
3
star
18

netpalm-flask-hello-route-world

simple hello world app to pull route table off multiple devices and render into a nice searchable datatable
HTML
2
star
19

genieacs-container

Dockerfile
2
star
20

cisshgo-webscale

simple CFN template generator for large scale cisgo deployments
Python
2
star
21

netpalm-kafka-webhook

simple kafka webhook example for netpalm
Python
1
star
22

py-servicenow-keepalive

python code for keeping dev servicenow instance alive
Python
1
star