| 1 | package Palm::Zetetic::Strip::PDB::AccountsV05i; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Palm::PDB; | ||
| 5 | use Palm::Raw; | ||
| 6 | use Palm::Zetetic::Strip::CryptV05i; | ||
| 7 | use Palm::Zetetic::Strip::Account; | ||
| 8 | |||
| 9 | use vars qw(@ISA $VERSION); | ||
| 10 | |||
| 11 | require Exporter; | ||
| 12 | |||
| 13 | @ISA = qw(Exporter); | ||
| 14 | $VERSION = "1.02"; | ||
| 15 | |||
| 16 | sub new | ||
| 17 | { | ||
| 18 | my $class = shift; | ||
| 19 | my $self = {}; | ||
| 20 | |||
| 21 | bless $self, $class; | ||
| 22 | $self->{pdb} = undef; | ||
| 23 | return $self; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub load | ||
| 27 | { | ||
| 28 | my ($self, $file) = @_; | ||
| 29 | my $pdb; | ||
| 30 | |||
| 31 | $pdb = new Palm::PDB; | ||
| 32 | $pdb->Load($file); | ||
| 33 | $self->{pdb} = $pdb; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub get_accounts | ||
| 37 | { | ||
| 38 | my ($self, $password) = @_; | ||
| 39 | my $records; | ||
| 40 | my $record; | ||
| 41 | my $crypt; | ||
| 42 | my @accounts; | ||
| 43 | |||
| 44 | $crypt = new Palm::Zetetic::Strip::CryptV05i($password); | ||
| 45 | |||
| 46 | $records = $self->{pdb}->{records}; | ||
| 47 | @accounts = (); | ||
| 48 | foreach $record (@$records) | ||
| 49 | { | ||
| 50 | my $data; | ||
| 51 | my $id; | ||
| 52 | my $system_id; | ||
| 53 | my $account_id; | ||
| 54 | my $username; | ||
| 55 | my $password; | ||
| 56 | my $system; | ||
| 57 | my $comment; | ||
| 58 | my $strings; | ||
| 59 | my $encrypted_data; | ||
| 60 | my $decrypted_data; | ||
| 61 | my $account; | ||
| 62 | |||
| 63 | $data = $record->{"data"}; | ||
| 64 | ($id, $encrypted_data) = unpack("na*", $data); | ||
| 65 | $decrypted_data = $crypt->decrypt($encrypted_data); | ||
| 66 | ($system_id, $account_id, $strings) | ||
| 67 | = unpack("nna*", $decrypted_data); | ||
| 68 | ($username, $password, $system, $comment) = split(/\000/, $strings); | ||
| 69 | $account = | ||
| 70 | new Palm::Zetetic::Strip::Account("system" => $system, | ||
| 71 | "username" => $username, | ||
| 72 | "password" => $password, | ||
| 73 | "system_id" => $system_id, | ||
| 74 | "comment" => $comment); | ||
| 75 | push(@accounts, $account); | ||
| 76 | } | ||
| 77 | |||
| 78 | return \@accounts; | ||
| 79 | } | ||
| 80 | |||
| 81 | 1; |