Package rekall :: Package plugins :: Package linux :: Module heap_analysis :: Class HeapAnalysis
[frames] | no frames]

Class HeapAnalysis

source code


Basic abstract class for linux heap analysis. Mostly serves the main_arena.

Nested Classes
  __metaclass__
Automatic Plugin Registration through metaclasses. (Inherited from rekall.plugin.Command)
  top_level_class
A command can be run from the rekall command line. (Inherited from rekall.plugin.Command)
Instance Methods
 
activate_chunk_preservation(self)
Sets _preserve_chunks to True.
source code
 
get_all_mmapped_chunks(self)
Returns all allocated MMAPPED chunks.
source code
 
get_aligned_address(self, address, different_align_mask=None)
Returns an aligned address or MINSIZE, if given MIN_CHUNK_SIZE as argument.
source code
 
get_aligned_size(self, size)
Returns an aligned size.
source code
 
get_all_allocated_chunks_for_arena(self, arena)
Returns all allocated chunks for a given arena.
source code
 
get_all_chunks(self)
Returns all chunks (allocated, freed and MMAPPED chunks).
source code
 
get_all_allocated_main_chunks(self)
Returns all allocated chunks belonging to the main arena (excludes thread and MMAPPED chunks).
source code
 
get_all_allocated_thread_chunks(self)
Returns all allocated chunks which belong to a thread arena.
source code
 
get_all_allocated_chunks(self)
Returns all allocated chunks, no matter to what arena they belong or if they are MMAPPED or not.
source code
 
get_all_freed_fastbin_chunks(self)
Returns all freed fastbin chunks, no matter to what arena they belong.
source code
 
get_all_freed_bin_chunks(self)
Returns all freed chunks, no matter to what arena they belong.
source code
 
get_all_freed_chunks(self)
Returns all top chunks, freed chunks and freed fastbin chunks, no matter to what arena they belong.
source code
 
heap_for_ptr(self, ptr)
Returns the heap from the internal heap lists, the given pointer belongs to.
source code
 
__init__(self, **kwargs)
A mixin for plugins which require a valid kernel address space.
source code
 
get_main_arena(self)
Returns the main_arena for the current task, which is the first arena in the arenas list.
source code
 
iterate_through_chunks(self, first_chunk, mem_end, only_free=False, only_alloc=False)
This function iterates chunk after chunk until hitting mem_end.
source code
 
init_for_task(self, task)
initializes the process address space and malloc_par struct and calls initialize_*.
source code
 
search_vmas_for_needle(self, search_string=None, search_regex=None, pointers=None, vmas=None, hidden_mmap_vmas=None, vma_regex=None)
Searches all vmas or only the given ones for the given pointer(s).
source code
 
get_chunks_for_addresses(self, addresses, ignore_prevsize=False)
Returns the chunks located at the given addresses.
source code
 
search_chunks_for_needle(self, search_string=None, search_regex=None, pointers=None, search_struct=False)
Searches all chunks for the given pointer(s) and returns the ones containing them.
source code
 
calculate_statistics(self)
Sets the class attribute self.statistics with a dict containing e.g.
source code
 
check_and_report_size_inconsistencies(self)
Calls size comparison methods to verify the gathered chunks and prints warnings on any discrepancies.
source code
 
compare_mmapped_chunks_with_mp_(self)
Compares the calculated count and size of all MMAPPED chunks with the data from the malloc_par struct.
source code
 
get_mallinfo_string(self)
Returns statistics according to the mallinfo struct except for keepcost and usmblks.
source code
 
__iter__(self)
Make plugins that define collect iterable, as convenience. (Inherited from rekall.plugin.Command)
source code
 
__repr__(self)
repr(x) (Inherited from rekall.plugin.Command)
source code
 
__str__(self)
Render into a string using the text renderer. (Inherited from rekall.plugin.Command)
source code
 
collect(self)
Collect data that will be passed to renderer.table_row. (Inherited from rekall.plugin.TypedProfileCommand)
source code
 
collect_as_dicts(self) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
column_types(self)
Returns instances for each column definition. (Inherited from rekall.plugin.TypedProfileCommand)
source code
 
filter_processes(self)
Filters eprocess list using pids lists. (Inherited from rekall.plugins.linux.common.LinProcessFilter)
source code
 
get_column(self, name) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
get_column_type(self, name) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
get_plugin(self, name, **kwargs)
Returns an instance of the named plugin. (Inherited from rekall.plugin.Command)
source code
 
getkeys(self) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
list_from_task_head(self) (Inherited from rekall.plugins.linux.common.LinProcessFilter) source code
 
list_tasks(self) (Inherited from rekall.plugins.linux.common.LinProcessFilter) source code
 
reflect(self, member) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
render(self, renderer, **options) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
virtual_process_from_physical_offset(self, physical_offset)
Tries to return an task in virtual space from a physical offset. (Inherited from rekall.plugins.linux.common.LinProcessFilter)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods
 
is_active(cls, session)
Checks we are active.
source code
 
GetActiveClasses(cls, session)
Return only the active commands based on config. (Inherited from rekall.plugin.Command)
source code
 
GetPrototype(cls, session)
Return an instance of this plugin with suitable default arguments. (Inherited from rekall.plugin.Command)
source code
 
ImplementationByClass(self, name) source code
 
ImplementationByName(self, name) source code
 
