rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/local/sudo_baron_samedit.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Sudo Heap-Based Buffer Overflow',
Severity: Major
Found in modules/exploits/linux/local/sudo_baron_samedit.rb - About 2 hrs to fix

    File sudo_baron_samedit.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'digest/sha2'
    require 'tempfile'
    
    class MetasploitModule < Msf::Exploit::Local
      Rank = ExcellentRanking
    Severity: Minor
    Found in modules/exploits/linux/local/sudo_baron_samedit.rb - About 2 hrs to fix

      Method exploit_userspec has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit_userspec(resolved_target)
          fail_with(Failure::BadConfig, 'The "NewUser" advanced option must be specified for this target') if datastore['NewUser'].blank?
      
          python_binary = find_exec_program
          fail_with(Failure::NotFound, 'The python binary was not found') unless python_binary
      Severity: Minor
      Found in modules/exploits/linux/local/sudo_baron_samedit.rb - About 1 hr to fix

        Method on_new_session has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def on_new_session(new_session)
            super
            # userspec exploits edited /etc/passwd; now that we have a root shell, we can clean that up
        
            if @inserted_password_hash
        Severity: Minor
        Found in modules/exploits/linux/local/sudo_baron_samedit.rb - About 1 hr to fix

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

            def do_post_exploit_checks
              # Just wait a bit; this should come in real fast if it's going to though
              4.times do |_i|
                Rex.sleep(0.5)
                # break if we get the shell
          Severity: Minor
          Found in modules/exploits/linux/local/sudo_baron_samedit.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 on_new_session has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def on_new_session(new_session)
              super
              # userspec exploits edited /etc/passwd; now that we have a root shell, we can clean that up
          
              if @inserted_password_hash
          Severity: Minor
          Found in modules/exploits/linux/local/sudo_baron_samedit.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 exploit_nss has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def exploit_nss(resolved_target)
              if target.name == 'Manual'
                fail_with(Failure::BadConfig, 'The "Lengths" advanced option must be specified for the manual target') if datastore['Lengths'].blank?
                exploit_params = datastore['Lengths'].gsub(/,/, ' ').gsub(/  +/, ' ')
              else
          Severity: Minor
          Found in modules/exploits/linux/local/sudo_baron_samedit.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 exploit_userspec has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def exploit_userspec(resolved_target)
              fail_with(Failure::BadConfig, 'The "NewUser" advanced option must be specified for this target') if datastore['NewUser'].blank?
          
              python_binary = find_exec_program
              fail_with(Failure::NotFound, 'The python binary was not found') unless python_binary
          Severity: Minor
          Found in modules/exploits/linux/local/sudo_baron_samedit.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

          There are no issues that match your filters.

          Category
          Status