ronin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/History.txt +39 -0
  2. data/Manifest.txt +46 -34
  3. data/README.txt +81 -20
  4. data/Rakefile +6 -4
  5. data/TODO.txt +1 -5
  6. data/bin/ronin +2 -2
  7. data/lib/ronin.rb +3 -3
  8. data/lib/ronin/arch.rb +5 -3
  9. data/lib/ronin/author.rb +2 -1
  10. data/lib/ronin/cache/cache.rb +78 -0
  11. data/lib/ronin/cache/extension.rb +6 -6
  12. data/lib/ronin/cache/extension_cache.rb +3 -21
  13. data/lib/ronin/{parameters/instance_param.rb → cache/maintainer.rb} +22 -17
  14. data/lib/ronin/cache/overlay.rb +74 -23
  15. data/lib/ronin/cache/overlay_cache.rb +3 -21
  16. data/lib/ronin/chars/char_set.rb +114 -31
  17. data/lib/ronin/chars/chars.rb +20 -10
  18. data/lib/ronin/{parameters/param.rb → code/emittable.rb} +29 -11
  19. data/lib/ronin/code/symbol_table.rb +13 -0
  20. data/lib/ronin/{parameters/class_param.rb → code/token.rb} +37 -10
  21. data/lib/ronin/config.rb +33 -0
  22. data/lib/ronin/context.rb +32 -29
  23. data/lib/ronin/database.rb +1 -2
  24. data/lib/ronin/extensions.rb +0 -1
  25. data/lib/ronin/extensions/string.rb +41 -0
  26. data/lib/ronin/extensions/uri/query_params.rb +8 -0
  27. data/lib/ronin/formatting/extensions/binary/string.rb +10 -0
  28. data/lib/ronin/{program.rb → hexdump.rb} +2 -2
  29. data/lib/ronin/{parameters/exceptions/missing_param.rb → hexdump/extensions.rb} +2 -6
  30. data/lib/ronin/{extensions/kernel.rb → hexdump/extensions/file.rb} +8 -6
  31. data/lib/ronin/{persistence.rb → hexdump/extensions/kernel.rb} +7 -6
  32. data/lib/ronin/hexdump/hexdump.rb +76 -0
  33. data/lib/ronin/license.rb +5 -3
  34. data/lib/ronin/model.rb +4 -2
  35. data/lib/ronin/models.rb +8 -2
  36. data/lib/ronin/object_context.rb +89 -62
  37. data/lib/ronin/rpc/console.rb +6 -4
  38. data/lib/ronin/rpc/shell.rb +4 -4
  39. data/lib/ronin/sessions/http.rb +144 -0
  40. data/lib/ronin/sessions/session.rb +2 -1
  41. data/lib/ronin/sessions/telnet.rb +3 -1
  42. data/lib/ronin/sessions/udp.rb +1 -1
  43. data/lib/ronin/sessions/web.rb +7 -2
  44. data/lib/ronin/translators/translator.rb +75 -0
  45. data/lib/ronin/ui/command_line.rb +25 -0
  46. data/lib/ronin/ui/command_line/command.rb +165 -0
  47. data/lib/ronin/ui/command_line/command_line.rb +117 -0
  48. data/lib/ronin/{program → ui/command_line}/commands.rb +12 -9
  49. data/lib/ronin/ui/command_line/commands/add.rb +75 -0
  50. data/lib/ronin/{program/commands/help.rb → ui/command_line/commands/default.rb} +26 -17
  51. data/lib/ronin/ui/command_line/commands/extension.rb +85 -0
  52. data/lib/ronin/ui/command_line/commands/help.rb +70 -0
  53. data/lib/ronin/{program → ui/command_line}/commands/install.rb +26 -23
  54. data/lib/ronin/ui/command_line/commands/list.rb +93 -0
  55. data/lib/ronin/ui/command_line/commands/overlay.rb +187 -0
  56. data/lib/ronin/{program/commands/uninstall.rb → ui/command_line/commands/remove.rb} +25 -17
  57. data/lib/ronin/{program/commands/update.rb → ui/command_line/commands/uninstall.rb} +27 -17
  58. data/lib/ronin/{program/commands/remove.rb → ui/command_line/commands/update.rb} +24 -18
  59. data/lib/ronin/{program → ui/command_line}/exceptions.rb +1 -1
  60. data/lib/ronin/{program → ui/command_line}/exceptions/unknown_command.rb +4 -2
  61. data/lib/ronin/ui/command_line/options.rb +148 -0
  62. data/lib/ronin/{console.rb → ui/console.rb} +0 -0
  63. data/lib/ronin/ui/shell.rb +117 -0
  64. data/lib/ronin/version.rb +1 -1
  65. data/lib/ronin/web.rb +1 -0
  66. data/lib/ronin/web/extensions.rb +1 -0
  67. data/lib/ronin/web/extensions/hpricot.rb +5 -0
  68. data/lib/ronin/web/extensions/hpricot/comment.rb +19 -0
  69. data/lib/ronin/web/extensions/hpricot/container.rb +46 -0
  70. data/lib/ronin/web/extensions/hpricot/doc.rb +21 -0
  71. data/lib/ronin/web/extensions/hpricot/elem.rb +25 -0
  72. data/lib/ronin/web/extensions/hpricot/tag.rb +19 -0
  73. data/lib/ronin/web/extensions/hpricot/text.rb +19 -0
  74. data/lib/ronin/web/web.rb +70 -4
  75. data/spec/arch_spec.rb +1 -1
  76. data/spec/author_spec.rb +1 -1
  77. data/spec/chars/char_set_spec.rb +177 -0
  78. data/spec/code/symbol_table_spec.rb +6 -0
  79. data/spec/extensions/string_spec.rb +12 -0
  80. data/spec/formatting/binary_spec.rb +9 -0
  81. data/spec/license_spec.rb +1 -1
  82. data/spec/object_context/object_context_spec.rb +29 -0
  83. data/spec/platform_spec.rb +1 -1
  84. data/spec/product_spec.rb +1 -1
  85. data/spec/ronin_spec.rb +1 -1
  86. data/spec/spec_helper.rb +3 -2
  87. data/spec/target_spec.rb +1 -1
  88. data/spec/translators/translator_spec.rb +63 -0
  89. data/spec/web/extensions/hpricot_spec.rb +62 -0
  90. data/static/extension.rb.erb +16 -0
  91. data/static/overlay.xsl +103 -0
  92. data/tasks/spec.rb +2 -0
  93. metadata +72 -42
  94. data/FAQ.txt +0 -103
  95. data/lib/ronin/environment.rb +0 -39
  96. data/lib/ronin/objects.rb +0 -27
  97. data/lib/ronin/parameters.rb +0 -27
  98. data/lib/ronin/parameters/exceptions.rb +0 -25
  99. data/lib/ronin/parameters/exceptions/param_not_found.rb +0 -29
  100. data/lib/ronin/parameters/parameters.rb +0 -286
  101. data/lib/ronin/program/command.rb +0 -203
  102. data/lib/ronin/program/commands/add.rb +0 -71
  103. data/lib/ronin/program/commands/list.rb +0 -79
  104. data/lib/ronin/program/options.rb +0 -201
  105. data/lib/ronin/program/program.rb +0 -168
  106. data/lib/ronin/rpc/interactive.rb +0 -55
  107. data/lib/ronin/rpc/interactive_console.rb +0 -58
  108. data/lib/ronin/rpc/interactive_shell.rb +0 -59
  109. data/lib/ronin/shell.rb +0 -81
  110. data/spec/parameters/parameters_spec.rb +0 -109
