File services.rb
has 434 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Msf
class Post
module Windows
# @deprecated Use {Services} instead
module WindowsServices
Method meterpreter_service_list
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def meterpreter_service_list
if session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_KEY)
begin
return session.extapi.service.enumerate
rescue Rex::Post::Meterpreter::RequestError => e
- 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
Class Post
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Post
module Windows
# @deprecated Use {Services} instead
module WindowsServices
def self.included(_base)
Method service_restart
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def service_restart(name, start_type = START_TYPE_AUTO, server = nil, should_retry = true)
status = service_start(name, server)
if status == Error::SUCCESS
vprint_good("[#{name}] Service started")
- 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 meterpreter_service_list
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def meterpreter_service_list
if session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_KEY)
begin
return session.extapi.service.enumerate
rescue Rex::Post::Meterpreter::RequestError => e
Method service_create
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def service_create(name, opts, server = nil)
access = 'SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_QUERY_LOCK_STATUS'
open_sc_manager(host: server, access: access) do |manager|
opts[:display] ||= Rex::Text.rand_text_alpha(8)
opts[:desired_access] ||= 'SERVICE_START'
- 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 each_service
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def each_service(&block)
if session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_KEY)
begin
return session.extapi.service.enumerate.each(&block)
rescue Rex::Post::Meterpreter::RequestError => e
- 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 service_restart
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def service_restart(name, start_type = START_TYPE_AUTO, server = nil, should_retry = true)
status = service_start(name, server)
if status == Error::SUCCESS
vprint_good("[#{name}] Service started")
Method service_create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def service_create(name, opts, server = nil)
access = 'SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_QUERY_LOCK_STATUS'
open_sc_manager(host: server, access: access) do |manager|
opts[:display] ||= Rex::Text.rand_text_alpha(8)
opts[:desired_access] ||= 'SERVICE_START'
Method service_change_startup
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def service_change_startup(name, mode, server = nil)
if mode.is_a? Integer
startup_number = mode
else
case mode.downcase
Method service_change_startup
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def service_change_startup(name, mode, server = nil)
if mode.is_a? Integer
startup_number = mode
else
case mode.downcase
- 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 open_sc_manager
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def open_sc_manager(opts = {})
host = opts[:host] || nil
access = opts[:access] || 'SC_MANAGER_ALL_ACCESS'
machine_str = host ? "\\\\#{host}" : nil
- 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 _shell_service_start
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _shell_service_start(service_name, server = nil)
host = server ? "\\\\#{server}" : nil
timeout = 75 # sc.exe default RPC connection timeout 60 seconds + cmd_exec default timeout 15 seconds
fingerprint = Rex::Text.rand_text_alphanumeric(6..8)
- 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 _shell_service_stop
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _shell_service_stop(service_name, server = nil)
host = server ? "\\\\#{server}" : nil
timeout = 75 # sc.exe default RPC connection timeout 60 seconds + cmd_exec default timeout 15 seconds
fingerprint = Rex::Text.rand_text_alphanumeric(6..8)
- 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
Avoid too many return
statements within this method. Open
return 2
Method service_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def service_info(name)
if session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_QUERY_VALUE)
begin
return session.extapi.service.query(name)
rescue Rex::Post::Meterpreter::RequestError => e
- 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"