当前位置: 首页 > news >正文

第11章 命令行使用

第11章:命令行使用

11.1 命令行概述

.NET Reactor 提供强大的命令行界面(CLI),支持自动化和批处理操作。

11.2 基本语法

dotNET_Reactor.Console.exe [options] -file <input> [-targetfile <output>]

11.3 常用参数

11.3.1 输入输出

# 指定输入文件
-file MyApp.exe# 指定输出文件
-targetfile MyApp.Protected.exe# 使用项目文件
-project MyProject.nrproj# 静默模式
-quiet# 详细输出
-verbose

11.3.2 保护选项

# 启用混淆
-obfuscation 1# 设置混淆级别
-obfuscation_level standard# 启用字符串加密
-stringencryption 1# 启用 NecroBit
-necrobit 1# 启用反调试
-antidebug 1# 启用防篡改
-antitampering 1

11.4 批处理脚本

11.4.1 Windows 批处理

@echo off
setlocalset REACTOR="C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"
set INPUT_DIR=bin\Release
set OUTPUT_DIR=bin\ProtectedREM 创建输出目录
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"REM 保护所有 DLL 和 EXE
for %%F in ("%INPUT_DIR%\*.exe" "%INPUT_DIR%\*.dll") do (echo Protecting %%F...%REACTOR% -file "%%F" -targetfile "%OUTPUT_DIR%\%%~nxF" -quietif errorlevel 1 (echo Failed to protect %%Fexit /b 1)
)echo All files protected successfully!
endlocal

11.4.2 PowerShell 脚本

# Protect-Assemblies.ps1param([Parameter(Mandatory=$true)][string]$InputPath,[Parameter(Mandatory=$true)][string]$OutputPath,[Parameter(Mandatory=$false)][string]$ProjectFile = "",[Parameter(Mandatory=$false)][switch]$NecroBit,[Parameter(Mandatory=$false)][switch]$Verbose
)$reactorPath = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"# 获取所有程序集
$assemblies = Get-ChildItem -Path $InputPath -Filter "*.exe", "*.dll"foreach ($assembly in $assemblies) {Write-Host "Protecting $($assembly.Name)..." -ForegroundColor Cyan$args = @("-file", $assembly.FullName,"-targetfile", (Join-Path $OutputPath $assembly.Name))if ($ProjectFile) {$args += @("-project", $ProjectFile)}if ($NecroBit) {$args += "-necrobit", "1"}if (-not $Verbose) {$args += "-quiet"}& $reactorPath $argsif ($LASTEXITCODE -ne 0) {Write-Error "Failed to protect $($assembly.Name)"exit 1}
}Write-Host "All assemblies protected successfully!" -ForegroundColor Green

11.5 CI/CD 集成

11.5.1 Azure DevOps

# azure-pipelines.yml
steps:
- task: PowerShell@2displayName: 'Protect Assemblies'inputs:targetType: 'filePath'filePath: 'scripts/Protect-Assemblies.ps1'arguments: >-InputPath "$(Build.BinariesDirectory)"-OutputPath "$(Build.ArtifactStagingDirectory)/protected"-ProjectFile "protection.nrproj"-NecroBit

11.5.2 GitHub Actions

# .github/workflows/protect.yml
- name: Protect with .NET Reactorrun: |$reactor = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"& $reactor -file "bin\Release\MyApp.exe" `-targetfile "protected\MyApp.exe" `-project "protection.nrproj" `-quietshell: powershell

11.5.3 Jenkins Pipeline

// Jenkinsfile
stage('Protect Assemblies') {steps {bat '''"C:\\Program Files (x86)\\Eziriz\\.NET Reactor\\dotNET_Reactor.Console.exe" ^-file "bin\\Release\\MyApp.exe" ^-targetfile "protected\\MyApp.exe" ^-project "protection.nrproj" ^-quiet'''}
}

11.6 高级用法

11.6.1 条件保护