@@ -52,9 +52,6 @@ module Ronin
52
52
  # The alpha-numeric character set
53
53
  ALPHA_NUMERIC = ALPHA + NUMERIC
54
54
 
55
- # The space character set
56
- SPACE = CharSet.new(' ', "\f", "\n", "\r", "\t", "\v")
57
-
58
55
  # The punctuation character set
59
56
  PUNCTUATION = CharSet.new(' ', '\'', '"', '`', ',', ';', ':', '~', '-',
60
57
  '(', ')', '[', ']', '{', '}', '.', '?', '!')
@@ -63,6 +60,12 @@ module Ronin
63
60
  SYMBOLS = PUNCTUATION + ['@', '#', '$', '%', '^', '&', '*', '_', '+',
64
61
  '=', '|', '\\', '<', '>', '/']
65
62
 
63
+ # The space character set
64
+ SPACE = CharSet.new(' ', "\f", "\n", "\r", "\t", "\v")
65
+
66
+ # The set of printable characters (including spaces)
67
+ PRINTABLE = ALPHA_NUMERIC + PUNCTUATION + SYMBOLS + SPACE
68
+
66
69
  # The control-char character set
67
70
  CONTROL = CharSet.new(0..0x1f, 0x7f)
68
71
 
@@ -135,13 +138,6 @@ module Ronin
135
138
  ALPHA_NUMERIC
