One method that springs to mind would be to add the obfu method names to the UNIVERSAL package and have them redirect to the actual methods.

This would allow you to obfuscate core/standard module calls without having to munge their source.

Another evil thing to do is to create constant subroutines to return the class names, and swap them around so the Foo subroutine returns the Bar package name. Can be most confusing.

For example:

#! /usr/bin/perl; use strict; use warnings; package Foo; sub new { bless {}, shift }; sub foo { my $self = shift; @_ ? $self->{foo} = shift : $self->{foo}; }; sub show { print "foo is ", shift->foo, "\n" }; package Bar; sub new { bless {}, shift }; sub bar { my $self = shift; @_ ? $self->{bar} = shift : $self->{bar}; }; sub show { print "bar is ", shift->bar, "\n" }; package main; use constant Bar => 'Foo'; use constant Foo => 'Bar'; { package UNIVERSAL; no warnings; *kwenve = sub { my $self = shift; $self->new(@_) }; *kwjehd = sub { my $self = shift; $self->foo(@_) }; *kjwehd = sub { my $self = shift; $self->bar(@_) }; *kfdlfe = sub { my $self = shift; $self->new(@_) }; *kedfgf = sub { my $self = shift; $self->show(@_) }; }; my ($kivbe, $kfovg) = (Bar->kwenve, Foo->kfdlfe); # my ($foo, $bar) = (Foo->new, Bar->new); $kivbe->kwjehd(12); # $foo->foo(12); $kfovg->kjwehd(42); # $bar->bar(42); $kivbe->kedfgf; # $foo->show; $kfovg->kedfgf; # $bar->show;

In reply to Re: Obfuscating method calls by adrianh
in thread Obfuscating method calls by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.