| 1 | #!/usr/bin/perl -w | ||
| 2 | |||
| 3 | use lib './lib'; | ||
| 4 | |||
| 5 | use XML::Malware; | ||
| 6 | use Data::Dumper; | ||
| 7 | use Digest::MD5 qw(md5_hex); | ||
| 8 | use Digest::SHA qw(sha1_hex sha256_hex sha512_hex); | ||
| 9 | |||
| 10 | my $h; | ||
| 11 | $h->{'company'} = 'wes co'; | ||
| 12 | $h->{'author'} = 'wes'; | ||
| 13 | $h->{'comment'} = 'test'; | ||
| 14 | $h->{'timestamp'} = '2009-02-23T17:34:56'; | ||
| 15 | $h->{'id'} = ''; | ||
| 16 | |||
| 17 | my $test_file = 'asdfasdfasdfasdfasdf'; | ||
| 18 | my $md5 = md5_hex($test_file); | ||
| 19 | my $sha1 = sha1_hex($test_file); | ||
| 20 | my $sha256 = sha256_hex($test_file); | ||
| 21 | my $sha512 = sha512_hex($test_file); | ||
| 22 | |||
| 23 | push(@{$h->{'objects'}->{'file'}}, { id => $md5, md5 => $md5, sha1 => $sha1, sha256 => $sha256, sha512 => $sha512 }); | ||
| 24 | push(@{$h->{'objects'}->{'classification'}}, { id => '', companyName => 'some company', type => 'dirty', classificationName => 'className'}); | ||
| 25 | |||
| 26 | my $m = XML::Malware->new($h); | ||
| 27 | |||
| 28 | warn $m->out(); | ||
| 29 | |||
| 30 | my $m2 = XML::Malware->new(); | ||
| 31 | $m2->in($m->out()); | ||
| 32 | |||
| 33 | warn Dumper($m2->_hash()); | ||
| 34 | my $x = $m2->_hash->{'objects'}->{'file'}[0]->{'id'}; |