Package rekall :: Package plugins :: Package common :: Package efilter_plugins :: Module search :: Class Search
[frames] | no frames]

Class Search

source code



Searches and recombines output of other plugins.

Search allows you to use the EFILTER search engine to filter, transform
and combine output of most Rekall plugins. The most common use for this
is running IOCs.

## Some examples

* Find the process with pid 1:

  ```
  select * pslist() where proc.pid == 1
  ```

* Sort lsof output by file descriptor:

  ```
  select * from lsof() order by fd
  ```

* Filter and sort through lsof in one step:

  ```
  select * from lsof() where proc.name =~ "rekall" order by fd
  ```

* Is there any proc with PID 1, that has a TCPv6 connection and
  isn't a dead process?

  ```
  search("(any lsof where (proc.pid == 1 and fileproc.human_type == 'TCPv6'))
  and not (any dead_procs where (proc.pid == 1))")
  ```

Note: "ANY" is just a short hand for "SELECT ANY FROM" which does what
it sounds like, and returns True or False depending on whether the
query has any results.

You will probably need to use the *describe* plugin to help
discover the exact column structure.


* regex match on array of strings - case insensitive.

  ```
  (Windows)
  select proc, proc.environ from pslist() where
    proc.environ.TMP =~ "temp"

  (Linux)
  select proc, proc.environ from pslist() where
     proc.environ.PATH =~ "home"
  ```

* Format using the hex() method, using *as* to name columns.

  ```
  (Windows)
  select hex(VAD.start) as start, hex(VAD.end) as end,
        Protect from vad(proc_regex: "rekal")

  (Linux)
  select hex(start) as start, hex(end) as end, filename
        from maps(proc_regex: "rekall")
  ```

* Autoselect column names - second column can not clash with first
  column name (should be hex, column 1).

  ```
  (Windows)
  select hex(VAD.start), hex(VAD.end), Protect
        from vad(proc_regex: "rekal")

  (Linux)
  select hex(start), hex(end), filename from maps(proc_regex: "rekall")
  ```
* Timestamp user function

  ```
    select proc, timestamp(proc.create_time) from pslist()
  ```

* Yarascan with sub query

  ```
    select * from file_yara(
       paths: (
        select path.filename from glob(
            "c:\windows\*.exe")).filename,
       yara_expression: "rule r1 {strings: $a = "Microsoft" wide condition: any of them}")
  ```

  On Linux:
  ```
  select * from file_yara(
        paths: (
          select path.filename from glob(
             "/home/*/.ssh/*")).filename,
        yara_expression: "rule r1 {strings: $a = "ssh-rsa" condition: any of them}")
  ```

* Parameter interpolations:

  ```
    a =  "select * from file_yara(paths: ( select path.filename from glob({0})).filename, yara_expression: {1})"

    search a, [r"c:\windows\*.exe",
         "rule r1 {strings: $a = "Microsoft" wide condition: any of them}"]
  ```
* WMI integration + unknown field:

  ```
    select Result.Name, Result.SessionId, Result.foo
         from wmi("select * from Win32_Process")

    select Result.Name, Result.BootDevice
         from wmi("select * from Win32_OperatingSystem")
  ```

* Describe WMI dynamic query

  ```
    describe wmi, dict(query="select * from Win32_Process")
  ```

* Substitute a single string

  ```
    select sub("Microsoft", "MS", Result.Name)
           from wmi("select * from Win32_OperatingSystem")
  ```
* Substiture an array

  ```
    select sub("rekal", "REKALL", proc.cmdline) from pslist()
  ```

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
 
collect(self)
Return the search results without displaying them.
source code
 
solve(self)
Return the search results exactly as EFILTER returns them.
source code
 
render(self, renderer)
Produce results on the renderer given.
source code
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
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_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
 
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
 
getmembers_runtime(self)
Get all available plugins. (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
source code
 
reflect(self, member) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
reflect_runtime_member(self, name)
Find the type* of 'name', which is a plugin. (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
source code
 
render_error(self, renderer)
Render the query parsing error in a user-friendly manner. (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
source code
 
resolve(self, name)
Find and return a CommandWrapper for the plugin 'name'. (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
source code

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

Class Methods
 
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, parser) (Inherited from rekall.plugin.TypedProfileCommand) source code
 
is_active(cls, session)
Checks we are active. (Inherited from rekall.plugin.ModeBasedActiveMixin)
source code
Class Variables
  name = 'search'
hash(x)
  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 = None
hash(x) (Inherited from rekall.plugin.Command)
  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)
  query = None
hash(x) (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
  query_error = None
hash(x) (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
  query_source = None
hash(x) (Inherited from rekall.plugins.common.efilter_plugins.search.EfilterPlugin)
  table_header = None
hash(x) (Inherited from rekall.plugin.TypedProfileCommand)
  table_options = {} (Inherited from rekall.plugin.TypedProfileCommand)
Properties
  first_result
Get only the first search result.

Inherited from object: __class__

Method Details

collect(self)

source code 
Return the search results without displaying them.

Returns:
    A list of results from the query solver.

Raises:
    EfilterError unless 'silent' flag was set.

Overrides: plugin.TypedProfileCommand.collect

solve(self)

source code 
Return the search results exactly as EFILTER returns them.

Returns:
    Depends on the query.

Raises:
    EfilterError if anything goes wrong.

render(self, renderer)

source code 
Produce results on the renderer given.

Each plugin should implement this method to produce output on the
renderer. The framework will initialize the plugin and provide it with
some kind of renderer to write output on. The plugin should not assume
that the renderer is actually TextRenderer, only that the methods
defined in the BaseRenderer exist.

Args:
  renderer: A renderer based at rekall.ui.renderer.BaseRenderer.

Overrides: plugin.Command.render
(inherited documentation)

ImplementationByClass(self, name)
Class Method

source code 
Overrides: plugin.Command.ImplementationByClass

ImplementationByName(self, name)
Class Method

source code 
Overrides: plugin.Command.ImplementationByName

Property Details

first_result

Get only the first search result.

This is useful when we need to find a concrete structure for some other purpose, such as finding a concrete allocator zone when writing a 'dump_zone' plugin.

Get Method:
unreachable.first_result(self) - Get only the first search result.