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夾中