3 ms·
My team is working on this problem in the context of creating Node.js single-executable applications. While the naive approach of just appending data at the end
by jviotti 4y ago
My team is working on this problem in the context of creating Node.js single-executable applications. While the naive approach of just appending data at the end of the binary works, it is not friendly with code-signature in macOS and Windows given that signing operates on PE and Mach-O sections.
We have recently open-sourced a small tool called Postject (https://github.com/postmanlabs/postject https://github.com/postmanlabs/postject), which is able to inject arbitrary data as proper ELF/Mach-O/PE sections for all major operating systems (with AIX support coming). The tool also provides C/C++ cross-platform headers for easily traversing the final binary and introspect whether the segment is present or not.
The tool is based on the LIEF (https://github.com/lief-project/LIEF https://github.com/lief-project/LIEF) project.
At Postman, we are making use of this on our custom Node.js single-executable applications and soon on our custom Electron.js builds too.
- CMCDragonkai 4y agoDo you have a full example somewhere or using postject. We are currently using vercel/pkg and it is quite opaque.
- jviotti 4y agoThe full example is sadly closed-source for now. That said, we are closely collaborating with the maintainer of PKG as part as the Node.js SEA initiative, and we hope to be kickstarting an experiment on refactoring PKG to use Postject pretty soon.