in reply to XML _is_ sick and twisted
OK, so this was all smoke and mirrors, the XML is barelly used: the code reads up to the line where the JAXH is, formats it nearly properly, then uses whats left as an XML document that will control how it gets output.
The important line is line 5, which is read by the hacker sub, cleaned of all non letter characters,and changed into a separate program:
print "my \njust \nanother \nor \nmy \nxml \nhacker \nand";This program is used as input for the ELT file handle, through a pipe.
The XML document parsed by the program starts on line 7 and ends at the end of the
code. It is used to control how data is read from ELT. Its structure (without the text,
which is not used) is:
<DATA> line 7 also reads line 5 + --> Just <ELT> line 12 also skips the first line of + ELT ('my') --> Another <!-- comment --> line 14 triggers the Comment handler + to skip the 'or' from ELT <!-- comment --> line 14 same with the second 'my' fr +om ELT <ELT> line 16 reads a line from ELT, that' +s the important bit --> Xml <ELT></ELT> line 18 read a line from ELT and doe +sn't do much with it (skip it) --> Hacker </ELT> line 21 just use the fact that < > a +re valid delimiters </ELT> line 21 same trick </DATA> line 23 back to depth 0 in the docum +ent, the final \n is output --> \n
So here is the commented code:
1 #!/bin/perl -w 2 use strict; 3 seek DATA, $[,$[; + # really seek 0,0, you have to use special variables ;--) 4 sub another{ foreach( $[..(($^W<<1)+$^W)) { <DATA>}} + # skip 3 lines ($^W is 1 so $^W<<1 is 2 ) 5 my $just= another or my $xml=hacker() and <DATA>; + # $xml is set to the text on this line FH set to line 7 6 sub hacker { $_= + # return line 5 7 <DATA> } + # beginning of the XML document 8 sub smoke { pipe 0, 1} + # used only because it returns true 9 sub mirror { return join( " \n", split( /[^a-x]+/, $xml))} + # return ("my \njust \nanother \nor \nmy \nxml \nhacker \n") 10 sub ON { "perl -e'print q{". (smoke and mirror) . "}' |" } + # prepare opening a pipe that will just print the text above 11 open( ELT, ON); + # ON will get the line generated by mirror 12 <ELT>; + # an XML element, also skip the first my on line 5 13 use XML::Parser; + # you need this in an XML obfus! 14 $xml=~ s<!-- smoke --><!--mirror-->; + # useless in Perl, but 2 XML comments (to skip 'or' and 'my') 15 my $parser= XML::Parser->new( Handlers => + # did I mention this was an XML obfus? 16 { Start => sub { while( <ELT>) { chomp; print ucfirst; last; } +}, # start handler: read from ELT, print the ucfirst'ed word, return 17 End => sub { print "\n" if( $_[0]->depth == 0); }, + # output the final \n 18 Comment => sub { <ELT>=~ m</ELT>;} + # used to skip unwanted token from line 5 19 }); 20 $parser->parse( \*DATA); + # XML has to be parsed using a parser, no silly regexp here! 21 $just=q</ELT>. qq</ELT>; + # close elements, usinq angle brackets as q delimitors 22 __DATA__ + # yes we need it 23 </DATA> + # the closing DATA tag must be the last token in the file
|
|---|