惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 黄彬子

【转】Go语言:编译后文件体积过大解决方案 Go语言获取路径的文件名、后缀 go - 如何将gin模式设置为release模式? 【Golang学习】SVG图片的生成 【Golang标准库】flag 【Golang踩过的坑】exported function Script should have comment or be unexported wget配置文件的使用:代理设置与不检查证书 Rust Crates 源使用帮助 2020大风口!什么是图神经网络?有什么用?终于有人讲明白了 2020必火的图神经网络(GNN)是什么?有什么用? 【每天学习一点点】Tensorflow 版本与CUDA版本 【每天学习一点点】使用plot_model绘制网络模式失败 【每天学习一点点】keras cifar10.load_data()自己下载数据 【每天学习一点点】Tensorflow2.X 运行问题:Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED 【每天学习一点点】mxnet 版本运行失败问题 【每天学习一点点】Tensorflow GPU与CPU版本 【每天学习一点点】不再显示I信息(Tensorflow GPU) 【每天学习一点点】numpy中的reshape中参数为-1 Putty与Xming组合应用
【转】使用 UPX 压缩可执行文件
黄彬子 · 2022-12-15 · via 博客园 - 黄彬子

URL:https://cloud.tencent.com/developer/article/1997890

使用 UPX 压缩可执行文件

发布于2022-05-09 20:34:03阅读 1.4K0

upx 对文件的默认操作即为压缩,使用上述命令会使用默认参数压缩并替换文件 yourfile。 upx 支持如下可选参数:

  • -1[23456789]:不同的压缩级别,数值越高压缩率越高,但耗时更长。对于小于 512 KiB 的文件默认使用 -8,其他的默认为 -7
    • --best:最高压缩级别
    • --brute:尝试使用各种压缩方式来获取最高压缩比
    • --ultra-brute:尝试使用更多的参数来获取更高的压缩比
  • -o [file]:将压缩文件保存为 [file]

解压

优劣

压缩的程序占用更少的硬盘空间,但会在打开时消耗更多的 CPU 资源,在运行时占用更多的内存(或 swap 空间、/tmp 存储等)。

优点

  • UPX 可以压缩各种类型的可执行文件
  • 压缩后的文件可以直接由操作系统执行
  • 压缩过程不会修改源文件,也就意味着解压后直接可以得到原始文件
  • 不会产生额外的动态库调用

缺点

  • 运行的程序不会共享数据段(汇编),所以多实例运行的程序不适合压缩
  • 使用 ldd 和 size 命令无法获取到程序的有效信息

原理

为什么压缩后的文件可由系统直接执行?

UPX 将程序压缩,并在头部加入解压的程序,具体的原理可以参看参考[2]。 在 Linux 系统中可以使用 strings 命令查看可执行文件的内容,通过查看 UPX 压缩后的程序可以看到,UPX 在文件中写入了自己的特征码。

参考

  1. UPX manual
  2. Packers, How They Work, Featuring UPX