It started on IRC, while I was trying to be tricky with an obfu :...

Continue on to read the exciting adventures of boo_radley on IRC!

<booradley> $_=""; <booradley> if (samanda) {print "eek"} <booradley> then <booradley> $_="m"; <booradley> if (samanda) {print "eek"} <booradley> the first one tests true, but the second doesn't. Why? <ar0n> samanda? <ar0n> Where is samanda defined? <booradley> ah ah <ar0n> Whhat <booradley> it's not defined at all. <booradley> I though it would be interpreted as : <booradley> $_="m"; <booradley> if (s amanda) {print "eek $_"} <booradley> (to be a little clearer) <Juerdje> deparse it
TIME PASSES AND THE CODE IS DEPARSED
<Juerdje> samanda seems to be an unquoted string, and therefore always true <booradley> aah <Juerdje> which will get optimized away <Juerdje> so there's no if(){} at all in the deparsed result <Zaxo> work like you want for me, with the space affter s <Juerdje> with the space after it, it'll be interpreted as s/m/nd/ <Juerdje> space is only optional for a non-whitespace non-alphanumeric character <booradley> I thought the separator/ delimiter rules of s/// would tak +e precidence, but I guess that was stupid :-) <Juerdje> (afaik, you can't use whitespace as a delimiter in current versions anymore) <Juerdje> booradley: if the space were optional, it'd be a regex, but the space can only be left out for non-alphanumeric characters
CHAPTER 3 : Too Tricky For His Own Good!
*booradley tries using a unicode character for a delimiter. <Juerdje> hmmm <booradley> keen <booradley> unicode will usher in a new world of obfu :-) <Juerdje> it works? <booradley> yep <Juerdje> omg <booradley> sámándá <booradley> HOO HOO HA HA HA <Juerdje> omfg <booradley> pheer <Juerdje> is that unicode? <Juerdje> looks like a normal chr(255) <Juerdje> hmmm <Juerdje> 225
The character I used was (A + COMBINING GRAVE ACCENT), but I wonder if this was a result of my editor, or one of our IRC clients translating the character into something else? Here's a small example which works appropriately (or my estimation of appropriately)
$_="I am you"; print if (sámándá);

does this work because my locale has no (A + COMBINING GRAVE ACCENT) defined, and treats it as a non alpha numeric? or are unicode characters outside the realm of alphanumeric characters as perl currently knows them?

I'm curious to hear your comments or opinions.


In reply to Unicode and the fine art of obfuscation by boo_radley

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.