File/Ole.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« File/Json.pm ↑ Summary File/Pcap.pm »
1 #
2 # $Id$
3 #
4 # file::ole Brik
5 #
6 package Metabrik::File::Ole;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Shell::Command Metabrik::System::Package);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable read vbs) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 attributes => {
19 input => [ qw(file) ],
20 output => [ qw(file) ],
21 olevba => [ qw(olevba.py) ],
22 },
23 attributes_default => {
24 olevba => '/usr/local/lib/python2.7/dist-packages/oletools/olevba.py',
25 },
26 commands => {
27 install => [ ], # Inherited
28 extract_vbs => [ qw(input|OPTIONAL output|OPTIONAL) ],
29 },
30 require_modules => {
31 'Metabrik::File::Text' => [ ],
32 'Metabrik::System::Os' => [ ],
33 'Metabrik::System::Package' => [ ],
34 },
35 require_binaries => {
36 'python' => [ ],
37 },
38 need_packages => {
39 ubuntu => [ qw(python python-pip) ],
40 debian => [ qw(python python-pip) ],
41 kali => [ qw(python python-pip) ],
42 },
43 };
44 }
45  
46 sub install {
47 my $self = shift;
48  
49 # Install system dependant packages
50 $self->SUPER::install or return;
51  
52 # Then Python dependant packages
53 $self->sudo_system('pip install oletools --upgrade');
54  
55 return 1;
56 }
57  
58 sub extract_vbs {
59 my $self = shift;
60 my ($input, $output) = @_;
61  
62 $input ||= $self->input;
63 $output ||= $self->output;
64 my $olevba = $self->olevba;
65 $self->brik_help_run_undef_arg('extract_vbs', $input) or return;
66 $self->brik_help_run_undef_arg('extract_vbs', $output) or return;
67 $self->brik_help_run_file_not_found('extract_vbs', $olevba) or return;
68  
69 my $out = $self->capture("python $olevba $input");
70  
71 my $ft = Metabrik::File::Text->new_from_brik_init($self) or return;
72 $ft->write($out, $output) or return;
73  
74 return 1;
75 }
76  
77 1;
78  
79 __END__
« File/Json.pm ↑ Summary File/Pcap.pm »