
- Python取證教程
- 首頁
- 簡介
- Python安裝
- Python概述
- 基本取證應用
- 雜湊函式
- 破解加密
- 虛擬化
- 網路取證
- Python模組
- Dshell和Scapy
- 搜尋
- 索引
- Python影像庫
- 移動取證
- 網路時間協議
- 多處理支援
- 記憶體與取證
- Linux中的取證
- 入侵指標
- 雲的實施
- Python取證有用資源
- Python取證 - 快速指南
- Python取證 - 有用資源
- Python取證 - 討論
Python取證 - 記憶體和取證
在本章中,我們將重點關注使用Volatility(一個基於Python的取證框架,適用於以下平臺:Android和Linux)來調查易失性記憶體。
易失性記憶體
易失性記憶體是一種儲存型別,當系統電源關閉或中斷時,其內容會被擦除。RAM是易失性記憶體的最佳示例。這意味著,如果您正在處理尚未儲存到非易失性記憶體(如硬碟驅動器)的文件,並且計算機斷電,則所有資料都將丟失。
通常,易失性記憶體取證遵循與其他取證調查相同的模式:
- 選擇調查目標
- 獲取取證資料
- 取證分析
用於Android的基本Volatility外掛會收集記憶體轉儲以進行分析。一旦收集了記憶體轉儲以進行分析,就需要開始在記憶體中搜索惡意軟體。
YARA規則
YARA是一個流行的工具,它提供了一個強大的語言,與基於Perl的正則表示式相容,並用於檢查可疑檔案/目錄並匹配字串。
在本節中,我們將使用基於模式匹配實現的YARA,並將其與實用程式功能結合起來。完整的流程將有利於取證分析。
示例
考慮以下程式碼。此程式碼有助於提取程式碼。
import operator import os import sys sys.path.insert(0, os.getcwd()) import plyara.interp as interp # Plyara is a script that lexes and parses a file consisting of one more Yara # rules into a python dictionary representation. if __name__ == '__main__': file_to_analyze = sys.argv[1] rulesDict = interp.parseString(open(file_to_analyze).read()) authors = {} imps = {} meta_keys = {} max_strings = [] max_string_len = 0 tags = {} rule_count = 0 for rule in rulesDict: rule_count += 1 # Imports if 'imports' in rule: for imp in rule['imports']: imp = imp.replace('"','') if imp in imps: imps[imp] += 1 else: imps[imp] = 1 # Tags if 'tags' in rule: for tag in rule['tags']: if tag in tags: tags[tag] += 1 else: tags[tag] = 1 # Metadata if 'metadata' in rule: for key in rule['metadata']: if key in meta_keys: meta_keys[key] += 1 else: meta_keys[key] = 1 if key in ['Author', 'author']: if rule['metadata'][key] in authors: authors[rule['metadata'][key]] += 1 else: authors[rule['metadata'][key]] = 1 #Strings if 'strings' in rule: for strr in rule['strings']: if len(strr['value']) > max_string_len: max_string_len = len(strr['value']) max_strings = [(rule['rule_name'], strr['name'], strr['value'])] elif len(strr['value']) == max_string_len: max_strings.append((rule['rule_name'], strr['key'], strr['value'])) print("\nThe number of rules implemented" + str(rule_count)) ordered_meta_keys = sorted(meta_keys.items(), key = operator.itemgetter(1), reverse = True) ordered_authors = sorted(authors.items(), key = operator.itemgetter(1), reverse = True) ordered_imps = sorted(imps.items(), key = operator.itemgetter(1), reverse = True) ordered_tags = sorted(tags.items(), key = operator.itemgetter(1), reverse = True)
以上程式碼將產生以下輸出。

實施的YARA規則的數量有助於更好地瞭解可疑檔案。間接地,可疑檔案列表有助於收集適當的取證資訊。
以下是github上的原始碼:https://github.com/radhikascs/Python_yara
廣告