跳到主要内容

命令行(CLI)使用说明

普通用户不支持

命令行(CLI)功能目前仅面向企业内部用户开放和定做。如需开通权限或者定做,请联系我们

安卓APK资源混淆加密重签名工具提供命令行(CLI)接口,支持通过命令行方式调用软件对APK进行混淆加固操作,方便集成到自动化构建流程或批量处理场景中。

命令概览

命令说明
obf混淆加密APK
reset重置默认证书
add-cert添加自定义证书
delete-cert删除自定义证书
list-cert列出所有已添加的证书

obf - 混淆APK

对APK文件进行混淆加密处理,支持多种混淆选项组合使用。

参数说明

参数必填默认值说明
--input-待处理的APK文件路径
--output-打包保存路径(需要是绝对路径)
--dex-shellfalse启用DEX加壳
--dex-shell-enhancefalse启用DEX加壳增强
--xml-confusorfalse启用XML混淆
--anti-debugfalse启用反调试
--anti-decompilefalse启用防止反编译
--apk-protectfalse启用APK优化处理
--name-自定义App名称
--certcert指定使用的证书名称
--quietfalse不显示日志信息

使用示例

基础混淆(不开启任何混淆功能,仅重签名):

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk"

开启反调试和XML混淆:

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk" --anti-debug --xml-confusor

开启全部混淆功能:

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk" --dex-shell --dex-shell-enhance --xml-confusor --anti-debug --anti-decompile --apk-protect

DEX加壳增强 + 防止反编译 + 自定义App名称:

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk" --dex-shell-enhance --anti-decompile --name "我的应用"

使用自定义证书进行混淆:

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk" --cert 我的证书 --anti-debug

静默模式(不输出日志,适合自动化脚本集成):

CLI.exe obf --input "C:\Desktop\input.apk" --output "C:\Desktop\output.apk" --anti-debug --quiet

证书管理

CLI工具内建默认签名证书,同时支持导入和管理自定义证书,满足企业不同项目的签名需求。

reset - 重置默认证书

删除默认证书,下次混淆时会自动生成新的默认证书。

CLI.exe reset
参数必填说明
--quiet不显示日志信息

add-cert - 添加自定义证书

导入一个已有的 keystore 证书文件,添加后可在 obf 命令中通过 --cert 参数引用。

参数必填说明
--keystore证书KeyStore文件路径(.keystore 或 .jks)
--storepassKeyStore密码
--alias证书Alias
--aliaspass证书Alias密码
--name自定义证书名称(不能为 "cert")
--quiet不显示日志信息

示例:

CLI.exe add-cert --keystore "C:\certs\my.keystore" --storepass mypass123 --alias myalias --aliaspass aliaspass123 --name 我的证书
注意

自定义名称不能使用 "cert",该名称保留给默认证书。


delete-cert - 删除自定义证书

删除一个已添加的自定义证书。

参数必填说明
--name要删除的证书名称
--quiet不显示日志信息

示例:

CLI.exe delete-cert --name 我的证书
注意

不能删除默认证书 "cert",如需重置默认证书请使用 reset 命令。


list-cert - 列出所有证书

查看当前已添加的所有证书。

CLI.exe list-cert

输出示例:

===证书列表===
cert [默认]
我的证书 (Alias: myalias)
测试证书 (Alias: test)
参数必填说明
--quiet不显示日志信息

常见使用流程

使用默认证书快速混淆APK

CLI.exe obf --input "C:\input.apk" --output "C:\output.apk" --anti-debug --xml-confusor

使用自定义证书混淆APK

# 第一步:添加证书
CLI.exe add-cert --keystore "C:\my.keystore" --storepass 123456 --alias mykey --aliaspass 123456 --name 正式证书

# 第二步:查看已添加的证书
CLI.exe list-cert

# 第三步:使用该证书进行混淆
CLI.exe obf --input "C:\input.apk" --output "C:\output.apk" --cert 正式证书 --anti-debug --anti-decompile

# 不再需要时删除证书
CLI.exe delete-cert --name 正式证书

重置默认证书

CLI.exe reset

常见问题

CLI工具如何获取?

CLI功能仅面向企业内部用户开放,请联系我们获取CLI工具及企业授权。

CLI是否支持批量处理?

可以通过编写脚本循环调用 obf 命令实现批量处理多个APK文件。例如使用 Windows 批处理脚本批量混淆一个文件夹下的所有APK:

@echo off
set INPUT_DIR=C:\apks
set OUTPUT_DIR=C:\apks_output

for %%f in ("%INPUT_DIR%\*.apk") do (
echo 正在处理: %%~nxf
CLI.exe obf --input "%%f" --output "%OUTPUT_DIR%\%%~nxf" --anti-debug --xml-confusor --quiet
)
echo 全部处理完成

或者使用 PowerShell:

$inputDir = "C:\apks"
$outputDir = "C:\apks_output"

Get-ChildItem -Path $inputDir -Filter "*.apk" | ForEach-Object {
Write-Host "正在处理: $($_.Name)"
& .\CLI.exe obf --input $_.FullName --output "$outputDir\$($_.Name)" --anti-debug --xml-confusor --quiet
}
Write-Host "全部处理完成"