Vous êtes sur la page 1sur 2

#!

/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(<I>) {
s/(\s+)//g;
if( ($an) = $_ =~ /^<name>(.*)<\/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 color 'bold red';
print "Unable to find 'accounts.xml' under username '@ARGV': $!\n";
print color 'reset';
print "------------------------------\n\n";
exit;
}

sub f {

print color 'bold blue';


print "Found 'accounts.xml' under username '@ARGV'.\n\n";
print color 'reset';

}
}

Vous aimerez peut-être aussi