# Detecting Nanocore RAT for Volatilitv # # Based on the script below: # https://github.com/kevthehermit/RATDecoders/blob/master/decoders/NanoCore.py # # How to use: # 1. cd "Volatility Folder" # 2. mv nanocoreconfigallocate.py volatility/plugins/malware # 3. python vol.py nanocoreconfig -f images.mem --profile=Win7SP1x64 import volatility.plugins.taskmods as taskmods import volatility.win32.tasks as tasks import volatility.utils as utils import volatility.debug as debug import volatility.plugins.malware.malfind as malfind import re from struct import unpack, unpack_from from collections import OrderedDict try: import yara has_yara = True except ImportError: has_yara = False nanocore_sig = { 'namespace1' : 'rule Nanocore { \ strings: \ $v1 = "NanoCore Client" \ $v2 = "PluginCommand" \ $v3 = "CommandType" \ condition: all of them}' } # Config pattern CONFIG_PATTERNS = [re.compile("Version.\x07(.*?)\x0cMutex", re.DOTALL)] MODE = {0x0: "Disable", 0x01: "Enable"} class nanocoreConfig(taskmods.DllList): "Parse the Nanocore configuration" @staticmethod def is_valid_profile(profile): return (profile.metadata.get('os', 'unknown') == 'windows'), profile.metadata.get('memory_model', '32bit') def get_vad_base(self, task, address): for vad in task.VadRoot.traverse(): if address >= vad.Start and address < vad.End: return vad.Start, vad.End return None def parse_config(self, data): p_data = OrderedDict() p_data['Version'] = re.search('Version..(.*?)\x0c', data).group()[8:16] p_data['Mutex'] = re.search('Mutex(.*?)\x0c', data).group()[6:-1].encode('hex') p_data['Group'] = re.search('DefaultGroup\x0c(.*?)\x0c', data).group()[14:-1] p_data['Domain1'] = re.search('PrimaryConnectionHost\x0c(.*?)Back', data, re.DOTALL).group()[23:-6] p_data['Domain2'] = re.search('BackupConnectionHost\x0c(.*?)\x0c', data).group()[22:-1] p_data['Port'] = unpack("