args(cls, metadata) (Inherited from rekall.plugin.PhysicalASMixin) source code
Class Variables
  METHODS = ['InitTask'] (Inherited from rekall.plugins.linux.common.LinProcessFilter)
  PHYSICAL_AS_REQUIRED = True (Inherited from rekall.plugin.PhysicalASMixin)
  PROFILE_REQUIRED = True (Inherited from rekall.plugin.ProfileCommand)
  ROW_OPTIONS = set(['annotation', 'depth', 'hex_width', 'highli... (Inherited from rekall.plugin.TypedProfileCommand)
  classes = {'AFF4Acquire': <class 'rekall.plugins.tools.aff4acq... (Inherited from rekall.plugin.Command)
  classes_by_name = {None: [<class 'rekall.plugins.tools.ipython... (Inherited from rekall.plugin.Command)
  error_status = None
hash(x) (Inherited from rekall.plugin.Command)
  interactive = False (Inherited from rekall.plugin.Command)
  mode = 'mode_linux_memory'
hash(x) (Inherited from rekall.plugins.linux.common.AbstractLinuxCommandPlugin)
  plugin_args = None
hash(x) (Inherited from rekall.plugin.ArgsParserMixin)
  plugin_feature = 'Command' (Inherited from rekall.plugin.Command)
  producer = False (Inherited from rekall.plugin.Command)
  table_header = None
hash(x) (Inherited from rekall.plugin.TypedProfileCommand)
  table_options = {} (Inherited from rekall.plugin.TypedProfileCommand)
Properties
  filtering_requested (Inherited from rekall.plugins.linux.common.LinProcessFilter)
  name (Inherited from rekall.plugin.Command)

Inherited from object: __class__

Method Details

activate_chunk_preservation(self)

source code 

Sets _preserve_chunks to True. This forces all allocated chunk functions to store chunks in lists, which highly increases the speed of a second walk over those chunks. This feature can only be activated if performance is set to 'fast'.

get_aligned_size(self, size)

source code 

Returns an aligned size. Originally used to align a user request size.

get_all_allocated_chunks_for_arena(self, arena)

source code 

Returns all allocated chunks for a given arena. This function is basically a wrapper around _allocated_chunks_for_main_arena and allocated_chunks_for_thread_arena.

__init__(self, **kwargs)
(Constructor)

source code 
A mixin for plugins which require a valid kernel address space.

Args:
  dtb: A potential dtb to be used.

Overrides: object.__init__
(inherited documentation)

get_main_arena(self)

source code 

Returns the main_arena for the current task, which is the first arena in the arenas list. If the current instance is not intialized, it logs a warning.

iterate_through_chunks(self, first_chunk, mem_end, only_free=False, only_alloc=False)

source code 

This function iterates chunk after chunk until hitting mem_end. Tests for allocation status are not made via bins/fastbins but with chunk flags. Note: This function will not return the last chunk, if only_free or/and only_alloc is set as there is no PREV_INUSE bit which could be tested.

init_for_task(self, task)

source code 

initializes the process address space and malloc_par struct and calls initialize_*. Should be the first method to be called for each task. Returns True if everything seems to be gone fine.

search_vmas_for_needle(self, search_string=None, search_regex=None, pointers=None, vmas=None, hidden_mmap_vmas=None, vma_regex=None)

source code 

Searches all vmas or only the given ones for the given pointer(s). pointers = a list of int pointers regex = a regex identifying relevant vm_areas Returns a list of hits

get_chunks_for_addresses(self, addresses, ignore_prevsize=False)

source code 

Returns the chunks located at the given addresses. The address can be at the beginning or somewhere in the middle of the chunk.

search_chunks_for_needle(self, search_string=None, search_regex=None, pointers=None, search_struct=False)

source code 

Searches all chunks for the given pointer(s) and returns the ones containing them. It only searches the data part of a chunk (e.g. not fd/bk fields for bin chunks).

pointers = a list of int pointers search_string/search_regex = a string or regex to search for in a chunk search_struct = if set to True, also fields like size and fd/bk for bin chunks are included

calculate_statistics(self)

source code 

Sets the class attribute self.statistics with a dict containing e.g. number of allocated/freed/fastbin chunks, their sizes...

compare_mmapped_chunks_with_mp_(self)

source code 

Compares the calculated count and size of all MMAPPED chunks with the data from the malloc_par struct. Returns None on any errors, True if count and sizes match and otherwise False.

get_mallinfo_string(self)

source code 

Returns statistics according to the mallinfo struct except for keepcost and usmblks. See http://man7.org/linux/man-pages/man3/mallinfo.3.html

is_active(cls, session)
Class Method

source code 

Checks we are active.

This method will be called with the session to check if this specific class is active. This mechanism allows multiple implementations to all share the same name, as long as only one is actually active. For example, we can have a linux, windows and mac version of plugins with the "pslist" name.

This mixin provides the mixed class with a basic is_active() method which honors a mode member defined on the class and all its subclasses. The mode is additive (meaning each class and its subclasses are only active if the mode is active).

Overrides: plugin.ModeBasedActiveMixin.is_active
(inherited documentation)

ImplementationByClass(self, name)
Class Method

source code 
Overrides: plugin.Command.ImplementationByClass

ImplementationByName(self, name)
Class Method

source code 
Overrides: plugin.Command.ImplementationByName