metasploit-framework/lib/rex/ole/samples/dir.rb

36 lines
605 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
msfbase = __FILE__
while File.symlink?(msfbase)
2013-08-30 21:28:33 +00:00
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
path = File.expand_path(File.dirname(msfbase))
path += "/../../../"
$:.unshift(path)
require 'rex/ole'
if (ARGV.length < 1)
2013-08-30 21:28:33 +00:00
$stderr.puts "usage: dir <file>"
exit(1)
end
document = ARGV.shift
# recursive printer :)
def show_entries(ent, spaces=0)
2013-08-30 21:28:33 +00:00
spstr = " " * spaces
2013-08-30 21:28:33 +00:00
puts "%s + #{ent.name}" % spstr
ent.each { |el|
show_entries(el, spaces+2)
}
end
if (stg = Rex::OLE::Storage.new(document))
2013-08-30 21:28:33 +00:00
show_entries(stg)
stg.close
end