最近真的太忙了,天天打仗一样,感谢大家的支持和关注,继续加油!该系列文章将系统整理和深入学习系统安全、逆向分析和恶意代码检测,文章会更加聚焦,更加系统,更加深入,也是作者的慢慢成长史。漫漫长征路,偏向虎山行。享受过程,一起奋斗~
-
一.恶意软件分析
-
1.静态特征
-
2.动态特征
-
二.Cuckoo和Cape沙箱简介
-
1.Cuckoo沙箱简介
-
2.Cape沙箱简介
-
3.Cape原理
-
三.Cape沙箱识别单样本特征
-
1.启动沙箱关键步骤
-
2.样本分析
-
四.Python批量提取Report报告
-
1.分析结果
-
2.文件批量提取
-
五.Python提取Json文件API特征和时间序列
-
六.总结
作者的github资源:
-
逆向分析:
-
https://github.com/eastmountyxz/
SystemSecurity-ReverseAnalysis
-
网络安全:
-
https://github.com/eastmountyxz/
-
NetworkSecuritySelf-study
一.恶意软件分析
1.静态特征
2.动态特征
二.Cuckoo和Cape沙箱简介
1.Cuckoo沙箱简介
2.Cape沙箱简介
3.Cape原理
三.Cape沙箱识别单样本特征
1.启动沙箱关键步骤
2.样本分析
1.分析结果
.
|-- analysis.conf
|-- analysis.log
|-- binary
|-- dump.pcap
|-- memory.dmp
|-- files
| |-- 1234567890
| `-- dropped.exe
|-- logs
| |-- 1232.raw
| |-- 1540.raw
| `-- 1118.raw
|-- reports
| |-- report.html
| |-- report.json
| |-- report.maec-4.0.1.xml
| `-- report.metadata.xml
`-- shots
|-- 0001.jpg
|-- 0002.jpg
|-- 0003.jpg
`-- 0004.jpg
2.文件批量提取
"target": {
"category": "file",
"file": {
"name": "033ad372890****ffc827fbac.bin",
"path": "/opt/CAPEv2/storage/binaries/26f5e813e34c05cd1e55****c24e58546e60",
"guest_paths": null,
"size": 70803,
"crc32": "12BCC81F",
"md5": "033ad372890****0ffc827fbac",
"sha1": "03b084e2c1c039****81d5f7d60eae",
"sha256": "26f5e813e34c05cd1e5532****416232c24e58546e60",
"sha512": "644860affd840d140198cea****bed41cca7887faebc",
"ssdeep": "1536:GiA3gHfirellrelGrzB/QhoCDW+4oDCdYH****3gHfirezre8/aDCdFoBjRaUnq",
"type": "Microsoft Word 2007+",
"yara": [],
"cape_yara": [],
"clamav": []
}
},
#coding:utf-8
#By:Eastmount CSDN 2023-04-10
import csv
import re
import os
import json
from jsonsearch import JsonSearch
def getAllFiles(targetDir):
listFiles = os.listdir(targetDir)
return listFiles
#-------------------------1.判断指定文件-----------------------------
aptname = "AAAA"
filenames = getAllFiles(aptname)
#['203', '204', ...,'277', '278']
i = 0
count = 0 #样本数量
while i<len(filenames):
#判断该文件夹中是否存在reports件夹 eg:Aggah277reports
filename = aptname + "\" + filenames[i] + "\reports"
print(filename)
if os.path.exists(filename):
#report.html report.json report.pdf summary-report.html
for n in os.listdir(filename):
if n=="report.json":
#----------------------2.提取MD5名称------------------
jsonfile = filename + "\report.json"
print(jsonfile)
with open(jsonfile) as fp:
data = json.load(fp)
print(data.keys())
count += 1
i += 1
print("Cape沙箱成功提取样本特征数量:", count)
#coding:utf-8
#By:Eastmount CSDN 2023-04-10
import csv
import re
import os
import json
from jsonsearch import JsonSearch
import shutil
def getAllFiles(targetDir):
listFiles = os.listdir(targetDir)
return listFiles
#-------------------------1.判断指定文件-----------------------------
aptname = "AAAA"
writename = aptname + "-Result"
filenames = getAllFiles(aptname)
#['203', '204', ...,'277', '278']
i = 0
count = 0 #样本数量
while i<len(filenames):
#判断该文件夹中是否存在reports件夹 eg:Aggah277reports
filename = aptname + "\" + filenames[i] + "\reports"
print(filename)
if os.path.exists(filename):
#report.html report.json report.pdf summary-report.html
for n in os.listdir(filename):
if n=="report.json":
#----------------------2.提取MD5名称------------------
jsonfile = filename + "\report.json"
htmlfile = filename + "\report.html"
print(jsonfile)
with open(jsonfile) as fp:
data = json.load(fp)
#print(data.keys())
target = data["target"]
#print(target)
#查找name对应的值
jsondata = JsonSearch(object=target,mode='j')
name = jsondata.search_all_value(key='name')
md5 = name[0].split(".")[0]
print(md5) #fb41ec1ea500beae2a7d5d373ebb906b.bin
#-----------------3.文件写入--------------------
if not os.path.exists(writename):
os.mkdir(writename)
fname = writename + "\" + md5 + ".json"
shutil.copy(jsonfile, fname)
fname = writename + "\" + md5 + ".html"
shutil.copy(htmlfile, fname)
count += 1
i += 1
print("Cape沙箱成功提取样本特征数量:", count)
五.Python提取Json文件API特征和时间序列
#coding:utf-8
#By:Eastmount CSDN 2023-04-10
import csv
import re
import os
import json
from jsonsearch import JsonSearch
import shutil
def getAllFiles(targetDir):
listFiles = os.listdir(targetDir)
return listFiles
apt = "AAAA"
aptname = apt + "-Result"
filenames = getAllFiles(aptname)
print(len(filenames))
writename = apt + "_result.csv"
fw = open(writename, mode="w", newline="")
writer = csv.writer(fw)
writer.writerow(['no', 'apt', 'md5', 'api'])
i = 0
while i<len(filenames):
#打开json文件
name = aptname + "\" + filenames[i]
print(name)
api_str = ""
md5 = filenames[i].split(".")[0]
with open(name, encoding='utf-8') as fp:
#特征解析
data = json.load(fp)
behavior = data["behavior"]
jsondata = JsonSearch(object=behavior, mode='j')
api = jsondata.search_all_value(key="api")
print("特征数量:", len(api))
print(api)
#特征存储
k = 0
while k<len(api):
value = str(api[k])
api_str += value + ";"
k += 1
else:
print("提取成功")
#print(api_str)
i += 1
#文件存储
writer.writerow([str(i), apt, md5, api_str])
print("------------------------------nn")
fw.close()
六.总结
-
一.恶意软件分析
-
1.静态特征
-
2.动态特征
-
二.Cuckoo和Cape沙箱简介
-
1.Cuckoo沙箱简介
-
2.Cape沙箱简介
-
3.Cape原理
-
三.Cape沙箱识别单样本特征
-
1.启动沙箱关键步骤
-
2.样本分析
-
四.Python批量提取Report报告
-
1.分析结果
-
2.文件批量提取
-
五.Python提取Json文件API特征和时间序列
-
六.总结
前文回顾(下面的超链接可以点击喔):
-
[系统安全] 四十八.恶意软件分析 (5)Cape沙箱分析结果Report报告的API序列批量提取详解
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论