rapid7/metasploit-framework

View on GitHub
modules/post/multi/gather/firefox_creds.rb

Summary

Maintainability
F
1 wk
Test Coverage

File firefox_creds.rb has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'tmpdir'

#
# Gems
#
Severity: Major
Found in modules/post/multi/gather/firefox_creds.rb - About 1 day to fix

    Method decrypt_trigger_decrypt has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

      def decrypt_trigger_decrypt(org_file, new_file, temp_file)
        [org_file, new_file, temp_file].each do |f|
          f.insert(0, @paths['ff'])
        end
    
    
    Severity: Minor
    Found in modules/post/multi/gather/firefox_creds.rb - About 7 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 do_decrypt has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      def do_decrypt
        unless datastore['DISCLAIMER']
          decrypt_disclaimer
          return
        end
    Severity: Minor
    Found in modules/post/multi/gather/firefox_creds.rb - About 5 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 enum_users has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def enum_users
        paths = []
        id = whoami
    
        if id.nil? || id.empty?
    Severity: Minor
    Found in modules/post/multi/gather/firefox_creds.rb - About 4 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 download_loot has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def download_loot(paths)
        loot = ''
        print_line
    
        paths.each do |path|
    Severity: Minor
    Found in modules/post/multi/gather/firefox_creds.rb - About 3 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 decrypt_trigger_decrypt has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def decrypt_trigger_decrypt(org_file, new_file, temp_file)
        [org_file, new_file, temp_file].each do |f|
          f.insert(0, @paths['ff'])
        end
    
    
    Severity: Major
    Found in modules/post/multi/gather/firefox_creds.rb - About 3 hrs to fix

      Method do_decrypt has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def do_decrypt
          unless datastore['DISCLAIMER']
            decrypt_disclaimer
            return
          end
      Severity: Major
      Found in modules/post/multi/gather/firefox_creds.rb - About 2 hrs to fix

        Method initialize has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(info = {})
            super(
              update_info(
                info,
                'Name' => 'Multi Gather Firefox Signon Credential Collection',
        Severity: Major
        Found in modules/post/multi/gather/firefox_creds.rb - About 2 hrs to fix

          Method decrypt_get_env has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def decrypt_get_env
              @paths = {}
              check_paths = []
              loot_file = Rex::Text.rand_text_alpha(6) + '.txt'
          
          
          Severity: Minor
          Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

            Method decrypt_patch_method has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def decrypt_patch_method(stor_js)
                data = ''
                # Imports needed for IO
                imports = %|Components.utils.import("resource://gre/modules/NetUtil.jsm");
            Components.utils.import("resource://gre/modules/FileUtils.jsm");
            Severity: Minor
            Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

              Method decrypt_download_creds has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def decrypt_download_creds
                  print_good("Downloading loot: #{@paths['loot']}")
                  loot = read_file(@paths['loot'])
              
                  if loot =~ /no creds/
              Severity: Minor
              Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

                Method decrypt_get_env has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def decrypt_get_env
                    @paths = {}
                    check_paths = []
                    loot_file = Rex::Text.rand_text_alpha(6) + '.txt'
                
                
                Severity: Minor
                Found in modules/post/multi/gather/firefox_creds.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 enum_users has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def enum_users
                    paths = []
                    id = whoami
                
                    if id.nil? || id.empty?
                Severity: Minor
                Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

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

                    def check_firefox_win(path)
                      paths = []
                      ffpath = []
                      path += '\\Mozilla\\'
                      print_status("Checking for Firefox profile in: #{path}")
                  Severity: Minor
                  Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

                    Method check_firefox_win has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def check_firefox_win(path)
                        paths = []
                        ffpath = []
                        path += '\\Mozilla\\'
                        print_status("Checking for Firefox profile in: #{path}")
                    Severity: Minor
                    Found in modules/post/multi/gather/firefox_creds.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 decrypt_modify_omnija has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def decrypt_modify_omnija(zip)
                        # Which files to extract from ja/zip
                        files = [
                          'components/storage-mozStorage.js',                        # stor_js
                          'chrome/toolkit/content/passwordmgr/passwordManager.xul',  # pwd_xul
                    Severity: Minor
                    Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

                      Method download_loot has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def download_loot(paths)
                          loot = ''
                          print_line
                      
                          paths.each do |path|
                      Severity: Minor
                      Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

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

                          def run
                            # Certain shells for certain platform
                            vprint_status('Determining session platform and type')
                            case session.platform
                            when 'unix', 'linux', 'bsd'
                        Severity: Minor
                        Found in modules/post/multi/gather/firefox_creds.rb - About 1 hr to fix

                          Method got_root has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def got_root
                              case @platform
                              when :windows
                                session.sys.config.getuid =~ /SYSTEM/ ? true : false
                              else # unix, bsd, linux, osx
                          Severity: Minor
                          Found in modules/post/multi/gather/firefox_creds.rb - About 55 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
                              # Certain shells for certain platform
                              vprint_status('Determining session platform and type')
                              case session.platform
                              when 'unix', 'linux', 'bsd'
                          Severity: Minor
                          Found in modules/post/multi/gather/firefox_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 decrypt_patch_method has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def decrypt_patch_method(stor_js)
                              data = ''
                              # Imports needed for IO
                              imports = %|Components.utils.import("resource://gre/modules/NetUtil.jsm");
                          Components.utils.import("resource://gre/modules/FileUtils.jsm");
                          Severity: Minor
                          Found in modules/post/multi/gather/firefox_creds.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

                          Avoid too many return statements within this method.
                          Open

                                  return
                          Severity: Major
                          Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                      return
                            Severity: Major
                            Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return
                              Severity: Major
                              Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                      return
                                Severity: Major
                                Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return
                                  Severity: Major
                                  Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                        return unless decrypt_trigger_decrypt(org_file, new_file, temp_file)
                                    Severity: Major
                                    Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return
                                      Severity: Major
                                      Found in modules/post/multi/gather/firefox_creds.rb - About 30 mins to fix

                                        Method decrypt_recover_omni has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def decrypt_recover_omni(temp_file, org_file)
                                            print_status("Restoring: #{@paths['ff'] + temp_file} (Possible backup)")
                                            file_rm(@paths['ff'] + org_file)
                                            rename_file(@paths['ff'] + temp_file, @paths['ff'] + org_file)
                                        
                                        
                                        Severity: Minor
                                        Found in modules/post/multi/gather/firefox_creds.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

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            print_status("#{org_file}   : Created- #{session.fs.file.stat(@paths['ff'] + org_file).ctime}  Modified- #{session.fs.file.stat(@paths['ff'] + org_file).mtime}  Accessed- #{session.fs.file.stat(@paths['ff'] + org_file).mtime}")
                                        Severity: Minor
                                        Found in modules/post/multi/gather/firefox_creds.rb and 1 other location - About 45 mins to fix
                                        modules/post/multi/gather/firefox_creds.rb on lines 220..220

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 40.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            print_status("#{temp_file}: Created- #{session.fs.file.stat(@paths['ff'] + temp_file).ctime}  Modified- #{session.fs.file.stat(@paths['ff'] + temp_file).mtime}  Accessed- #{session.fs.file.stat(@paths['ff'] + temp_file).ctime}")
                                        Severity: Minor
                                        Found in modules/post/multi/gather/firefox_creds.rb and 1 other location - About 45 mins to fix
                                        modules/post/multi/gather/firefox_creds.rb on lines 219..219

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 40.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        There are no issues that match your filters.

                                        Category
                                        Status