modules/exploits/windows/dcerpc/cve_2021_1675_printnightmare.rb
Method initialize
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Print Spooler Remote DLL Injection',
File cve_2021_1675_printnightmare.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'windows_error'
require 'ruby_smb'
require 'ruby_smb/error'
class MetasploitModule < Msf::Exploit::Remote
Method check
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def check
begin
connect(backend: :ruby_smb)
rescue Rex::ConnectionError
return Exploit::CheckCode::Unknown('Failed to connect to the remote service.')
Method add_printer_driver_ex
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def add_printer_driver_ex(container)
flags = PrintSystem::APD_INSTALL_WARNED_DRIVER | PrintSystem::APD_COPY_FROM_DIRECTORY | PrintSystem::APD_COPY_ALL_FILES
begin
response = rprn_call('RpcAddPrinterDriverEx', p_name: "\\\\#{datastore['RHOST']}", p_driver_container: container, dw_file_copy_flags: flags)
- 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"
Further reading
Method check
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def check
begin
connect(backend: :ruby_smb)
rescue Rex::ConnectionError
return Exploit::CheckCode::Unknown('Failed to connect to the remote service.')
- 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"
Further reading
Method add_printer_driver_ex
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_printer_driver_ex(container)
flags = PrintSystem::APD_INSTALL_WARNED_DRIVER | PrintSystem::APD_COPY_FROM_DIRECTORY | PrintSystem::APD_COPY_ALL_FILES
begin
response = rprn_call('RpcAddPrinterDriverEx', p_name: "\\\\#{datastore['RHOST']}", p_driver_container: container, dw_file_copy_flags: flags)
Avoid too many return
statements within this method. Open
Open
return Exploit::CheckCode::Unknown('Received unknown status code, implying the target is not vulnerable.')
Avoid too many return
statements within this method. Open
Open
return Exploit::CheckCode::Vulnerable('Received ERROR_BAD_NET_NAME, implying the target is vulnerable.')
Avoid too many return
statements within this method. Open
Open
return Exploit::CheckCode::Safe('Received ERROR_ACCESS_DENIED implying the target is patched.')
Avoid too many return
statements within this method. Open
Open
return Exploit::CheckCode::Vulnerable('Received ERROR_PATH_NOT_FOUND, implying the target is vulnerable.')