Skip to content

Jayson-Fong/netapult

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏹 Netapult



Purpose

Netapult is a framework for querying and managing terminal-based devices without requiring software installation on targets, designed for network and security engineers to automate workflows involving the configuration or auditing of devices.

The framework is designed to execute human-readable commands for deployments where commands may rapidly change or where a machine-to-machine protocol is not available. Through offering a plugin approach to protocols and device-specific implementations, Netapult offers the ability for developers to easily integrate their own features without waiting for a vendor.

Use Cases

🤖 Network Automation and Orchestration

Automate repetitive tasks such as configuration management, asset inventorying, and compliance checking.

🛡️ Device Auditing and Hardening

Acquire device information at scale to enable environment-aware risk management.

📚 Training

Rapidly configure a lab environment for trainees or validate their configuration.

Netapult is ideal for situations where a dedicated machine-to-machine protocol is not available as it provides an interface to execute raw commands, automating the workflow a human would undergo.

For systems where a machine-to-machine protocol is available (such as NETCONF or the Simple Network Management Protocol) combined with a use case that does not require quick command modification, you may find the following alternatives more suitable:

Vendors may also offer products specific to their product suite.

When these protocols or services are not available, such as during initial configuration, Netapult may aid setup and automate tasks that would otherwise mandate human intervention.

Usage

As the framework does not provide any protocol or device-specific implementation, additional packages are required to efficiently use netapult. For example, to integrate an SSH capabilities, netapult-ssh is available and offered as an extra dependency.

Some protocol and client implementations are available as extras to this package, such as ssh, which provides netapult-ssh:

python3 -m pip install 'netapult[ssh]'

The following example leverages netapult-ssh to execute a command and retrieve its response:

import time
import getpass

import netapult

with netapult.dispatch(
    "generic",  # Use the generic client
    "ssh",  # Use the SSH protocol provided by netapult-ssh
    protocol_options={
        "host": input("Host: "),
        "username": input("Username: "),
        "password": getpass.getpass("Password: "),
    },
) as client:
    # Allow time for the terminal to initialize
    time.sleep(3)

    # Acquire the banner
    banner: str = client.read(text=True)
    prompt_found, result = client.run_command("echo Hello World", text=True)

    print("Banner:", banner)
    print("Result:", result)

Across protocols, command execution generally remains in a consistent format. However, protocols may require different options to establish a connection such as when authentication or a remote connection is required. Additionally, device-specific implementations may offer an enhanced API, such as for switching in and out of modes (ex. privileged and configuration mode).

You can find additional examples in examples.

Backlog

While not yet implemented, these are some expected features in the future:

  • Prompt stripping: Strip the prompt from command output
  • Echo verification: Verify that a command was sent successfully
  • Echo stripping: Strip echoed commands from the output.

About

Framework for terminal-based device management

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages