I want just to add a quick receipt about qemu-user and ptrace.
Start qemu-binfmt service on the host to register qemu-user binaries.
Use buildah to create amd64 container.
Install latest qemu inside this amd64 container, kernel will use them instead of host.
Build some toolchain inside amd64 container.
Use regular strace to trace your binaries.
In this particular case, repairing the header can be automated. Since the section header string table is present, the original value of e_shnum can be found by counting the number of strings in the table.
$ readelf -h hello
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
One approach to solving the challenge:
readelf -SW was used to look at 2 small baseline binaries: a simple "hello world"-style ELF binary and the cat utility. This provided a frame of reference for how GCC organizes information in a binary.
Hex dumps of the fragments were then compared to a hex dump of these 2 programs.
Areas of particular importance ...