rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/local/ms15_078_atmfd_bof.rb

Summary

Maintainability
D
2 days
Test Coverage

File ms15_078_atmfd_bof.rb has 349 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Local
  Rank = ManualRanking

  WIN32K_VERSIONS = [
    '6.3.9600.17393',
Severity: Minor
Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 4 hrs to fix

    Method set_win32k_offsets has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def set_win32k_offsets
        @set_win32k_offsets ||= proc do |version|
          case version
          when '6.3.9600.17393'
            {
    Severity: Major
    Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 4 hrs to fix

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

        def initialize(info = {})
          super(
            update_info(
              info,
              {
      Severity: Major
      Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 2 hrs to fix

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

          def exploit
            print_status('Checking target...')
            if is_system?
              fail_with(Failure::None, 'Session is already elevated')
            end
        Severity: Minor
        Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 1 hr to fix

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

            def patch_win32k_offsets(dll)
              @win32k_offsets.each do |k, v|
                case k
                when 'info_leak'
                  dll.gsub!([0xdeedbeefdeedbe00].pack('Q<'), [v].pack('Q<'))
          Severity: Minor
          Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 1 hr to fix

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

              def check
                # We have tested only windows 8.1
                version = get_version_info
                unless version.build_number != Msf::WindowsVersion::Win81 && !version.windows_server?
                  return Exploit::CheckCode::Unknown
            Severity: Minor
            Found in modules/exploits/windows/local/ms15_078_atmfd_bof.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 exploit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def exploit
                print_status('Checking target...')
                if is_system?
                  fail_with(Failure::None, 'Session is already elevated')
                end
            Severity: Minor
            Found in modules/exploits/windows/local/ms15_078_atmfd_bof.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

            Avoid too many return statements within this method.
            Open

                  return Exploit::CheckCode::Unknown
            Severity: Major
            Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb - About 30 mins to fix

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

                def ntoskrnl_version
                  file_path = expand_path('%windir%') << '\\system32\\ntoskrnl.exe'
                  major, minor, build, revision, branch = file_version(file_path)
                  return nil if major.nil?
              
              
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 2 other locations - About 50 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 272..280
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 283..291

              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 43.

              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 3 locations. Consider refactoring.
              Open

                def atmfd_version
                  file_path = expand_path('%windir%') << '\\system32\\atmfd.dll'
                  major, minor, build, revision, branch = file_version(file_path)
                  return nil if major.nil?
              
              
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 2 other locations - About 50 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 283..291
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 294..302

              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 43.

              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 3 locations. Consider refactoring.
              Open

                def win32k_version
                  file_path = expand_path('%windir%') << '\\system32\\win32k.sys'
                  major, minor, build, revision, branch = file_version(file_path)
                  return nil if major.nil?
              
              
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 2 other locations - About 50 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 272..280
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 294..302

              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 43.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17630'
                      {
                        'info_leak' => 0x3d200,
                        'pop_rax_ret' => 0x19e9b, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x6024, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 127..142
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 161..176
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 178..193
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 196..211
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 213..228

              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 32.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17796'
                      {
                        'info_leak' => 0x3d000,
                        'pop_rax_ret' => 0x19e4f, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x5f64, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 127..142
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 144..159
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 161..176
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 196..211
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 213..228

              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 32.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17915'
                      {
                        'info_leak' => 0x3d800,
                        'pop_rax_ret' => 0x1A4EF, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x62CC, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 127..142
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 144..159
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 161..176
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 178..193
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 196..211

              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 32.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17393'
                      {
                        'info_leak' => 0x3cf00,
                        'pop_rax_ret' => 0x19fab, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x6121, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 144..159
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 161..176
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 178..193
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 196..211
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 213..228

              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 32.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17694'
                      {
                        'info_leak' => 0x3d300,
                        'pop_rax_ret' => 0x151f4, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x600c, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 127..142
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 144..159
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 178..193
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 196..211
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 213..228

              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 32.

              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 6 locations. Consider refactoring.
              Open

                    when '6.3.9600.17837'
                      {
                        'info_leak' => 0x3d800,
                        'pop_rax_ret' => 0x1a51f, # pop rax # ret # 58 C3
                        'xchg_rax_rsp' => 0x62b4, # xchg eax, esp # ret # 94 C3
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 5 other locations - About 30 mins to fix
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 127..142
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 144..159
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 161..176
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 178..193
              modules/exploits/windows/local/ms15_078_atmfd_bof.rb on lines 213..228

              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 32.

              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 31 locations. Consider refactoring.
              Open

                          ['CVE', '2015-2426'],
                          ['CVE', '2015-2433'],
                          ['MSB', 'MS15-078'],
                          ['MSB', 'MS15-080'],
                          ['URL', 'https://github.com/vlad902/hacking-team-windows-kernel-lpe'],
              Severity: Major
              Found in modules/exploits/windows/local/ms15_078_atmfd_bof.rb and 30 other locations - About 15 mins to fix
              modules/auxiliary/admin/http/cisco_ios_xe_os_exec_cve_2023_20273.rb on lines 54..65
              modules/auxiliary/dos/windows/rdp/ms12_020_maxchannelids.rb on lines 22..29
              modules/auxiliary/scanner/ssh/ssh_enumusers.rb on lines 37..44
              modules/exploits/android/browser/stagefright_mp4_tx3g_64bit.rb on lines 53..61
              modules/exploits/freebsd/local/ip6_setpktopt_uaf_priv_esc.rb on lines 48..55
              modules/exploits/linux/http/fritzbox_echo_exec.rb on lines 31..38
              modules/exploits/linux/http/klog_server_authenticate_user_unauth_command_injection.rb on lines 40..47
              modules/exploits/linux/http/vmware_vcenter_vsan_health_rce.rb on lines 32..40
              modules/exploits/linux/local/af_packet_packet_set_ring_priv_esc.rb on lines 61..68
              modules/exploits/linux/local/blueman_set_dhcp_handler_dbus_priv_esc.rb on lines 39..46
              modules/exploits/linux/local/ptrace_sudo_token_priv_esc.rb on lines 43..50
              modules/exploits/linux/local/rds_rds_page_copy_user_priv_esc.rb on lines 48..55
              modules/exploits/linux/local/servu_ftp_server_prepareinstallation_priv_esc.rb on lines 41..48
              modules/exploits/linux/local/sudoedit_bypass_priv_esc.rb on lines 47..54
              modules/exploits/multi/browser/java_atomicreferencearray.rb on lines 35..42
              modules/exploits/multi/browser/java_jre17_jmxbean_2.rb on lines 35..42
              modules/exploits/multi/browser/java_verifier_field_access.rb on lines 35..42
              modules/exploits/multi/http/hp_sitescope_uploadfileshandler.rb on lines 34..41
              modules/exploits/multi/http/struts2_multi_eval_ognl.rb on lines 33..40
              modules/exploits/multi/http/vmware_vcenter_uploadova_rce.rb on lines 43..50
              modules/exploits/unix/dhcp/rhel_dhcp_client_command_injection.rb on lines 35..42
              modules/exploits/unix/fileformat/imagemagick_delegate.rb on lines 39..46
              modules/exploits/unix/webapp/vicidial_manager_send_cmd_exec.rb on lines 37..44
              modules/exploits/windows/browser/adobe_flash_otf_font.rb on lines 34..41
              modules/exploits/windows/browser/adobe_flash_regex_value.rb on lines 33..40
              modules/exploits/windows/browser/adobe_flashplayer_flash10o.rb on lines 30..37
              modules/exploits/windows/browser/java_docbase_bof.rb on lines 46..53
              modules/exploits/windows/browser/mozilla_firefox_onreadystatechange.rb on lines 32..39
              modules/exploits/windows/browser/ms06_013_createtextrange.rb on lines 34..41
              modules/exploits/windows/fileformat/winamp_maki_bof.rb on lines 33..40

              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 25.

              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