20 ms·
Justine Tunney's APE (actually portable executables) exploits, er, makes use of, the fact that a shebang isn't required to run a shell script. The single execu
by TimTheTinker 4y ago
Justine Tunney's APE (actually portable executables) exploits, er, makes use of, the fact that a shebang isn't required to run a shell script.
The single executable file generated by the Cosmopolitan linker creates an insane polyglot binary executable that runs on 6 operating systems as well as on bare metal (i.e. bootable as its own OS); in addition, it's a valid Zip archive, and you can modify files inside it using any zip utility... fascinating stuff. On Linux, it bootstraps execution initially as a shell script, but the shell script writes the "ELF" file header and executes it (I'm probably doing a horrible job of explaining though).
https://justine.lol/ape.html https://justine.lol/ape.html
If you're interested in learning more, this talk from 2021 is fascinating: https://www.youtube.com/watch?v=1ZTRb-2DZGs https://www.youtube.com/watch?v=1ZTRb-2DZGs. It covers Redbean, a portable, run-anywhere web server built with the APE toolchain; since then Redbean 2 has been released, which adds a lot more features. Here's a link to Redbean: https://redbean.dev/ https://redbean.dev/
- easrng 4y agoIf you want a simpler polyglot, here's a sh/bat to get you started: REM=;echo hello from sh;exit# echo hello from cmd