rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/misc/ahsay_backup_fileupload.rb

Summary

Maintainability
D
2 days
Test Coverage

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

  def check
    #We need a cookie first
    cookie_res = send_request_cgi({
      #/cbs/system/ShowDownload.do
      'uri' => normalize_uri(target_uri.path, 'cbs','system','ShowDownload.do'),
Severity: Minor
Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 6 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

File ahsay_backup_fileupload.rb has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking
  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::EXE
  include Msf::Exploit::FileDropper
Severity: Minor
Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 4 hrs to fix

    Method exploit has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit
        username = datastore['USERNAME']
        password = datastore['PASSWORD']
    
        if is_trial_enabled? and datastore['CREATEACCOUNT'] == "true"
    Severity: Minor
    Found in modules/exploits/windows/misc/ahsay_backup_fileupload.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 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(update_info(info,
          'Name'        => 'Ahsay Backup v7.x-v8.1.1.50 (authenticated) file upload',
          'Description' => %q{
           This module exploits an authenticated insecure file upload and code
    Severity: Major
    Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 2 hrs to fix

      Method check has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check
          #We need a cookie first
          cookie_res = send_request_cgi({
            #/cbs/system/ShowDownload.do
            'uri' => normalize_uri(target_uri.path, 'cbs','system','ShowDownload.do'),
      Severity: Minor
      Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 2 hrs to fix

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

          def drop_and_execute()
            path = prepare_path(datastore['UPLOADPATH'])
            exploitpath = path.gsub("../../webapps/cbs/",'')
            exploitpath = exploitpath.gsub("/","\\\\\\")
            requestpath = path.gsub("../../webapps/",'')
        Severity: Minor
        Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 1 hr to fix

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

            def exploit
              username = datastore['USERNAME']
              password = datastore['PASSWORD']
          
              if is_trial_enabled? and datastore['CREATEACCOUNT'] == "true"
          Severity: Minor
          Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 1 hr to fix

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

              def remove_account
                if datastore['CREATEACCOUNT']
                  username = datastore['USERNAME']
                  users_xml = "../../conf/users.xml"
                  print_status("Looking for account #{username} in #{users_xml}")
            Severity: Minor
            Found in modules/exploits/windows/misc/ahsay_backup_fileupload.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

            Avoid deeply nested control flow statements.
            Open

                            if l.include? 'VERSION="'
                              number = l.split("=")[1].split('"')[1]
                              if number.match /(\d+\.)?(\d+\.)?(\d+\.)?(\*|\d+)$/
                                if number <= '8.1.1.50' and not number < '7'
                                  return Exploit::CheckCode::Appears
            Severity: Major
            Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 45 mins to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  There are no issues that match your filters.

                  Category
                  Status