Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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
BEGIN X
1 direct reply — Read more / Contribute
by Discipulus
on Jan 31, 2019 at 16:24
    BEGIN{print','; BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'k'; BEGIN{print'c'; BEGIN{print'a'; BEGIN{print'H'; BEGIN{print' '; BEGIN{print'l'; BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'P'; BEGIN{print' ';BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'h'; BEGIN{print't'; BEGIN{print'o'; BEGIN{print'n'; BEGIN{print'A'; BEGIN{print' '; BEGIN{print't'; BEGIN{print's'; BEGIN{print'u'; BEGIN{print'J'; BEGIN{print''; }}}}}}}}}}}}}; }}}}}}}}}}}}};

    Inspired by Assignment and use statement in the same BEGIN block and

    perl -e "$}.=qq(BEGIN{print qq($_);)for(q(,rekcaH lreP rehtonA tsuJ)=~/./g);$}.=q(})x25;eval$}"

    A little modification after having seen it under the morning light.

    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.
cOMPRESSed JaPH,
No replies — Read more | Post response
by kschwab
on Dec 30, 2018 at 13:55
    Run on a VT100 compatible terminal
    #!/usr/bin/perl BEGIN{$^="USE\0cOMPRESS\x1a\x1azLIB"^" ",$^=~s,$, $^,ee};$_=q|M'XL(`*[Q*%P"`Y5231J%(`C<=PJ.VJ)E"U?T\\ZSNYDD>(B)HF_P^R V9@A!A(MN"5<0!=]P[@831@,-!4@,\\(N"1%8[U%)BV[Y-,:12L?1&S.C5]A]F4+RES `)M=WN*$C4R#/YH[YT\\/>:$IY/?&(M#&>VATA0W9VBE7T-U<2LWU%.$ALFQ=J"\\M= ICPR"76N)ZYZS7P<7U/*.ZP!N$BHG,%-BZ,`E+WV@_7_N90.FH18I'@K*69M(LSP4X; :C=:)EP[H@MXNEWIO?[&'U@_#@,?:O54D([YD6E$_3F^+*NOL<Q1+4Y0[.M_SP=<;<Y O0'IR@8@`4$|;y| \n||d;$_=unpack'u';$,='-V4Jfdy{lzz33Se`k33dldN|gs'. '`y!-V 2y{`g}2';$,^="\t"x$,=~y,,,c;$,=~s;^;$,;ee;
Perl Golang Partial Polyglot
No replies — Read more | Post response
by kschwab
on Dec 30, 2018 at 09:50

    Similar to my earlier Perl Python Partial Polyglot.

    This one runs under either Golang (go run ./script) or Perl, and produces *mostly* the same output. Arguably not a true polyglot since the Go doesn't depend on the Perl, but the Perl certainly depends on the Go.

    //;$_=<<'/*',y'>>''; package main; func main() { print("Just another Golang Hacker,\n"); } //;main() /* s&(\146\w{3})(.*)\x47\w{5}&lc($1^'5 ,C').$2.('dQFX'^4x4)&es;s;$;$_;ee; */
More fun with a reference
1 direct reply — Read more / Contribute
by kschwab
on Dec 22, 2018 at 12:48
    Stealing part of choroba's idea.
    perl -e 's/^/pack+q.a..($^F^$^F**$^F),qq^\x19"\x11\x04mX^^\$\//e/print +'
Just Another Perl Hacker,
1 direct reply — Read more / Contribute
by choroba
on Dec 21, 2018 at 10:43
    Having fun with references.
    print map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[ +{}],[sub{}^*ARGV,3];

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
VT100 Screensaver
1 direct reply — Read more / Contribute
by kschwab
on Dec 09, 2018 at 16:27

    Only works on Unix like machines...requires a VT100 compatible terminal like an xterm, and a working "stty" binary. Handles resizing the window while it's running. Ctrl-C to stop it.

    #!/usr/bin/perl use warnings;use strict;my($r,$c);$|=1;init(); sub init{print "\ec";($r,$c)=split' ',qx"stty size";$r-=5;$c-=16}; $SIG{INT}= sub{print "\ec\n";exit};$SIG{WINCH}=sub{init()}; $_='!X!E!EIC%IC%IC%!X!ECu#kCD@3ilowg!E!WICD@biloQgIO#kAr@DiloT@/@j'. '@D@j@%IO#myD@gg!QCu#kC%IO#kO#gO#gC%!MIC%!QCu#kC%IO#ne#me#ni%!MICD'. '@f@/iloQK';s/!/4pa/g;s/@/ilp/g;s/#/KW/g;s/%/Ag/g;tr|A-Za-z0-9+/| -_|; @_=split(/\n/,unpack('u',join($',map(chr(32+length($_)*3/4). $_,/(.{1,60})/gs))));print "\ec\e[2J\e[?25l";srand(); for (;;) { my($x,$y)= map{int(rand($_))+1}($c,$r); for(0..4){print "\e[".($y+$_).";${x}H".$_[$_];} select($\,$\,$\,rand(1.2)+.3); for(0..4){print "\e[".($y+$_).";${x}H"." "x16;} }
