Personal website https://benkurtovic.com/
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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

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