Personal website https://benkurtovic.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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

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