audit node modules with yara
Intial release
此工具的目的是针对给定的node_module文件夹运行给定的YARA规则。
使用这种方法,我们可以定义YARA规则以识别注入节点软件包的可疑脚本。
主要受这些文章的启发。
该软件包可以添加到CI/CD管道中,如下所述(CI/CD集成)。
git clone https://github.com/rpgeeganage/audit-node-modules-with-yara.gitmake NODE_MODULE_FOLDER_TO_AUDIT= < path to node_module > runmake NODE_MODULE_FOLDER_TO_AUDIT=../restful4up/node_modules run该报告可在artifacts/output.json中找到。
[
{
"rule" : " evil_package_1 " ,
"string_information" : [
" 0x6:$name: " name " : " nodecaffe " , " ,
" 0x1f:$version: " version " : " 0.0.1 " "
]
},
{
"rule" : " evil_package_2 " ,
"string_information" : [
" 0x6:$name: " name " : " sqlserver " , " ,
" 0x1f:$version: " version " : " 4.0.5 " "
]
},
{
"rule" : " evil_package_3 " ,
"string_information" : [
" 0x1d:$scripts: " scripts " : " ,
" 0x39:$install: " mkdir -p ~/Desktop/sploit && touch ~/Desktop/sploit/haxx " "
]
}
]如下所述,我们可以将此工具与CI/CD一起使用。
#! /bin/bash
make NODE_MODULE_FOLDER_TO_AUDIT=../restful4up/node_modules run
suspicious_file_count= $( jq length artifacts/output.json )
exit $suspicious_file_count 当我们需要添加新的YARA规则时,必须将它们添加到带有扩展名.yara yara_rules文件夹中。
(现有规则是根据本文创建的。它们可能已过时)
可能的规则如下。
rule evil
{
meta:
name = "[email protected]"
strings:
$ scripts = /"scripts":/
$ inst all = /"mkdir -p ~/Desktop/sploit && touch ~/Desktop/sploit/haxx"/
condition:
all of them
}将此规则保存在yara_rules evil.yara夹中