JAXSLTH

R

roy axenov

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="translate(
'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">0806320220303115020111162024252628200130133611160420</with-param>
</call-template></template><template name="a"><param name="a"/><if
test="$a">
<value-of
select="substring(translate(namespace-uri(document('')/*),'w/p91.3m',
'Ju, jeck'),substring($a,1,2),1)"/><call-template name="a"><with-param
name="a"
select="substring($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="*"><param name="x"><call-template
name="a">
<with-param name="s"
select="namespace-uri(document('')/*)"/></call-template>
</param><value-of select="translate($x,'19o3g:/pwrfans.htm',
'r toet sahc hanJuk')"/>er, </template><template name="a"><param
name="s"/><if
test="$s"><value-of select="substring($s,1,1)"/><call-template
name="a">
<with-param name="s"
select="translate(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">4622010281381716020705138148495051810738714705139281</param>
<if test="$a"><value-of
select="substring($JkXSLT,substring($a,1,2),1)"/>
<call-template name="a"><with-param name="a" select="substring($a,3)"/>
</call-template></if></template><template match="*|@*"><value-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:

t sanuthore JLTSh aXkec,r </param><param name="b" select="string-length($a)*
0.5"/><if test="$a"><value-of
select="substring($a,$b,1)"/><call-template name=
"a"><with-param name="a"
select="substring($a,1,($b)-1)"/></call-template>
<call-template name="a"><with-param name="a"
select="substring($a,$b+1)"/>
</call-template></if></template></stylesheet>

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

Joseph Kesselman

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.)
 
R

roy axenov

Joseph said:
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.
 
A

Andy Dingley

roy said:
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?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,006
Messages
2,570,265
Members
46,860
Latest member
JeremiahCo

Latest Threads

Top