From c0b8e531dc9d6493ca89dc0408e1be854207570d Mon Sep 17 00:00:00 2001 From: iansus Date: Wed, 11 Sep 2019 13:37:49 +0100 Subject: [PATCH] [iansus][notpetyakeys] merged plugin published in own repo in 2017 --- iansus/NotPetyaKeys/notpetya.py | 137 ++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 iansus/NotPetyaKeys/notpetya.py diff --git a/iansus/NotPetyaKeys/notpetya.py b/iansus/NotPetyaKeys/notpetya.py new file mode 100644 index 0000000..d027e4e --- /dev/null +++ b/iansus/NotPetyaKeys/notpetya.py @@ -0,0 +1,137 @@ +#!/usr/bin/python + +''' +Copyright: Wavestone 2017 (c) +Author: Jean MARSAULT (@iansus) +Version: 1.0 +Thanks: @gentilkiwi, @th3m4ks +Description: + Volatility plugin to search for NotPetya AES keys in memory + Report bugs to Jean MARSAULT (@iansus almost everywhere) +''' + +import struct + +import volatility.commands as commands +import volatility.debug as debug +import volatility.utils as utils +import volatility.win32.tasks as tasks + +try: + import yara + has_yara = True +except ImportError: + has_yara = False + + +try: + import pefile + has_pefile = True +except ImportError: + has_pefile = False + + +def read_bytes(address, a, length=4): + return a.read(address, length) + + +def deref(address, a, length=4): + try: + d = struct.unpack(" 8*1024*1024*1024: + continue + + # read the VAD content + data = process_space.zread(vad.Start, vad.Length) + + # match yara rules + matches = rules.match(data=data) + + # profit ! + if matches: + for offset, _, match in matches[0].strings: + + keyaddr = struct.unpack('