UPX 教程

原文:http://blog.csdn.net/mengyafei43/article/details/22887649

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 目标文件] 源文件..下面我们以UPX 1.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 compress better
   -d     decompress                      -l list compressed 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 write output 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 <A href=http://upx.tsx.org>http://upx.tsx.org
可通过带 -h 命令参数,获取更详细的帮助:
复制内容到剪贴板
代码:
C:\>UPX -h

                  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 compress better
   --best compress best (can be very slow for big files)
   -d     decompress                      -l list compressed 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 write output 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 a file with an overlay
   --overlay=copy    copy any extra data 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 no relocations 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 LE output [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 compress any icons
   --compress-icons=1    compress all but the first icon
   --compress-icons=2    compress all but the 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 <A href=http://upx.tsx.org>http://upx.tsx.org
常用操作
二、压缩可执行文件:
复制内容到剪贴板
代码:
C:\>UPX sample.exe
                  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

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


                  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

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

Packed 1 file.
压缩文件可使用命令参数-1~-9来控制压缩速度及压缩率,数字越小压缩速度越快,数字越大压缩率越大。使用--best命令参数将获得最大的压缩率,但其压缩速度也是最慢的。压缩过程将以动态方式显示,压缩完毕将给出压缩前后的文件大小,压缩率,文件格式及名称。
三、解压缩可执行文件:
复制内容到剪贴板
代码:
C:\>UPX -d sample.exe
                  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

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

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

                  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

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

                  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

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 Packer for 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 be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值