136
139
  end
137
140
 
138
- #
139
- # The space character set.
140
- #
141
- def Chars.space
142
- SPACE
143
- end
144
-
145
141
  #
146
142
  # The punctuation character set.
147
143
  #
@@ -156,6 +152,20 @@ module Ronin
156
152
  SYMBOLS
157
153
  end
158
154
 
155
+ #
156
+ # The space character set.
157
+ #
158
+ def Chars.space
159
+ SPACE
160
+ end
161
+
162
+ #
163
+ # The set of printable characters, including spaces.
164
+ #
165
+ def Chars.printable
166
+ PRINTABLE
167
+ end
168
+
159
169
  #
160
170
  # The control-char character set.
161
171
  #
@@ -22,24 +22,42 @@
22
22
  #
23
23
 
24
24
  module Ronin
25
- module Parameters
26
- class Param
25
+ module Code
26
+ module Emittable
27
+ #
28
+ # Default emit method which simply returns +nil+.
29
+ #
30
+ def emit
31
+ []
32
+ end
27
33
 
28
- # Name of parameter
29
- attr_reader :name
34
+ protected
30
35
 
31
- # Description of parameter
32
- attr_reader :description
36
+ #
37
+ # Emits a Token with the specified _name_.
38
+ #
39
+ def emit_token(name)
40
+ [Token.new(name)]
41
+ end
33
42
 
34
43
  #
35
- # Creates a new Param object with the specified _name_ and the given
36
- # _description_.
44
+ # Emits the specified _value_ if _value_ is an Emittable object,
45
+ # otherwise _value_ will be returned.
37
46
  #
38
- def initialize(name,description='')
39
- @name = name.to_sym
40
- @description = description
47
+ def emit_value(value)
48
+ if value.kind_of?(Emittable)
49
+ return value.emit
50
+ else
51
+ return [value]
52
+ end
41
53
  end
42
54
 
55
+ #
56
+ # Emits each of the specified _valueis_.
57
+ #
58
+ def emit_values(values)
59
+ values.inject([]) { |tokens,value| tokens + emit_value(value) }
60
+ end
43
61
  end
44
62
  end
45
63
  end
@@ -52,6 +52,19 @@ module Ronin
52
52
  @table[name.to_s]
53
53
  end
54
54
 
55
+ #
56
+ # Returns a Hash of the symbol names and their values.
57
+ #
58
+ def symbols
59
+ hash = {}
60
+
61
+ @table.each do |name,symbol|
62
+ hash[name] = symbol.value
63
+ end
64
+
65
+ return hash
66
+ end
67
+
55
68
  #
56
69
  # Sets the symbol values en-mass using the specified _hash_ of
57
70
  # symbol names and their values.
@@ -21,25 +21,52 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/parameters/param'
24
+ require 'ronin/code/emittable'
25
25
 
26
26
  module Ronin
27
- module Parameters
28
- class ClassParam < Param
27
+ module Code
28
+ class Token
29
+
30
+ include Emittable
29
31
 
30
- # Default value of the class parameter
31
- attr_accessor :value
32
+ # Value of the token
33
+ attr_reader :value
32
34
 
33
35
  #
34
- # Creates a new ClassParam object with the specified _name_,
35
- # given _description_ and _value_.
36
+ # Creates a new Token object with the specified _value_.
36
37
  #
37
- def initialize(name,description='',value=nil)
38
- super(name,description)
39
-
38
+ def initialize(value)
40
39
  @value = value
41
40
  end
42
41
 
42
+ #
43
+ # Emits the token.
44
+ #
45
+ def emit
46
+ [self]
47
+ end
48
+
49
+ #
50
+ # Returns +true+ if the token has the same value as the specified
51
+ # _other_ token, returns +false+ otherwise.
52
+ #
53
+ def ==(other)
54
+ self.value == other.value
55
+ end
56
+
57
+ #
58
+ # Inspects the token.
59
+ #
60
+ def inspect
61
+ "#<Token:#{@value.inspect}>"
62
+ end
63
+
64
+ #
65
+ # Returns the String form of the token.
66
+ #
67
+ def to_s
68
+ @value.to_s
69
+ end
43
70
  end
