2005-12-17 07:46:23 +01:00
|
|
|
#!/usr/bin/env ruby
|
2010-05-03 19:13:09 +02:00
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
2005-12-09 01:03:52 +01:00
|
|
|
|
2012-02-04 07:38:21 +01:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
|
|
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
|
|
|
|
require 'fastlib'
|
|
|
|
|
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2005-12-09 01:03:52 +01:00
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
|
2010-11-05 01:06:31 +01:00
|
|
|
if ARGV.length < 1
|
2006-11-13 14:38:11 +01:00
|
|
|
$stderr.puts("Usage: #{File.basename($0)} <search item> <length of buffer>")
|
2006-04-21 23:06:31 +02:00
|
|
|
$stderr.puts("Default length of buffer if none is inserted: 8192")
|
|
|
|
$stderr.puts("This buffer is generated by pattern_create() in the Rex library automatically")
|
|
|
|
exit
|
2005-12-09 01:03:52 +01:00
|
|
|
end
|
|
|
|
|
2006-04-21 23:06:31 +02:00
|
|
|
value = ARGV.shift
|
|
|
|
len = ARGV.shift || 8192
|
|
|
|
|
2005-12-09 01:03:52 +01:00
|
|
|
value = value.hex if (value.length >= 8 and value.hex > 0)
|
2006-04-21 23:06:31 +02:00
|
|
|
buffer = Rex::Text.pattern_create(len.to_i)
|
2005-12-09 01:03:52 +01:00
|
|
|
|
2009-11-09 18:50:53 +01:00
|
|
|
offset = Rex::Text.pattern_offset(buffer, value)
|
|
|
|
while offset
|
|
|
|
puts offset
|
|
|
|
offset = Rex::Text.pattern_offset(buffer, value, offset + 1)
|
|
|
|
end
|