python 郵件檢測(cè)工具mmpi的使用
概要介紹
mmpi,是一款使用python實(shí)現(xiàn)的開(kāi)源郵件快速檢測(cè)工具庫(kù),基于community框架設(shè)計(jì)開(kāi)發(fā)。mmpi支持對(duì)郵件頭、郵件正文、郵件附件的解析檢測(cè),并輸出json檢測(cè)報(bào)告。
mmpi,代碼項(xiàng)目地址:https://github.com/a232319779/mmpi,pypi項(xiàng)目地址https://pypi.org/project/mmpi/
mmpi,郵件快速檢測(cè)工具庫(kù)檢測(cè)邏輯:
- 支持解析提取郵件頭數(shù)據(jù),包括收件人、發(fā)件人的姓名和郵箱,郵件主題,郵件發(fā)送時(shí)間,以及郵件原始發(fā)送IP。通過(guò)檢測(cè)發(fā)件人郵箱和郵件原始發(fā)送IP,實(shí)現(xiàn)對(duì)郵件頭的檢測(cè)。
- 支持對(duì)郵件正文的解析檢測(cè),提取text和html格式的郵件正文,對(duì)text郵件正文進(jìn)行關(guān)鍵字匹配,對(duì)html郵件正文進(jìn)行解析分析檢測(cè),實(shí)現(xiàn)探針郵件檢測(cè)、釣魚(yú)郵件檢測(cè)、垃圾郵件檢測(cè)等其他檢測(cè)。
- 支持對(duì)郵件附件等解析檢測(cè)
ole文件格式:如doc、xls等,提取其中的vba宏代碼、模板注入鏈接
zip文件格式:提取壓縮文件列表,統(tǒng)計(jì)文件名、文件格式等
rtf文件格式:解析內(nèi)嵌ole對(duì)象等
其他文件格式:如PE可執(zhí)行文件
- 檢測(cè)方式包括
基礎(chǔ)信息規(guī)則檢測(cè)方式
yara規(guī)則檢測(cè)方式
適用前提
mmpi的分析判定檢測(cè)前提:郵件系統(tǒng)環(huán)境。脫離郵件環(huán)境上下文,檢測(cè)規(guī)則的依據(jù)就不可靠了。
使用方式
1. 安裝
$ pip install mmpi
備注:windows安裝yara-python,可以從這里下載
2. 命令執(zhí)行
$ mmpi-run $email_path
3. 快速開(kāi)始
from mmpi import mmpi
def main():
emp = mmpi()
emp.parse('test.eml')
report = emp.get_report()
print(report)
if __name__ == "__main__":
main()
4. 輸出格式
{
// 固定字段
"headers": [],
"body": [],
"attachments": [],
"signatures": []
// 動(dòng)態(tài)字段
"vba": [],
"rtf": [],
}
工具特色
mmpi完全基于python開(kāi)發(fā),使用python原生email、html、zip庫(kù)進(jìn)行解析,基于oletool做定制化修改,支持對(duì)office文檔和rtf文檔的解析,再結(jié)合yara實(shí)現(xiàn)對(duì)其他文件的檢測(cè)。
項(xiàng)目代碼結(jié)構(gòu)
. ├── mmpi │ ├── common │ ├── core │ ├── data │ │ ├── signatures │ │ │ ├── eml │ │ │ ├── html │ │ │ ├── ole │ │ │ ├── other │ │ │ ├── rtf │ │ │ └── zip │ │ ├── white │ │ └── yara │ │ ├── exe │ │ ├── pdf │ │ └── vba │ └── processing └── tests └── samples
- mmpi/common:基礎(chǔ)模塊,實(shí)現(xiàn)基本流程功能
- mmpi/core:核心調(diào)度模塊,實(shí)現(xiàn)插件的加載及相關(guān)模塊的初始化
- mmpi/data:核心檢測(cè)模塊,實(shí)現(xiàn)基本檢測(cè)規(guī)則及yara檢測(cè)規(guī)則
- mmpi/processing:核心解析模塊,實(shí)現(xiàn)eml、html、zip等文件格式的解析
- tests:測(cè)試模塊
檢測(cè)規(guī)則示例說(shuō)明
1. PE文件偽裝文檔類(lèi)檢測(cè)
檢測(cè)規(guī)則:壓縮包中文件名以.exe結(jié)尾,并且中間插入20個(gè)以上空格的
class PEFakeDocument(Signature):
authors = ["ddvv"]
sig_type = 'zip'
name = "pe_fake_document"
severity = 9
description = "PE File Fake Document"
def on_complete(self):
results = self.get_results()
for result in results:
if result.get('type', '') == self.sig_type:
infos = result.get('value', {}).get('infos', [])
for info in infos:
file_type = info.get('type')
file_name = info.get('name')
space_count = file_name.count(' ')
if 'exe' == file_type and space_count > 20:
self.mark(type="zip", tag=self.name, data=info.get('name'))
return self.has_marks()
return None
2. DLL劫持檢測(cè)
檢測(cè)規(guī)則:壓縮包中同時(shí)存在exe和dll文件
class DLLHijacking(Signature):
authors = ["ddvv"]
sig_type = 'zip'
name = "dll_hijacking"
severity = 9
description = "DLL Hijacking"
def on_complete(self):
results = self.get_results()
for result in results:
if result.get('type', '') == self.sig_type:
infos = result.get('value', {}).get('infos', [])
file_types = [info.get('type') for info in infos]
if set(['exe', 'dll']).issubset(file_types):
self.mark(type="zip", tag=self.name)
return self.has_marks()
return None
3. RTF漏洞利用檢測(cè)
檢測(cè)規(guī)則:RTF文檔中存在OLE對(duì)象,并且class_name是OLE2Link或者以equation開(kāi)頭
class RTFExploitDetected(Signature):
authors = ["ddvv"]
sig_type = 'rtf'
name = "rtf_exploit_detected"
severity = 9
description = "RTF Exploit Detected"
def on_complete(self):
results = self.get_results()
for result in results:
if result.get('type', '') == self.sig_type:
infos = result.get('value', {}).get('infos', [])
for info in infos:
if info.get('is_ole', False):
class_name = info.get('class_name', '')
if class_name == 'OLE2Link' or class_name.lower().startswith('equation'):
self.mark(type="rtf", tag=self.name)
return self.has_marks()
return None
結(jié)果示例
結(jié)果說(shuō)明:郵件包含漏洞利用的RTF文檔,屬于惡意郵件。
- 包括收發(fā)件人信息、主題信息、發(fā)送時(shí)間,郵件正文,以及附件信息。
- vba和rtf字段為附件檢測(cè)基本信息。
- signatures字段說(shuō)明命中規(guī)則。
{
"headers": [
{
"From": [
{
"name": "Mohd Mukhriz Ramli (MLNG/GNE)",
"addr": "info@vm1599159.3ssd.had.wf"
}
],
"To": [
{
"name": "",
"addr": ""
}
],
"Subject": "Re: Proforma Invoice",
"Date": "2020-11-24 12:37:38 UTC+01:00",
"X-Originating-IP": []
}
],
"body": [
{
"type": "text",
"content": " \nDEAR SIR, \n\nPLEASE SIGN THE PROFORMA INVOICE SO THAT I CAN PAY AS SOON AS POSSIBLE.\n\nATTACHED IS THE PROFORMA INVOICE,\n\nPLEASE REPLY QUICKLY, \n\nTHANKS & REGARDS' \n\nRAJASHEKAR \n\n Dubai I Kuwait I Saudi Arabia I India I Egypt \nKuwait: +965 22261501 \nSaudi Arabia: +966 920033029 \nUAE: +971 42431343 \nEmail ID: help@rehlat.co [1]m\n \n\nLinks:\n------\n[1]\nhttps://deref-mail.com/mail/client/OV1N7sILlK8/dereferrer/?redirectUrl=https%3A%2F%2Fe.mail.ru%2Fcompose%2F%3Fmailto%3Dmailto%253ahelp%40rehlat.com"
}
],
"attachments": [
{
"type": "doc",
"filename": "Proforma Invoice.doc",
"filesize": 1826535,
"md5": "558c4aa596b0c4259182253a86b35e8c",
"sha1": "63982d410879c09ca090a64873bc582fcc7d802b"
}
],
"vba": [],
"rtf": [
{
"is_ole": true,
"format_id": 2,
"format_type": "Embedded",
"class_name": "EQUATion.3",
"data_size": 912305,
"md5": "a5cee525de80eb537cfea247271ad714"
}
],
"signatures": [
{
"name": "rtf_suspicious_detected",
"description": "RTF Suspicious Detected",
"severity": 3,
"marks": [
{
"type": "rtf",
"tag": "rtf_suspicious_detected"
}
],
"markcount": 1
},
{
"name": "rtf_exploit_detected",
"description": "RTF Exploit Detected",
"severity": 9,
"marks": [
{
"type": "rtf",
"tag": "rtf_exploit_detected"
}
],
"markcount": 1
}
]
}
以上就是python 郵件檢測(cè)工具mmpi的使用的詳細(xì)內(nèi)容,更多關(guān)于python mmpi庫(kù)實(shí)現(xiàn)郵件檢測(cè)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- python 檢測(cè)nginx服務(wù)郵件報(bào)警的腳本
- 利用Python發(fā)送郵件或發(fā)帶附件的郵件
- python基于exchange函數(shù)發(fā)送郵件過(guò)程詳解
- 如何使用Python自動(dòng)生成報(bào)表并以郵件發(fā)送
- python 利用zmail庫(kù)發(fā)送郵件
- python實(shí)現(xiàn)郵件循環(huán)自動(dòng)發(fā)件功能
- Python發(fā)送郵件實(shí)現(xiàn)基礎(chǔ)解析
- Python自動(dòng)發(fā)送和收取郵件的方法
- python使用QQ郵箱實(shí)現(xiàn)自動(dòng)發(fā)送郵件
相關(guān)文章
Python?eval()函數(shù)和ast.literal_eval()的區(qū)別你知道嗎
這篇文章主要為大家詳細(xì)介紹了Python?eval()函數(shù)和ast.literal_eval()的區(qū),文中圖片代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-02-02
使用python提取html文件中的特定數(shù)據(jù)的實(shí)現(xiàn)代碼
python提供了SGMLParser類(lèi)用于html文件的解析。用戶(hù)只需從SGMLParser類(lèi)繼承子類(lèi),并在子類(lèi)中對(duì)html文件做具體處理2013-03-03
Python實(shí)現(xiàn)數(shù)據(jù)庫(kù)并行讀取和寫(xiě)入實(shí)例
本篇文章主要介紹了Python實(shí)現(xiàn)數(shù)據(jù)庫(kù)并行讀取和寫(xiě)入實(shí)例,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2017-06-06
Python裝飾器類(lèi)方法擴(kuò)展元類(lèi)管理實(shí)例探究
這篇文章主要為大家介紹了Python裝飾器類(lèi)方法擴(kuò)展元類(lèi)管理實(shí)例探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01
centos6.8安裝python3.7無(wú)法import _ssl的解決方法
這篇文章主要介紹了centos6.8安裝python3.7無(wú)法import _ssl的解決方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
Python實(shí)現(xiàn)獲取sonarqube數(shù)據(jù)
sonarqube是一款代碼分析的工具,可以對(duì)通過(guò)soanrScanner掃描后的數(shù)據(jù)傳遞給sonarqube進(jìn)行分析,本文為大家整理了Python獲取sonarqube數(shù)據(jù)的方法,需要的可以參考下2023-05-05
PyCharm Anaconda配置PyQt5開(kāi)發(fā)環(huán)境及創(chuàng)建項(xiàng)目的教程詳解
這篇文章主要介紹了PyCharm Anaconda配置PyQt5開(kāi)發(fā)環(huán)境及創(chuàng)建項(xiàng)目的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03
pyinstaller 3.6版本通過(guò)pip安裝失敗的解決辦法(推薦)
這篇文章主要介紹了pyinstaller 3.6版本通過(guò)pip安裝失敗的解決辦法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01

