7 ms·
Movfuscator: Compile C into only mov instructions
- nickysielicki 6y agoThis paper (`mov` is Turing Complete) [1] and this StackOverflow post [2] about why this is possible is probably more interesting to most people than the actual implementation. [1]: https://drwho.virtadpt.net/files/mov.pdf https://drwho.virtadpt.net/files/mov.pdf [2]: https://stackoverflow.com/questions/61048788/why-is-mov-turing-complete https://stackoverflow.com/questions/61048788/why-is-mov-turi...
- nroets 6y agoThe idea a create a CPU with only one instruction is much older. I recall that Professor Van Der Poel of Deft University did it in the 1960s. A decrement-and-jump-if-non-zero instruction.
- musicale 6y agoAs in some examples that I think were posted recently on HN, you can make a simple multi-cycle "CPU" based entirely on lookup tables (and possibly a bit of SRAM for storage.)
- dieortin 6y agoYou can create any arbitrary logic using LUTs. That’s how FPGAs work.
- vincent-manis 6y agoThe IBM 1620 (early 1960s) did integer arithmetic entirely with lookup tables. Clearing memory without reloading the lookup tables resulted in a machine that was bereft of arithmetic.
- schoen 6y agoWow! Could it conceivably re-derive them "experimentally" with nested loops or something?
- bogomipz 6y agoThis sounds interesting. Does anyone have a link to these posts or similar?
- jsnell 6y agoThe canonical repo is at https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator Previous submissions with significant discussion: - https://news.ycombinator.com/item?id=18991404 https://news.ycombinator.com/item?id=18991404 - https://news.ycombinator.com/item?id=16218872 https://news.ycombinator.com/item?id=16218872 - https://news.ycombinator.com/item?id=12372242 https://news.ycombinator.com/item?id=12372242 - https://news.ycombinator.com/item?id=10021259 https://news.ycombinator.com/item?id=10021259 - https://news.ycombinator.com/item?id=9751312 https://news.ycombinator.com/item?id=9751312
- grawprog 6y agoFrom the top link: https://news.ycombinator.com/item?id=18992556 https://news.ycombinator.com/item?id=18992556 >The mov-only DOOM renders approximately one frame every 7 hours, so playing this version requires somewhat increased patience. https://github.com/xoreaxeaxeax/movfuscator/tree/master/validation/doom https://github.com/xoreaxeaxeax/movfuscator/tree/master/vali... I have to say, reading through the github for the movfuscator was pretty damn amusing. I honestly burst out laughing at the control flow graphs. But I'm curious, is this actually practical for anything? Running Doom at 1 Frame per 7 hours is, pretty unreasonable. Would text based software even be usable with this? Either way, I do enjoy cleverly, overly engineered, possibly useless things created just because someone thought it would be funny.
- oddlama 6y agoThere also is the demovfuscator (https://github.com/kirschju/demovfuscator https://github.com/kirschju/demovfuscator) which does the opposite and is capable of recovering the control-flow of the original program before movfuscation.
- throwamon 6y ago(Disclaimer: I know exactly zero things about reverse engineering, so this is probably a very stupid question. Read at your own peril.) Could this be helpful in reverse engineering binaries by first movfuscating and then demovfuscating them? My hypothesis is that movfuscation (maybe coupled with some other techniques) might “normalize” the program in some way and demovfuscation might recover some more human-understandable structures. Or would demovfuscation just bring back the same original obfuscated mess?
- notorandit 6y agoMovfuscating works from source code, not compiled binary.
- ashton314 6y agoThe control flow graph section of the README is my favorite part. Is there some thing like the lambda calculus that corresponds to this? I.e., the Turing completeness of a single instruction?
- schoen 6y agoThere's apparently a whole field about this: https://en.wikipedia.org/wiki/One-instruction_set_computer https://en.wikipedia.org/wiki/One-instruction_set_computer (I don't know what's known about how to tell whether or not a particular instruction will be Turing complete. Maybe, as in many other parts of computer science, you can do it by reductions: FOO is Turing complete if you can implement BAR with it, where BAR is already known to be Turing complete; BAZ is not Turing complete if you can implement it with QUX, where QUX is already known not to be Turing complete?)
- userbinator 6y agoI think the most interesting thing about this is the "other architectures" section, where it shows how this technique is applicable to any architecture with nothing more than "mov reg, [reg+const]" (where const can be 0) and "mov [reg+const], reg" --- making it usable on all the major "big" ISAs like x86, ARM (32 and 64-bit), MIPS/RISC-V, etc. as well as some microcontrollers like the Z80.
- vincent-manis 6y agoThis is impressive, on the order of building a working rapid transit system entirely out of q-tips.
- rambojazz 6y agoI would like to see a performance comparison with normal GCC output.
- rataata_jr 6y agoI think there is a doom comparison, is it 1 frame every 6 hours? I can't remember.
- notorandit 6y agoDoom is not a good comparison as it presumably uses a lot of floating point.
- sitkack 6y agoDoom uses fixed point arithmetic [1] Quake was the first Id game to use floating point and why other chips like Cyrix which had poor floating point units, suffered as a result. https://doomwiki.org/wiki/Fixed_point https://doomwiki.org/wiki/Fixed_point
- deleted 6y ago[deleted]
- totetsu 6y agoDEF CON 23 - Chris Domas talk on this https://www.youtube.com/watch?v=HlUe0TUHOIc https://www.youtube.com/watch?v=HlUe0TUHOIc previously on hn https://news.ycombinator.com/item?id=12372242 https://news.ycombinator.com/item?id=12372242
- bogomipz 6y agoIn the overview section the author states: >"... there is no self-modifying code, no transport-triggered calculation, and no other form of non-mov cheating." Could someone say what is meant by "transport-triggered calculation"? Also how does "self-modifying code" work in the context of such constraints exactly? I had a look through the "mov is Turing-complete" paper referenced in this README but didn't come across these.
- iggldiggl 6y agoI guess something like the Wireworld computer? (https://www.quinapalus.com/wires10.html https://www.quinapalus.com/wires10.html – another fascinating topic, by the way…) That one only uses MOVs, too, but the simulated CPU has a number of special registers implementing a number of basic operations, so instead of having to manually implement them the hard way using only MOVs (which in the particular case of the wireworld computer probably wouldn't even be possible due to its constrained resources and architecture), you can "cheat" by simply MOVing your operands into the respective special registers and then reading the result.
- bogomipz 6y agoThanks for the Wireworld link. This is indeed fascinating. Cheers.