Fix up makeiplist.rb, so empty arguments doesn't error out

GSoC/Meterpreter_Web_Console
g0tmi1k 2018-03-20 12:51:15 +00:00
parent 8463ed99b0
commit a0cbb898a3
1 changed files with 12 additions and 9 deletions

View File

@ -11,7 +11,7 @@
# echo 192.168.100.0-50 >> rangelist.txt
# echo 192.155-156.0.1 >> rangelist.txt
# echo 192.168.200.0/25 >> rangelist.txt
# ruby tools/makeiplist.rb
# ruby tools/recon/makeiplist.rb
#
# Author:
# mubix
@ -30,7 +30,7 @@ require 'optparse'
class OptsConsole
def self.parse(args)
options = {'output' => 'iplist.txt'}
options = {}
opts = OptionParser.new do |opts|
opts.banner = %Q|This script takes a list of ranges and converts it to a per line IP list.
@ -56,15 +56,23 @@ Usage: #{__FILE__} [options]|
end
end
opts.parse!(args)
if options.empty?
puts "[*] No options specified, try -h for usage"
exit
end
begin
opts.parse!(args)
if options['input'] == nil
puts opts
raise OptionParser::MissingArgument, "-i is a required option"
raise OptionParser::MissingArgument, '-i is a required argument'
end
unless ::File.exist?(options['input'])
raise OptionParser::InvalidArgument, "Not found: #{options['input']}"
end
if options['output'] == nil
options['output'] = 'iplist.txt'
end
rescue OptionParser::InvalidOption
puts "[*] Invalid option, try -h for usage"
exit
@ -73,11 +81,6 @@ Usage: #{__FILE__} [options]|
exit
end
if options.empty?
puts "[*] No options specified, try -h for usage"
exit
end
options
end
end