Closed 0xQRx closed 1 week ago
Oh very nice! That was really needed, encountered the problem on a pentest myself. Thanks for the PR!
Added generic functions for backup&enabling options so we now can simply enable advanced options
and then xp_cmdshell
with the ability to restore the state after execution. With that i added that to the get and put file functions as well. Now we shouldn't alter the mssql state with our commands
name: Pull request about: Update code to add an enhancement title: Add functionality to check if xp_cmdshell is enabled before execution labels: enhancement
Description
This update adds functionality to check if
xp_cmdshell
is enabled before attempting to enable it. This enhancement prevents unnecessary changes to the state ofxp_cmdshell
. The updated code now:xp_cmdshell
is enabled usingsp_configure
.xp_cmdshell
is already enabled, without altering its state.xp_cmdshell
only if it is disabled, executes the command, and then restores the original state by disabling it again.Motivation: This change ensures that
xp_cmdshell
is not disabled after the execution if it was enabled initially, maintaining the target system's configuration integrity.Dependencies: No new dependencies were introduced in this change.
Type of change
How Has This Been Tested?
xp_cmdshell
already enabled: Verified that the command executes without disablingxp_cmdshell
.xp_cmdshell
disabled: Verified that the command enablesxp_cmdshell
, executes successfully, and restores the disabled state afterward.Test Configuration:
Screenshots:
xp_cmdshell
disabled flow:xp_cmdshell
enabled flow: