2000-05-20 00:04:55 +08:00
|
|
|
The UPX Hacker's Guide
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
|
|
Foreword
|
|
|
|
--------
|
|
|
|
|
|
|
|
The precompiled UPX versions are linked against the NRV compression
|
2000-12-12 11:44:19 +08:00
|
|
|
library instead of the UCL library. Using the same compression algorithms,
|
2000-05-20 00:04:55 +08:00
|
|
|
NRV achieves a better compression ratio. NRV is not publicly
|
|
|
|
available, though, and probably never will be.
|
|
|
|
|
|
|
|
While you may be disappointed that you don't have access to the
|
|
|
|
latest state-of-the-art compression technology this is actually
|
|
|
|
a safe guard for all of us. The UPX source code release makes
|
|
|
|
it very easy for any evil-minded person to do all sort of bad
|
|
|
|
things. By not providing the very best compression ratio it is much
|
|
|
|
more difficult to create fake or otherwise disguised UPX versions (or
|
|
|
|
similar trojans), as any end user will notice when the compression
|
|
|
|
has gotten worse with a new "version" or "product".
|
|
|
|
|
|
|
|
Finally please be aware that you now have your hands on the source
|
|
|
|
code of the most sophisticated executable packer ever.
|
|
|
|
Let's join our forces to make it even better :-)
|
|
|
|
|
|
|
|
Share and enjoy,
|
|
|
|
Markus & Laszlo
|
|
|
|
|
|
|
|
|
|
|
|
Short overview
|
|
|
|
--------------
|
|
|
|
|
|
|
|
The UPX source code consists of two mainly independent parts:
|
|
|
|
|
2000-12-12 11:44:19 +08:00
|
|
|
1) The src/stub directory contains the decompression stubs that
|
2000-05-20 00:04:55 +08:00
|
|
|
will get added to each compressed executable.
|
|
|
|
The stubs are mainly written in assembler and get "compiled"
|
|
|
|
into ordinary C header files.
|
|
|
|
|
|
|
|
2) The src directory contains the actual packer sources. The stubs
|
|
|
|
are #included by the individual executable format handlers.
|
|
|
|
|
|
|
|
|
|
|
|
Tools needed to build/modify the UPX sources
|
|
|
|
--------------------------------------------
|
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- A C++ compiler that supports C++ 14: clang, gcc or msvc
|
2000-05-20 00:04:55 +08:00
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- GNU make
|
2000-05-20 00:04:55 +08:00
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- CMake 3.13 or better; see https://cmake.org/
|
2012-07-17 06:22:22 +08:00
|
|
|
|
2000-05-20 00:04:55 +08:00
|
|
|
|
|
|
|
To compile the packer sources
|
|
|
|
-----------------------------
|
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- just run "make" in the top-level source directory
|
2000-05-20 00:04:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
If you want to modify the stub sources you'll also need
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- a Linux host system
|
2006-06-15 23:52:30 +08:00
|
|
|
|
2016-09-20 04:41:32 +08:00
|
|
|
- upx-stubtools - a number of cross-assemblers and cross-compilers.
|
2022-08-23 08:32:31 +08:00
|
|
|
Precompiled binaries for amd64-linux hosts are available from
|
2016-09-20 04:41:32 +08:00
|
|
|
https://github.com/upx/upx-stubtools/releases
|
2006-01-23 15:01:54 +08:00
|
|
|
|
2022-08-23 08:32:31 +08:00
|
|
|
- Perl & Python2
|
|
|
|
|
|
|
|
- NOTE: also see misc/rebuild-stubs-with-podman
|
|
|
|
|
2000-05-20 00:04:55 +08:00
|
|
|
|
|
|
|
Misc. notes
|
|
|
|
-----------
|
|
|
|
|
|
|
|
As the docs say: UPX is a portable, extendable and endian neutral
|
|
|
|
program, so if you want to add some new stuff, try not to break these
|
|
|
|
nice properties.
|
|
|
|
|
|
|
|
- Use the types LE16, LE32, BE16 and BE32 for fields in file headers.
|
|
|
|
- Use [sg]et_[bl]e(16|32) for getting/setting values in the data
|
|
|
|
stream.
|
|
|
|
- Use gcc extensions and other compiler specific stuff only through
|
|
|
|
macros.
|
|
|
|
|
|
|
|
|
|
|
|
Some conventions:
|
2022-08-23 08:32:31 +08:00
|
|
|
-----------------
|
2000-05-20 00:04:55 +08:00
|
|
|
|
|
|
|
- follow our coding style
|
|
|
|
- indent level = 4
|
|
|
|
- expand all tabulators
|
|
|
|
|
|
|
|
- Use throwSomeException() functions instead of throw SomeException():
|
|
|
|
this makes the code shorter if used often.
|
|
|
|
|
2016-09-23 00:17:37 +08:00
|
|
|
# vim:set ts=4 sw=4 et:
|