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 규칙을 추가해야 할 때는 extension .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 .