使用 LLMs 逆转 JavaScript 变量名最小化

This blog introduces a novel way to reverse minified Javascript using large language models (LLMs) like ChatGPT and llama2 while keeping the code semantically intact. The code is open source and available at Github project Humanify.

这篇博客介绍了一种使用大型语言模型(LLMs)如 ChatGPT 和 llama2 来逆向压缩 Javascript 的新颖方法,同时保持代码语义完整。代码是开源的,可在 Github 项目 Humanify 获取。

What is minification?

什么是 minification?

Minification is a process of reducing the size of a Javascript file in order to optimize for fast network transfer. Looking from the reverse engineering standpoint, there are a few different categories of minification that present increasing challenges:

Minification是将Javascript文件大小减小以优化快速网络传输的过程。从逆向工程的角度来看,有几类不同的minification呈现出日益增加的挑战:

Lossless minification

无损 minification

Most minification is lossless; There's no data lost when true is converted to its minified alternative !0. It's straightforward to write a Babel transformation to reverse this process. There are many tools that are specifically designed to reverse these kind of lossless transformations.

大多数 minification 是无损的;当 true 被转换为其最小化的替代形式 !0 时,没有数据丢失。编写一个 Babel 转换 来逆转这个过程是很直接的。有 许多 工具 专门设计用于逆转这类无损转换。

Unimportant data loss

不重要的数据丢失

Some data is lost during the minification, but that data may be trivial to recreate. A good example is whitespace; it's trivial to use Prettier (or a similar tool) to reformat minified code's indentation and whitespace to a human-readable format. Most of the time the developers have used similar tools with the original code too, so the whitespace data can be recreated with high confidence.

在 minification 过程中会丢失一些数据,但这些数据可能很容易重新创建。一个很好的例子是空白字符;使用 Prettier(或类似工具)将最小化代码的缩进和空白重新格式化为人类可读格式是很简单的。大多数情况下,开发者在原始代码上也使用了类似的工具,因此空白数据可以高度自信地重新创建。

Variable names

变量名

The most important information that's lost during the minification process is the loss of variable and function names. When you run a minifier, it completely replaces all possible variable and function names to save bytes.

在压缩过程中丢失的最重要信息是变量和函数名称的丢失。当你运行一个压缩工具时,它会完全替换所有可能的变量和函数名称以节省字节。

Until now, there has not b...

开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.0. UTC+08:00, 2026-03-20 02:43
浙ICP备14020137号-1 $bản đồ khách truy cập$