line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hidden from PAUSE |
2
|
|
|
|
|
|
|
JavaScript::Packer1; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
98
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.25'; |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:FAYLAND'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
10
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
164
|
|
11
|
2
|
|
|
2
|
|
11
|
use vars qw/@EXPORT_OK/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1630
|
|
12
|
|
|
|
|
|
|
@EXPORT_OK = qw/js_packer/; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my (@lines); |
15
|
|
|
|
|
|
|
my ($payload, $symtab, $radix, $count, $splitchar, $before, $after); |
16
|
|
|
|
|
|
|
my (@alfa_values, @symbols); |
17
|
|
|
|
|
|
|
my $ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
18
|
|
|
|
|
|
|
my ($decoded); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub check_packer($) { |
21
|
281
|
|
|
281
|
0
|
540
|
my ($line) = @_; |
22
|
281
|
|
|
|
|
481
|
$before = ''; |
23
|
281
|
|
|
|
|
431
|
$after = ''; |
24
|
281
|
|
|
|
|
405
|
$decoded = ''; |
25
|
281
|
100
|
|
|
|
713
|
if ($line =~ /eval\(function\(p,a,c,k,e,([d|r])\)\{/) { |
26
|
3
|
|
|
|
|
14
|
return 1; |
27
|
|
|
|
|
|
|
} else { |
28
|
278
|
|
|
|
|
926
|
return 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_table_elements($) { |
33
|
3
|
|
|
3
|
0
|
9
|
my ($line) = @_; |
34
|
3
|
|
|
|
|
7
|
$before = ''; |
35
|
3
|
|
|
|
|
10
|
$after = ''; |
36
|
|
|
|
|
|
|
# caret2.js miatt |
37
|
3
|
50
|
|
|
|
156
|
if ($line =~ /eval\(function\(p,a,c,k,e,[d|r]\)\{.*?\}?\}?return \w+\}\('(.*?[^\\])',(\d+|\[\]),(\d+),'(.*?)'\.split\('(.*?)'\).*?\)\)/) { |
38
|
3
|
|
|
|
|
23
|
$payload = $1; |
39
|
3
|
100
|
|
|
|
17
|
if ($2 eq '[]') { $radix = 62; } |
|
1
|
|
|
|
|
6
|
|
40
|
2
|
|
|
|
|
6
|
else { $radix = $2; } |
41
|
3
|
|
|
|
|
13
|
$count = $3; |
42
|
3
|
|
|
|
|
17
|
$symtab = $4; |
43
|
3
|
|
|
|
|
11
|
$splitchar = $5; |
44
|
3
|
|
|
|
|
14
|
$after = $'; |
45
|
3
|
|
|
|
|
11
|
$before = $`; |
46
|
3
|
50
|
|
|
|
14
|
if ($splitchar eq '\\u005e') { $splitchar = '^'; } |
|
0
|
|
|
|
|
0
|
|
47
|
3
|
|
|
|
|
16
|
return 1; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
return 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_index($) { |
54
|
48
|
|
|
48
|
0
|
106
|
my ($ix) = @_; |
55
|
48
|
|
|
|
|
133
|
my @values = split('', $ix); |
56
|
48
|
|
|
|
|
90
|
my $size = @values; |
57
|
48
|
|
|
|
|
160
|
my ($idx) = grep { $alfa_values[$_] eq $values[$size - 1] } 0 .. $#alfa_values; |
|
2976
|
|
|
|
|
6227
|
|
58
|
48
|
50
|
|
|
|
185
|
if ($size == 2) { $idx += $values[0] * $radix; } |
|
0
|
|
|
|
|
0
|
|
59
|
48
|
|
|
|
|
109
|
return $idx; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub do_decode() { |
63
|
3
|
|
|
3
|
0
|
16
|
my ($rest, $ix); |
64
|
3
|
|
|
|
|
0
|
my ($ix1, $ix2, $ix3, $ix4, $muv, $muv1); |
65
|
3
|
|
|
|
|
14
|
$decoded = ''; |
66
|
3
|
|
|
|
|
66
|
@alfa_values = split('', $ALPHABET); |
67
|
3
|
|
|
|
|
102
|
@symbols = split('\\' . $splitchar, $symtab); |
68
|
3
|
|
|
|
|
24
|
for (my $i = 0; $i < $#symbols; $i++) { |
69
|
35
|
50
|
|
|
|
100
|
if ($symbols[$i] eq '') { |
70
|
0
|
|
|
|
|
0
|
$symbols[$i] = $i; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
3
|
|
|
|
|
9
|
$rest = $payload; |
74
|
3
|
|
|
|
|
28
|
while ($rest =~ /(\W+)?(\w+)(\W+)?/) { |
75
|
48
|
|
|
|
|
140
|
$rest = $'; |
76
|
48
|
|
|
|
|
75
|
$ix1 = 0; |
77
|
48
|
50
|
|
|
|
107
|
if (defined($2)) { $ix1 = get_index($2); } |
|
48
|
|
|
|
|
116
|
|
78
|
48
|
100
|
66
|
|
|
227
|
if (defined($1) and defined($3)) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
79
|
2
|
|
|
|
|
18
|
$decoded .= "$1$symbols[$ix1]$3"; |
80
|
|
|
|
|
|
|
} elsif (defined($1)) { |
81
|
0
|
|
|
|
|
0
|
$decoded .= "$1$symbols[$ix1]"; |
82
|
|
|
|
|
|
|
} elsif (defined($3)) { |
83
|
46
|
|
|
|
|
298
|
$decoded .= "$symbols[$ix1]$3"; |
84
|
|
|
|
|
|
|
} elsif (defined($2)) { |
85
|
0
|
|
|
|
|
0
|
$decoded .= "$symbols[$ix1]"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
3
|
|
|
|
|
8
|
$decoded .= $rest; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub js_packer { |
92
|
281
|
|
|
281
|
0
|
562
|
my ($js_source_code) = @_; |
93
|
281
|
100
|
|
|
|
574
|
if (check_packer($js_source_code)) { |
94
|
3
|
50
|
|
|
|
10
|
if (get_table_elements($js_source_code)) { |
95
|
3
|
|
|
|
|
14
|
do_decode(); |
96
|
|
|
|
|
|
|
} |
97
|
3
|
|
|
|
|
11
|
my $retval = join('', $before, $decoded, $after); |
98
|
3
|
50
|
|
|
|
10
|
if ($retval eq '') { |
99
|
0
|
|
|
|
|
0
|
$retval = $js_source_code; |
100
|
|
|
|
|
|
|
} |
101
|
3
|
|
|
|
|
16
|
return $retval; |
102
|
|
|
|
|
|
|
} |
103
|
278
|
|
|
|
|
701
|
return $js_source_code; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |