Autor Tema: Como compilar el compresor de ejecutables UPX  (Leído 1294 veces)

Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9577
Como compilar el compresor de ejecutables UPX
« en: 04 de Enero de 2021, 04:22:20 pm »
https://upx.github.io/

https://github.com/upx/upx

UPX is a free, portable, extendable, high-performance executable packer for several executable formats.

UPX achieves an excellent compression ratio and offers very fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression. UPX strengths in a nutshell:

excellent compression ratio: typically compresses better than WinZip/zip/gzip, use UPX to decrease the size of your distribution!
very fast decompression: ~10 MB/sec on an ancient Pentium 133, ~200 MB/sec on an Athlon XP 2000+.
no memory overhead for your compressed executables because of in-place decompression.
safe: you can list, test and unpack your executables. Also, a checksum of both the compressed and uncompressed file is maintained internally.
universal: UPX can pack a number of executable formats.
portable: UPX is written in portable endian-neutral C++.
extendable: because of the class layout it's very easy to add new executable formats or new compression algorithms.
free: UPX is distributed with full source code under the GNU General Public License v2+, with special exceptions granting the free usage for commercial programs as stated in the UPX License Agreement.
You probably understand now why we call UPX the "Ultimate Packer for eXecutables".


Llevo usándolo desde 1996  :fuckyeah:

Adjunto script y binario compilado x86_64

NO GIT VERSION SCRIPT
Código: [Seleccionar]
#
# upx/ucl bash compiler no git version and no zlib1g-dev deps
# by KAPITALSIN B23092021
#
# SCRIPT TESTED UNDER LINUX MINT 19.3 x85_64 GLIBC 2.27 AND ARCOLINUX GLIBC 2.33 x86_64 
#
# NO GIT VERSION
#
# B23092021
# Added -N to wget
# Modified the command "cp -r lib/* ../../ucl-1.03/src/.libs/"
# Minor changes strip and renaming the compiled upx
#
sudo apt-get install libtool g++
wget -N https://github.com/upx/upx/releases/download/v3.96/upx-3.96-src.tar.xz
tar xvfa upx-3.96-src.tar.xz
cd upx-3.96-src
wget -N https://github.com/upx/upx-lzma-sdk/archive/refs/heads/master.zip -O lzmasdk.zip
unzip lzmasdk.zip && rm lzmasdk.zip
mv upx-lzma-sdk-master lzma

wget -N http://www.oberhumer.com/opensource/ucl/download/ucl-1.03.tar.gz
tar xvfa ucl-1.03.tar.gz && rm  ucl-1.03.tar.gz
cd ucl-1.03
export CPPFLAGS="$CPPFLAGS -std=c90 -fPIC"
./configure  --enable-static  --disable-shared
unset CPPFLAGS
make -j$(nproc)
export UPX_UCLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ../src

wget -N https://fossies.org/linux/misc/zlib-1.2.11.tar.xz
tar xvfa zlib-1.2.11.tar.xz && rm zlib-1.2.11.tar.xz
cd zlib-1.2.11
./configure --static --prefix=$PWD
make -j4 install
cp zconf.h zlib.h   ../../ucl-1.03/src/
cp zconf.h zlib.h   ../../ucl-1.03/include
cp -r lib/* ../../ucl-1.03/src/.libs/
cd ..


sed -i 's/$(CHECK_WHITESPACE)//g' Makefile
rm -rf lzma-sdk
cp -r ../lzma lzma-sdk
make -j$(nproc) LDFLAGS="--static"
strip upx.out
mv upx.out ../../upx.396.bin
unset UPX_UCLDIR

GIT VERSION SCRIPT
Código: [Seleccionar]
#
# upx/ucl bash compiler
# by KAPITALSIN 2o21 B11092021
#
# B11092021
# ADDED DEPENDENCIES FOR BETTER COMPILATION
#
sudo apt-get install git zlib1g-dev libtool g++

git clone https://github.com/upx/upx.git
cd upx
git submodule update --init --recursive
wget http://www.oberhumer.com/opensource/ucl/download/ucl-1.03.tar.gz
tar xvfa ucl-1.03.tar.gz
cd ucl-1.03
export CPPFLAGS="$CPPFLAGS -std=c90 -fPIC"
./configure  --enable-static  --disable-shared
unset CPPFLAGS
make -j$(nproc)
export UPX_UCLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ../src
sed -i 's/.out/.git-$(UPX_VERSION_GITREV).bin/g' Makefile
make -j$(nproc) LDFLAGS="--static"
unset UPX_UCLDIR
strip upx.*.bin && ./upx*.bin --ultra-brute upx*.bin
mv upx*.bin ..
Siempre que pasa igual sucede lo mismo



Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9577
Re:Como compilar el compresor de ejecutables UPX
« Respuesta #1 en: 11 de Septiembre de 2021, 01:25:11 pm »
Mejorados los script, ahora se puede escoger que versión se quiere compilar, si la del GIT o la oficial, aparte se han mejorado y son 100% user-debian/buntu/mint...friendly, es decir que haces doble click al .sh y lo hace todo solo mientras que en las versiones previas tenias de buscar que dependéncia se requeria e instalarla

Se ha testeado bajo una Mint 19.3 Cinnnamon reciendo instalada y tambien bajo ARCOLinux, para este último los usuarios tienen de instalar la dependéncias manualmente, es decir, [git, llibtool, g++] en caso de que no esten ya en el sistema
Siempre que pasa igual sucede lo mismo



Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9577
Re:Como compilar el compresor de ejecutables UPX
« Respuesta #2 en: 23 de Febrero de 2022, 04:58:08 pm »
Creado binarios de 32 bits compilados con MUSLC bajo Void Linux (x86) , te ahorras unos 200kb's  :ok:  es 100% funcional con cualquier distro ya que son binarios estáticos.
Siempre que pasa igual sucede lo mismo



Fl0ppy

  • Administrador
  • Usuario Héroe
  • *****
  • Mensajes: 9577
Re:Como compilar el compresor de ejecutables UPX
« Respuesta #3 en: 27 de Febrero de 2022, 06:43:34 pm »
Creada versión NO GIT, es decir, la 3.96, de 64 bits con muslc y parámetro -Os de compilación reduciendo el tamaño unos 59 KB.
Siempre que pasa igual sucede lo mismo