Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Length obfuscation

by emilbarton (Scribe)
on Aug 29, 2011 at 17:01 UTC ( [id://923065]=note: print w/replies, xml ) Need Help??


in reply to Length obfuscation

Hi, I found your obfuscation nice and I was asking myself why it should be so simple and easy to understand. So I treated it permutationally and I propose the following de-obfuscation. It does not look much clearer unfortunately.

There's a little problem in this code too: the seed for translation (right shift $tran=6012345) is not in itself obtained permutationally.

P.S. the script should print:

another--<-> ranothe--r<->anothe hranote--h<->ranot ohrante--o<->hran aohrnte--a<->ohr haornte--h<->ao ahornte--a<->h ahornte
#!/usr/bin/perl $_=q qanotherq, my $l=length; while($l){s/(.{$l})(.)/$2$1/;--$l; print+$_."--".$2."<->".$1."\n"}; ## De-obfuscation: print &deobf("another")."\n"; sub deobf { my $n = 0; my (@tran,$res); my %h = map { $n++ => $_ } (split //,shift); while ($n > 0) { $n--; $res = $n.$res ; } $tran = $res; $tran =~ s/(.+)(.{1})/$2$1/; ## The shift seed. ## print "tran: $tran\n"; for ($n = 0; $n < length($res)-1; $n++) { $res = &comp(&perm($tran,$res),$n) } return join('',map{ $h{$_} } (split //,$res)); } ## END deobf() sub perm { my ($target,$agent) = @_; ## Max. base (string length) = 10. my @targ = split //,$target;## Digital permutations only.. my @perm = split //,$agent; ## e.g. 021, 3102, etc.. my $res; ## but not 031, 123, ... nor 0123456789A,.. for (my $i = 0; $i < (@perm); $i++){ $res .= $perm[$targ[$i]] } return $res; } ## END perm() sub comp { my ($res, $pos) = @_; if ($pos > 0){ my @perm = split //,$res; my $l = scalar(@perm); my $p1a = $perm[0]; my $p1b = $perm[$l-$pos]; $perm[0] = $p1b; $perm[$l-$pos] = $p1a; for (my $n = 0; $n < $pos; $n++){ my $p2a = $perm[$l-1]; my $p2b = $perm[$l-$n-1]; $perm[$l-1] = $p2b; $perm[$l-$n-1] = $p2a; } $res = join '', @perm; } return $res; } ## END comp() 1;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found