Cisco Type 7 Passwörter entschlüsseln

Relativ früh in meiner Laufbahn als Netzwerkadministrator habe ich erfahren, dass Passwörter auf Cisco-Routern manchmal reversibel gespeichert werden. Da es nicht immer praktikabel ist, auf einem entsprechenden Gerät einfach “no service password-encryption” einzugeben, gibt es diverse Skripte zur Umkehrung dieser Verschlüsselung. Damit ich nie wieder suchen muss lege ich ein Skript, von dem ich leider keine Ahnung habe wer der ursprüngliche Autor ist, hier ab:

#!/usr/bin/perl
use File::Copy;

############################################################################
# Vigenere translation table
############################################################################
@V=(0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f, 0x41, 0x2c, 0x2e,
    0x69, 0x79, 0x65, 0x77, 0x72, 0x6b, 0x6c, 0x64, 0x4a, 0x4b, 0x44,
    0x48, 0x53, 0x55, 0x42, 0x73, 0x67, 0x76, 0x63, 0x61, 0x36, 0x39,
    0x38, 0x33, 0x34, 0x6e, 0x63, 0x78, 0x76, 0x39, 0x38, 0x37, 0x33,
    0x32, 0x35, 0x34, 0x6b, 0x3b, 0x66, 0x67, 0x38, 0x37);
############################################################################

############################################################################
# Usage guidelines
############################################################################
if ($ARGV[0] eq ""){
   print "This script reveals the IOS passwords obfuscated using the Vigenere algorithm.n";
   print "n";
   print "Usage guidelines:n";
   print " cdecrypt.pl 04480E051A33490E     # Reveals a single passwordn";
   print " cdecrypt.pl running-config.rcf   # Changes all passwords in a file to cleartextn";
   print "                                  # Original file stored with .bak extensionn";
}

############################################################################
# Process arguments and execute
############################################################################
if(open(F,"<$ARGV[0]")){    # If argument passed can be opened then convert a file
  open(FO,">cdcout.rcf") || die("Cannot open 'cdcout.rcf' for writing ($!)n");
  while(<F>){
    if (/(.*passwords)(7s)([0-9a-fA-F]{4,})/){     # Find password commands
      my $d=Decrypt($3);                             # Deobfuscate passwords
      s/(.*passwords)(7s)([0-9a-fA-F]{4,})/$1$d/;  # Remove '7' and add cleartext password
    }
    print FO $_;
  }
  close(F);
  close(FO);
  copy($ARGV[0],"$ARGV[0].bak")||die("Cannot copy '$ARGV[0]' to '$ARGV[0].bak'");
  copy("cdcout.rcf",$ARGV[0])||die("Cannot copy '$ARGV[0]' to '$ARGV[0].bak'");
  unlink "cdcout.rcf";
}else{                      # If argument passed cannot be opened it is a single password
  print Decrypt($ARGV[0]) . "n";
}

############################################################################
# Vigenere decryption/deobfuscation function
############################################################################
sub Decrypt{
  my $pw=shift(@_);                             # Retrieve input obfuscated password
  my $i=substr($pw,0,2);                        # Initial index into Vigenere translation table
  my $c=2;                                      # Initial pointer
  my $r="";                                     # Variable to hold cleartext password
  while ($c<length($pw)){                       # Process each pair of hex values
    $r.=chr(hex(substr($pw,$c,2))^$V[$i++]);    # Vigenere reverse translation
    $c+=2;                                      # Move pointer to next hex pair
    $i%=53;                                     # Vigenere table wrap around
  }                                             #
  return $r;                                    # Return cleartext password
}

2 Responses to “Cisco Type 7 Passwörter entschlüsseln”

  1. Hallo,

    Ja, dass ist durch aus die Rettung. Funktioniert es auch auf Aironets (Aironet Access Points von Cisco) weil da versuche ich gerade an die W-Lan Passwörter oder zumindest ans WebLogin zu kommen weil ich kein bock habe es alles wieder neu zu konfigurieren.

  2. Arne P. Boettger sagt:

    Moin,
    Leider liegt mir keine Konfoguration eines Standalone Accesspoints vor. Wenn du auf die Konfiguration zugreifen kannst, poste sie doch einmal, dann kann ich dir sagen welche Passwörter reversibel gespeichert sind.

Leave a Reply