Fnord 是一个用于混淆代码的模式提取器
Fnord 有两个主要功能:
Fnord 使用大小可变的滑动窗口处理文件,提取所有长度从 -m X(默认:4)到 -x X(默认:40)的序列。对于每个长度,Fnord 将以表格形式展示出现最频繁的序列 -t X(默认:3)。
表格中的每一行包含:
Fnord 还会生成一条实验性的 YARA 规则。在创建 YARA 规则时,它会根据序列长度和出现次数计算一个分数(长度 × 出现次数)。然后,它会处理每个序列,移除所有非字母字符,并与关键词列表(不区分大小写)进行比较,以检测比其他序列更有趣的序列。在将每个字符串写入规则之前,Fnord 会计算 Levenshtein 距离,并跳过与已集成到规则中的序列过于相似的序列。
[实验性] Fnord 是几天前创建的,我已经用少量样本进行了测试。我预计在未来几周内会调整默认值,并添加更多关键词、过滤器和评分选项。
如果你在样本中发现了混淆代码,使用十六进制编辑器提取样本中的混淆部分并保存到一个新文件中。使用这个新文件进行分析。
尝试使用 -s、-k、-r、--yara-strings、-m 和 -e 等标志。
请将产生弱 YARA 规则(可以改进)的样本发送给我。
____ __
/ __/__ ___ _______/ /
/ _// _ \/ _ \/ __/ _ /
/_/ /_//_/\___/_/ \_,_/ Pattern Extractor for Obfuscated Code
v0.7, Florian Roth
usage: fnord.py [-h] [-f file] [-m min] [-x max] [-t top] [-n min-occ]
[-e min-entropy] [--strings] [--include-padding] [--debug]
[--noyara] [-s similarity] [-k keywords-multiplier]
[-r structure-multiplier] [-c count-limiter] [--yara-exact]
[--yara-strings max] [--show-score] [--show-count]
[--author author]
Fnord - Pattern Extractor for Obfuscated Code
optional arguments:
-h, --help show this help message and exit
-f file File to process
-m min Minimum sequence length
-x max Maximum sequence length
-t top Number of items in the Top x list
-n min-occ Minimum number of occurrences to show
-e min-entropy Minimum entropy
--strings Show strings only
--include-padding Include 0x00 and 0x20 in the extracted strings
--debug Debug output
YARA Rule Creation:
--noyara Do not generate an experimental YARA rule
-s similarity Allowed similarity (use values between 0.1=low and
10=high, default=1.5)
-k keywords-multiplier
Keywords multiplier (multiplies score of sequences if
keyword is found) (best use values between 1 and 5,
default=2.0)
-r structure-multiplier
Structure multiplier (multiplies score of sequences if
it is identified as code structure and not payload)
(best use values between 1 and 5, default=2.0)
-c count-limiter Count limiter (limts the impact of the count by
capping it at a certain amount) (best use values
between 5 and 100, default=20)
--yara-exact Add magic header and magic footer limitations to the
rule
--yara-strings max Maximum sequence length
--show-score Show score in comments of YARA rules
--show-count Show count in sample in comments of YARA rules
--author author YARA rule author
git clone https://github.com/Neo23x0/Fnord.git 然后 cd Fnordpip3 install -r ./requirements.txtpython3 ./fnord.py --helppython3 fnord.py -f ./test/wraeop.sct --yara-strings 10
python3 fnord.py -f ./test/vbs.txt --show-score --show-count -t 1 -x 20
python3 fnord.py -f ./test/inv-obf.txt --show-score --show-count -t 1 --yara-strings 4 --yara-exact



./test 文件夹包含恶意脚本,可能被本地防病毒软件检测到。只要不运行它们,就不会对系统造成损害。
yarGen 使用白名单方法来过滤最适合创建 YARA 规则的字符串。yarGen 在创建 YARA 规则之前应用一些正则表达式来调整字符串的分数。但其方法与 Fnord 使用的方法有很大不同,Fnord 基于统计计算字节序列的分数。
虽然 yarGen 最适合用于未混淆的代码,但 Fnord 仅适用于混淆代码,并且应该能比 yarGen 产生更好的结果。
关注我的 Twitter 获取更新 @cyb3rops