Limit to the amount of options that can be created using Ruby's OptParse

100 views Asked by At

Due to the size of the program I will not be able to post all of it, please see the latest push here

I have a program that has around 15 option flags in it:

ARGV << '-h' if ARGV.empty? # Display help dialog if no flags are passed
OptionParser.new do |opt|
  opt.banner = banner_message
  opt.on('-f FILE', '--file FILE', 'Pass a filename to scan for vulnerabilities')         { |o| OPTIONS[:file]    = o }
  opt.on('-s URL', '--spider URL', 'Spider a web page and save all the URLS')             { |o| OPTIONS[:spider]  = o }
  opt.on('-p IP:PORT', '--proxy IP:PORT', 'Configure to run with a proxy, must use ":"')  { |o| OPTIONS[:proxy]   = o }
  opt.on('-x NUM', '--run-x NUM', 'Run the specified amount of dry runs')                 { |o| OPTIONS[:run]     = o }
  opt.on('-D DORK', '--dork DORK', 'Use your own dork to do the searching')               { |o| OPTIONS[:dork]    = o } # Issue #32 https://github.com/Ekultek/whitewidow/issues/32
  opt.on('-c NAME', '--column NAME', 'Specify a column name to be run for union SQLi')    { |o| OPTIONS[:cols]    = o }
  opt.on('-d', '--default', 'Run in default mode, scrape Google')                         { |o| OPTIONS[:default] = o }
  opt.on('-l', '--legal', 'Show the legal information and the TOS')                       { |o| OPTIONS[:legal]   = o }
  opt.on('-b', '--banner', 'Hide the banner')                                             { |o| OPTIONS[:banner]  = o }
  opt.on('-v', '--version', 'Display the version number and exit')                        { |o| OPTIONS[:version] = o }
  opt.on('-u', '--update', 'Update whitewidow with the newest version')                   { |o| OPTIONS[:update]  = o }
  opt.on('--dry-run', 'Run a dry run (no checking for vulnerability with prompt)')        { |o| OPTIONS[:dry]     = o }
  opt.on('--batch', 'No prompts, used in conjunction with the dry run')                   { |o| OPTIONS[:batch]   = o }
  opt.on('--beep', 'Make a beep when the program finds a vulnerability')                  { |o| OPTIONS[:beep]    = o }
  opt.on('--rand-agent', 'Use a random user agent')                                       { |o| OPTIONS[:agent]   = o }
  opt.on('--sqlmap', 'Run sqlmap through the SQL_VULN.LOG file as a bulk file')           { |o| OPTIONS[:sqlmap]  = o }
  opt.on('--test', 'Used mostly for development use')                                     { |o| OPTIONS[:test]    = o }
  opt.on('-h', '--help', 'Display this help dialog and exit') do
    usage_page
    puts opt
  end
end.parse!

The newest option is the -c flag, what I'm trying to do is get the information from the -c flag and use it as the extraction point for the information, however, when I run the flag, it will only pull information from the file that is default:

#
# Decide whether to use random column names, or a specific one
#
def random_col_name?
  if OPTIONS[:cols]
    OPTIONS[:cols]
  else
    File.readlines("#{PATH}/lib/lists/common_columns.txt").sample
  end
end

For example: ruby program.rb -d -c test -D php?id= Will pull http://www.bible-history.com/subcat.php?id=2 which is correct, put from there is should add the information from the -c flag to the end of it like so: http://www.bible-history.com/subcat.php?id=2 test. However all it does is add the information from the file: http://www.bible-history.com/subcat.php?id=2 clave. My question being, why is it that when I try to extract the information from the flag, it will not accept the ARGV and only reads from the file, is there a limit to the amount of options I can create?

0

There are 0 answers