Christmas Package Obfuscation
1 direct reply — Read more / Contribute
by kschwab
on Dec 08, 2018 at 14:11
    #!/usr/bin/perl $;;$^;s#^#$\ _-~,..___ .-' .--._ ```--.-----.___ ._^---- (`-...`-. _/,----. ) ````---=. _.-'' ````-- `.___.-.) (---=='' .-' | _.-' _.-. )(`.-._``--.._ .' | |`---..__ .-'.-'.' )| |_ ``--...`. | | ``--.._ ,'.-' ( ( `-.`-. .'| : | | | | --.._`. ) `. `. | : | | | | ( )-.._.') ) ) : | | | | | | | ( ( ) : | | | | (_( | ) ) | : .' | | | | L/ | : .' (__ | | | | :.' `-.._ | | | | : `-.._ | | | |/ `--`_|_ | .' `._ | .' ``-.__ | .' `--`; # and "Happy Holidays" or Merry Christmas! print "Is print broken?\n";print;# guess not?
perl: we package API -- oneliner
2 direct replies — Read more / Contribute
by Discipulus
on Dec 07, 2018 at 07:11
    perl -we "package API{$|++;$'__=__PACKAGE__;$\"=','}print/J$__/?exit:q +q($_\r)for glob qq{{@{[A..P,I]}}}x4"

    Note: Win32 double quotes!

    Thanks Tux, thanks Eily

    L*

    PS changed the title from empty API package -- oneliner to the current

    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.
die if lie! fun with Win32
1 direct reply — Read more / Contribute
by Discipulus
on Nov 12, 2018 at 05:27
    Hello nuns and monks!

    I'm not an obfusctor, but as Win32 is obfuscated per se i present you this little lie/truth game

    use Win32; exit unless @}; $ms = \&Win32::GetSystemMet +rics if $^O; END{ exit if @};while(<DATA>) { s/\s//g ; push @} , jo +in '', map {chr (($^O =~ s/\D+//r)+$_)}( $_ =~ /\d{2}/g ) } seek DA +TA, 0, 0; ; $s.=$_ for<DATA>;die if !eval $s; system('cls'); print $ +^O,' ', map {uc $_} substr($} [4], 0, 1 ), substr ($}[0] , 7 , 1), sub +str( $}[5] ,4,1), substr ($}[8],1,1), $/;} map{die 'lie!' unless($$_[1 +]->($$_[2] )?6:7 )== Win32::MsgBox($}[$$_ [0]] . "?", 4, $0); }[0, $ms +,75], [1, $ms, 91], [2, $ms, 23],[3,$ms, 0x2004], [4,$ms, 67],[5, $ms +,0x2003]; map { print $}[$$_[0]]. "?\n"; <STDIN> eq $$_[1] ( $$_[2] ). +"\n" or die'lie!'}[6,$ms,80],[7,$ms,0], [8,$ms,1]; eval '#!perl' unle +ss $^O; __DATA__ 777 9 8 5 8 36 9 00 7265 830 08 669 82 847 36 765 760 08 7726 +96 976 77 79 858 36 90 0726 5830072798 27390 7978 84 65 76 00 8772 69 +69 76 7 7 7 98583 69 0 0 66 8 58 4847 97 8830 0658 26900 83 876 58080 + 6968 73 8 30 08 4 726 90 080 670 073 78 006 8 79 67 756 96 80 077 796 + 869 74 85 8 3 84006 67 9798 4007378 007 065 7376 1383 6570 69 007779 +6869 89 798 500 808 5840 08 0670 079 78 0 08 37 6 6 58 4 69 0 07 779 6 +869 72798 70077 65788 9007 77 97873 84798283 0068790089798 500726 58 +669 87726584078 3008472690087736884 720079700070738 28384008367 826969 +78 8772658407830084726900726973717 284007970007073 8283840083678269697 +8

    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.
rand ( perl --help )
No replies — Read more | Post response
by usemodperl
on Jun 18, 2018 at 19:28
    perl -le 'chomp(@_=`perl -h`);($u)=grep/^U/,@_;($r)=grep/^R/,@_;@_=gre +p/^\s+\-/,@_;$s=$_[int(rand(scalar@_))];for(1..2){system"clear";print +"\033\[1m$u\033\[0m";print/1/?"\033[5m":"",$s,/1/?"\033[0m":"";print" +\033\[1m$r\033\[0m";sleep(3)if/1/}'

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":


  • 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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (7)
    As of 2019-02-22 20:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I use postfix dereferencing ...









      Results (118 votes). Check out past polls.

      Notices?