Module: Kernel

Ronin - A Ruby platform for exploit development and security research.

Copyright © 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Public Visibility

Public Instance Method Summary

#attempt(&block)

Calls the given block and ignores any raised exceptions.

Returns: nil

#catch_all(verbose = true, &block)

Attempts to run the given block and catches any SyntaxError,.

Returns: nil

#hexdump(object, output = STDOUT)

Hexdumps an object.

#require_within(directory, sub_path)

Safely requires the specified sub_path from within the specified.

Returns: Boolean

#ronin_extension(&block)

Creates a new Ronin::Platform::Extension object using the given.

Public Instance Method Details

attempt

public nil attempt(&block)

Calls the given block and ignores any raised exceptions.

Meta Tags

Example:

  attempt do
    Resolv.getaddress('might.not.exist.com')
  end

Yields:

[Object]
The block to be called.

Returns:

[nil]

An exception was ignored, or the block returned nil.

[View source]


36
37
38
39
40
41
42
# File 'lib/ronin/extensions/kernel.rb', line 36

def attempt(&block)
  begin
    block.call() if block
  rescue Exception
    return nil
  end
end

catch_all

public nil catch_all(verbose = true, &block)

Attempts to run the given block and catches any SyntaxError, RuntimeError or StandardError exceptions.

Meta Tags

Example:

  catch_all do
    load 'suspicious.rb'
  end

Parameters:

[Boolean] verbose

Specifies wether a backtrace will be printed when an exception has been raised.

Yields:

[Object]
The block to be called.

Returns:

[nil]

An exception was ignored, or the block returned nil.

[View source]


63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ronin/extensions/kernel.rb', line 63

def catch_all(verbose=true,&block)
  begin
    block.call() if block
  rescue Exception => e
    if verbose
      STDERR.puts "#{e.class}: #{e}"
      e.backtrace[0,5].each { |trace| STDERR.puts "\t#{trace}" }
    end

    return nil
  end
end

hexdump

public hexdump(object, output = STDOUT)

Hexdumps an object.

Meta Tags

[View source]


29
30
31
# File 'lib/ronin/ui/hexdump/extensions/kernel.rb', line 29

def hexdump(object,output=STDOUT)
  Ronin::UI::Hexdump.dump(object,output)
end

require_within

public Boolean require_within(directory, sub_path)

Safely requires the specified sub_path from within the specified directory.

Meta Tags

Example:

  require_within 'ronin/exploits/helpers', helper_name

Parameters:

[String] directory

The directory to require the sub_path within.

[String] sub_path

The relative path to require, specifically within the specified directory.

Returns:

[Boolean]

Specifies wether or not the sub_path has not been loaded before.

[View source]


93
94
95
96
# File 'lib/ronin/extensions/kernel.rb', line 93

def require_within(directory,sub_path)
  path = File.expand_path(File.join('',sub_path))
  require File.join(directory,path)
end

ronin_extension

public ronin_extension(&block)

Creates a new Ronin::Platform::Extension object using the given block.

  ronin_extension do
    ...
  end
[View source]


46
# File 'lib/ronin/platform/extension.rb', line 46

contextify :ronin_extension
Generated on Friday, September 25 2009 at 02:57:38 PM by YARD 0.2.3.5 (ruby-1.8.6).