rapid7/metasploit-framework

View on GitHub
modules/post/windows/gather/credentials/moba_xterm.rb

Summary

Maintainability
D
2 days
Test Coverage

File moba_xterm.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Post
  include Msf::Post::Windows::Registry
  include Msf::Post::Windows::UserProfiles

  def initialize(info = {})
Severity: Minor
Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 3 hrs to fix

    Method run has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        pw_tbl = Rex::Text::Table.new(
          'Header' => 'MobaXterm Password',
          'Columns' => [
            'Protocol',
    Severity: Major
    Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 2 hrs to fix

      Method gather_password has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def gather_password(config)
          result = []
          if config['PasswordsInRegistry'] == '1'
            parent_key = "#{config['RegistryKey']}\\P"
            return if !registry_key_exist?(parent_key)
      Severity: Minor
      Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 2 hrs 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 initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Windows Gather MobaXterm Passwords',
      Severity: Minor
      Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr to fix

        Method gather_creds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def gather_creds(config)
            result = []
            if config['PasswordsInRegistry'] == '1'
              parent_key = "#{config['RegistryKey']}\\C"
              return if !registry_key_exist?(parent_key)
        Severity: Minor
        Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr 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

        Consider simplifying this complex logical expression.
        Open

              if file_contents.nil? || file_contents.empty?
                print_warning('Configuration file content is empty')
                return
              else
                config = Rex::Parser::Ini.from_s(file_contents)
        Severity: Critical
        Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr to fix

          Method gather_password has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def gather_password(config)
              result = []
              if config['PasswordsInRegistry'] == '1'
                parent_key = "#{config['RegistryKey']}\\P"
                return if !registry_key_exist?(parent_key)
          Severity: Minor
          Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr to fix

            Method windows_unprotect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def windows_unprotect(entropy, data)
                begin
                  pid = session.sys.process.getpid
                  process = session.sys.process.open(pid, PROCESS_ALL_ACCESS)
            
            
            Severity: Minor
            Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr to fix

              Method key_crafter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def key_crafter(config)
                  if (!config['SessionP'].empty? && !config['SessionP'].nil?)
                    s1 = config['SessionP']
                    s1 += s1 while s1.length < 20
                    key_space = [s1.upcase, s1.upcase, s1.downcase, s1.downcase]
              Severity: Minor
              Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr 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 gather_creds has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def gather_creds(config)
                  result = []
                  if config['PasswordsInRegistry'] == '1'
                    parent_key = "#{config['RegistryKey']}\\C"
                    return if !registry_key_exist?(parent_key)
              Severity: Minor
              Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 1 hr to fix

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

                  def mobaxterm_decrypt(ciphertext, key)
                    ct = ''.bytes
                    ciphertext.each_byte do |c|
                      ct << c if key.include?(c)
                    end
                Severity: Minor
                Found in modules/post/windows/gather/credentials/moba_xterm.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
                    pw_tbl = Rex::Text::Table.new(
                      'Header' => 'MobaXterm Password',
                      'Columns' => [
                        'Protocol',
                Severity: Minor
                Found in modules/post/windows/gather/credentials/moba_xterm.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 parse_bookmarks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def parse_bookmarks(bookmarks)
                    result = []
                    protocol_hash = { '#109#0' => 'ssh', '#98#1' => 'telnet', '#128#5' => 'vnc', '#140#7' => 'sftp', '#130#6' => 'ftp', '#100#2' => 'rsh', '#91#4' => 'rdp' }
                    bookmarks.each_key do |key|
                      next if key.eql?('ImgNum') || key.eql?('SubRep') || bookmarks[key].empty?
                Severity: Minor
                Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 35 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 parser_ini has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def parser_ini(ini_config_path)
                    valuable_info = {}
                    if session.fs.file.exist?(ini_config_path)
                      file_contents = read_file(ini_config_path)
                      if file_contents.nil? || file_contents.empty?
                Severity: Minor
                Found in modules/post/windows/gather/credentials/moba_xterm.rb - About 25 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

                There are no issues that match your filters.

                Category
                Status