rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb

Summary

Maintainability
D
1 day
Test Coverage

Method do_login has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def do_login(user, pass)
    vprint_status("#{rhost}:#{rport} - Trying username:#{user.inspect} with password:#{pass.inspect}")

    # Set Cookie - Box is vuln to Session Fixation. Generating a random cookie for use.
    randomvalue = Rex::Text.rand_text_alphanumeric(26)
Severity: Minor
Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.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 do_login has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def do_login(user, pass)
    vprint_status("#{rhost}:#{rport} - Trying username:#{user.inspect} with password:#{pass.inspect}")

    # Set Cookie - Box is vuln to Session Fixation. Generating a random cookie for use.
    randomvalue = Rex::Text.rand_text_alphanumeric(26)
Severity: Major
Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb - About 3 hrs to fix

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

      def initialize(info={})
        super(update_info(info,
          'Name' => 'Carlo Gavazzi Energy Meters - Login Brute Force, Extract Info and Dump Plant Database',
          'Description' => %{
            This module scans for Carlo Gavazzi Energy Meters login portals, performs a login brute force attack, enumerates device firmware version, and attempt to extract the SMTP configuration. A valid, admin privileged user is required to extract the SMTP password. In some older firmware versions, the SMTP config can be retrieved without any authentication. The module also exploits an access control vulnerability which allows an unauthenticated user to remotely dump the database file EWplant.db. This db file contains information such as power/energy utilization data, tariffs, and revenue statistics. Vulnerable firmware versions include - VMU-C EM prior to firmware Version A11_U05 and VMU-C PV prior to firmware Version A17.
    Severity: Minor
    Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb - About 1 hr to fix

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

        def report_cred(opts)
          service_data = {
            address: opts[:ip],
            port: opts[:port],
            service_name: opts[:service_name],
      Severity: Major
      Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb and 24 other locations - About 1 hr to fix
      lib/msf/core/auxiliary/cnpilot.rb on lines 15..39
      lib/msf/core/auxiliary/epmp.rb on lines 15..39
      modules/auxiliary/admin/scada/modicon_password_recovery.rb on lines 91..115
      modules/auxiliary/scanner/http/binom3_login_config_pass_dump.rb on lines 55..79
      modules/auxiliary/scanner/http/meteocontrol_weblog_extractadmin.rb on lines 107..131
      modules/auxiliary/scanner/http/oracle_ilom_login.rb on lines 70..94
      modules/auxiliary/scanner/http/pocketpad_login.rb on lines 65..89
      modules/auxiliary/scanner/http/rfcode_reader_enum.rb on lines 144..168
      modules/auxiliary/scanner/http/sap_businessobjects_user_brute_web.rb on lines 44..68
      modules/auxiliary/scanner/http/sentry_cdu_enum.rb on lines 70..94
      modules/auxiliary/scanner/http/sevone_enum.rb on lines 66..90
      modules/auxiliary/scanner/http/typo3_bruteforce.rb on lines 39..63
      modules/auxiliary/scanner/lotus/lotus_domino_login.rb on lines 31..55
      modules/auxiliary/scanner/misc/oki_scanner.rb on lines 38..62
      modules/auxiliary/scanner/mongodb/mongodb_login.rb on lines 132..156
      modules/auxiliary/scanner/msf/msf_rpc_login.rb on lines 55..79
      modules/auxiliary/scanner/msf/msf_web_login.rb on lines 140..164
      modules/auxiliary/scanner/nessus/nessus_ntp_login.rb on lines 59..83
      modules/auxiliary/scanner/nexpose/nexpose_api_login.rb on lines 58..82
      modules/auxiliary/scanner/nntp/nntp_login.rb on lines 167..185
      modules/auxiliary/scanner/openvas/openvas_omp_login.rb on lines 56..80
      modules/auxiliary/scanner/openvas/openvas_otp_login.rb on lines 56..80
      modules/auxiliary/scanner/sap/sap_soap_rfc_brute_login.rb on lines 103..127
      modules/auxiliary/scanner/sap/sap_web_gui_brute_login.rb on lines 107..131

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

      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("#{rhost}:#{rport} - dumping EWplant.db")
            print_good("#{rhost}:#{rport} - EWplant.db retrieved successfully!")
            loot_name = 'EWplant.db'
            loot_type = 'SQLite_db/text'
            loot_desc = 'Carlo Gavazzi EM - EWplant.db'
      Severity: Minor
      Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb and 1 other location - About 50 mins to fix
      modules/auxiliary/scanner/http/cnpilot_r_web_login_loot.rb on lines 84..90

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

            begin
              res = send_request_cgi(
                {
                  'uri' => '/setupfirmware.php',
                  'method' => 'GET',
      Severity: Minor
      Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb and 1 other location - About 35 mins to fix
      modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb on lines 194..208

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

      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

            begin
              res = send_request_cgi(
                {
                  'uri'       => '/setupmail.php',
                  'method'    => 'GET',
      Severity: Minor
      Found in modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb and 1 other location - About 35 mins to fix
      modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb on lines 157..170

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

      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