| 1 | package Palm::Zetetic::Strip::PDB::AccountsV10; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Palm::PDB; | ||
| 5 | use Palm::Raw; | ||
| 6 | use Palm::Zetetic::Strip::CryptV10; | ||
| 7 | use Palm::Zetetic::Strip::Account; | ||
| 8 | use Palm::Zetetic::Strip::Util qw(hexdump null_split); | ||
| 9 | |||
| 10 | use vars qw(@ISA $VERSION); | ||
| 11 | |||
| 12 | require Exporter; | ||
| 13 | |||
| 14 | @ISA = qw(Exporter); | ||
| 15 | $VERSION = "1.02"; | ||
| 16 | |||
| 17 | sub new | ||
| 18 | { | ||
| 19 | my $class = shift; | ||
| 20 | my $self = {}; | ||
| 21 | |||
| 22 | bless $self, $class; | ||
| 23 | $self->{pdb} = undef; | ||
| 24 | return $self; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub load | ||
| 28 | { | ||
| 29 | my ($self, $file) = @_; | ||
| 30 | my $pdb; | ||
| 31 | |||
| 32 | $pdb = new Palm::PDB; | ||
| 33 | $pdb->Load($file); | ||
| 34 | $self->{pdb} = $pdb; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub get_accounts | ||
| 38 | { | ||
| 39 | my ($self, $password) = @_; | ||
| 40 | my $records; | ||
| 41 | my $record; | ||
| 42 | my $crypt; | ||
| 43 | my @accounts; | ||
| 44 | |||
| 45 | $crypt = new Palm::Zetetic::Strip::CryptV10($password); | ||
| 46 | |||
| 47 | $records = $self->{pdb}->{records}; | ||
| 48 | @accounts = (); | ||
| 49 | foreach $record (@$records) | ||
| 50 | { | ||
| 51 | my $encrypted_data; | ||
| 52 | my $decrypted_data; | ||
| 53 | my $account; | ||
| 54 | |||
| 55 | my $system_id; | ||
| 56 | my $account_id; | ||
| 57 | my $hash; | ||
| 58 | my $series; | ||
| 59 | my $hash_type; | ||
| 60 | my $system_type; | ||
| 61 | my $service_type; | ||
| 62 | my $username_type; | ||
| 63 | my $password_type; | ||
| 64 | my $account_mod_date; | ||
| 65 | my $password_mod_date; | ||
| 66 | my $binary_data_length; | ||
| 67 | my $strings; | ||
| 68 | my $system; | ||
| 69 | my $username; | ||
| 70 | my $comment; | ||
| 71 | my $key; | ||
| 72 | my $service; | ||
| 73 | my @binary_data; | ||
| 74 | |||
| 75 | ($system_id, $account_id, $hash, $encrypted_data) | ||
| 76 | = unpack("nna32a*", $record->{data}); | ||
| 77 | $decrypted_data = $crypt->decrypt($encrypted_data); | ||
| 78 | ($series, $hash_type, $system_type, $service_type, $username_type, | ||
| 79 | $password_type, $account_mod_date, $password_mod_date, | ||
| 80 | $binary_data_length, $strings) | ||
| 81 | = unpack("nnnnnnNNna*", $decrypted_data); | ||
| 82 | |||
| 83 | ($system, $service, $username, $password, $comment, $key, @binary_data) | ||
| 84 | = split("\0", $strings); | ||
| 85 | |||
| 86 | $account = | ||
| 87 | new Palm::Zetetic::Strip::Account("system" => $system, | ||
| 88 | "username" => $username, | ||
| 89 | "password" => $password, | ||
| 90 | "system_id" => $system_id, | ||
| 91 | "comment" => $comment); | ||
| 92 | push(@accounts, $account); | ||
| 93 | } | ||
| 94 | |||
| 95 | return \@accounts; | ||
| 96 | } | ||
| 97 | |||
| 98 | 1; |