JAXSLTH

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • roy axenov

    JAXSLTH


    Warning! Some lines in this post are longer than 78
    characters.

    It just struck me - JAXSLTH! I mean, why not? XSLT is a
    powerful language, and while string processing is not its
    strong suit, it has more than enough tricks up its sleeve.
    'What a wonderful idea! And something to distract me from
    those awful UMLs, too. No, seriously, I just gotta try it.
    Who cares if it's useless? I might still learn a thing or
    two while doing it.' I'm a really bright fella, you know.
    Pointlessness never stopped me from finding a good reason
    to write the specs tomorrow.

    Anyway, writing a JAXSLTH is not much of problem:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/>
    <template match="/">Just another XSLT hacker, </template>
    </stylesheet>

    ....but that's not very interesting. Randalschwartzy , yes,
    and that can't possibly be a bad thing, but still
    uninspiring. Well, it also has the virtue of fitting in the
    sig block nicely. And, unfortunately, it seems to be just
    about the best that you *can* fit in the sig block.
    Something like:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/><template match="/"><value-of select="transla te(
    'Heck twoksid XSLT stupid, ','Htwksiceupd' ,'Janthesuckr') "/></template>
    </stylesheet>

    ....is possible, but that's arguably a worse JAXSLTH than
    the first one.

    Anyway, unaware of that problem, I started trying. Pretty
    soon I came up with the idea of using that otherwise
    useless namespace URI as a base string to work with. Half
    an hour later I came up with an even better idea of taking
    a good look at the XSL FAQ. Turned out, using namespace URI
    in obfuscated XSLT is a well-known trick. Oh well. I've no
    idea why this was so disheartening: I almost literally
    stumbled upon it, and I always knew there are quite a few
    people that are smarter than I am. I should've been able to
    add two and two toghether and realize this has already been
    done before (not that realizations like that ever stopped
    me from reinventing the wheel). Nevertheless, I decided I'd
    better get some, uh, work done and fired up the umbrello.
    After looking at it for two minutes straight with a
    *really* dumb look on my face, I gave up and went back to
    toying with XSLT.

    Another half an hour later, when I was deep in thinking of
    ways to obfuscate the data, I suddenly realized that the
    stylesheet I was working on was getting really long. 'Not
    much of a JAXSLTH, that', I told myself. After applying the
    KISS principle I was left with a stylesheet that was still
    about twice as long as I needed. I toyed with substring-foo
    and decimal-format for a while, but that wasn't getting me
    anywhere. At this point:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/><template match="*"><call-template
    name="a"><with-param
    name="a">080632 022030311502011 116202425262820 013013361116042 0</with-param>
    </call-template></template><templ ate name="a"><param name="a"/><if
    test="$a">
    <value-of
    select="substri ng(translate(na mespace-uri(document('' )/*),'w/p91.3m',
    'Ju, jeck'),substrin g($a,1,2),1)"/><call-template name="a"><with-param
    name="a"
    select="substri ng($a,3)"/></call-template></if></template></stylesheet>

    ....I decided to try something else (for relatively small
    values of 'else').

    Unfortunately, even after giving up that ugly long string
    literal and applying a nice little transformation to the
    namespace URI, I was still left with:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform"
    version="1.0">< output
    method="text"/><template match="*"><para m name="x"><call-template
    name="a">
    <with-param name="s"
    select="namespa ce-uri(document('' )/*)"/></call-template>
    </param><value-of select="transla te($x,'19o3g:/pwrfans.htm',
    'r toet sahc hanJuk')"/>er, </template><templ ate name="a"><param
    name="s"/><if
    test="$s"><valu e-of select="substri ng($s,1,1)"/><call-template
    name="a">
    <with-param name="s"
    select="transla te(substring($s ,2),substring($ s,1,1),'')"
    /></call-template></if></template></stylesheet>

    Not good enough. (Actually, it's worse than the previous
    example.)

    I tried various minor optimizations, but again, that wasn't
    getting me anywhere.

    I increased the value of 'else' a little. But still:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/><param name="JkXSLT">< apply-templates select=
    "document (concat('',''))/*"/></param><template match="/" name="a">
    <param
    name="a">462201 028138171602070 513814849505181 073871470513928 1</param>
    <if test="$a"><valu e-of
    select="substri ng($JkXSLT,subs tring($a,1,2),1 )"/>
    <call-template name="a"><with-param name="a" select="substri ng($a,3)"/>
    </call-template></if></template><templ ate match="*|@*"><v alue-of
    select=
    "name()"/><if test="not(node( ))"><value-of select="string( )"/></if>
    <apply-templates select="*|@*"/></template></stylesheet>

    Way too long.

    I decided to try something simpler and more elegant, and:

    <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/><template match="/" name="a"><param name="a"
    >t sanuthore JLTSh aXkec,r </param><param name="b" select="string-length($a)*
    0.5"/><if test="$a"><valu e-of
    select="substri ng($a,$b,1)"/><call-template name=
    "a"><with-param name="a"
    select="substri ng($a,1,($b)-1)"/></call-template>
    <call-template name="a"><with-param name="a"
    select="substri ng($a,$b+1)"/>
    </call-template></if></template></stylesheet>

    I guess the idea is a write-off, but maybe someone will
    find those stylesheets interesting.

    --
    roy axenov

  • Joseph Kesselman

    #2
    Re: JAXSLTH

    I know I'm going to regret asking, but -- What prior signature-block
    convention is this (implicitly) referring to?

    (Personal reaction: Deliberately obfuscated code is a newbie's game.
    Elegance is a heck of a lot more impressive.)

    Comment

    • roy axenov

      #3
      Re: JAXSLTH


      Joseph Kesselman wrote:
      I know I'm going to regret asking, but -- What prior
      signature-block convention is this (implicitly) referring
      to?
      Just another Perl hacker, naturally. Perl arguably has the
      highest obfuscation potential among the modern popular
      languages (for some values of 'modern' and 'popular'; and
      some values of 'languages').
      (Personal reaction: Deliberately obfuscated code is a
      newbie's game. Elegance is a heck of a lot more
      impressive.)
      I tend to agree, but I definitely don't mind being
      newbieish every once in a while. 't helps with the cork.
      Besides, where XSLT is concerned, I *am* a newbie, and
      likely to stay that way, unless a project involving XSLT
      comes my way.

      --
      roy axenov

      Comment

      • Andy Dingley

        #4
        Re: JAXSLTH

        roy axenov wrote:
        Just another Perl hacker, naturally. Perl arguably has the
        highest obfuscation potential among the modern popular
        languages
        I don't believe this -- surely there's worse by now! (Forth isn't dead
        yet and I've seen some pretty ugly Ruby). However Perl does seem to
        attract the coders to whom "elegant obfuscation" is an attractive goal.
        They do more of it, and they're doing it in Perl.

        Perl is terse though and terseness is an important factor in this sort
        of obfuscation. All obfuscated XSLT stylesheets must still be
        well-formed XML, and that's likely to limit the graphical creativity of
        their creators. Likewise Python - can you really obfuscate when the
        structure is still visible in the whitespace?
        (Personal reaction: Deliberately obfuscated code is a
        newbie's game. Elegance is a heck of a lot more
        impressive.)
        JAPH isn't just obfuscation, it's obfuscation until your code contains
        the full text of Omar Khayyam and is still executable. Or it's a valid
        JPG or your dog, and it's still executable.

        Comment

        Working...