# megamansec/ssh-snake architecture

> Architecture diagram of the GitHub repository megamansec/ssh-snake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/megamansec/ssh-snake
- Repository: https://github.com/megamansec/ssh-snake

## Overview

SSH-Snake is a Bash-based SSH network traversal and mapping tool. The principal workflow recursively discovers local SSH keys and destinations, attempts SSH connections, and continues discovery on reachable systems while avoiding rescanning; it emits traversal results for visualization and lookup utilities. The shell scripts were not sampled, so traversal links below rely on README statements. The Python utilities are sampled; their graph and lookup behavior is visible in their source.

Main entry points: [`Snake.sh`](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh) (SSH-Snake Runtime), [`tools/generate-graph.py`](https://github.com/megamansec/ssh-snake/blob/main/tools/generate-graph.py) (Graph Generator), [`tools/forward-lookup-host.py`](https://github.com/megamansec/ssh-snake/blob/main/tools/forward-lookup-host.py) (Forward Lookup), [`tools/reverse-lookup-host.py`](https://github.com/megamansec/ssh-snake/blob/main/tools/reverse-lookup-host.py) (Reverse Lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_traversal["SSH Traversal"]
  node_scanner["SSH-Snake Runtime<br/>[Snake.sh]"]
  node_privilege["Privilege Elevation<br/>[Snake.sh]"]
  node_remote["Remote Execution<br/>[Snake.sh]"]
  node_scan_guard["Rescan Guard<br/>[Snake.sh]"]
  node_scan_output["Traversal Output<br/>[Snake.sh]"]
end

subgraph group_discovery["Host Discovery"]
  node_key_discovery["Key Discovery<br/>[Snake.sh]"]
  node_history_keys["History Key Search<br/>[Snake.sh]"]
  node_destination_discovery["Destination Discovery<br/>[Snake.sh]"]
  node_custom_commands["Custom Commands<br/>[Snake.sh]"]
end

subgraph group_analysis["Output Analysis"]
  node_graph_generator["Graph Generator<br/>[generate-graph.py]"]
  node_forward_lookup["Forward Lookup"]
  node_reverse_lookup["Reverse Lookup"]
  node_shortest_path["Shortest Path"]
  node_graph_file["Network Graph"]
end

node_operator(("Operator"))

node_operator -->|"runs scan"| node_scanner
node_scanner -->|"tries elevation"| node_privilege
node_scanner -->|"discovers keys"| node_key_discovery
node_key_discovery -->|"searches history"| node_history_keys
node_scanner -->|"finds destinations"| node_destination_discovery
node_scanner -->|"runs configured"| node_custom_commands
node_scanner -->|"attempts SSH"| node_remote
node_remote -->|"checks rescan"| node_scan_guard
node_remote -->|"repeats discovery"| node_key_discovery
node_scanner -->|"emits results"| node_scan_output
node_scan_output -->|"reads output"| node_graph_generator
node_graph_generator -->|"writes graph"| node_graph_file
node_scan_output -->|"reads output"| node_forward_lookup
node_scan_output -->|"reads output"| node_reverse_lookup
node_scan_output -->|"reads output"| node_shortest_path

click node_scanner "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_privilege "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_remote "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_scan_guard "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_key_discovery "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_history_keys "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_destination_discovery "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_custom_commands "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_scan_output "https://github.com/megamansec/ssh-snake/blob/main/Snake.sh"
click node_graph_generator "https://github.com/megamansec/ssh-snake/blob/main/tools/generate-graph.py"
click node_forward_lookup "https://github.com/megamansec/ssh-snake/blob/main/tools/forward-lookup-host.py"
click node_reverse_lookup "https://github.com/megamansec/ssh-snake/blob/main/tools/reverse-lookup-host.py"
click node_shortest_path "https://github.com/megamansec/ssh-snake/blob/main/tools/shortest-path-create-chain.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_scanner,node_privilege,node_remote,node_scan_guard,node_scan_output toneBlue
class node_key_discovery,node_history_keys,node_destination_discovery,node_custom_commands toneAmber
class node_graph_generator,node_forward_lookup,node_reverse_lookup,node_shortest_path,node_graph_file toneMint
class node_operator toneIndigo
```

## Components

### SSH Traversal

- [SSH-Snake Runtime](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Privilege Elevation](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Remote Execution](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Rescan Guard](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Traversal Output](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`

### Host Discovery

- [Key Discovery](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [History Key Search](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Destination Discovery](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`
- [Custom Commands](https://github.com/megamansec/ssh-snake/blob/main/Snake.sh): `Snake.sh`

### Output Analysis

- [Graph Generator](https://github.com/megamansec/ssh-snake/blob/main/tools/generate-graph.py): `tools/generate-graph.py`
- [Forward Lookup](https://github.com/megamansec/ssh-snake/blob/main/tools/forward-lookup-host.py): `tools/forward-lookup-host.py`
- [Reverse Lookup](https://github.com/megamansec/ssh-snake/blob/main/tools/reverse-lookup-host.py): `tools/reverse-lookup-host.py`
- [Shortest Path](https://github.com/megamansec/ssh-snake/blob/main/tools/shortest-path-create-chain.py): `tools/shortest-path-create-chain.py`
- **Network Graph**

### Other components

- **Operator**

## Connections

- Operator → SSH-Snake Runtime: runs scan (evidence: `README.md`)
- SSH-Snake Runtime → Privilege Elevation: tries elevation (evidence: `README.md`)
- SSH-Snake Runtime → Key Discovery: discovers keys (evidence: `README.md`)
- Key Discovery → History Key Search: searches history (evidence: `README.md`)
- SSH-Snake Runtime → Destination Discovery: finds destinations (evidence: `README.md`)
- SSH-Snake Runtime → Custom Commands: runs configured (evidence: `README.md`)
- SSH-Snake Runtime → Remote Execution: attempts SSH (evidence: `README.md`)
- Remote Execution → Rescan Guard: checks rescan (evidence: `README.md`)
- Remote Execution → Key Discovery: repeats discovery (evidence: `README.md`)
- SSH-Snake Runtime → Traversal Output: emits results (evidence: `README.md`)
- Traversal Output → Graph Generator: reads output (evidence: `tools/generate-graph.py`)
- Graph Generator → Network Graph: writes graph (evidence: `tools/generate-graph.py`)
- Traversal Output → Forward Lookup: reads output (evidence: `tools/forward-lookup-host.py`)
- Traversal Output → Reverse Lookup: reads output (evidence: `tools/reverse-lookup-host.py`)
- Traversal Output → Shortest Path: reads output (evidence: `tools/shortest-path-create-chain.py`)
