UPX 使用教程

说到压缩,大家可能首先想到的是WinRAR和WinZIP之类的压缩软件,但是肯定都没听说过UPX。如果你是一个对程序占用空间斤斤计较的人,那么UPX压缩可以很好的解决你的一些问题,当然,首先我需要先给一些不懂UPX是什么的同学补补课。

UPX是什么?

可以理解成压缩软件,不过他只对可执行文件进行压缩(如EXE文件),当然也有人把他叫壳,即为软件各程序加个壳。

通俗点说,就是UPX仅仅可以用来压缩EXE文件,而且压缩后的EXE文件还可以无需解压缩直接运行的,怎么样,很棒吧?

UPX压缩和未压缩文件的区别?

压缩过的可执行文件,虽然节约了点空间并且可以直接运行,不过运行的时候需要在内存进行解压,所以压缩过的文件比未压缩过的文件稍慢(理论上是这样,但一般情况下人是感觉不出这个慢的)。

UPX压缩的用途

主要是写程序的朋友,当然也有一些黑客喜欢使用UPX加壳来躲避杀毒软件的查杀。

UPX是一个通用可执行文件压缩器,由于其具有:

  • 压缩率高:压缩效果优于zip/gzip;
  • 解压速度快:在奔腾133上即可达到大约10MB/秒;
  • 压缩的可执行文件没有额外的内存开销;
  • 安全:可以列表,检测和解压可执行文件,压缩和解压缩文件内部都维持有一个校验和;
  • 广域:可以压缩多种可执行文件格式:
    • dos/exe
    • dos/sys
    • dos/com
    • djgpp2/coff
    • watcom/le ( 支持DOS4G, PMODE/W, DOS32a 和 CauseWay )
    • win32/pe
    • rtm32/pe
    • tmt/adam
    • linux/386
    • atari/tos
  • 免费
等特性,因此其也成为我们在压缩可执行文件时的首选工具。
UPX是一个控制台应用程序,以命令行方式进行操作,其使用是极其简单的:
upx [-命令] [-选项] [-o 目标文件] 源文件..下面我们以UPX1.07W为例,具体讲解其使用方法。默认情况下,UPX将直接对源文件进行操作,但也可指定目标文件,而不覆盖源文件,文件名支持通配符,即一次可对多个文件进行同一操作。
一、显示 UPX 通用信息(版权信息,使用说明等),在命令行直接输入 UPX 并回车。
复制内容到剪贴板
代码:
C:\>UPX
         Ultimate Packer for eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

Usage: upx [-123456789dlthVL] [-qvfk] [-o file] file..

Commands:
   -1   compress faster            -9 compressbetter
  -d    decompress                -l listcompressed file
   -t   test compressed file         -V display version number
   -h   give more help              -L display software license
Options:
   -q   be quiet                  -v be verbose
   -oFILE writeoutput to `FILE'
   -f   force compression of suspicious files
   -k   keep backup files
   file..executables to (de)compress

This version supports: dos/exe, dos/com, dos/sys, djgpp2/coff,watcom/le,
               win32/pe, rtm32/pe, tmt/adam, atari/tos, linux/386

UPX comes with ABSOLUTELY NO WARRANTY; for details visit<Ahref=http://upx.tsx.org>http://upx.tsx.org
可通过带 -h 命令参数,获取更详细的帮助:
复制内容到剪贴板
代码:
C:\>UPX -h

             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

Usage: upx [-123456789dlthVL] [-qvfk] [-o file] file..

Commands:
   -1   compress faster            -9 compressbetter
   --best compressbest (can be very slow for big files)
   -d   decompress                -l listcompressed file
   -t   test compressed file         -V display version number
   -h   give this help              -L display software license

Options:
   -q   be quiet                  -v be verbose
   -oFILE writeoutput to `FILE'
   -f   force compression of suspicious files
   --no-color,--mono, --color, --no-progress change look

Backup options:
   -k, --backup     keep backup files
   --no-backup     no backup files[default]

