【笔记】YARA学习笔记
前言
YARA is a tool aimed at (but not limited to) helping malware researchers to identify and classify malware samples. With YARA you can create descriptions of malware families (or whatever you want to describe) based on textual or binary patterns. Each description, a.k.a. rule, consists of a set of strings and a boolean expression which determine its logic.(Github)
下载项目
1 | certutil -urlcache -split -f https://github.com/VirusTotal/yara/releases/download/v4.5.2/yara-v4.5.2-2326-win64.zip |
规则文件
使用第三方规则集
1 | git clone https://github.com/Yara-Rules/rules.git |
自定义规则
meta:定义规则元数据strings:定义规则变量
"":定义字符串变量
nocase:不区分大小写的字符串base64:Base64编码的字符串xor:异或后的字符串wide:宽字符
{}:定义十六进制数变量//:定义正则表达式变量
condition:定义匹配规则
all of them:所有变量需同时满足则匹配成功any of them:所有变量只需满足其一则匹配成功$hex and $str:两者需同时满足则匹配成功$hex or $str:两者只需满足其一则匹配成功not $str:不满足则匹配成功
1 | rule 规则名 |
根据规则检测文件
<file>.yar:规则文件<dir_or_file>:指定被检测的文件或目录,如果是目录则自动递归检测
1 | .\yara64.exe <file>.yar -r <dir_or_file> |
根据规则检测内存
<pid>:进程的PID
1 | .\yara64.exe <file>.yar <pid> |