Weirdest obfuscated "Hello World!"

Python 2

I happened to be playing with this yesterday, so:

(lambda _, __, ___, ____, _____, ______, _______, ________: getattr(__import__(True.__class__.__name__[_] + [].__class__.__name__[__]), ().__class__.__eq__.__class__.__name__[:__] + ().__iter__().__class__.__name__[_____:________])(_, (lambda _, __, ___: _(_, __, ___))(lambda _, __, ___: chr(___ % __) + _(_, __, ___ // __) if ___ else (lambda: _).func_code.co_lnotab, _ << ________, (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __) - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______ << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) << ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) << __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______ << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) + _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ << _))) + (_____ << ______) + (_ << ___))))(*(lambda _, __, ___: _(_, __, ___))((lambda _, __, ___: [__(___[(lambda: _).func_code.co_nlocals])] + _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []), lambda _: _.func_code.co_argcount, (lambda _: _, lambda _, __: _, lambda _, __, ___: _, lambda _, __, ___, ____: _, lambda _, __, ___, ____, _____: _, lambda _, __, ___, ____, _____, ______: _, lambda _, __, ___, ____, _____, ______, _______: _, lambda _, __, ___, ____, _____, ______, _______, ________: _)))

Here is a more readable version: http://codepad.org/UzSmoxF2

Notes:

  • One line, single expression (i.e. no print statement).

  • No strings, no ints; only functions, attribute access, lists, tuples, basic math, one True, and one star-args.

  • Minimal builtin usage (__import__, getattr, and chr once each).

  • The payload can be changed easily. Here is the program I wrote to generate it.

Edit: I wrote a fairly substantial explanation of how this works on my blog.


JavaScript

([]+/H/)[1&11>>1]+(+[[]+(1-~1<<1)+(~1+1e1)+(1%11)+(1|1>>1|1)+(~1+1e1)+(.1^!1)])[[([]+!![
11])[11^11]+[[{}]+{}][1/1.1&1][1]]+([[]+111/!1][+!1][([{}]+{})[1e1>>1]+[[],[]+{}][1&11>>
1][1|[]]+([]+[][111])[1&1]+[{},1e1,!1+{}][~~(1.1+1.1)][1^1<<1]+(11/!{}+{})[1-~1<<1]+[!!{
}+[]][+(11>11)][[]+1]+(/^/[1.11]+/&/)[.1^!1]+[{},[{}]+{},1][1&11>>1][1+1e1+1]+([]+!!{})[
.1^!1]+([]+{}+[])[[]+1]+[!!{}+{}][!11+!111][[]+1]]+[])[(!/~/+{})[1|1<<1]+[/=/,[]+[][1]][
1&11>>1][1&1>>1]+([]+{})[~~(1.1+1.1)]+[1,!1+{}][1%11][1^1<<1]+(111/[]+/1/)[~1+1e1+~1]+[!
!/-/+[]][+(11>11)][1]]((1<<1^11)+((+(1<1))==([]+/-/[(!![11]+[])[+!1]+(!!/-/+{})[1-~1]+([
]+!/~/)[1-~1]+(!!/-/+{})[!111+!111]])[11%11]),-~11>>1)](~1-~1e1<<1<<1)+([]+{111:1111}+[]
)[11111.1%11.1*111e11|!11]+({}+/W/)[1+~1e1-(~11*1.1<<1)]+(+[[]+(1|1>>1)+(1|1>>1|1)+(11-1
>>1)+(1e1>>1|1)+(1e1>>1)+(1>>11)+(11>>>1)])[[(!!{}+[])[11>>>11]+[[]+{}][.1^!1][111%11]]+
([11/[]+[]][111%111][([{}]+[{}])[1e1>>1]+[[],[{}]+[{}]][1|1>>1|1][1|[]]+([][11]+[])[[]+1
]+[{},1e1,![1]+/~/][1<<!1<<1][1<<1^1]+(1/!1+{})[11+1>>1]+[!!/-/+{}][+(111>111)][111%11]+
([][11]+/&/)[1&1>>1]+[{},[]+{}+[],1][[]+1][11-~1+11>>1]+([]+!!/-/)[11>>11]+([]+{})[1|1>>
1|1]+[[]+!!{}][1>>>1][1&11]]+[])[(!{}+[])[1^1<<1]+[/=/,[]+[][1]][1<<1>>1][!111+!111]+([]
+{}+[])[1<<1^1>>1]+[1,![11]+[]][1|1>>1][1|1<<1|1]+(11/[]+/1/)[-~11>>1]+[!![111]+{}][+[]]
[1|1>>1]]((1e1-1)+((1&1>>1)==([]+/-/[(!!{}+{})[+(1>1)]+(!!/-/+{})[1|1<<1]+(!1+{})[1|1<<1
|1]+(!!/-/+{})[11.11>>11.11]])[1&1>>1]),1-~1<<1)](~1-~1e1<<1<<1)+(/^!/+[])[1+!![11%111]]

Description of how it works can be found in this answer on StackOverflow.

Simply run this in the browser console (e.g. in Firebug or in Chrome Dev Tools).


PHP

<?=${[${[${[${[${[${[${[${[${${![]}.=[]}.=${![]}{!![]}]}.=${!![${[${[
${[${[${[${[${[]}++]}++]}++]}++]}++]}++]}++]}{![]+![]+![]}]}.=${[${[$
{[${[${[]}++]}++]}++]}++]}{![]}]}.=${[${[${[${[${[${[${[${[]}++]}++]}
++]}++]}++]}++]}++]}{![]+![]}.${[]}{![]+![]}]}.=${![]}^${!![${[${[${[
]}++]}++]}++]}{![]+![]+![]}]}.=${[]}{!![]}]}.=${[${[${[${[${[${[${[${
[${[${[${[${[${[${[${[${[]}++]}++]}++]}++]}++]}++]}++]}++]}++]}++]}++
]}++]}++]}++]}++]}{![]+![]+![]+![]}.${[]}{![]+![]+![]+![]}]}.=${[${[$
{[${[]}++]}++]}++]}{![]+![]}.${![]}{![]+![]+![]}]}.=${[${![]}=${![]}{
!![]}]}{!![${!![${!![${![]}++]}++]}++]}^${!![${[${[${[]}++]}++]}++]};

I've translated this into a single statement, which I think makes it considerably harder to decipher. This version uses only 13 unique characters.


Original version

<?${[]}.=[];${![]}.=${[]}{!![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${
![]};++${![]};${![]}.=${[]}{![]+![]+![]};++${![]};++${![]};++${![]};++${![]};${![
]}.=${![]}{![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]};${
![]}.=${![]}{![]+![]}.${![]}{![]+![]};++${![]};++${![]};++${![]};${![]}.=${[]}^${
[]}{![]+![]+![]};${![]}.=${![]}{!![]};++${![]};++${![]};++${![]};++${![]};++${![]
};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]};++${![]
};++${![]};${![]}.=${![]}{![]+![]+![]+![]}.${![]}{![]+![]+![]+![]};++${![]};++${!
[]};++${![]};${![]}.=${![]}{![]+![]}.${[]}{![]+![]+![]};++${![]};++${![]};++${![]
};${[]}=${[]}{!![]};++${[]};++${[]};++${[]};${![]}.=${[]}^${![]}{![]}?><?=${![]};

14 unique characters. I could make a script to generate these and dub it "PHPFuck", but I don't think it would be very useful.


How it works

When an array - including the empty array - is cast to string, the result is always the amazingly helpful string "Array". I'm not sure who thought that was a good idea. PHP supports the increment operator (but not decrement) for strings, for example "++A" → "B". The original string contains both "A" and "a", so all latin characters can be produced, brainfuck style. Space is produced with "A" ^ "a", and exclamation with "D" ^ "e".