Class: Rex::ElfScan::Scanner::RegexScanner
- Inherits:
-
JmpRegScanner
- Object
- Generic
- JmpRegScanner
- Rex::ElfScan::Scanner::RegexScanner
- Defined in:
- lib/rex/elfscan/scanner.rb
Instance Attribute Summary
Attributes inherited from Generic
Instance Method Summary collapse
Methods inherited from JmpRegScanner
#_build_byte_list, #_parse_ret, #_ret_size
Methods inherited from Generic
Constructor Details
This class inherits a constructor from Rex::ElfScan::Scanner::Generic
Instance Method Details
#config(param) ⇒ Object
173 174 175 |
# File 'lib/rex/elfscan/scanner.rb', line 173 def config(param) self.regex = Regexp.new(param['args'], nil, 'n') end |
#scan_segment(program_header, param = {}) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rex/elfscan/scanner.rb', line 177 def scan_segment(program_header, param={}) offset = program_header.p_offset hits = [] while offset < program_header.p_offset + program_header.p_filesz && (offset = elf.index(regex, offset)) != nil idx = offset buf = '' mat = nil while (! (mat = buf.match(regex))) buf << elf.read(idx, 1) idx += 1 end rva = elf.offset_to_rva(offset) hits << [ rva, buf.unpack("H*") ] offset += buf.length end return hits end |