rapid7/metasploit-framework

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

Summary

Maintainability
C
1 day
Test Coverage

Method exploit has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exploit
    def upload_and_compile(filename, file_path, file_content, compile=nil)
      rm_f "#{file_path}"
      if not compile.nil?
        rm_f "#{file_path}.c"
Severity: Major
Found in modules/exploits/linux/local/ntfs3g_priv_esc.rb - About 4 hrs to fix

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

      def check
    
        # check if linux headers were installed on Debian (not ubuntu). The 'common' headers won't work.
        def headers_installed?()
          output = cmd_exec('dpkg -l | grep \'^ii\' | grep linux-headers.*[^common]{7}')
    Severity: Minor
    Found in modules/exploits/linux/local/ntfs3g_priv_esc.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 check has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def check
    
        # check if linux headers were installed on Debian (not ubuntu). The 'common' headers won't work.
        def headers_installed?()
          output = cmd_exec('dpkg -l | grep \'^ii\' | grep linux-headers.*[^common]{7}')
    Severity: Minor
    Found in modules/exploits/linux/local/ntfs3g_priv_esc.rb - About 1 hr to fix

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

        def initialize(info={})
          super( update_info( info, {
              'Name'          => 'Debian/Ubuntu ntfs-3g Local Privilege Escalation',
              'Description'   => %q{
                ntfs-3g mount helper in Ubuntu 16.04, 16.10, Debian 7, 8, and possibly 9 does not properly sanitize the environment when executing modprobe.
      Severity: Minor
      Found in modules/exploits/linux/local/ntfs3g_priv_esc.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status