使用yarac.exe编译.yar文件
@echo off
echo 删除上次提取的YARA规则文件
del %CD%\AllYARAs.txt
echo 把当前路径下所有yar文件内容提取到AllYARAs.txt
for /r %%i in (*.yar) do (
type %%i >> AllYARAs.txt
)
echo 用yarac将AllYARAs.txt编译成AllYARAs.Pass
call %CD%\yarac.exe -w %CD%\AllYARAs.txt %CD%\AllYARAs.Pass
::如果编译成功跳转,不成功则打印出错误码,删除规则文件后跳转到结束位置
if %ERRORLEVEL% == 0 goto :CompiledSuccessful
echo 编译失败
goto :EndOfscript
:CompiledSuccessful
echo 编译成功
::del %CD%\AllYARAs.txt
echo 测试编译后的文件:
call %CD%\yara.exe -C -w -f %CD%\AllYARAs.Pass .\Test
goto :EndOfscript
:EndOfscript
pause>nul
成功
失败