Overlay options:
   --overlay=skip   don't compress afile with an overlay
   --overlay=copy   copy any extradata attached to the file [default]
   --overlay=strip   strip any extra data attached to the file [dangerous]

Options for dos/exe:
   --8086         make compressed exe work on any 8086
   --no-reloc     put norelocations in to the exe header

Options for dos/com:
   --8086         make compressed com work on any 8086

Options for dos/sys:
   --8086         make compressed sys work on any 8086

Options for djgpp2/coff:
   --coff         produce COFF output [default: EXE]

Options for watcom/le:
   --le         produce LEoutput [default: EXE]

Options for win32/pe & rtm32/pe:
  --compress-exports=0 do not compress the export section
  --compress-exports=1 compress the export section [default]
  --compress-icons=0   do not compressany icons
  --compress-icons=1   compress all butthe first icon
  --compress-icons=2   compress all butthe first icon directory [default]
  --compress-resources=0  do not compress any resources at all
   --strip-relocs=0     do not strip relocations
   --strip-relocs=1     strip relocations [default]

   file..executables to (de)compress

This version supports: dos/exe, dos/com, dos/sys, djgpp2/coff,watcom/le,
               win32/pe, rtm32/pe, tmt/adam, atari/tos, linux/386

UPX comes with ABSOLUTELY NO WARRANTY; for details visit<Ahref=http://upx.tsx.org>http://upx.tsx.org
常用操作
二、压缩可执行文件:
复制内容到剪贴板
代码:
C:\>UPX sample.exe
             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

     File size      Ratio   Format   Name
-------------------- ------ ----------- -----------
Compressing sample.exe [win32/pe]
[*****************************...................................]45.8%   |


             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

     File size      Ratio   Format   Name
-------------------- ------ ----------- -----------
341504 -> 142336 41.67% win32/pe   sample.exe

Packed 1 file.
压缩文件可使用命令参数-1~-9来控制压缩速度及压缩率,数字越小压缩速度越快,数字越大压缩率越大。使用--best命令参数将获得最大的压缩率,但其压缩速度也是最慢的。压缩过程将以动态方式显示,压缩完毕将给出压缩前后的文件大小,压缩率,文件格式及名称。
三、解压缩可执行文件:
复制内容到剪贴板
代码:
C:\>UPX -dsample.exe
             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

     File size      Ratio   Format   Name
-------------------- ------ ----------- -----------
341504 <- 142336 41.67% win32/pe   sample.exe

Unpacked 1 file.
四、列表
复制内容到剪贴板
代码:
C:\>UPX -lsample.exe

             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

     File size      Ratio   Format   Name
-------------------- ------ ----------- -----------
341504 -> 142336 41.67% win32/pe   sample.exe
五、 测试压缩过的可执行文件
复制内容到剪贴板
代码:
C:\>UPX -tsample.exe

             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

testing sample.exe [OK]

Tested 1 file.
其它操作
六、显示版本号:
复制内容到剪贴板
代码:
C:\>UPX -V

upx 1.07
NRV data compression library 0.81
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2001 Laszlo Molnar
UPX comes with ABSOLUTELY NO WARRANTY; for details type `upx-L'.
七、显示软件许可声明: 复制内容到剪贴板
代码:
C:\>UPX -L

             Ultimate Packerfor eXecutables
       Copyright (C)1996, 1997, 1998, 1999, 2000, 2001
UPX 1.07w      Markus F.X.J. Oberhumer & Laszlo Molnar     Feb 20th 2001

This program may be used freely, and you are welcome to
redistribute it under certain conditions.

This program is distributed in the hope that it will beuseful,
but WITHOUT ANY WARRANTY; without even the implied warrantyof
MERCHANTABILITY or FITNESS FOR A PARTICULARPURPOSE.   Seethe
UPX License Agreement for more details.

You should have received a copy of the UPX License Agreement
along with this program; see the file LICENSE.
If not, visit one of the following pages:

     http://upx.tsx.org
     http://www.oberhumer.com/upx/
     http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值