Class: Rex::PeScan::Analyze::Fingerprint
- Inherits:
-
Object
- Object
- Rex::PeScan::Analyze::Fingerprint
- Defined in:
- lib/rex/pescan/analyze.rb
Instance Attribute Summary collapse
-
#pe ⇒ Object
Returns the value of attribute pe.
Instance Method Summary collapse
- #config(param) ⇒ Object
-
#initialize(pe) ⇒ Fingerprint
constructor
A new instance of Fingerprint.
- #scan(param) ⇒ Object
Constructor Details
#initialize(pe) ⇒ Fingerprint
Returns a new instance of Fingerprint.
11 12 13 |
# File 'lib/rex/pescan/analyze.rb', line 11 def initialize(pe) self.pe = pe end |
Instance Attribute Details
#pe ⇒ Object
Returns the value of attribute pe.
9 10 11 |
# File 'lib/rex/pescan/analyze.rb', line 9 def pe @pe end |
Instance Method Details
#config(param) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rex/pescan/analyze.rb', line 15 def config(param) @sigs = {} name = nil regx = '' epon = 0 sidx = 0 fd = File.open(param['database'], 'rb') fd.each_line do |line| case line when /^\s*#/ next when /\[\s*(.*)\s*\]/ if (name) @sigs[ name ] = [regx, epon] end name = $1 + " [#{ sidx+=1 }]" epon = 0 next when /signature\s*=\s*(.*)/ pat = $1.strip regx = '' pat.split(/\s+/).each do |c| next if c.length != 2 regx << (c.index('?') ? '.' : "\\x#{c}") end when /ep_only\s*=\s*(.*)/ epon = ($1 =~ /^T/i) ? 1 : 0 end end if (name and ! @sigs[name]) @sigs[ name ] = [regx, epon] end fd.close end |
#scan(param) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rex/pescan/analyze.rb', line 54 def scan(param) config(param) epa = pe.hdr.opt.AddressOfEntryPoint buf = pe.read_rva(epa, 256) || "" @sigs.each_pair do |name, data| begin if (buf.match(Regexp.new('^' + data[0], nil, 'n'))) $stdout.puts param['file'] + ": " + name end rescue RegexpError $stderr.puts "Invalid signature: #{name} #{data[0]}" end end end |