当前位置: 首页 > 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.jsqmd.com/news/114610/

相关文章:

  • 计算机毕设Java基于Android的旅游自助APP 基于Android平台的Java旅游自助应用开发 Android环境下Java驱动的旅游自助服务系统设计
  • 第13章 高级配置选项
  • 第06章 NecroBit技术详解
  • (29)阶段性个人总结
  • 网络安全零基础入门:保姆级全栈学习指南,一篇就够了!
  • 【QML 界面编写实战之:模块化、多QML文档调用与跨语言交互】
  • 交叉编译总结-续(configure(Autotools)和CMake构建配置工具)
  • 大学生必备6个免费AI写论文工具:知网查重过+无AIGC痕迹
  • 第14章 最佳实践与优化
  • 计算机毕设Java基于Android疫情期间旅游助手 基于Java的Android平台疫情期间旅游信息管理系统 Java驱动的Android疫情期间旅游辅助应用开发
  • 第09章 反调试与防篡改
  • 2025年靠谱离子交换膜加工厂排行榜,新测评精选离子交换膜资深厂商推荐 - mypinpai
  • 2025成都火锅必吃榜:春熙路口碑前十强出炉!烧菜火锅/社区火锅/美食/火锅/特色美食成都火锅品牌口碑推荐 - 品牌推荐师
  • 如何评估Linly-Talker生成质量?LPIPS指标实测分析
  • 为什么你的AutoGLM系统总卡顿?90%问题出在任务队列设计上
  • 神仙网站,建议收藏
  • Python requests实现图片上传接口自动化测试
  • 基于Spring Boot的交通事故处理系统的设计毕设
  • 2025年靠谱振动盘生产企业排行榜,口碑好的振动盘厂家新测评推荐 - myqiye
  • 解压摸鱼神器!打发时间的微信休闲小游戏十大榜单,好玩不上头超省心 - 速递信息
  • 2025年不可错过的进口化妆品代理品牌TOP10,广州口碑好的进口化妆品代理品牌优质品牌榜单更新 - 品牌推荐师
  • 用Linly-Talker制作儿童故事机?亲子教育场景落地案例
  • 2025年海外发稿公司选择哪家好?专业海外发稿公司服务推荐与全解析 - myqiye
  • 2025年腐竹推荐供应商、腐竹厂家加工厂、腐竹专业制造商年度排名 - 工业推荐榜
  • FCKEditor跨平台兼容Word文档图片上传与转存
  • Open-AutoGLM生产环境部署必备技能:确保高可用的开机自启方案设计
  • 【Open-AutoGLM饮食热量统计】:揭秘AI自动识别食物热量的黑科技与实测效果
  • 电渗析装置加工厂哪家售后好、电渗析生产厂选哪家好? - mypinpai
  • Linly-Talker模型剪枝实践:在消费级显卡上流畅运行
  • Linly-Talker与Unity结合:打造三维空间中的AI虚拟角色