def self.parse(args, banner=nil)
op = OptionParser.new do |op|
unless (banner.nil?)
op.banner = banner
end
op.on("-b", "Bruteforce URLs") do |o|
@options.brute = o
end
op.on("-d", "Show debug output (SIGUSR2)") do |o|
@options.debug = o
end
op.on("-f", "Force offsite crawling") do |o|
@options.force = o
end
op.on_tail("-h", "Show help") do
puts op
exit
end
op.on("-H [HEADER]", "Append this header to all requests. May be called multiple times") do |o|
if (o =~ /([^:]*):\s+?(.*)/)
@options.headers[$1] = $2
else
@options.headers[o] = ""
end
end
op.on("-p", "\"Peek\" at all URIs (HEAD)") do |o|
@options.peek = o
end
op.on("-r [=DEPTH]", "Recurse. DEPTH optional") do |o|
@options.recurse = true
@options.depth = o.to_i if (o)
end
op.on("-s [SLEEP]", "Sleep s seconds between each hit") do |o|
@options.sleep = o.to_i
end
op.on("-t [TYPES]", "Only download, crawl and analyze these types") do |o|
@options.types = o.to_i
end
op.on("-v", "Run verbosely (SIGUSR1)") do |o|
@options.verbose = o
end
end
@options.help = op.help
begin
op.parse!(args)
rescue OptionParser::InvalidOption => e
end
@options
end