audit node modules with yara
Intial release
วัตถุประสงค์ของเครื่องมือนี้คือการเรียกใช้ชุดกฎ YARA ที่กำหนดกับโฟลเดอร์ node_module ที่กำหนด
ด้วยวิธีการนี้เราสามารถกำหนดกฎของ 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 และดีที่จะไป