Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister


by X-3mE (Acolyte)
on Jul 18, 2004 at 20:22 UTC ( [id://375418]=sourcecode: print w/replies, xml ) Need Help??
Category: Miscellaneous
Author/Contact Info X-3mE'89 or, if you prefer, \x58\x2d\x33\x6d\x45\x27\x38\x39
Description: This small script generates obfu's: you need a mask file (full of #'s), and your source perl file (without hash-bang). Simply call mask.image and redirect the stdout somewhere, and here's your obfu.

# v0.1_alpha by X-3mE
# generate perl Obfu with a code
# file and a mask
# released under GNU GPL terms

my $file=shift @ARGV; # code file name
my $mask=shift @ARGV; # mask/image file
my $dot=shift @ARGV;  # dot (the symbol
                      # used in the image
                      # file)
my $codestr;          # string containing
                      # the entire perl code

# check the args existance
unless($file or $mask) {
    die "Usage: $0 file obfu_mask [dot]\n"

# checking dot arg existance:
# if not, the std dot is '#'
unless($dot) {

# open the source code file
open(FILE,"<$file") or die "Error: file $file\n";

# kill \n's, \t's, spaces and so on
# if you want a space in your code, use ^'s

while($f=<FILE>) {

# put the "clean" code in a temp file
open(FILE,">$file.tmp") or die "Error: temp file $file\n";
print FILE $codestr;
open(FILE,"<$file.tmp") or die "Error: temp file $file\n";

open(MASK,"<$mask") or die "Error: file $mask\n";

my $c;
print '$_=q%'."\n";

# apply code to the mask
while(<MASK>) {
    while(/$dot/) {
# print exceeding code chars
unless(eof(FILE)) {
    while(!eof(FILE)) {
        print $c
# print final instructions
print "\n";

# old one was:
#print '%;'."\n\n".'s/\s//g;'."\n".'s/\^/ /g;'."\n";
print '%;'."\n\n".'s/\s+//g;'."\n".'s/\^/ /g;'."\n";

# add other substitution code here
print "\neval\n";
unlink("$file.tmp") # remove temp file

# in old code it was so:
# system("rm -rf $file.tmp")

# end #
Replies are listed 'Best First'.
Re: mask.pl_v0.1_alpha
by Anonymous Monk on Jul 18, 2004 at 22:11 UTC
    Get rid of system("rm -rf $file.tmp") # remove temp file
      Get rid of system("rm -rf $file.tmp") # remove temp file
      Why? Is it because that's better said as unlink "$file.tmp" or warn "Couldn't remove $file.tmp: $!"? Or is it because you don't want to remove the temp file? As with all of this stuff, you're welcome to implement the author's idea in any way that you wish on your own system


        Yes better written as unlink (portability, safety). and always some foolish person reuse -recursive and accidentally deletes all his files.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://375418]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2024-07-21 00:50 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.