| 1 | package PAR::Filter::Obfuscate; | ||
| 2 | use 5.006; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use base 'PAR::Filter'; | ||
| 6 | use File::Temp (); | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | PAR::Filter::Obfuscate - Obfuscating filter | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | PAR::Filter::Obfuscate->apply(\$code); # transforms $code | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | This filter uses L<B::Deobfuscate> (available separately from CPAN) to | ||
| 19 | turn the script into comment-free, architecture-independent Perl code | ||
| 20 | with mangled variable names. | ||
| 21 | |||
| 22 | =head1 CAVEATS | ||
| 23 | |||
| 24 | A harmless message will be displayed during C<pp>: | ||
| 25 | |||
| 26 | /tmp/8ycSoLaSI1 syntax OK | ||
| 27 | |||
| 28 | Please just ignore it. :-) | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub apply { | ||
| 33 | my $ref = $_[1]; | ||
| 34 | |||
| 35 | my ($fh, $in_file) = File::Temp::tempfile(); | ||
| 36 | print $fh $$ref; | ||
| 37 | close $fh; | ||
| 38 | |||
| 39 | require B::Deobfuscate; | ||
| 40 | $$ref = `$^X -MO=Deobfuscate $in_file`; | ||
| 41 | warn "Cannot transform $in_file$! ($?)\n" if $?; | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | =head1 SEE ALSO | ||
| 47 | |||
| 48 | L<PAR::Filter>, L<B::Deobfuscate>, L<PAR::Filter::Crypto> | ||
| 49 | |||
| 50 | =head1 AUTHORS | ||
| 51 | |||
| 52 | Audrey Tang E<lt>cpan@audreyt.orgE<gt> | ||
| 53 | |||
| 54 | You can write | ||
| 55 | to the mailing list at E<lt>par@perl.orgE<gt>, or send an empty mail to | ||
| 56 | E<lt>par-subscribe@perl.orgE<gt> to participate in the discussion. | ||
| 57 | Archives of the mailing list are available at | ||
| 58 | E<lt>https://www.mail-archive.com/par@perl.org/E<gt> or E<lt>https://groups.google.com/g/perl.parE<gt>. | ||
| 59 | |||
| 60 | Please submit bug reports to E<lt>https://github.com/rschupp/PAR-Packer/issuesE<gt>. | ||
| 61 | |||
| 62 | =head1 COPYRIGHT | ||
| 63 | |||
| 64 | Copyright 2003-2009 by Audrey Tang E<lt>cpan@audreyt.orgE<gt>. | ||
| 65 | |||
| 66 | This program is free software; you can redistribute it and/or modify it | ||
| 67 | under the same terms as Perl itself. | ||
| 68 | |||
| 69 | See F<LICENSE>. | ||
| 70 | |||
| 71 | =cut |