Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Obfuscated code

( #1597=superdoc: print w/replies, xml ) Need Help??

Got some code which would take a Perl grand master to understand without running it? Post it in this section so we can stare at it in awe.

Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

New Less than Readable Code
Cumulative Guessing JAPH
3 direct replies — Read more / Contribute
by kschwab
on Jan 06, 2021 at 19:31

    May take a while on an old PC.

    Also see Progressive JAPH by Athanasius.

    $|++,$a=$b='Ktru!`onuids!Qdsm!i`bjds-',$==length$b,$b^="\01"x$=, @_=map{chr}(32..126);while($=>(($a^$b)=~tr/\x0//)){for(sort{rand >.5}1..$=){substr($a,$_-$|,1)ne(substr($b,$_-1,1))and substr($a, $_-$|,1)=@_[rand@_],print"\r",$a;select($,,$,,$,,.001)}};print$/
Self-referential QR code / JAPH
No replies — Read more | Post response
by davido
on May 31, 2020 at 23:40

    A proper JAPH this is not. And there's not really any obfu here but I thought this was a fun abuse of QR codes and Perl:

    use Term::QRCode;for(DATA){shift&&do{seek$_,0,undef$/};print Term::QRC +ode->new->plot(<$_>)} __DATA__ Just another Perl hacker,

    You'll need to install Term::QRCode, which will fail unless you have libqrencode-dev installed (Debian, Ubuntu).

    Usage:

    $ perl qrjaph self # Generate a QR that contains this script as its en +coded text. $ perl qrjaph # Generate a QR that contains just the text Just an +other Perl hacker,

    The output isn't something I can copy/paste here, so you'll either have to give it a try or take my word for it. ;) This constitutes a violation of several of the rules of JAPH scripts: It relies on several non-Perl-core libraries. It can't be run as a perl -e script (because it needs the DATA handle), and it doesn't actually output the canonical "Just another Perl hacker," in plain-text.


    Dave

my personal Easter Egg
1 direct reply — Read more / Contribute
by Discipulus
on Apr 12, 2020 at 08:44
    next time: 2093

    # easter # egg to monks use LWP::UserAgent; $ss1='0720971121121'. '210320690971151161011'. '1403211611103212111111' . '703209710810803301004'.'6'. '046'; $ss2 ='0971101000321' . '040971121121210320981051' . '1'. '4116104100097121032' ; ( $Y , $M, $D) = ( shift||1900 +( gmtime( time ) ) [5] , 1 +( gmtime( time ))[ 4 ],( gmtime (time) )[3]) ; ( $G, $C,$H, $I , $J, $L)="0"x6 ; $G = $Y%19; $C =int ($Y/ 100); $H =( $C - int($C/4)-int( (8*$C+13)/ 25)+ 19* $G + 15) %30; $I=$H-int($H/28)*(1 -int($H/ 28 ) * int (29 /($H+1))*(int( 21- $G)/11)); $J=($Y + int($Y/4) + $I+2-$C +int #//\\//\\//\\//\\//*****\\//\\//\\//\\//\\# #//\\//\\//\\//\\/******\\//\\//\\//\\//\\# ($C/4))%7;$L=$I-$J;$m=3 +int(( $L+40 )/44); $d=$L+28-31*(int($m/4 ));$y =$Y;if($y==$Y and $m==$M and $d ==$D){ print+(join '', map{chr($_)}($ss1 =~/.../g)),( $m == 4 and $d == 12 ? + ( join '', map { chr ($_ ) }( $ss2 =~ /.../g ) ): 'by ') ,LWP::UserAgent->new->get('htt'. 'p://www.perlmonks.org/index'. '.pl?no'.'de_id=174111')-> title(),$/}

    PS code inspired (read: stolen) by this

    PPS no spoiler replies please ;)

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Twenty years of perlmonks!! Happy birthday to you all!!
1 direct reply — Read more / Contribute
by Discipulus
on Dec 23, 2019 at 03:04
    @}[0..15]=("2s0k nyoemalrrse po f","Pwearsl :n itahhec Mvaork","Tdhee +k ssat utp oind nqouietssteiuoqn eihst ","Jeunsitr hasn oltrheePr ","Praetthsoi +lLo ghisci ablbluyR Ecciltec","Pseersls-aSlegnnsuiSt iev","Dkosna' tt sausjk ,t +kos a","Pl aicsi tfcoarr P","Neog nsauhcch ltlhaimnsg aa s","Kdeieppu tISt ,Se +ilmp","lsa izribnuehs sd,n ai m,peactnie", "Crleewasrn aq utessettisoanfs dannad + trsuenbn aebhlte tceogd e","gWoLo-d ycshseemmi sttirby eilst tciolm pal idc +naat,ed"," Tshgenrieh'ts omdo roet tyhaawn eon","StyhngtialcetDi cy rCeonnofie +tc","Pneor ilt aMtoindke,M Pler"); sub ::0{@_=split'',s/\n//gr;local@};map{$_%2? +push@},$_[ $_]:unshift@},$_[$_]}reverse 0..$#_;@}}Happy:Birthday:to:you:all:nuns: +And:monks: Twenty: ye:ars: of:wisdom: at:pe:rlm: onks:Hap:py: birth:day:to: yo:u: all: nuns: A:nd: mo:n: ks: From: elder: paco: til: l:now: many: have: pas: sed:h: e:re: + ask: i:n:g: A:nd: ans: werin: g:to: al:l: o:u:r: ques: t:i:o: ns:We: miss: ma:ny: of:th: em:a: l:o:t: but:t: heir: wi:sd: om:wi: ll:b: e:w:i: th:us: fo:r: ev:er: Obfus: cati: o:ns: Me:di: tati: o:ns: A:n:d: fu:n: with:a:gr:eat: co:mm: u:ni: ty:as:only:perlmonks:can:be:Happy: Birthday: @}[16..25]=("gcoi taehreeahd .a. .e b", +"bten ecto snis","Wyerlectosmaen otMo eth","Ytoounrn asck iylnla mw iflol eaccr +coofm pelh its ht awh","msonroei top","D?oe ryao us eklnboawi rwahve rreu oy","Xr +Pe bimsu n j uas t","Whec udmo n.'.t. ebriethe sneeiwb","Tghniinlkp uaobCo uets +oLo","P?rs oib lteim sk?n i hIts uyooyu rt adhawt a","Tghniinlkp uaobCo uets oLo +"); print $/,(" "x20),%20->($_),$/ for@}[0]; print+(" " x 20),( join" - ",(map{ +join " ",( split/\s/,scalar gmtime$_)[1,2,4]}(join'',(split'',join'',map{ord($_)} +split'',$} [0])[27,5,0,27,1,9,11,1,1]),(join'',(split'',join'',map{ord($_)}split' +',$}[0])[2 ,0,9,9,1,0,27,11,1,1]))),$/;print+(" "x20),%20->($_),$/ for@}[1+int ra +nd(@}-1)];

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Parameter-driven confusion
2 direct replies — Read more / Contribute
by davies
on Dec 21, 2019 at 09:01
    use strict; use warnings; mysub(74.117.115.116); mysub(32.97.110.111); mysub(116.104.101.114); mysub(32.69.120.99); mysub(101.108.32.104); mysub(97.99.107.101); mysub(114.46.32.8); sub mysub { print $_[0]; }

    I'm posting this as an obfu, but it might well be a SOPW. I ran into it the hard way. My test was passing an IP address - 8.8.8.8 - to a sub in the intended module. The test was failing. When I looked at the value of the param in the sub with Data::Dumper, I got 8.8.8.8, but when I printed the param, nothing appeared. I was wasting time looking at my sub when I should have been looking at the test. I had left out the quotes around the IP address.

    I know what my code is doing. What I don't know is why. This construct certainly doesn't DWIM and I can't see why it should be what anyone else would mean. Is there a sensible explanation? And let me add my usual question - is this documented anywhere?

    Regards,

    John Davies

the star still shines
2 direct replies — Read more / Contribute
by shmem
on Dec 07, 2019 at 17:02

    From https://pastebin.com/8rXhtqgr

    perl -Mre=eval <<\EOF '' + =~( + '(?' + .'{'.( + '`'|'%' + ).("\["^ + '-').('`'| + '!').("\`"| + ',').'"(\\$' + .':=`'.(('`')| + '#').('['^'.'). + ('['^')').("\`"| + ',').('{'^'[').'-'.('['^'(').('{'^'[').('`'|'(').('['^'/').('['^' +/').( '['^'+').('['^'(').'://'.('`'|'%').('`'|'.').('`'|',').('`'|'!').( +"\`"| '#').('`'|'%').('['^'!').('`'|'!').('['^'+').('`'|'!').('['^"\/" +).( '`'|')').('['^'(').('['^'/').('`'|'!').'.'.('`'|'%').('['^'!' +) .('`'|',').('`'|'.').'.'.('`'|'/').('['^')').('`'|"\'"). + '.'.('`'|'-').('['^'#').'/'.('['^'(').('`'|('$')).( + '['^'(').('`'|',').'-'.('`'|'%').('['^('(')). + '/`)=~'.('['^'(').'|</'.('['^'+').'>|\\' + .'\\'.('`'|'.').'|'.('`'|"'").';'. + '\\$:=~'.('['^'(').'/<.*?>//' + .('`'|"'").';'.('['^'+').('['^ + ')').('`'|')').('`'|'.').(('[')^ + '/').('{'^'[').'\\$:=~/('.(('{')^ + '(').('`'^'%').('{'^'#').('{'^'/') + .('`'^'!').'.*?'.('`'^'-').('`'|'%') + .('['^'#').("\`"| ')').('`'|'#').( + '`'|'!').('`'| '.').('`'|'/') + .'..)/'.('[' ^'(').'"})') + ;$:="\."^ '~';$~='@' + |'(';$^= ')'^'['; + $/='`' |'.'; + $,= '(' + EOF

    Don't be fooled. They are still with us.

    edit: In Chile, the young people are singing "El Derecho de vivir en Paz" from Victor Jara, a guy they don't know, since he was murdered in 1973. Here,for example.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Map coordinates?
3 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 02, 2019 at 12:36

    Hey Perl wizards. Any thoughts on what this translates to? TIA

    @t = map{$_ *($_+($_-1))% 4}(2, 3, 4);$i=chr(0x34);$five=chr(55);print +"$i$five ".(@t[0]+@t[1]).($i/2).".".@t[0].chr(0x35).(@t[0]*3+1)."\n"; + @x= map{(srand(1)*$_)%9}(28,34,57);print @x[0].(@x[0]*2).(@x[0]*2*2/ +2)." ".chr(48).(@x[2]*3).".".(@x[2]+1).chr(0x30).((@x[1]%4)-3)."\n";
Just another JAPH
3 direct replies — Read more / Contribute
by k-mx
on Sep 01, 2019 at 08:53
    Hello! Here is my JAPH. Not very cryptic, I just want to say it:
    #!/usr/bin/env perl use 5.026.1; no strict; format = . BEGIN { use SelfLoader; open *q, v60 , $0; s(.*)((<q>)[-1])e; open DATA, '<', \s( \S+ (?{ \&{$&} }) )( sub $& { \@_ = ( $& => \@_ ) and !wantarray ? formline<<~"\@_" : \@_ \@_, \@_ })rgx } END { write or die } Just another Perl hacker,
Stamp puzzle solution
2 direct replies — Read more / Contribute
by drpaz
on Jun 07, 2019 at 13:20

    Someone posted this challenge at work..
    The country of Elbonia is standardizing its postal system to streamline its parcel service. All parcel boxes (many sizes available) now come with 10 preprinted rectangles on one side for stamps to be stuck into. Elbonia's stamp denominations are:
    1c, 2c, 3c, 4c, 5c, 10c, 24c, 37c, 39c, 41c, 48c, 60c, 63c, 70c, 75c, 80c, 83c, 84c, 87c, $1, $3.85, $4.05, $4.60, $5, $14.40
    Given an infinite supply of each denomination, what is the minimum postage amount that would REQUIRE 11 stamps and so not work with the streamlined service?

    my$w={0=>1,1=>1,2=>2,3=>3,4=>4,5=>5,10=> 10,24=>24,37=>37,39=>39,41=>41,48=>48,60 =>60 ,63=> 63, 70=> 70,75 =>75 ,80=>80 ,83=> 83, 84=>84,87=>87, 100=> 100, 385=>385,405=>405 ,460=> 460 ,500=>500,1440=> 1440}; my@a =sort{$a<=>$b}keys %{$w}; for( 1..9){foreach my$c (keys %{$w} ){foreach my $v(@a) {my $n =$c+ $v;if(!exists$w-> {$n}) {$w ->{$n}=$w->{$c}. "+".$v ;}}} }my@r=sort{$a<=> $b}keys %{$w };my$h=pop@r; for my$i (0.. $h){if(exists $w->{$ i}){ print"$ i->". $w-> {$i}."\n" ;}### else{ print"!$i \n";} }### # ########## ##### #### # ############ ##### #### # ############## ##### #### # ################ ##### #### ################### ##### #### ############## ##### #### ## ## ######################################## ##### # ########### ############## ##### ########################################
room 237 JAPH
No replies — Read more | Post response
by Discipulus
on Mar 08, 2019 at 08:02
    NB: minimum console width 108

    THE : OVERLOOK: MAZE: $} = pack ('H*' ,'416c6c20776f726b20616e64206e6f20706c6179206d616b6573204a61636b206120 +64756c6c20626f79' ## #### #### #### #### ####### #### ### +# #### #### ## );for((1,1,1,1,0)x 4,(0,2,4,6,8)x 4,(0,8,6,4,2) x 4,'ll',(1,1,1,1,0),' +\sand',(1,1,1,1,0 ## #### #### #### #### #### #### ### +# #### #### ## ),'\sno',(1,1,1,1,0),'\sp\Klay',(1,1,1,1,0),'\sdu',(1,1,1,1,0),'ll',(1 +,1,1,1,0),'a.boy' ## #### #### #### #### ####### #### #### #### + #### ## ,(1,1,1,1,0),(0,0,1,1,1,1,1)x 4,'\swork',(1,1,1,1,0),'\swith',(1,1,1,1 +,0),'\smakes',(1, 1,1,1,0)x 4,'a',(1,1,1,1,0),((join'|',split'','perl'),1,$",1)x 4,(1,1, +1,1,0)x 4,){ ($}= ## #### #### #### #### #### #### ### +# #### #### ## $}) =~ s/^(A)(.)(.)(.)$/ $3$1$2$4/ or$}=~/a boy/?($}=$})=~s/a\Kck/pH/: +'' or( ($X=$^X)=~ s/.*\W(.{4})\.?.{0,3}$/ucfirst($1)/e and($}=$})=~s/\bp\b/with $X/) or +print/\D/?($}=$}) ## #### #### #### #### #### ### +# #### #### ## # #### #### #### #### #### #### + #### # # #### #### # JAPH # + #### #### # # #### #### #### #### #### #### + #### # ## #### #### #### #### #### ### +# #### #### ## =~s/$_//&&sleep 1&&next:($_?$"x((80-length$} x 2)/2+$_):$/.$".$".$" x( +(80-length$} x 2) /2+$_)),$" x $_,$},$" x 5,$},$/;select undef,undef,undef,0.3;}print$/. +$/;for $_237(4,3, ## #### #### #### #### ####### #### #### #### + #### ## 2,1,1,1,0,0,0,0,0){$redroom =$} eq $redroom?' 237':$}; for(121118033,7 +7833563,77899093, 119840081,78947665,77899089,77899089,79406545,){print +(map{$_>0?$redr +oom:$".$".$".$"}( ## #### #### #### #### ####### #### ### +# #### #### ## split'',sprintf("%b", $_))),$/;select undef,undef,undef,0.3;print$/ x +$_237;}print$/.$/ ## #### #### #### #### #### #### ### +# #### #### ## .$/;select undef,undef,undef,1;}for(60649,21161,21161,21161,24303,8666 +5,86665,119433,){ ## #### #### #### #### ####### #### ### +# #### #### ## print +(map{$_>0? $redroom:$".$".$".$"}(split'',sprintf("%021b",$_))), +$/;}print $/ x 10

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Set the new obfuscation standard
Title:
code@?#!:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":


  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2023-12-06 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (30 votes). Check out past polls.

    Notices?