rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    user = datastore['USER'] || cmd_exec('/usr/bin/whoami')

    # Check file exists
    messages_path = "/Users/#{user}/Library/Messages/chat.db"
Severity: Minor
Found in modules/post/osx/gather/enum_messages.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    cred_tbl = Rex::Text::Table.new({
      'Header' => 'Credentials',
      'Indent' => 1,
      'Columns' => ['Domain', 'Username', 'Password']
Severity: Minor
Found in modules/post/osx/gather/safari_lastsession.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method native_init_connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def native_init_connect(proto, ip, port, num, gw)
    vprint_status("[#{num}:NATIVE] Connecting to #{ip} port #{proto}/#{port}")
    if proto == 'TCP'
      begin
        Rex::Socket::Tcp.create(
Severity: Minor
Found in modules/post/multi/recon/multiport_egress_traffic.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method get_keyring_shares has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_keyring_shares(security_path)
    # Grep for desc srvr and ptcl
    data = cmd_exec("#{security_path} dump")
    lines = data.lines.select { |line| line =~ /desc|srvr|ptcl/ }.map(&:strip)

Severity: Minor
Found in modules/post/osx/manage/mount_share.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method egress has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def egress(type, proto, remote, dport, num, gw)
    if type == 'WINAPI'
      if proto == 'ALL'
        winapi_egress_to_port('TCP', remote, dport, num)
        winapi_egress_to_port('UDP', remote, dport, num)
Severity: Minor
Found in modules/post/multi/recon/multiport_egress_traffic.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    if client.nil?
      print_error("Invalid session ID selected. Make sure the host isn't dead.")
      return
    end
Severity: Minor
Found in modules/post/osx/gather/password_prompt_spoof.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method egress has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def egress(type, proto, remote, dport, num, gw)
Severity: Minor
Found in modules/post/multi/recon/multiport_egress_traffic.rb - About 45 mins to fix

    Method parser_minio has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def parser_minio(config_path)
        print_status("Parsing file #{config_path}")
        some_result = Hash.new
        if file?(config_path)
          file_contents = read_file(config_path)
    Severity: Minor
    Found in modules/post/multi/gather/minio_client.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method download_loot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def download_loot(paths)
        print_status("Looting #{paths.count} directories")
        paths.each do |path|
          path.chomp!
          sep = '/'
    Severity: Minor
    Found in modules/post/multi/gather/gpg_creds.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method find_db_paths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_db_paths(path, browser, account)
        paths = []
    
        vprint_status "Checking #{account}'s #{browser}"
        if browser == 'IE' # Special case for IE
    Severity: Minor
    Found in modules/post/multi/gather/lastpass_creds.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method show_report has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def show_report(res, filename)
        md5 = res['md5'] || ''
        sha1 = res['sha1'] || ''
        sha256 = res['sha256'] || ''
    
    
    Severity: Minor
    Found in modules/post/multi/gather/check_malware.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method check_for_backups_unix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_for_backups_unix(backup_dirs)
        dirs = []
        backup_dirs.each do |backup_dir|
          print_status("Checking for backups in #{backup_dir}")
          session.shell_command("ls #{backup_dir}").each_line do |dir|
    Severity: Minor
    Found in modules/post/multi/gather/apple_ios_backup.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method enum_users_unix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def enum_users_unix
        if @platform == :osx
          home = '/Users/'
        else
          home = '/home/'
    Severity: Minor
    Found in modules/post/multi/gather/apple_ios_backup.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Avoid deeply nested control flow statements.
    Open

                  rescue Rex::Post::Meterpreter::RequestError
                    print_error("Failed to resolve SLD hostname: #{sld_hostname}")
    Severity: Major
    Found in modules/post/multi/sap/smdagent_get_properties.rb - About 45 mins to fix

      Method winhome has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def winhome
          home = []
          exec = cmd_exec('WMIC PROCESS get Caption,Commandline').split("\n")
          exec.each do |line|
            next unless line.downcase.include?('java.exe') && line.downcase.include?('jboss')
      Severity: Minor
      Found in modules/post/multi/gather/jboss_gather.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          return unless session_good?
      
          print_status("Running module against #{sysinfo['Computer']}")
      
      
      Severity: Minor
      Found in modules/post/multi/manage/autoroute.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method read_registry_key_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def read_registry_key_value(key, value)
          begin
            root_key, base_key = session.sys.registry.splitkey(key)
            reg_key = session.sys.registry.open_key(root_key, base_key, KEY_READ)
            return nil unless reg_key
      Severity: Minor
      Found in modules/post/multi/gather/lastpass_creds.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          id = cmd_exec('id')
          unless id =~ (/root/) || id =~ (/shell/)
            print_error('This module requires shell or root permissions')
            return
      Severity: Minor
      Found in modules/post/android/capture/screen.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          fields = datastore['FIELDS'].gsub(/\s+/, '').split(',')
          search_filter = datastore['FILTER']
          max_search = datastore['MAX_SEARCH']
      
      
      Severity: Minor
      Found in modules/post/windows/gather/enum_ad_user_comments.rb - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Avoid deeply nested control flow statements.
      Open

              if migrate_system
                print_status('Trying to get SYSTEM privilege')
                results = session.priv.getsystem
                if results[0]
                  print_good('Got SYSTEM privilege')
      Severity: Major
      Found in modules/post/windows/gather/smart_hashdump.rb - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language