44
71
  end
45
72
  end
@@ -27,5 +27,38 @@ module Ronin
27
27
  module Config
28
28
  # Ronin home directory
29
29
  PATH = FileUtils.mkdir_p(File.join(ENV['HOME'],'.ronin'))
30
+
31
+ # Path to static directory
32
+ STATIC_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','..','static'))
33
+
34
+ # Main configuration file
35
+ CONFIG_PATH = File.expand_path(File.join(PATH,'config.rb'))
36
+
37
+ # Configuration files directory
38
+ CONFIG_DIR = File.expand_path(File.join(PATH,'config'))
39
+
40
+ # Temporary file directory
41
+ TMP_DIR = FileUtils.mkdir_p(File.join(PATH,'tmp'))
42
+
43
+ #
44
+ # Require the Ronin configuration file with the given _name_ in the
45
+ # Ronin configuration files directory. If _name_ is not given, than the
46
+ # main Ronin configuration file will be loaded.
47
+ #
48
+ # # Load the main config file at <tt>~/.ronin/config.rb</tt>
49
+ # Config.load # => true
50
+ #
51
+ # # Load a specific config file in <tt>~/.ronin/config/</tt>
52
+ # Config.load 'sql' # => true
53
+ #
54
+ def Config.load(name=nil)
55
+ if name
56
+ path = File.expand_path(File.join(CONFIG_DIR,name))
57
+ else
58
+ path = CONFIG_PATH
59
+ end
60
+
61
+ require path if File.file?(path)
62
+ end
30
63
  end
31
64
  end
@@ -29,40 +29,44 @@ require 'ronin/extensions/meta'
29
29
  module Ronin
30
30
  module Context
31
31
  def self.included(base)
32
- base.metaclass_def(:contextify) do |name|
33
- Context.contexts[name.to_sym] = self
32
+ base.module_eval do
33
+ def self.contextify(name)
34
+ name = name.to_sym
34
35
 
35
- meta_def(:context_name) { name }
36
+ Context.contexts[name] = self
36
37
 
37
- class_def(:context_name) { name }
38
+ meta_def(:context_name) { name }
38
39
 
39
- meta_def(:load_context) do |path,*args|
40
- Context.load_context(self.context_name,path,*args)
41
- end
40
+ class_def(:context_name) { name }
42
41
 
