DevNetwork Obfuscated PHP Contest 2006

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

jayshields wrote:@hawley: I don't get it. Is this a variant of that brainf*ck language thing? I was gunna attempt something like that but it said pure PHP only. Your test page just shows a weird string. How do I reverse a string?
Oops. I hardcoded the string. I'll update my code...
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

You have to seperate the IiIo stuff to see the string. If you take those out, you can read the script as there are just some comments around each variable declaration all jumbled on the same line.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Nice hawley, nice. How do you use it? I went to the page but just saw code.

Oh yeah....

?looc nikaerf os krowtenved tnsi
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I updated the code to accept a variable. Also, changed the URL to:

http://jameshawley.com/forum/devnet.php?IO0=HAWLEYJR
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

sorry, hawleyjr, according to the rules your script must accept $_GET parameter with string to reverse.
Image
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Weirdan wrote:sorry, hawleyjr, according to the rules your script must accept $_GET parameter with string to reverse.
Image
I already fixed that Image
hawleyjr wrote:I updated the code to accept a variable. Also, changed the URL to:

http://jameshawley.com/forum/devnet.php?IO0=HAWLEYJR
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

hawley's script deciphered (original version):

Code: Select all

 
<?php
$input = 'IIIi$oI1Io==1=' . 'Ii11io1ii1ioIOIo=';
echo $input;
$strlen = create_function ('$str','
    $length=0;
    for($i=0; $i < strlen($str); $i++) {
        $length++;
    }
    return $length;
')
;
for($index = $strlen($input); $index >= 0; $index--) {
    echo $input[$index];
}
?>
 
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

hawleyjr you script left my jaw gaping.
I am considering frameing it :D:D
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php 
/*****************************************************************************/
/************************************** **************************************/
/*************************************   *************************************/
/************************************     ************************************/
/***********************************       ***********************************/
/**********************************         **********************************/
/**********************************   (O)   **********************************/
/**********************************         **********************************/
/***********************************       ***********************************/
/************************************     ************************************/
/*************************************   *************************************/
/************************************** **************************************/
/*****************************************************************************/
/*<>-->*/$s=(isset($_GET['s']))/*<>-->?<--<>*/?/*!$$et*/$_GET['s']:'';/*<--<>*/ 
/*_-^-_()<-0o0->()*/$sd=/*== -&<=> ==*/(isset($_GET['s']));/*_-^-_()<-0o0->()*/
/*(/'"'\)while- >< -([A-Za-z0-9?])`field`!=`yesterday =date($doggie)phpspat__*/
/*(*)*/$sc=/*require(['@#']);$beersgonewild=*/strlen($s);/*&$hawley->drunk($u*/
/*file_get_contents($somerandomarbitrarytextstringtogetfromalongassvariable);*/
/*$string='itwasacolddayinweeweelandwhenheawoketosoakedsheetsandapandlaughing*/
/*//\\_--_//\\*/$sn=/*'anotherlongabitrarystring';*/'';/*$0->make=&new Me();-*/
/*()*\__e();*/$se=/*$october=coldweatherexceptforburrito;*/'';/*chr(5).chr(1)*/
/*function malbec() {*/$y=/*global $warming,$kills,$fish,$for,$bbq;*/$sc-1;/**/
/*['^@#\s\t\n\\/'"";'/\\]*/while/*$we->gosailing();*/($y >= 0)/*try($_sleep);*/
/*throw(Exception $vestibule)*/{/*becauseIcan*/$sn.=/*if($s)*/$s{$y};/*||$y  */
/*<-->kill($y);*/$y-=1;/*||$so-I-was-told;//butwhoreallyknowsthesthinganyway?*/
/*{*/}/*}--{*/if /*$y;>;<;str_replace(1,'1',$_1);*/($sd)/**/echo $sn;/*die();*/
/*$new_string='butikeptthepursuitforalongwhilethinkingthepimphaditcoming...';*/
/*****************************************************************************/
/************************************** **************************************/
/*****************************************************************************/
/*************************************   *************************************/
/**********************************         **********************************/
/*******************************               *******************************/
/*****************************        (O)        *****************************/
/**********************************         **********************************/
/***********************************       ***********************************/
/************************************     ************************************/
/*************************************   *************************************/
/************************************** **************************************/
/*****************************************************************************/
?>
EDIT | I know it goes against out rules, but using php tags gives it away. So it is wrapped in code tags. Sorry.

This one works. Thanks Hawley, love that style. I screwed the pooch on it, but it looks pretty. Anyhow, new one to try is at http://www.codecompare.com/sonew.php. Blank on load, reverse string on passing of ?s=stringtoreverse.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Weirdan wrote:hawley's script deciphered (original version):

Code: Select all

 
<?php
$input = 'IIIi$oI1Io==1=' . 'Ii11io1ii1ioIOIo=';
echo $input;
$strlen = create_function ('$str','
    $length=0;
    for($i=0; $i < strlen($str); $i++) {
        $length++;
    }
    return $length;
')
;
for($index = $strlen($input); $index >= 0; $index--) {
    echo $input[$index];
}
?>
 
lol, I could have given that to you if ya wanted ... :roll:
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I’m starting to sense some criticism on the level of code I submitted. However, according to Wikipedia
Obfuscated code is source code that is (perhaps intentionally) very hard to read and understand.
Therefore, you don’t necessarily have to write a complex 3 page function when all you need to do is make code ‘Hard to Read’
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

lol, I could have given that to you if ya wanted ...
That would be boring Image
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

His code lit up when run through the highlighter. I still love the layout though. That is some sweet stuff, as evidenced by my tribute to Hawley with my less than stellar copy cat version...
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

Code: Select all

<?php while($_=(!$_?72:($_==72?101:($_==101?108:($_==108?109:($_==109?111:
($_==111?44:($_==44?32:($_==32?87:($_==87?112:($_==112?114:($_==114?666:
($_==666?100:($_==100?33:($_==33?0:1)))))))))))))))echo chr($_==109?108:($_==112?
111:($_==666?108:($_))));?>
Every programmer starts with this little program.. ;)

I've noticed a lot of comment filler in other code.. does that even count?

EDIT: Sorry just read the thread as Obfuscated code.. didn't relise there was a spec untill I just read it completly :? Obfuscated spec?!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It just needs to be hard to read while still achieving the desired task. Comment filler can be used. I think.
Post Reply