iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 30
0
自我挑戰組

自然語言技術與AI/ML初探系列 第 30

python for malware static analysis (2) -yara

Yara rules Generation

什麼是Yara
使用Yara可以基於文本或二進制模式創建惡意軟件家族描述與匹配信息
規則的字符串有三種類型:
 文本字符串用來定義文檔或進程內存中可讀型內容
 十六進制字符串用來定義字節內容
 正則表達式可用在文本字符串和十六進制字符串中

EquationGroup Cluster
Generate automatically yara rules based on an intersection of strings

假設已經知道 GoogleUpdate.exe 裡,有 “GoogleUpdate_unsigned.pdb” 的字串
Yara規則檔如下
rule MatchGoogleUpdateExe
{
strings:
$my_text_string = "GoogleUpdate_unsigned.pdb"
condition:
$my_text_string
}

安裝 Yara
brew install yara

應用情境:用 yara 掃瞄目錄,
發現 GoogleUpdate.exe 和 GoogleUpdate.tar 都有中 MatchGoogleUpdateExe 這個規則:
testuser@localhost $ yara ../yara/rule_MatchGoogleUpdateExe.yar .
MatchGoogleUpdateExe ./GoogleUpdate.exe
MatchGoogleUpdateExe ./GoogleUpdate.tar

加上 -s 選項的話,可以看到符合的字串內容:

testuser@localhost $ yara -s ../yara/rule_MatchGoogleUpdateExe.yar .

MatchGoogleUpdateExe ./GoogleUpdate.tar
0x10748:$my_text_string: GoogleUpdate_unsigned.pdb
MatchGoogleUpdateExe ./GoogleUpdate.exe
0x10548:$my_text_string: GoogleUpdate_unsigned.pdb

參考來源
https://2018.pass-the-salt.org/files/talks/14-python-and-ml.pdf
[Mac] 撰寫 Yara 規則,用 Yara 掃瞄含有特定字串的檔案
https://ephrain.net/mac-%E6%92%B0%E5%AF%AB-yara-%E8%A6%8F%E5%89%87%EF%BC%8C%E7%94%A8-yara-%E6%8E%83%E7%9E%84%E5%90%AB%E6%9C%89%E7%89%B9%E5%AE%9A%E5%AD%97%E4%B8%B2%E7%9A%84%E6%AA%94%E6%A1%88/
【識別惡意木馬必備】用命令行與Python,使用YARA規則
https://hk.saowen.com/a/b0a2e4c7974ca7b57d976997f27a2ae676bf1ed093d9d272fa0c55a49810c463


上一篇
python for malware static analysis (1)
系列文
自然語言技術與AI/ML初探30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
CyberSerge
iT邦好手 1 級 ‧ 2018-11-17 12:54:13

恭喜完賽!

我要留言

立即登入留言