43
- # define the top-level context wrappers
44
- Kernel.module_eval %{
45
- def ronin_#{name}(*args,&block)
46
- if (args.empty? && Ronin::Context.is_pending?)
47
- Ronin::Context.pending.blocks[:#{name}] = block
48
- return nil
49
- else
50
- new_context = #{self}.new(*args)
51
- new_context.instance_eval(&block) if block
52
- return new_context
53
- end
42
+ meta_def(:load_context) do |path,*args|
43
+ Context.load_context(self.context_name,path,*args)
54
44
  end
55
- }
56
45
 
57
- # define the Ronin-level context loader
58
- Ronin.module_eval %{
59
- def ronin_load_#{name}(path,*args,&block)
60
- new_context = #{self}.load_context(path,*args)
46
+ # define the top-level context wrappers
47
+ Kernel.module_eval %{
48
+ def ronin_#{name}(*args,&block)
49
+ if (args.empty? && Ronin::Context.is_pending?)
50
+ Ronin::Context.pending.blocks[:#{name}] = block
51
+ return nil
52
+ else
53
+ new_context = #{self}.new(*args)
54
+ new_context.instance_eval(&block) if block
55
+ return new_context
56
+ end
57
+ end
58
+ }
61
59
 
62
- block.call(new_context) if block
63
- return new_context
64
- end
65
- }
60
+ # define the Ronin-level context loader
61
+ Ronin.module_eval %{
62
+ def ronin_load_#{name}(path,*args,&block)
63
+ new_context = #{self}.load_context(path,*args)
64
+
65
+ block.call(new_context) if block
66
+ return new_context
67
+ end
68
+ }
69
+ end
66
70
  end
67
71
  end
68
72
 
@@ -90,7 +94,6 @@ module Ronin
90
94
  # Context.namify(Analysis::Audio) # => "ronin_analysis_audio"
91
95
  #
92
96
  def Context.namify(base)
93
- # similar to the way Og tableizes Class names
94
97
  base.to_s.downcase.gsub(/::/,'_').gsub(/^ronin_/,'').to_sym
95
98
  end
96
99
 
@@ -221,12 +224,12 @@ module Ronin
221
224
  new_obj = Context.contexts[name].new
222
225
  new_obj.instance_eval(&context_block)
223
226
 
227
+ block.call(new_obj) if block
224
228
  new_objs << new_obj
225
229
  end
226
230
  end
227
231
  end
228
232
 
229
- new_objs.each(&block) if block
230
233
  return new_objs
231
234
  end
232
235
  end
@@ -22,13 +22,12 @@
22
22
  #
23
23
 
24
24
  require 'ronin/exceptions/invalid_database_config'
25
- require 'ronin/extensions/kernel'
26
- require 'ronin/config'
27
25
  require 'ronin/arch'
28
26
  require 'ronin/platform'
29
27
  require 'ronin/author'
30
28
  require 'ronin/license'
31
29
  require 'ronin/product'
30
+ require 'ronin/config'
32
31
 
33
32
  require 'yaml'
34
33
  require 'dm-core'
@@ -25,4 +25,3 @@ require 'ronin/extensions/meta'
25
25
  require 'ronin/extensions/hash'
26
26
  require 'ronin/extensions/uri'
27
27
  require 'ronin/extensions/string'
28
- require 'ronin/extensions/kernel'
@@ -83,4 +83,45 @@ class String
83
83
  return self[prefix.length...(length - postfix.length)]
84
84
  end
85
85
 
86
+ #
87
+ # Inspects the string, returning a C style encoded version of the string.
88
+ #
89
+ # "hello\x00\073\x90\r\n"
90
+ # # => "hello\0;\x90\r\n"
91
+ #
92
+ def inspect
93
+ c_string = ''
94
+
95
+ each_byte do |b|
96
+ c_string << case b
97
+ when 0x00
98
+ "\\0"
99
+ when 0x07
100
+ "\\a"
101
+ when 0x08
102
+ "\\b"
103
+ when 0x09
104
+ "\\t"
105
+ when 0x0a
106
+ "\\n"
107
+ when 0x0b
108
+ "\\v"
109
+ when 0x0c
110
+ "\\f"
111
+ when 0x0d
112
+ "\\r"
113
+ when 0x22
114
+ "\\\""
115
+ when 0x5c
116
+ "\\\\"
117
+ when (0x20..0x7e)
118
+ b.chr
119
+ else
120
+ ("\\x%.2x" % b)
121
+ end
122
+ end
123
+
124
+ return "\"#{c_string}\""
125
+ end
126
+
86
127
  end
@@ -47,6 +47,14 @@ module URI
47
47
  return new_query
48
48
  end
49
49
 
50
+ #
51
+ # Iterates over every query parameter, passing each to the given
52
+ # _block_.
53
+ #
54
+ def each_query_param(&block)
55
+ @query_params.each(&block)
56
+ end
57
+
50
58
  protected
51
59
 
52
60
  #
@@ -56,6 +56,16 @@ class String
56
56
  return integer
57
57
  end
58
58
 
59
+ #
60
+ # XOR encodes the string using the specified _key_.
61
+ #
62
+ def xor(key)
63
+ encoded = ''
64
+
65
+ each_byte { |b| encoded << (b ^ key).chr }
66
+ return encoded
67
+ end
68
+
59
69
  #
60
70
  # Returns the base64 encoded form of the string.
61
71
  #
@@ -21,5 +21,5 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/program/program'
25
- require 'ronin/program/commands'
24
+ require 'ronin/hexdump/hexdump'
25
+ require 'ronin/hexdump/extensions'
@@ -21,9 +21,5 @@
21
21
  #++
22
22
  #
23
23
 
24
- module Ronin
25
- module Parameters
26
- class MissingParam < RuntimeError
27
- end
28
- end
29
- end
24
+ require 'ronin/hexdump/extensions/file'
25
+ require 'ronin/hexdump/extensions/kernel'