forked from upx/upx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.SRC
145 lines (93 loc) · 4.16 KB
/
README.SRC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
The UPX Hacker's Guide
======================
Foreword
--------
The precompiled UPX versions are linked against the NRV compression
library instead of the UCL library. Using the same compression algorithms,
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
Introduction
------------
Welcome to the UPX source code release!
UPX is not a toy for kids. Apart from basic knowledge about executables
and data compression you will need to be firm in C++, assembler,
Perl and Makefiles. Probably some other things as well.
If you can't manage to compile it then the sources are
probably not for you. Don't email us for help.
The authors use Linux for development. You might want to as well.
Short overview
--------------
The UPX source code consists of two mainly independent parts:
1) The src/stub directory contains the decompression stubs that
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.
Prerequisites
-------------
- first of all you need to build the UCL compression library
http://www.oberhumer.com/opensource/ucl/
Use "CC=gcc -std=gnu89" especially with gcc-6.3 and gcc-7.1.
To build for native aarch64 (64-bit ARM) the files config.guess
and config.sub must be updated according to the recipe at
https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
Tools needed to build/modify the UPX sources
--------------------------------------------
- A C++ compiler: gcc >= 3.3 or clang.
- GNU make 3.81 or better
- zlib and zlib-devel [or zlib-dev] software packages for your
host environment
- LZMA SDK from https://github.com/upx/upx-lzma-sdk
When using git run 'git submodule update --init --recursive'.
To compile the packer sources
-----------------------------
Set the environment variable UPX_UCLDIR to point to your
UCL build directory, e.g.
set UPX_UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
export UPX_UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
Finally type
make
If you want to modify the stub sources you'll also need
-------------------------------------------------------
- Perl & Python
- upx-stubtools - a number of cross-assemblers and cross-compilers.
Precompiled binaries for i386-linux hosts are available from
https://github.com/upx/upx-stubtools/releases
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:
- 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.
***
Patches/Contributions
- Please send us bug fixes/contributions only using
diff -u oldfile newfile
or
diff -uNr olddirectory newdirectory
# vim:set ts=4 sw=4 et: