WhitewidowScanner / whitewidow

SQL Vulnerability Scanner
972 stars 235 forks source link

`find_python_env_var': undefined method `split' for nil:NilClass (NoMethodError) #46

Closed jask05 closed 7 years ago

jask05 commented 7 years ago

Issue/Enhancement/Question (be specific)

Hi there,

I've installed your tool in ParrotOS and when I try to execute it i had this message:

Exact error message/Enhancement information

/home/user/tools/whitewidow/lib/helpers/sqlmap_config_helper.rb:13:in `find_python_env_var': undefined method `split' for nil:NilClass (NoMethodError)
    from /home/jask/tools/whitewidow/lib/imports/constants_and_requires.rb:59:in `<top (required)>'
    from whitewidow.rb:2:in `require_relative'
    from whitewidow.rb:2:in `<main>'

Steps to reproduce if applicable or steps on what should be done

cd /home/user/tools/whitewidow

Search query if applicable (please use exact search query)

ruby whitewidow.rb -d

User agent (if applicable)

Whitewidow version number (must have the actual version run ruby whitewidow.rb --version)

I can't get it.

Ruby version number (run ruby --version)

ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

Labels

Thanks a lot!

Ekultek commented 7 years ago

Alright do this for me:

jask05 commented 7 years ago

Of course :)


- **Run python --version post the output**
Python 2.7.13
Ekultek commented 7 years ago

Since when does Linux separate their env PATH with ":"..? The problem being, I separated the array by ";" like a normal fucking person, but apparently it doesn't work like that on parrot. I'm going to have to play around with this a little bit before I figure it out

Ekultek commented 7 years ago

I'm going to implement a temporary fix for you, see it in the next push here shortly

Ekultek commented 7 years ago
  def sqlmap_config
      command_file = File.open(SQLMAP_CONFIG_PATH, "a+")
      if command_file.read == "false"
        commands = FORMAT.prompt('Enter sqlmap commands, python sqlmap.py -m SQL_VULN.LOG')  # Temp fix for issue #46, I'm working on a permanent fix https://github.com/WhitewidowScanner/whitewidow/issues/46
        # commands = FORMAT.prompt("Enter sqlmap commands, #{extract_python_env_type} sqlmap.py -m SQL_VULN.LOG")
        default = FORMAT.prompt("Make commands default [y/N]")
        if default.downcase.start_with?("y")
          command_file.truncate(0)
          command_file.puts("#{extract_python_env_type} #{SQLMAP_PATH} -m #{SQL_VULN_SITES_LOG} #{commands}")
          FORMAT.info("Commands saved, you need to rerun --sqlmap in order for the changes to take effect")
          exit(0)
        end
      else
        FORMAT.info("Running default sqlmap commands: #{File.read(SQLMAP_CONFIG_PATH)}")
      end
    end
jask05 commented 7 years ago

It works!! Thanks a lot =)

PS: Mac has PATH with ":" PATH=/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

Ekultek commented 7 years ago

No problem, leave this open though because I'm still working on a permanent fix for it.

Ekultek commented 7 years ago

So far:

#require_relative '../../lib/imports/constants_and_requires'

#
# sqlmap configuration, figure out if you have python installed or not
#
class SqlmapConfigHelper

  #
  # Python isn't real... It's just a conspiracy to make people believe they're hackers..
  #
  class PythonNotImplementedException < NotImplementedError
  end

  class << self

    def verify_operating_system
      data = RUBY_PLATFORM
      if data[/cygwin|mswin|mingw|bccwin|wince|emx/]
        true
      else
        false
      end
    end

    def find_python_env_var_windows
      py_path = [] # Results of the python env variables
      env_vars = ENV.to_h
      items = env_vars.to_s.split(/[^a-zA-Z0-9\/\\]/) # Split the environment variables into an array
      items.each { |var|
        if var.include?('Python')
          py_path.push(var)
        end
      }
      py_path.each { |python|
        if python.include?('2.7')
          return true
        elsif python.include?('3')
          return false
        else
          raise PythonNotImplementedException("Python must be installed before you can run sqlmap!") #Go here: #{PYTHON_DOWNLOAD_LINK}")
        end
      }
    end

    def find_python_version_linux
      version_string = system('python', '--version')
      if version_string.to_s.include?('2.7')
        return true
      elsif version_string.to_s.include?('3')
        return false
      else
        raise PythonNotImplementedException("Python must be installed before you can run sqlmap!") #Go here: #{PYTHON_DOWNLOAD_LINK}"
      end
    end

    def decisions_decisions
      if !(verify_operating_system)
        find_python_version_linux
      else
        find_python_env_var_windows
      end
    end

    def create_var_path
      if verify_operating_system
        ENV['python27'] = 'C:\\Python27'
      else
        ENV['python27'] = 'usr/local/bin'
      end
    end

  end

end

SqlmapConfigHelper.decisions_decisions

Just trying to figure out how to get Linux to work the way I want it to.

Ekultek commented 7 years ago

Going to mark this as duplicate and add your issue to the sqlmap config issue

Ekultek commented 7 years ago

Duplicate of #45