# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ @author: Edwin Smulders @license: GNU General Public License 2.0 or later @contact: mail@edwinsmulders.eu """ import struct import collections import itertools import volatility.plugins.linux.pslist as linux_pslist import volatility.plugins.linux.proc_maps as linux_proc_maps import volatility.plugins.linux.common as linux_common import volatility.plugins.linux.threads as linux_threads # Because we want to address registers like "registers.eip" # TODO: replace with linux_info_regs registers = collections.namedtuple('registers', [ 'r15', 'r14', 'r13', 'r12', 'rbp', 'rbx', 'r11', 'r10', 'r9', 'r8', 'rax', 'rcx', 'rdx', 'rsi', 'rdi', 'unknown', 'rip', 'cs', 'eflags', 'rsp', 'ss' ]) # TODO: these were the initial registers, they might be valid for x86 # To investigate: view kernel stack using this module # compare using "info r" in gdb. # registers = collections.namedtuple('registers', # ['bla1', 'bla2','bla3','bla4', 'ebx', 'ecx', 'edx', # 'esi', 'edi', 'ebp', # 'eax', 'eds', 'ees', # 'efs', 'egs', 'orig_eax', # 'eip', 'ecs', 'flags', # 'esp', 'ess', # ]) #test #registers = collections.namedtuple('registers', ['ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp', 'eax', 'eds', 'ees', 'efs', 'egs', 'orig_eax', 'eip', 'ecs', 'flags', 'esp', 'ess']) address_size = 8 # Helper functions def null_list(pages, size): """ Split a section (divided by pages) on 0-bytes. @param pages: a list of pages @param size: total size of the section @return: a list of strings """ res = [] for page in pages: if size > 4096: size -= 4096 else: page = page[:size] for s in page.split('\0'): if s != "": res.append(s) return res def int_list(pages, size): """ Split a range into integers. Will split into words (e.g. 4 or 8 bytes). @param pages: a list of pages @param size: total size of the section @return: a list of word-sized integers """ if address_size == 4: fmt = "