What's in a Linux Executable?
fasterthanli.me
fasterthanli.me
LD_PRELOAD=<ELF> /bin/true
The constraint being the ELF needed to be less than 196 bytes so obviously it could not be created by gcc. In the end I could not believe it ran, considering the amount of hacks that I had to do to trim it to 193 bytes.
https://github.com/TeamGreyFang/CTF-Writeups/tree/master/Pla...
Glad I wasn't the only one! When I was a kid, I had tried several times to somehow create executables myself, without knowing how to program. Long after the failures I had suffered from, I discovered I could make an executable using so-called "programming". I still can't forget the time I created a Hello World executable for the first time. It was a gorgeous experience. Good times.
I remember being super puzzled when I tried that with a .exe and it didn't work
Hyperspeed was an interesting one. The crack that comes with the Steam version doesn't actually work since it triggers a lockup the first time you use the spindrive, so players just disable the crack and play the game normally with a PDF manual. I spent a long time trying to bypass that copy protection screen and all the checks to see if I'd bypassed it, but every time I thought I'd finally nailed it I ran into a new place the game would intentionally lock up. Ultimately I just truncated the word match table to a single entry so the word would always be the same. That was a single-byte change.
I looked at DOS .exe (NE? or was that the format for Win 3.1...) format too. Still relatively simple. Then came the PE which was super complicated.
As a teenager who didn't know any better, it was empowering to gain that level of access to a computer, to realize a certain level of control over it that was previously abstracted away. It felt like some insider knowledge that I was becoming aware of.
Somehow a lost experience in today's hardware.
https://fasterthanli.me/content/series/making-our-own-execut...
Comments below already figured out the rotate-hue trick :)
Styling inside the SVG is possible... if the SVG is inline, and not in an `<img>` tag. Also, it would be really hard to target which elements to style, as draw.io does not really give you classes for each color family.
Oh also, I have a whole .drawio => .pdf => .svg => optimized .svg pipeline so you can just save the .svg and not worry about having the fonts. (But also the svg no longer contains the text itself — it's a trade-off).
I thought about going the "declarative / adhoc tool" way but I make lots of different diagram types, so I would probably spend forever bikeshedding it instead of writing the actual article.
Also worth checking is GLE. https://glx.sourceforge.io/index.html
> What’s the structure behind: usr/, bin/ etc/ lib/ and moving those to usr/local
A brief resume of the filesystem structure purposes is documented in "man hier" in any non stripped down linux (or online).
When you compile source code to binary format, there is a default PREFIX (i.e. /usr). So libraries will be installed to /usr/lib and binaries to /usr/bin...
Build systems, let you change such PREFIX, so you can build a program telling it to live under /usr/local, or any other root directory like /opt/myprog-version...
Then. if you build another program, that depends on the libraries of the previous program, you may need to tell where to locate such libraries if they are not in the default place, each program build flags may vary, but for example in ruby you can pass it to ./configure --with-openssl-dir=/opt/myopenssl-X.Y
For a description of the directories, see: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Note that these directories do not actually have many hard and fast rules... while you can't change /proc, you can argue all you like over whether something goes in /bin or /sbin, or argue whether it should go in /usr. There are a ton of differences in the details.
https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-AMD6...
Those are good places to refer to when unsure.
Distros mostly keep to this, but they implement their own details and you should look into each distribution to know exactly what goes on in any particular one.
For user applications the XDG Base Directory specification is also useful https://specifications.freedesktop.org/basedir-spec/basedir-...
The links lead directly into the POSIX documents, which can be quite handy when you write shell scripts, because there you can read which options should be the same on every POSIX compliant OS.
It's insecure and it's very prone to error on Linux. There's almost always a better way (and anyone who says differently is probably trying to sell something to someone.)
There is, in fact, no de jure standard for the ELF binary format. It is, however, pretty much a universal standard format for executable, dynamic shared object, and partially-linked compiled file format used on every platform except Apple and Microsoft systems.
In a pinch, the uClibc website will do: https://uclibc.org/docs/psABI-x86_64.pdf
Bloaty McBloatface.
https://github.com/corkami/pics
Here are Windows and Linux executables:
https://raw.githubusercontent.com/corkami/pics/master/binary...
https://raw.githubusercontent.com/corkami/pics/master/binary...
Like most things written by fasterthanlime, it will take more than an hour to read.
It's all custom now, and closed source, since I want to focus on writing rather than maintaining an OSS project that fits everyone's needs
Other executable formats, for instance, support multiple architectures per file. Why does Linux not?
My favourite use for this feature is via `qemu-user-static`, which allows you to transparently "run" executables compiled for other architectures thanks to QEMU emulation. Very handy for embedded systems development.
If the kernel has the bin_fmt mod loaded, it can also recognize other binary formats before falling back to /bin/sh.