#!/usr/bin/perl use strict; use warnings; use XML::Simple; print "What do you want to do: \n"; print "1 - Display Stored Passwords\n"; print "2 - Export stored passwords\n"; print "3 - Exit\n"; chomp(my $OPTION = ); while ($OPTION !~m/^[123]$/) { print "Wrong option selected, Please choose 1, 2 or 3: "; chomp($OPTION = ); } if ( $OPTION == 3) { exit; }elsif ( $OPTION == 2 ) { print "Enter file name: "; chomp(my $File = ); if (-e $File ) { print "File already exists, replace it? [Y,N]"; chomp(my $Answer = ); while ($Answer!~m/^[YyNn]/) { print "Please answer Yes or NO: "; chomp($Answer = ); } if ($Answer=~m/^[Nn]/ ) { exit; } } my @Passwords = ShowPasswords(); open(F,">$File"); print F @Passwords; close(F); print "Your password were saved to $File\n"; }else{ print ShowPasswords(); } sub ShowPasswords { my $APP_DATA = $ENV{'APPDATA'}; if (!-e "$APP_DATA/FileZilla/recentservers.xml" ) { print "No stored passwords found!"; }else{ my @List; my @Servers; my $xml = XML::Simple->new; my $data = $xml->XMLin("$APP_DATA/FileZilla/recentservers.xml"); if (ref $data eq 'ARRAY' ) { @Servers = @{ $data->{'RecentServers'}->{'Server'} }; }else{ @Servers = $data->{'RecentServers'}->{'Server'}; } foreach my $Server (@Servers) { push @List, sprintf("%-30s%20s%20s\n",$Server->{'Host'},$Server->{'User'},$Server->{'Pass'}); } return @List; } }