Class: Ronin::PHP::LFI::Target
- Inherits:
-
Object
- Object
- Ronin::PHP::LFI::Target
- Defined in:
- lib/ronin/php/lfi/target.rb
Instance Attribute Summary collapse
-
#extractors ⇒ Object
readonly
Hash of extractor rules.
-
#paths ⇒ Object
readonly
Hash of OS specific paths for the target.
-
#recognizor ⇒ Object
Hash of patterns to recognize the target by.
Class Method Summary collapse
- .all ⇒ Object
- .categories ⇒ Object
- .category(name) ⇒ Object
- .config(&block) ⇒ Object
- .configs ⇒ Object
- .each(&block) ⇒ Object
- .log(&block) ⇒ Object
- .logs ⇒ Object
- .targets_for(os) ⇒ Object
- .test(&block) ⇒ Object
- .tests ⇒ Object
- .with_extractors ⇒ Object
- .with_file(name) ⇒ Object
Instance Method Summary collapse
-
#all_paths ⇒ Object
Returns all the paths of the target.
-
#each_path(&block) ⇒ Object
Iterates over each path passing each one to the specified block.
-
#extract(name, pattern) ⇒ Object
Add an extraction rule with the specified name and the specified pattern.
- #extract_from(body) ⇒ Object
-
#included_in?(body) ⇒ Boolean
Returns
true
if the specified body has the path included in it, returnsfalse
otherwise. -
#initialize(&block) ⇒ Target
constructor
Creates a new Path object with the specified path and pattern.
-
#oses ⇒ Object
Returns the supported OSes.
-
#paths_for(os) ⇒ Object
Returns the paths for the target commonly found on the specified os.
Constructor Details
#initialize(&block) ⇒ Target
Creates a new Path object with the specified path and pattern.
41 42 43 44 45 46 47 48 |
# File 'lib/ronin/php/lfi/target.rb', line 41 def initialize(&block) @paths = Hash.new { |hash,key| hash[key] = [] } @recognizor = nil @extractors = {} block.call(self) if block end |
Instance Attribute Details
#extractors ⇒ Object (readonly)
Hash of extractor rules
36 37 38 |
# File 'lib/ronin/php/lfi/target.rb', line 36 def extractors @extractors end |
#paths ⇒ Object (readonly)
Hash of OS specific paths for the target
30 31 32 |
# File 'lib/ronin/php/lfi/target.rb', line 30 def paths @paths end |
#recognizor ⇒ Object
Hash of patterns to recognize the target by
33 34 35 |
# File 'lib/ronin/php/lfi/target.rb', line 33 def recognizor @recognizor end |
Class Method Details
.all ⇒ Object
128 129 130 |
# File 'lib/ronin/php/lfi/target.rb', line 128 def Target.all Target.categories.values.flatten end |
.categories ⇒ Object
120 121 122 |
# File 'lib/ronin/php/lfi/target.rb', line 120 def Target.categories @@categories ||= Hash.new { |hash,key| hash[key] = [] } end |
.category(name) ⇒ Object
124 125 126 |
# File 'lib/ronin/php/lfi/target.rb', line 124 def Target.category(name) Target.categories[name] end |
.config(&block) ⇒ Object
146 147 148 |
# File 'lib/ronin/php/lfi/target.rb', line 146 def Target.config(&block) Target.define(:config,&block) end |
.configs ⇒ Object
150 151 152 |
# File 'lib/ronin/php/lfi/target.rb', line 150 def Target.configs Target.category(:config) end |
.each(&block) ⇒ Object
132 133 134 135 136 |
# File 'lib/ronin/php/lfi/target.rb', line 132 def Target.each(&block) Target.categories.each_value do |targets| targets.each(&block) end end |
.log(&block) ⇒ Object
154 155 156 |
# File 'lib/ronin/php/lfi/target.rb', line 154 def Target.log(&block) Target.define(:log,&block) end |
.logs ⇒ Object
158 159 160 |
# File 'lib/ronin/php/lfi/target.rb', line 158 def Target.logs Target.category(:logs) end |
.targets_for(os) ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/ronin/php/lfi/target.rb', line 162 def Target.targets_for(os) Target.each do |target| if target.oses.include?(os) return target end end end |
.test(&block) ⇒ Object
138 139 140 |
# File 'lib/ronin/php/lfi/target.rb', line 138 def Target.test(&block) Target.define(:test,&block) end |
.tests ⇒ Object
142 143 144 |
# File 'lib/ronin/php/lfi/target.rb', line 142 def Target.tests Target.category(:test) end |
Instance Method Details
#all_paths ⇒ Object
Returns all the paths of the target.
60 61 62 |
# File 'lib/ronin/php/lfi/target.rb', line 60 def all_paths @paths.values.flatten.uniq end |
#each_path(&block) ⇒ Object
Iterates over each path passing each one to the specified block.
74 75 76 77 78 |
# File 'lib/ronin/php/lfi/target.rb', line 74 def each_path(&block) @paths.each_value do |os_paths| os_paths.each(&block) end end |
#extract(name, pattern) ⇒ Object
Add an extraction rule with the specified name and the specified pattern.
96 97 98 |
# File 'lib/ronin/php/lfi/target.rb', line 96 def extract(name,pattern) @extractors[name] = pattern end |
#extract_from(body) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ronin/php/lfi/target.rb', line 100 def extract_from(body) data = {} @extractors.each do |name,pattern| match = pattern.match(body) if match if match.length > 2 data[name] = match[1..-1] elsif match.length == 2 data[name] = match[1] else data[name] = match[0] end end end return data end |
#included_in?(body) ⇒ Boolean
Returns true
if the specified body has the path included in it, returns false
otherwise.
84 85 86 87 88 89 90 |
# File 'lib/ronin/php/lfi/target.rb', line 84 def included_in?(body) if @recognizor return !((body =~ @recognizor).nil?) else return false end end |
#oses ⇒ Object
Returns the supported OSes.
53 54 55 |
# File 'lib/ronin/php/lfi/target.rb', line 53 def oses @paths.keys end |
#paths_for(os) ⇒ Object
Returns the paths for the target commonly found on the specified os.
67 68 69 |
# File 'lib/ronin/php/lfi/target.rb', line 67 def paths_for(os) @paths[os] end |