# 根据环境变量决定保护级别
if [ "$BUILD_CONFIGURATION" = "Release" ]; thenNECROBIT="-necrobit 1"
elseNECROBIT=""
fidotNET_Reactor.Console.exe \-file MyApp.exe \-obfuscation 1 \$NECROBIT \-targetfile MyApp.Protected.exe

11.6.2 并行处理

# 并行保护多个程序集
$assemblies = Get-ChildItem -Path "bin\Release" -Filter "*.dll"$assemblies | ForEach-Object -Parallel {$reactor = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"& $reactor -file $_.FullName -targetfile "protected\$($_.Name)" -quiet
} -ThrottleLimit 4

11.7 错误处理

11.7.1 退出代码

0  - 成功
1  - 一般错误
2  - 文件未找到
3  - 许可证无效
4  - 配置错误
5  - 保护失败

11.7.2 日志记录

# 启用日志
dotNET_Reactor.Console.exe \-file MyApp.exe \-log protection.log \-verbose# 检查日志
if grep -q "ERROR" protection.log; thenecho "Protection failed!"exit 1
fi

11.8 本章小结

本章介绍了 .NET Reactor 的命令行使用方法,包括:

  • 基本命令语法
  • 常用参数选项
  • 批处理脚本编写
  • CI/CD 集成方案
  • 错误处理机制

掌握命令行工具可以实现自动化保护流程,提高开发效率。

http://www.rkmt.cn/news/126503.html

相关文章:

  • 数字人配音自由化:Linly-Talker允许任意声音上传克隆
  • 基于 Python 开发的机器学习房价预测系统
  • 基于PHP的音乐网站后台管理系统设计与实现
  • 基于Android的地球村共享书屋平台
  • Linly-Talker模型剪枝实践:在消费级显卡上流畅运行
  • Topaz Photo(图像增强软件)
  • Linly-Talker表情控制系统详解:72种微表情参数调节
  • 高性能GPU推荐:运行Linly-Talker最合适的显卡TOP5
  • 从零搭建Open-AutoGLM任务流水线(工业级自动化架构设计曝光)
  • 数字人版权归属问题探讨:由Linly-Talker引发的法律思考
  • Linly-Talker支持WebSocket通信,前后端数据交互更高效
  • 【AI系统稳定性保障】:基于Open-AutoGLM的实时资源监控体系构建
  • 【Open-AutoGLM高阶应用指南】:如何用1个配置文件处理10万+任务?
  • 实战|基于Kappa架构的实时数据监控平台搭建,告警系统设计
  • 权威认证!铁路地铁电力电缆生产厂家推荐:中低压、中压、聚乙烯绝缘、聚氯乙烯绝缘电缆生产厂家推荐(2025年12月更新) - 品牌2026
  • 【Open-AutoGLM循环任务核心机密】:20年专家亲授高效自动化配置秘诀
  • 2025年目前正规的装修设计公司多少钱,软装设计/房屋装修/室内装修/别墅设计/大平层设计/室内设计/室内空间设计装修设计公司多少钱 - 品牌推荐师
  • 跨境电商新玩法:用Linly-Talker制作多语言产品介绍视频
  • 基于 Django 框架开发的智慧农业管理系统
  • 【从入门到精通Open-AutoGLM】:3步构建零宕机进程管理体系
  • 基于Python的个人云盘管理系统设计与实现
  • 深入解析:[Linux]学习笔记系列 -- [kernel]pid
  • 设备容器内存配额不足致OOM 后来才知道动态调整限制
  • 别再手动清队列了!Open-AutoGLM智能调度的7个自动化实践
  • Open-AutoGLM后台运行避坑指南(90%新手都会忽略的3个致命错误)
  • DAY 40
  • 基于 Python 的股票数据可视化是金融数据分析领域的重要应用
  • Open-AutoGLM开机自启实战:systemd服务配置的8个核心要点
  • 基于 Django 框架开发的青岛滨海学院升学信息管理系统
  • 2025年合肥靠谱有实力的装修专业公司排行榜,口碑优选不错的装修专业公司推荐 - 工业推荐榜