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('