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_rulesフォルダーに追加する必要があります.yara
(既存のルールはこの記事に基づいて作成されます。それらは時代遅れかもしれません)
可能なルールは以下のとおりです。
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として保存します。