Personal website https://benkurtovic.com/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

2014-06-01-obfuscating-hello-world.md 21 KiB

10年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. ---
  2. layout: post
  3. title: Obfuscating "Hello world!"
  4. description: Fun with functional programming in Python.
  5. ---
  6. A few months ago, I got first place in
  7. [this Code Golf contest](//codegolf.stackexchange.com/q/22533) to create the
  8. weirdest obfuscated program that prints the string "Hello world!". I decided to
  9. write up an explanation of how the hell it works. So, here's the entry, in
  10. Python 2.7:
  11. {% highlight python linenos=table %}
  12. (lambda _, __, ___, ____, _____, ______, _______, ________:
  13. getattr(
  14. __import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
  15. ().__class__.__eq__.__class__.__name__[:__] +
  16. ().__iter__().__class__.__name__[_____:________]
  17. )(
  18. _, (lambda _, __, ___: _(_, __, ___))(
  19. lambda _, __, ___:
  20. chr(___ % __) + _(_, __, ___ // __) if ___ else
  21. (lambda: _).func_code.co_lnotab,
  22. _ << ________,
  23. (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
  24. - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
  25. __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
  26. << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
  27. ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
  28. __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
  29. << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
  30. _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
  31. (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
  32. _))) + (_____ << ______) + (_ << ___)
  33. )
  34. )
  35. )(
  36. *(lambda _, __, ___: _(_, __, ___))(
  37. (lambda _, __, ___:
  38. [__(___[(lambda: _).func_code.co_nlocals])] +
  39. _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []
  40. ),
  41. lambda _: _.func_code.co_argcount,
  42. (
  43. lambda _: _,
  44. lambda _, __: _,
  45. lambda _, __, ___: _,
  46. lambda _, __, ___, ____: _,
  47. lambda _, __, ___, ____, _____: _,
  48. lambda _, __, ___, ____, _____, ______: _,
  49. lambda _, __, ___, ____, _____, ______, _______: _,
  50. lambda _, __, ___, ____, _____, ______, _______, ________: _
  51. )
  52. )
  53. )
  54. {% endhighlight %}
  55. String literals weren't allowed, but I set some other restrictions for fun: it
  56. had to be a single expression (so no `print` statement) with minimal builtin
  57. usage and no integer literals.
  58. ## Getting started
  59. Since we can't use `print`, we can write to the `stdout` file object:
  60. {% highlight python %}
  61. import sys
  62. sys.stdout.write("Hello world!\n")
  63. {% endhighlight %}
  64. But let's use something lower-level:
  65. [`os.write()`](//docs.python.org/2/library/os.html#os.write). We need
  66. `stdout`'s [file descriptor](//en.wikipedia.org/wiki/File_descriptor), which is
  67. `1` (you can check with `print sys.stdout.fileno()`).
  68. {% highlight python %}
  69. import os
  70. os.write(1, "Hello world!\n")
  71. {% endhighlight %}
  72. We want a single expression, so we'll use
  73. [`__import__()`](//docs.python.org/2/library/functions.html#__import__):
  74. {% highlight python %}
  75. __import__("os").write(1, "Hello world!\n")
  76. {% endhighlight %}
  77. We also want to be able to obfuscate the `write()`, so we'll throw in a
  78. `getattr()`:
  79. {% highlight python %}
  80. getattr(__import__("os"), "write")(1, "Hello world!\n")
  81. {% endhighlight %}
  82. This is the starting point. Everything from now on will be obfuscating the
  83. three strings and the int.
  84. ## Stringing together strings
  85. `"os"` and `"write"` are fairly simple, so we'll create them by joining parts
  86. of the names of various built-in classes. There are many different ways to do
  87. this, but I chose the following:
  88. - `"o"` from the second letter of `bool`: `True.__class__.__name__[1]`
  89. - `"s"` from the third letter of `list`: `[].__class__.__name__[2]`
  90. - `"wr"` from the first two letters of `wrapper_descriptor`, an implementation
  91. detail in CPython found as the type of some builtin classes' methods (more on
  92. that
  93. [here](http://utcc.utoronto.ca/~cks/space/blog/python/SlotWrapperObjects)):
  94. `().__class__.__eq__.__class__.__name__[:2]`
  95. - `"ite"` from the sixth through eighth letters of `tupleiterator`, the type of
  96. object returned by calling `iter()` on a tuple:
  97. `().__iter__().__class__.__name__[5:8]`
  98. We're starting to make some progress!
  99. {% highlight python linenos=table %}
  100. getattr(
  101. __import__(True.__class__.__name__[1] + [].__class__.__name__[2]),
  102. ().__class__.__eq__.__class__.__name__[:2] +
  103. ().__iter__().__class__.__name__[5:8]
  104. )(1, "Hello world!\n")
  105. {% endhighlight %}
  106. `"Hello world!\n"` is more complicated. We're going to encode it as a big
  107. integer, which will be formed of the ASCII code of each character multiplied by
  108. 256 to the power of the character's index in the string. In other words, the
  109. following series:
  110. <div>$$\sum_{n=0}^{L-1} c_n(256^n)$$</div>
  111. where <span>\\(L\\)</span> is the length of the string and
  112. <span>\\(c_n\\)</span> is the ASCII code of the
  113. <span>\\(n\\)</span><sup>th</sup> character in the string. To create the
  114. number:
  115. {% highlight pycon %}
  116. >>> codes = [ord(c) for c in "Hello world!\n"]
  117. >>> num = sum(codes[i] * 256 ** i for i in xrange(len(codes)))
  118. >>> print num
  119. 802616035175250124568770929992
  120. {% endhighlight %}
  121. Now we need the code to convert this number back into a string. We use a simple
  122. recursive algorithm:
  123. {% highlight pycon %}
  124. >>> def convert(num):
  125. ... if num:
  126. ... return chr(num % 256) + convert(num // 256)
  127. ... else:
  128. ... return ""
  129. ...
  130. >>> convert(802616035175250124568770929992)
  131. 'Hello world!\n'
  132. {% endhighlight %}
  133. Rewriting in one line with `lambda`:
  134. {% highlight python %}
  135. convert = lambda num: chr(num % 256) + convert(num // 256) if num else ""
  136. {% endhighlight %}
  137. Now we use
  138. [anonymous recursion](//en.wikipedia.org/wiki/Anonymous_recursion) to turn this
  139. into a single expression. This requires a
  140. [combinator](//en.wikipedia.org/wiki/Combinatory_logic). Start with this:
  141. {% highlight pycon %}
  142. >>> comb = lambda f, n: f(f, n)
  143. >>> convert = lambda f, n: chr(n % 256) + f(f, n // 256) if n else ""
  144. >>> comb(convert, 802616035175250124568770929992)
  145. 'Hello world!\n'
  146. {% endhighlight %}
  147. Now we just substitute the two definitions into the expression, and we have our
  148. function:
  149. {% highlight pycon %}
  150. >>> (lambda f, n: f(f, n))(
  151. ... lambda f, n: chr(n % 256) + f(f, n // 256) if n else "",
  152. ... 802616035175250124568770929992)
  153. 'Hello world!\n'
  154. {% endhighlight %}
  155. Now we can stick this into our code from before, replacing some variable names
  156. along the way (`f` &rarr; `_`, `n` &rarr; `__`):
  157. {% highlight python linenos=table %}
  158. getattr(
  159. __import__(True.__class__.__name__[1] + [].__class__.__name__[2]),
  160. ().__class__.__eq__.__class__.__name__[:2] +
  161. ().__iter__().__class__.__name__[5:8]
  162. )(
  163. 1, (lambda _, __: _(_, __))(
  164. lambda _, __: chr(__ % 256) + _(_, __ // 256) if __ else "",
  165. 802616035175250124568770929992
  166. )
  167. )
  168. {% endhighlight %}
  169. ## Function internals
  170. We're left with a `""` in the body of our convert function (remember: no string
  171. literals!), and a large number that we'll have to hide somehow. Let's start
  172. with the empty string. We can make one on the fly by examining the internals of
  173. some random function:
  174. {% highlight pycon %}
  175. >>> (lambda: 0).func_code.co_lnotab
  176. ''
  177. {% endhighlight %}
  178. What we're _really_ doing here is looking at the
  179. [line number table](http://svn.python.org/projects/python/branches/pep-0384/Objects/lnotab_notes.txt)
  180. of the `code` object contained within the function. Since it's anonymous, there
  181. are no line numbers, so the string is empty. Replace the `0` with `_` to make
  182. it more confusing (it doesn't matter, since the function's not being called),
  183. and stick it in. We'll also refactor out the `256` into an argument that gets
  184. passed to our obfuscated `convert()` along with the number. This requires
  185. adding an argument to the combinator:
  186. {% highlight python linenos=table %}
  187. getattr(
  188. __import__(True.__class__.__name__[1] + [].__class__.__name__[2]),
  189. ().__class__.__eq__.__class__.__name__[:2] +
  190. ().__iter__().__class__.__name__[5:8]
  191. )(
  192. 1, (lambda _, __, ___: _(_, __, ___))(
  193. lambda _, __, ___:
  194. chr(___ % __) + _(_, __, ___ // __) if ___ else
  195. (lambda: _).func_code.co_lnotab,
  196. 256,
  197. 802616035175250124568770929992
  198. )
  199. )
  200. {% endhighlight %}
  201. ## A detour
  202. Let's tackle a different problem for a bit. We want a way to obfuscate the
  203. numbers in our code, but it'll be cumbersome (and not particularly interesting)
  204. to recreate them each time they're used. If we can implement, say,
  205. `range(1, 9) == [1, 2, 3, 4, 5, 6, 7, 8]`, then we can wrap our current work in
  206. a function that takes variables containing the numbers from 1 to 8, and replace
  207. occurrences of integer literals in the body with these variables:
  208. {% highlight python linenos=table %}
  209. (lambda n1, n2, n3, n4, n5, n6, n7, n8:
  210. getattr(
  211. __import__(True.__class__.__name__[n1] + [].__class__.__name__[n2]),
  212. ...
  213. )(
  214. ...
  215. )
  216. )(*range(1, 9))
  217. {% endhighlight %}
  218. Even though we need to form `256` and `802616035175250124568770929992` as well,
  219. these can be created using arithmetic operations on these eight "fundamental"
  220. numbers. The choice of 1–8 is arbitrary, but seems to be a good middle ground.
  221. We can get the number of arguments a function takes via its `code` object:
  222. {% highlight pycon %}
  223. >>> (lambda a, b, c: 0).func_code.co_argcount
  224. 3
  225. {% endhighlight %}
  226. Build a tuple of functions with argcounts between 1 and 8:
  227. {% highlight python linenos=table %}
  228. funcs = (
  229. lambda _: _,
  230. lambda _, __: _,
  231. lambda _, __, ___: _,
  232. lambda _, __, ___, ____: _,
  233. lambda _, __, ___, ____, _____: _,
  234. lambda _, __, ___, ____, _____, ______: _,
  235. lambda _, __, ___, ____, _____, ______, _______: _,
  236. lambda _, __, ___, ____, _____, ______, _______, ________: _
  237. )
  238. {% endhighlight %}
  239. Using a recursive algorithm, we can turn this into the output of `range(1, 9)`:
  240. {% highlight pycon %}
  241. >>> def convert(L):
  242. ... if L:
  243. ... return [L[0].func_code.co_argcount] + convert(L[1:])
  244. ... else:
  245. ... return []
  246. ...
  247. >>> convert(funcs)
  248. [1, 2, 3, 4, 5, 6, 7, 8]
  249. {% endhighlight %}
  250. As before, we convert this into `lambda` form:
  251. {% highlight python %}
  252. convert = lambda L: [L[0].func_code.co_argcount] + convert(L[1:]) if L else []
  253. {% endhighlight %}
  254. Then, into anonymous-recursive form:
  255. {% highlight pycon %}
  256. >>> (lambda f, L: f(f, L))(
  257. ... lambda f, L: [L[0].func_code.co_argcount] + f(f, L[1:]) if L else [],
  258. ... funcs)
  259. [1, 2, 3, 4, 5, 6, 7, 8]
  260. {% endhighlight %}
  261. For fun, we'll factor out argcount operation into an additional function
  262. argument, and obfuscate some variable names:
  263. {% highlight python linenos=table %}
  264. (lambda _, __, ___: _(_, __, ___))(
  265. (lambda _, __, ___:
  266. [__(___[0])] + _(_, __, ___[1:]) if ___ else []
  267. ),
  268. lambda _: _.func_code.co_argcount,
  269. funcs
  270. )
  271. {% endhighlight %}
  272. There's a new problem now: we still need a way to hide `0` and `1`. We can get
  273. these by examining the number of local variables within arbitrary functions:
  274. {% highlight pycon %}
  275. >>> (lambda: _).func_code.co_nlocals
  276. 0
  277. >>> (lambda _: _).func_code.co_nlocals
  278. 1
  279. {% endhighlight %}
  280. Even though the function bodies look the same, `_` in the first function is not
  281. an argument, nor is it defined in the function, so Python interprets it as a
  282. global variable:
  283. {% highlight pycon %}
  284. >>> import dis
  285. >>> dis.dis(lambda: _)
  286. 1 0 LOAD_GLOBAL 0 (_)
  287. 3 RETURN_VALUE
  288. >>> dis.dis(lambda _: _)
  289. 1 0 LOAD_FAST 0 (_)
  290. 3 RETURN_VALUE
  291. {% endhighlight %}
  292. This happens regardless of whether `_` is actually defined in the global scope.
  293. Putting this into practice:
  294. {% highlight python linenos=table %}
  295. (lambda _, __, ___: _(_, __, ___))(
  296. (lambda _, __, ___:
  297. [__(___[(lambda: _).func_code.co_nlocals])] +
  298. _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []
  299. ),
  300. lambda _: _.func_code.co_argcount,
  301. funcs
  302. )
  303. {% endhighlight %}
  304. Now we can substitute the value of `funcs` in, and then using `*` to pass the
  305. resulting list of integers as eight separate variables, we get this:
  306. {% highlight python linenos=table %}
  307. (lambda n1, n2, n3, n4, n5, n6, n7, n8:
  308. getattr(
  309. __import__(True.__class__.__name__[n1] + [].__class__.__name__[n2]),
  310. ().__class__.__eq__.__class__.__name__[:n2] +
  311. ().__iter__().__class__.__name__[n5:n8]
  312. )(
  313. n1, (lambda _, __, ___: _(_, __, ___))(
  314. lambda _, __, ___:
  315. chr(___ % __) + _(_, __, ___ // __) if ___ else
  316. (lambda: _).func_code.co_lnotab,
  317. 256,
  318. 802616035175250124568770929992
  319. )
  320. )
  321. )(
  322. *(lambda _, __, ___: _(_, __, ___))(
  323. (lambda _, __, ___:
  324. [__(___[(lambda: _).func_code.co_nlocals])] +
  325. _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []
  326. ),
  327. lambda _: _.func_code.co_argcount,
  328. (
  329. lambda _: _,
  330. lambda _, __: _,
  331. lambda _, __, ___: _,
  332. lambda _, __, ___, ____: _,
  333. lambda _, __, ___, ____, _____: _,
  334. lambda _, __, ___, ____, _____, ______: _,
  335. lambda _, __, ___, ____, _____, ______, _______: _,
  336. lambda _, __, ___, ____, _____, ______, _______, ________: _
  337. )
  338. )
  339. )
  340. {% endhighlight %}
  341. ## Shifting bits
  342. Almost there! We'll replace the `n{1..8}` variables with `_`, `__`, `___`,
  343. `____`, etc., since it creates confusion with the variables used in our inner
  344. functions. This doesn't cause actual problems, since scoping rules mean the
  345. right ones will be used. This is also one of the reasons why we refactored
  346. `256` out to where `_` refers to `1` instead of our obfuscated `convert()`
  347. function. It's getting long, so I'll paste only the first half:
  348. {% highlight python linenos=table %}
  349. (lambda _, __, ___, ____, _____, ______, _______, ________:
  350. getattr(
  351. __import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
  352. ().__class__.__eq__.__class__.__name__[:__] +
  353. ().__iter__().__class__.__name__[_____:________]
  354. )(
  355. _, (lambda _, __, ___: _(_, __, ___))(
  356. lambda _, __, ___:
  357. chr(___ % __) + _(_, __, ___ // __) if ___ else
  358. (lambda: _).func_code.co_lnotab,
  359. 256,
  360. 802616035175250124568770929992
  361. )
  362. )
  363. )
  364. {% endhighlight %}
  365. Only two more things are left. We'll start with the easy one: `256`.
  366. <span>\\(256 = 2^8\\)</span>, so we can rewrite it as `1 << 8` (using a
  367. [left bit shift](//stackoverflow.com/a/141873)), or `_ << ________` with our
  368. obfuscated variables.
  369. We'll use the same idea with `802616035175250124568770929992`. A simple
  370. divide-and-conquer algorithm can break it up into sums of numbers which are
  371. themselves sums of numbers that are shifted together, and so on. For example,
  372. if we had `112`, we could break it up into `96 + 16` and then
  373. `(3 << 5) + (2 << 3)`. I like using bit shifts because the `<<` reminds me of
  374. `std::cout << "foo"` in C++, or
  375. [`print` chevron](//docs.python.org/2/reference/simple_stmts.html#the-print-statement)
  376. (`print >>`) in Python, both of which are red herrings involving other ways of
  377. doing I/O.
  378. The number can be decomposed in a variety of ways; no one method is correct
  379. (after all, we could just break it up into `(1 << 0) + (1 << 0) + ...`, but
  380. that's not interesting). We should have some substantial amount of nesting, but
  381. still use most of our numerical variables. Obviously, doing this by hand isn't
  382. fun, so we'll come up with an algorithm. In pseudocode:
  383. {% highlight text linenos=table %}
  384. func encode(num):
  385. if num <= 8:
  386. return "_" * num
  387. else:
  388. return "(" + convert(num) + ")"
  389. func convert(num):
  390. base = shift = 0
  391. diff = num
  392. span = ...
  393. for test_base in range(span):
  394. for test_shift in range(span):
  395. test_diff = |num| - (test_base << test_shift)
  396. if |test_diff| < |diff|:
  397. diff = test_diff
  398. base = test_base
  399. shift = test_shift
  400. encoded = "(" + encode(base) + " << " + encode(shift) + ")"
  401. if diff == 0:
  402. return encoded
  403. else:
  404. return encoded + " + " + convert(diff)
  405. convert(802616035175250124568770929992)
  406. {% endhighlight %}
  407. The basic idea here is that we test various combinations of numbers in a
  408. certain range until we come up with two numbers, `base` and `shift`,
  409. such that `base << shift` is as closest to `num` as possible (i.e. we minimize
  410. their absolute difference, `diff`). We then use our divide-and-conquer
  411. algorithm to break up `best_base` and `best_shift`, and then repeat the
  412. procedure on `diff` until it reaches zero, summing the terms along the way.
  413. The argument to `range()`, `span`, represents the width of the search space.
  414. This can't be too large, or we'll end getting `num` as our `base` and `0` as
  415. our `shift` (because `diff` is zero), and since `base` can't be represented as
  416. a single variable, it'll repeat, recursing infinitely. If it's too small, we'll
  417. end up with something like the `(1 << 0) + (1 << 0) + ...` mentioned above. In
  418. practice, we want `span` to get smaller as the recursion depth increases.
  419. Through trial and error, I found this equation to work well:
  420. <div>$$\mathit{span} = \lceil\log_{1.5} \lvert{\mathit{num}}\lvert\rceil + \lfloor2^{4-\mathit{depth}}\rfloor$$</div>
  421. Translating the pseudocode into Python and making some tweaks (support for the
  422. `depth` argument, and some caveats involving negative numbers), we get this:
  423. {% highlight python linenos=table %}
  424. from math import ceil, log
  425. def encode(num, depth):
  426. if num == 0:
  427. return "_ - _"
  428. if num <= 8:
  429. return "_" * num
  430. return "(" + convert(num, depth + 1) + ")"
  431. def convert(num, depth=0):
  432. result = ""
  433. while num:
  434. base = shift = 0
  435. diff = num
  436. span = int(ceil(log(abs(num), 1.5))) + (16 >> depth)
  437. for test_base in xrange(span):
  438. for test_shift in xrange(span):
  439. test_diff = abs(num) - (test_base << test_shift)
  440. if abs(test_diff) < abs(diff):
  441. diff = test_diff
  442. base = test_base
  443. shift = test_shift
  444. if result:
  445. result += " + " if num > 0 else " - "
  446. elif num < 0:
  447. base = -base
  448. if shift == 0:
  449. result += encode(base, depth)
  450. else:
  451. result += "(%s << %s)" % (encode(base, depth),
  452. encode(shift, depth))
  453. num = diff if num > 0 else -diff
  454. return result
  455. {% endhighlight %}
  456. Now, when we call `convert(802616035175250124568770929992)`, we get a nice
  457. decomposition:
  458. {% highlight pycon %}
  459. >>> convert(802616035175250124568770929992)
  460. (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __) - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______ << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) << ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) << __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______ << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) + _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ << _))) + (_____ << ______) + (_ << ___)
  461. {% endhighlight %}
  462. Stick this in as a replacement for `802616035175250124568770929992`, and put
  463. all the parts together:
  464. {% highlight python linenos=table %}
  465. (lambda _, __, ___, ____, _____, ______, _______, ________:
  466. getattr(
  467. __import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
  468. ().__class__.__eq__.__class__.__name__[:__] +
  469. ().__iter__().__class__.__name__[_____:________]
  470. )(
  471. _, (lambda _, __, ___: _(_, __, ___))(
  472. lambda _, __, ___:
  473. chr(___ % __) + _(_, __, ___ // __) if ___ else
  474. (lambda: _).func_code.co_lnotab,
  475. _ << ________,
  476. (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
  477. - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
  478. __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
  479. << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
  480. ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
  481. __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
  482. << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
  483. _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
  484. (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
  485. _))) + (_____ << ______) + (_ << ___)
  486. )
  487. )
  488. )(
  489. *(lambda _, __, ___: _(_, __, ___))(
  490. (lambda _, __, ___:
  491. [__(___[(lambda: _).func_code.co_nlocals])] +
  492. _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []
  493. ),
  494. lambda _: _.func_code.co_argcount,
  495. (
  496. lambda _: _,
  497. lambda _, __: _,
  498. lambda _, __, ___: _,
  499. lambda _, __, ___, ____: _,
  500. lambda _, __, ___, ____, _____: _,
  501. lambda _, __, ___, ____, _____, ______: _,
  502. lambda _, __, ___, ____, _____, ______, _______: _,
  503. lambda _, __, ___, ____, _____, ______, _______, ________: _
  504. )
  505. )
  506. )
  507. {% endhighlight %}
  508. And there you have it.