From b07913f9308dc46d974d6d029e5d75ba43bedf8c Mon Sep 17 00:00:00 2001 From: magnum Date: Sun, 17 Mar 2013 19:31:00 +0100 Subject: [PATCH] Change cisco2john.pl so it supports file[s] (or stdin) as input and preserves any login/additional fields. --- run/cisco2john.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/run/cisco2john.pl b/run/cisco2john.pl index 2b3f58e..1db4a43 100755 --- a/run/cisco2john.pl +++ b/run/cisco2john.pl @@ -25,7 +25,7 @@ use strict; -die "Usage: $0 \n" if ($#ARGV lt 0); +die "Usage: $0 \n" if ($ARGV[0] =~ /-h/); my %Alphabets = ( VOMS => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[]", RFC3548 => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", @@ -78,11 +78,15 @@ sub Decode { return $data; } -my $hash; - -foreach $hash (@ARGV) { - +foreach my $line (<>) { + chomp $line; + my @fields = split(/:/, $line); + if (defined($fields[1])) { + print shift(@fields), ":"; + } + my $hash = shift(@fields); my $binhash = Decode($hash, 'CISCO'); - print join("", map { sprintf("%02x", ord($_)) } split(//, join("", $binhash))) . "\n"; + print join("", map { sprintf("%02x", ord($_)) } split(//, join("", $binhash))); + print $#fields >= 0 ? ":" : "", join(':', @fields), "\n"; } -- 1.8.1.4