Class: Rex::ElfScan::Scanner::RegexScanner

Inherits:
JmpRegScanner show all
Defined in:
lib/rex/elfscan/scanner.rb

Instance Attribute Summary

Attributes inherited from Generic

#elf, #regex

Instance Method Summary collapse

Methods inherited from JmpRegScanner

#_build_byte_list, #_parse_ret, #_ret_size

Methods inherited from Generic

#initialize, #scan

Constructor Details

This class inherits a constructor from Rex::ElfScan::Scanner::Generic

Instance Method Details

#config(param) ⇒ Object



174
175
176
# File 'lib/rex/elfscan/scanner.rb', line 174

def config(param)
	self.regex = Regexp.new(param['args'], nil, 'n')
end

#scan_segment(program_header, param = {}) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/rex/elfscan/scanner.rb', line 178

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