Deobfuscate.pm

filter: Statementstmt 18.4% 45 / 244 Branchbran 1.8% 2 / 108 Conditioncond 0.0% 0 / 31 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 44.8% 13 / 29 Podpod 7.1% 1 / 14 totaltotal 13.6% 61 / 446 CC 74 SCAR 53.7
CC
74
Cov
12%
__ANON__
697.4
load_unknown_dict
91.3
load_user_config
72.0
CRAP 214.6
↑ Summary Deobfuscate/Dict/Flowers.pm »
1 package B::Deobfuscate;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use B qw( main_cv main_root main_start );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use B::Deparse;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=14.7
9 1 @ISA = 'B::Deparse';
10 1 $VERSION = '0.20';
11  
12 1 for my $func (qw( begin_av init_av check_av end_av )) {
13  
14 ## no critic
15 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶ if ( defined &{"B::$func"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &{"B::$func";}) { } 4 0 4
17 4 B->import($func);
18 }
19 else {
20  
21 # If I couldn't create it, I'll just declare it to keep lint happy.
22 0 eval "sub $func;";
23 }
24 }
25  
26 # B::perlstring was added in 5.8.0
27 1 ▶ if ( defined &B::perlstring ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &B::perlstring) { } 1 0 1
28 1 B->import('perlstring');
29 }
30 else {
31 0 ▶ *perlstring = sub { '"' . quotemeta( shift @_ ) . '"' };
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 }
33  
34 }
35 1 ▶use B::Keywords qw( @Barewords @Symbols );
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use YAML qw( LoadFile Dump );
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 # use Data::Postponed 'postpone_forever';
42 0 ▶sub postpone_forever { return shift @_ }
Subroutine postpone_forever: not called CC=1 SCAR=6.9
Pod undocumented
43  
44 0 ▶sub load_keywords {
Subroutine load_keywords: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my $self = shift @_;
46 0 my $p = $self->{ +__PACKAGE__ };
47  
48 return $p->{keywords} = {
49 0 map { $_, undef } @Barewords,
50  
51 # Snip the sigils.
52 0 map { substr $_, 1 } @Symbols
53 };
54 }
55  
56 0 ▶sub load_unknown_dict {
Subroutine load_unknown_dict: not called CC=10 SCAR=45.1
Pod undocumented
57 0 my $self = shift @_;
58 0 my $p = $self->{ +__PACKAGE__ };
59  
60 0 my $dict_data;
61  
62 # slurp the entire dictionary at once
63 0 ▶ if ( defined( my $dict_file = $p->{unknown_dict_file} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dict_file = $p->{'unknown_dict_file'})) { } 0 0 0
64 0 ▶ open my $fh, '<', $dict_file
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $dict_file or confess("Cannot open dictionary ${dict_file}: $!") 0 0 0
65 or confess "Cannot open dictionary $dict_file: $!";
66 0 local $/; ## no critic
67 0 $dict_data = [<$fh>];
68 }
69 else {
70 LOAD_DICTIONARY_MODULE:
71 0 for my $module ( $p->{unknown_dict_module}, 'PGPHashKeywords',
72 'Flowers' )
73 {
74 0 ▶ next if not defined $module;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $module 0 0 0
75 0 eval "require B::Deobfuscate::Dict::$module"; ## no critic
76 0 ▶ next if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
77  
78 1 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
79 0 $dict_data = ${"B::Deobfuscate::Dict::$module"};
80 0 last LOAD_DICTIONARY_MODULE;
81 }
82 }
83  
84 0 ▶ unless ($dict_data) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dict_data) 0 0 0
85 0 confess "The symbol dictionary was empty!";
86 }
87  
88 0 my $k = $self->load_keywords;
89  
90 $p->{unknown_dict_data} = [
91 0 ▶ sort { length $a <=> length $b or $a cmp $b }
Condition0%0/3
length $a <=> length $b || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
length $a <=> length $b || $a cmp $b
length $a <=> length $b $a cmp $b
Truth table0%0/3
A || B
A= length $a <=> length $bB= $a cmp $b
ABresult
1X1
011
000
92 0 ▶ grep { not( /\W/ or exists $k->{$_} ) }
Condition0%0/3
/\W/ || exists $k->{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
/\W/ || exists $k->{$_}
/\W/ exists $k->{$_}
Truth table0%0/3
A || B
A= /\W/B= exists $k->{$_}
ABresult
1X1
011
000
93 split /\n/,
94 $dict_data
95 ];
96  
97 0 ▶ unless ( scalar @{ $p->{'unknown_dict_data'} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @{$p->{"unknown_dict_data"};}) 0 0 0
98 0 confess "The symbol dictionary is empty!";
99 }
100  
101 0 return;
102 }
103  
104 0 ▶sub next_short_dict_symbol {
Subroutine next_short_dict_symbol: not called CC=2 SCAR=17.9
Pod undocumented
105 0 my $self = shift @_;
106 0 my $p = $self->{ +__PACKAGE__ };
107  
108 0 my $sym = shift @{ $p->{unknown_dict_data} };
109 0 push @{ $p->{used_symbols} }, $sym;
110  
111 0 ▶ unless ($sym) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sym) 0 0 0
112 0 confess "The symbol dictionary has run out and is now empty";
113 }
114  
115 0 return $sym;
116 }
117  
118 0 ▶sub next_long_dict_symbol {
Subroutine next_long_dict_symbol: not called CC=2 SCAR=17.9
Pod undocumented
119 0 my $self = shift @_;
120 0 my $p = $self->{ +__PACKAGE__ };
121  
122 0 my $sym = pop @{ $p->{unknown_dict_data} };
123 0 push @{ $p->{used_symbols} }, $sym;
124  
125 0 ▶ unless ($sym) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sym) 0 0 0
126 0 confess "The symbol dictionary has run out and is now empty";
127 }
128  
129 0 return $sym;
130 }
131  
132 0 ▶sub load_user_config {
Subroutine load_user_config: not called CC=8 SCAR=42.8
Pod undocumented
133 0 my $self = shift @_;
134 0 my $p = $self->{ +__PACKAGE__ };
135 0 my $config_file = $p->{user_config};
136  
137 0 ▶ return unless $config_file;
Branch: 1 branch
BranchTrueFalseTotal
unless $config_file 0 0 0
138  
139 0 ▶ unless ( -f $config_file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $config_file) 0 0 0
140 0 confess "Configuration file $config_file doesn't exist";
141 }
142  
143 0 my $config = ( LoadFile($config_file) )[0];
144 0 $p->{globals_to_ignore} = $config->{globals_to_ignore};
145 0 $p->{pad_symbols} = $config->{lexicals};
146 0 $p->{gv_symbols} = $config->{globals};
147 0 ▶ if ( $config->{dictionary} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"dictionary"}) 0 0 0
148 0 $p->{unknown_dict_file} = $config->{dictionary};
149 }
150 0 ▶ if ( $config->{global_regex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"global_regex"}) 0 0 0
151 0 $p->{global_regex} = qr/$config->{global_regex}/;
152 }
153  
154 # Symbols that are listed with an undef value actually
155 # just aren't renamed at all.
156 0 for my $symt_nym (qw/pad gv/) {
157 0 my $symt = $p->{ $symt_nym . "_symbols" };
158 0 for my $symt_key ( keys %$symt ) {
159 0 ▶ if ( not defined $symt->{$symt_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $symt->{$symt_key}) 0 0 0
160 0 $symt->{$symt_key} = $symt_key;
161 }
162 }
163 }
164  
165 0 return;
166 }
167  
168 0 ▶sub gv_should_be_renamed {
Subroutine gv_should_be_renamed: not called CC=7 SCAR=40.3
Pod undocumented
169 0 my ( $self, $sigil, $name ) = @_;
170 0 my $p = $self->{ +__PACKAGE__ };
171 0 my $k = $p->{keywords};
172  
173 0 ▶ confess("Undefined sigil") unless defined $sigil;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sigil 0 0 0
174 0 ▶ confess("Undefined name") unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 0 0
175  
176 # Bug 24334: $1 gets passed in w/o a sigil. Dunno why. That's wrong and broke the previous version of
177 # the regexp which read m{^\$\d+\z}
178  
179 # Ignore keywords.
180 return
181 0 ▶ if exists $k->{$name}
Branch: 1 branch
BranchTrueFalseTotal
if exists $k->{$name} or "$sigil$name" =~ /^\$?\d+\z/ 0 0 0
Condition0%0/3
exists $k->{$name} or "$sigil$name" =~ /^\$?\d+\z/
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $k->{$name} or "$sigil$name" =~ /^\$?\d+\z/
exists $k->{$name} "$sigil$name" =~ /^\$?\d+\z/
Truth table0%0/3
A or B
A= exists $k->{$name}B= "$sigil$name" =~ /^\$?\d+\z/
ABresult
1X1
011
000
182 or "$sigil$name" =~ m{^\$?\d+\z};
183  
184 0 ▶ if ( exists $p->{gv_symbols}{$name}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $p->{"gv_symbols"}{$name} or $name =~ /$p->{"gv_match"}/) 0 0 0
Condition0%0/3
exists $p->{"gv_symbols"}{$name} or $name =~ /$p->{"gv_match"}/
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $p->{"gv_symbols"}{$name} or $name =~ /$p->{"gv_match"}/
exists $p->{"gv_symbols"}{$name} $name =~ /$p->{"gv_match"}/
Truth table0%0/3
A or B
A= exists $p->{"gv_symbols"}{$name}B= $name =~ /$p->{"gv_match"}/
ABresult
1X1
011
000
185 or $name =~ $p->{gv_match} )
186 {
187 0 return 1;
188 }
189 0 return;
190 }
191  
192 0 ▶sub rename_pad {
Subroutine rename_pad: not called CC=4 SCAR=30.0
Pod undocumented
193 0 my ( $self, $name ) = @_;
194 0 my $p = $self->{ +__PACKAGE__ };
195  
196 0 ▶ my ($sigil) = $name =~ m{^(\W+)}
Branch: 1 branch
BranchTrueFalseTotal
my($sigil) = $name =~ /^(\W+)/ or confess("Invalid pad variable name $name") 0 0 0
197 or confess "Invalid pad variable name $name";
198  
199 0 my $dict = $p->{pad_symbols};
200 0 ▶ return $dict->{$name} if $dict->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $dict->{$name} 0 0 0
201  
202 # $dict->{$name} = $name;
203 0 $dict->{$name} = postpone_forever $sigil . $self->next_short_dict_symbol;
204  
205 0 ▶ unless ( $dict->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dict->{$name}) 0 0 0
206 0 confess "The suggested name for the lexical variable $name is empty";
207 }
208 0 return $dict->{$name};
209 }
210  
211 0 ▶sub lookup_sigil {
Subroutine lookup_sigil: not called CC=6 SCAR=37.4
Pod undocumented
212 0 my $rv = shift @_;
213  
214 0 ▶ return $rv =~ /(?:gv|pad|rv2)sv\z/ ? '$'
Branch: 5 branches
BranchTrueFalseTotal
$rv =~ /(?:gv|pad|rv2)sv\z/ ? : 0 0 0
$rv =~ /(?:gvav|padav|av2arylen|rv2av|aelemfast|aelem|aslice)\z/ ? : 0 0 0
$rv =~ /(?:padhv|rv2hv|helem|hslice)\z/ ? : 0 0 0
$rv =~ /rv2cv\z/ ? : 0 0 0
$rv =~ /(?:gv|gelem|rv2gv)\z/ ? : 0 0 0
215 : $rv =~ /(?:gvav|padav|av2arylen|rv2av|aelemfast|aelem|aslice)\z/
216 ? '@'
217 : $rv =~ /(?:padhv|rv2hv|helem|hslice)\z/ ? '%'
218 : $rv =~ /rv2cv\z/ ? '&'
219 : $rv =~ /(?:gv|gelem|rv2gv)\z/ ? ''
220 :
221  
222 # Nothing valid;
223 ();
224 }
225  
226 0 ▶sub rename_gv {
Subroutine rename_gv: not called CC=7 SCAR=40.3
Pod undocumented
227 0 my ( $self, $name ) = @_;
228 0 my $p = $self->{ +__PACKAGE__ };
229  
230 0 my $sigil_debug = '';
231 0 my $sigil;
232 FIND_SIGIL: {
233 0 ▶ for ( my $cx = 0; not defined $sigil; ++$cx ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sigil) 0 0 0
234 0 my ( undef, undef, undef, $rv ) = caller $cx;
235 0 ▶ if ( not $rv ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rv) 0 0 0
236 0 confess
237 "No sigil could be found. Please report the following text:\n$sigil_debug\n";
238 }
239  
240 0 $sigil = lookup_sigil($rv);
241  
242 0 $sigil_debug .= "$cx = $rv\n";
243 }
244 }
245  
246 0 ▶ unless ( defined $sigil ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sigil) 0 0 0
247 0 confess
248 "No sigil could be found. Please report the following text:\n$sigil_debug\n";
249 }
250  
251 0 ▶ return $name unless $self->gv_should_be_renamed( $sigil, $name );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->gv_should_be_renamed($sigil, $name) 0 0 0
252  
253 0 my $dict = $p->{gv_symbols};
254  
255 0 my $sname = "$sigil$name";
256 0 ▶ return $dict->{$sname} if exists $dict->{$sname};
Branch: 1 branch
BranchTrueFalseTotal
if exists $dict->{$sname} 0 0 0
257 0 $dict->{$sname} = postpone_forever $self->next_long_dict_symbol;
258  
259 0 ▶ unless ( $dict->{$sname} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dict->{$sname}) 0 0 0
260 0 confess "$sname could not be renamed.";
261 }
262  
263 0 return $dict->{$sname};
264 }
265  
266 ## OVERRIDE METHODS FROM B::Deparse
267  
268 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
269 0 my $class = shift @_;
270 0 my $self = $class->SUPER::new(@_);
271 0 my $p = $self->{ +__PACKAGE__ } = {};
272 0 $p->{unknown_dict_file} = undef;
273 0 $p->{unknown_dict_module} = undef;
274 0 $p->{unknown_dict_data} = undef;
275 0 $p->{user_config} = undef;
276 0 $p->{gv_match} = qw/^[[:lower:][:digit:]_]+\z/;
277 0 $p->{pad_symbols} = {};
278 0 $p->{gv_symbols} = {};
279 0 $p->{output_yaml} = 0;
280 0 $p->{output_fh} = \*STDOUT;
281  
282 0 ▶ while ( my $arg = shift @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $arg = shift @_) 0 0 0
283 ## no critic
284 0 ▶ if ( $arg =~ m{^-d([^,]+)} ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($arg =~ /^-d([^,]+)/) { } 0 0 0
elsif ($arg =~ /^-D([^,]+)/) { } 0 0 0
elsif ($arg =~ /^-c([^,]+)/) { } 0 0 0
elsif ($arg =~ m[^-m/([^/]+)/]) { } 0 0 0
elsif ($arg =~ /^-y/) { } 0 0 0
285 0 $p->{unknown_dict_file} = $1;
286 }
287 elsif ( $arg =~ m{^-D([^,]+)} ) {
288 0 $p->{unknown_dict_module} = $1;
289 }
290 elsif ( $arg =~ m{^-c([^,]+)} ) {
291 0 $p->{user_config} = $1;
292 }
293 elsif ( $arg =~ m{^-m/([^/]+)/} ) {
294 0 $p->{gv_match} = $1;
295 }
296 elsif ( $arg =~ m{^-y} ) {
297 0 $p->{output_yaml} = 1;
298 }
299 }
300  
301 0 $self->load_user_config;
302 0 $self->load_unknown_dict;
303  
304 0 return $self;
305 }
306  
307 0 ▶sub compile { ## no critic Complex
Subroutine compile: not called CC=1 SCAR=6.5
Pod undocumented
308 0 my (@args) = @_;
309  
310 0 ▶ return sub {
Subroutine __ANON__: not called CC=27 SCAR=65.5
311 0 my $source = '';
312 0 my $self = __PACKAGE__->new(@args);
313  
314 # First deparse command-line args
315 0 ▶ if ( defined $^I ) { # deparse -i
Branch: 1 branch
BranchTrueFalseTotal
if (defined $^I) 0 0 0
316 0 $source .= q(BEGIN { $^I = ) . perlstring($^I) . qq(; }\n);
317 }
318 0 ▶ if ($^W) { # deparse -w
Branch: 1 branch
BranchTrueFalseTotal
if ($^W) 0 0 0
319 0 $source .= qq(BEGIN { \$^W = $^W; }\n);
320 }
321 ## no critic PackageVar
322 0 ▶ if ( $/ ne "\n" or defined $O::savebackslash ) { # deparse -l -0
Branch: 1 branch
BranchTrueFalseTotal
if ($/ ne "\n" or defined $O::savebackslash) 0 0 0
Condition0%0/3
$/ ne "\n" or defined $O::savebackslash
l!l&&r!l&&!r
000
MC/DC0%0/2
$/ ne "\n" or defined $O::savebackslash
$/ ne "\n" defined $O::savebackslash
Truth table0%0/3
A or B
A= $/ ne "\n"B= defined $O::savebackslash
ABresult
1X1
011
000
323 0 ▶ my $fs = perlstring($/) || 'undef';
Condition0%0/2
perlstring($/) || 'undef'
l!l
00
MC/DC0%0/1
perlstring($/) || 'undef'
perlstring($/)
Truth table0%0/2
A
A= perlstring($/)
Aresult
11
00
324 0 ▶ my $bs = perlstring($O::savebackslash) || 'undef';
Condition0%0/2
perlstring($O::savebackslash) || 'undef'
l!l
00
MC/DC0%0/1
perlstring($O::savebackslash) || 'undef'
perlstring($O::savebackslash)
Truth table0%0/2
A
A= perlstring($O::savebackslash)
Aresult
11
00
325 0 $source .= qq(BEGIN { \$/ = $fs; \$\\ = $bs; }\n);
326 }
327  
328 # I need to do things differently depending on the perl
329 # version.
330 0 ▶ if ( $] >= 5.008 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.008) { } 0 0 0
331 0 ▶ if ( defined &begin_av
Branch: 1 branch
BranchTrueFalseTotal
if (defined &B::Deobfuscate::begin_av and begin_av()->isa("B::AV")) 0 0 0
Condition0%0/3
defined &B::Deobfuscate::begin_av and begin_av()->isa("B::AV")
!ll&&!rl&&r
000
MC/DC0%0/2
defined &B::Deobfuscate::begin_av and begin_av()->isa("B::AV")
defined &B::Deobfuscate::begin_av begin_av()->isa("B::AV")
Truth table0%0/3
A and B
A= defined &B::Deobfuscate::begin_avB= begin_av()->isa("B::AV")
ABresult
0X0
100
111
332 and begin_av->isa('B::AV') )
333 {
334 0 $self->todo( $_, 0 ) for begin_av->ARRAY;
335 }
336 0 ▶ if ( defined &check_av
Branch: 1 branch
BranchTrueFalseTotal
if (defined &B::Deobfuscate::check_av and check_av()->isa("B::AV")) 0 0 0
Condition0%0/3
defined &B::Deobfuscate::check_av and check_av()->isa("B::AV")
!ll&&!rl&&r
000
MC/DC0%0/2
defined &B::Deobfuscate::check_av and check_av()->isa("B::AV")
defined &B::Deobfuscate::check_av check_av()->isa("B::AV")
Truth table0%0/3
A and B
A= defined &B::Deobfuscate::check_avB= check_av()->isa("B::AV")
ABresult
0X0
100
111
337 and check_av->isa('B::AV') )
338 {
339 0 $self->todo( $_, 0 ) for check_av->ARRAY;
340 }
341 0 ▶ if ( defined &init_av
Branch: 1 branch
BranchTrueFalseTotal
if (defined &B::Deobfuscate::init_av and init_av()->isa("B::AV")) 0 0 0
Condition0%0/3
defined &B::Deobfuscate::init_av and init_av()->isa("B::AV")
!ll&&!rl&&r
000
MC/DC0%0/2
defined &B::Deobfuscate::init_av and init_av()->isa("B::AV")
defined &B::Deobfuscate::init_av init_av()->isa("B::AV")
Truth table0%0/3
A and B
A= defined &B::Deobfuscate::init_avB= init_av()->isa("B::AV")
ABresult
0X0
100
111
342 and init_av->isa('B::AV') )
343 {
344 0 $self->todo( $_, 0 ) for init_av->ARRAY;
345 }
346 0 ▶ if ( defined &end_av
Branch: 1 branch
BranchTrueFalseTotal
if (defined &B::Deobfuscate::end_av and end_av()->isa("B::AV")) 0 0 0
Condition0%0/3
defined &B::Deobfuscate::end_av and end_av()->isa("B::AV")
!ll&&!rl&&r
000
MC/DC0%0/2
defined &B::Deobfuscate::end_av and end_av()->isa("B::AV")
defined &B::Deobfuscate::end_av end_av()->isa("B::AV")
Truth table0%0/3
A and B
A= defined &B::Deobfuscate::end_avB= end_av()->isa("B::AV")
ABresult
0X0
100
111
347 and end_av->isa('B::AV') )
348 {
349 0 $self->todo( $_, 0 ) for end_av->ARRAY;
350 }
351  
352 0 $self->stash_subs;
353 0 $self->{curcv} = main_cv;
354 0 $self->{curcvlex} = undef;
355 }
356 else {
357  
358 # 5.6.x
359 0 $self->stash_subs('main');
360 0 $self->{curcv} = main_cv;
361 0 $self->walk_sub( main_cv, main_start );
362 }
363  
364 0 $source .= join "\n", $self->print_protos;
365 0 @{ $self->{subs_todo} }
366 0 = sort { $a->[0] <=> $b->[0] } @{ $self->{subs_todo} };
367 0 ▶ $source .= join "\n", $self->indent( $self->deparse( main_root, 0 ) ),
Branch: 1 branch
BranchTrueFalseTotal
unless B::Deparse::null(main_root()) 0 0 0
368 "\n"
369 unless B::Deparse::null main_root;
370 0 my @text;
371 0 ▶ while ( scalar @{ $self->{subs_todo} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"subs_todo"};}) 0 0 0
372 0 push @text, $self->next_todo;
373 }
374 0 ▶ $source .= join "\n", $self->indent( join "", @text ), "\n"
Branch: 1 branch
BranchTrueFalseTotal
if @text 0 0 0
375 if @text;
376  
377 # Print __DATA__ section, if necessary
378 my $laststash
379 = defined $self->{curcop}
380 ? $self->{curcop}->stash->NAME
381 0 ▶ : $self->{curstash};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'curcop'} ? : 0 0 0
382 {
383 ## no critic
384 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
385 ## use critic
386 0 ▶ if ( defined *{ $laststash . "::DATA" } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *{$laststash . '::DATA';}) 0 0 0
387 0 ▶ if ( eof *{ $laststash . "::DATA" } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eof do { $laststash . '::DATA' }) 0 0 0
388  
389 # I think this only happens when using B::Deobfuscate
390 # on itself.
391 {
392 0 local $/ = "__DATA__\n";
393 0 seek *{ $laststash . "::DATA" }, 0, 0;
394 0 readline *{ $laststash . "::DATA" };
395 }
396 }
397  
398 0 $source .= "__DATA__\n";
399 0 $source .= join '', readline *{ $laststash . "::DATA" };
400 }
401 }
402  
403 0 my $p = $self->{ +__PACKAGE__ };
404 my %dump = (
405 lexicals => $p->{pad_symbols},
406 globals => $p->{gv_symbols},
407 dictionary => $p->{unknown_dict_file},
408 global_regex => $p->{gv_match}
409 0 );
410  
411 0 ▶ if ( $p->{output_yaml} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'output_yaml'}) { } 0 0 0
412 0 $p->{output_fh}->print( Dump( \%dump, $source ) );
413 }
414 else {
415 0 $p->{output_fh}->print($source);
416 }
417  
418 0 return;
419 0 };
420 }
421  
422 0 ▶sub padname {
Subroutine padname: not called CC=1 SCAR=6.9
Pod undocumented
423 0 my $self = shift @_;
424 0 my $padname = $self->SUPER::padname(@_);
425  
426 0 return $self->rename_pad($padname);
427 }
428  
429 0 ▶sub gv_name {
Subroutine gv_name: not called CC=1 SCAR=6.9
Pod undocumented
430 0 my $self = shift @_;
431 0 my $gv_name = $self->SUPER::gv_name(@_);
432  
433 0 return $self->rename_gv($gv_name);
434 }
435  
436 # BEGIN {
437 # ## no critic
438 # no strict 'refs';
439 # for my $sub ( grep defined &$_, keys %B::Deobfuscate:: ) {
440 # my $orig = \&$sub;
441 # *$sub = sub {
442 # print "$sub\n";
443 # &$orig;
444 # };
445 # }
446 # }
447  
448 1 1;
449  
450 ## Local Variables:
451 ## perl-lint-bin: "/home/josh/bin/perl/5.9.4/bin/perl5.9.4"
452 ## eval: (setenv "/home/josh/src/B-Deobfuscate/lib" "PERL5LIB")
453 ## End:
↑ Summary Deobfuscate/Dict/Flowers.pm »