#!/usr/bin/perl # 'perl pwget -h' for help # To execute with './', type 'sudo chmod a+x pwget' # This program only shows saved passwords. If an account has no # saved passwords, then it won't show. # Created by Franc using Perl5. use strict 'vars'; use Term::ANSIColor; my $h = @ARGV[0] eq '-h'; shift @ARGV if $h; if($h) { print color 'bold blue'; print "Syntax: perl pwget username\n"; print "Example: perl pwget frank\n"; print color 'reset'; exit; } { print "\n"; print "------------------------------\n"; open (I,"/home/@ARGV/.purple/accounts.xml") or die &d; &f; print "Protocol ";&c; print "Account ";&c; print "Password\n\n"; my ($an, $ac, @a, $ap, $pc, @p, $apr, $prc, @pr, $pre); while() { s/(\s+)//g; if( ($an) = $_ =~ /^(.*)<\/name>$/) { $ac++; @a[ac] = $an; }elsif( ($pre, $apr) = $_ =~ /^<protocol>(.*)-(.*)<\/protocol>$/) { $prc++; @pr[prc] = $apr; }elsif( ($ap) = $_ =~ /^<password>(.*)<\/password>$/) { $pc++; @p[pc] = $ap; print "\U@pr\E ";&c; print "@a ";&c; print "@p\n"; } } print "------------------------------\n"; print "\n"; sub c { print color 'bold blue'; print "=> "; print color 'reset'; return; }
sub d { print print print print exit; }
color 'bold red'; "Unable to find 'accounts.xml' under username '@ARGV': $!\n"; color 'reset'; "------------------------------\n\n";
sub f { print color 'bold blue'; print "Found 'accounts.xml' under username '@ARGV'.\n\n"; print color 'reset'; } }