line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hidden from PAUSE |
2
|
|
|
|
|
|
|
JavaScript::Packer1; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
8
|
|
|
|
|
|
|
# our $AUTHORITY = 'cpan:FAYLAND'; # from eleonora45 |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
22
|
use base 'Exporter'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
162
|
|
11
|
2
|
|
|
2
|
|
10
|
use vars qw/@EXPORT_OK/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1285
|
|
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
|
280
|
|
|
280
|
0
|
365
|
my ($line) = @_; |
22
|
280
|
100
|
|
|
|
587
|
if ($line =~ /eval\(function\(p,a,c,k,e,([d|r])\)\{/) { |
23
|
2
|
|
|
|
|
5
|
return 1; |
24
|
|
|
|
|
|
|
} else { |
25
|
278
|
|
|
|
|
570
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_table_elements($) { |
30
|
2
|
|
|
2
|
0
|
4
|
my ($line) = @_; |
31
|
2
|
|
|
|
|
3
|
$before = ''; |
32
|
2
|
|
|
|
|
3
|
$after = ''; |
33
|
|
|
|
|
|
|
# caret2.js miatt |
34
|
2
|
50
|
|
|
|
93
|
if ($line =~ /eval\(function\(p,a,c,k,e,[d|r]\)\{.*?\}?\}?return \w+\}\('(.*?)(\}?\)?;?)?',(\d+),(\d+),'(.*?)'\.split\('(.*?)'\).*?\)\)/) { |
35
|
2
|
50
|
|
|
|
6
|
if (defined($2)) { |
36
|
2
|
|
|
|
|
5
|
$payload = $1 . $2; |
37
|
|
|
|
|
|
|
} else { |
38
|
0
|
|
|
|
|
0
|
$payload = $1; |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
5
|
$radix = $3; |
41
|
2
|
|
|
|
|
5
|
$count = $4; |
42
|
2
|
|
|
|
|
4
|
$symtab = $5; |
43
|
2
|
|
|
|
|
3
|
$splitchar = $6; |
44
|
2
|
|
|
|
|
5
|
$after = $'; |
45
|
2
|
|
|
|
|
3
|
$before = $`; |
46
|
2
|
50
|
|
|
|
6
|
if ($splitchar eq '\\u005e') { $splitchar = '^'; } |
|
0
|
|
|
|
|
0
|
|
47
|
2
|
|
|
|
|
4
|
return 1; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
return 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_index($) { |
54
|
33
|
|
|
33
|
0
|
50
|
my ($ix) = @_; |
55
|
33
|
|
|
|
|
52
|
my @values = split('', $ix); |
56
|
33
|
|
|
|
|
50
|
my $size = @values; |
57
|
33
|
|
|
|
|
66
|
my ($idx) = grep { $alfa_values[$_] eq $values[$size - 1] } 0 .. $#alfa_values; |
|
2046
|
|
|
|
|
2561
|
|
58
|
33
|
50
|
|
|
|
85
|
if ($size == 2) { $idx += $values[0] * $radix; } |
|
0
|
|
|
|
|
0
|
|
59
|
33
|
|
|
|
|
44
|
return $idx; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub do_decode() { |
63
|
2
|
|
|
2
|
0
|
6
|
my ($rest, $ix); |
64
|
2
|
|
|
|
|
0
|
my ($ix1, $ix2, $ix3, $ix4, $muv, $muv1); |
65
|
2
|
|
|
|
|
3
|
$decoded = ''; |
66
|
2
|
|
|
|
|
20
|
@alfa_values = split('', $ALPHABET); |
67
|
2
|
|
|
|
|
26
|
@symbols = split('\\' . $splitchar, $symtab); |
68
|
2
|
|
|
|
|
8
|
for (my $i = 0; $i < $#symbols; $i++) { |
69
|
24
|
50
|
|
|
|
44
|
if ($symbols[$i] eq '') { |
70
|
0
|
|
|
|
|
0
|
$symbols[$i] = $i; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
2
|
|
|
|
|
5
|
$rest = $payload; |
74
|
2
|
|
|
|
|
8
|
while ($rest =~ /(\W+)?(\w+)(\W+)?/) { |
75
|
33
|
|
|
|
|
60
|
$rest = $'; |
76
|
33
|
|
|
|
|
46
|
$ix1 = get_index($2); |
77
|
33
|
100
|
|
|
|
58
|
if (defined($1)) { |
78
|
1
|
|
|
|
|
7
|
$decoded .= "$1$symbols[$ix1]$3"; |
79
|
|
|
|
|
|
|
} else { |
80
|
32
|
|
|
|
|
110
|
$decoded .= "$symbols[$ix1]$3"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
2
|
|
|
|
|
5
|
$decoded .= $rest; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub js_packer { |
87
|
280
|
|
|
280
|
0
|
429
|
my ($js_source_code) = @_; |
88
|
280
|
100
|
|
|
|
425
|
if (check_packer($js_source_code)) { |
89
|
2
|
50
|
|
|
|
5
|
if (get_table_elements($js_source_code)) { |
90
|
2
|
|
|
|
|
4
|
do_decode(); |
91
|
|
|
|
|
|
|
} |
92
|
2
|
|
|
|
|
5
|
my $retval = join('', $before, $decoded, $after); |
93
|
2
|
50
|
|
|
|
6
|
if ($retval eq '') { |
94
|
0
|
|
|
|
|
0
|
$retval = $js_source_code; |
95
|
|
|
|
|
|
|
} |
96
|
2
|
|
|
|
|
7
|
return $retval; |
97
|
|
|
|
|
|
|
} else { |
98
|
278
|
|
|
|
|
617
|
return $js_source_code; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |