Pennyw0rth / NetExec

The Network Execution Tool
https://netexec.wiki/
BSD 2-Clause "Simplified" License
3.27k stars 358 forks source link

Mssql xp_cmdshell added "is enabled" check #405

Closed 0xQRx closed 1 week ago

0xQRx commented 2 months ago

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 of xp_cmdshell. The updated code now:

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?

Test Configuration:

Screenshots:

xp_cmdshell disabled flow:

cmdshell_disabled cmdshell_disabled_2

xp_cmdshell enabled flow:

cmdshell_enabled

NeffIsBack commented 2 months ago

Oh very nice! That was really needed, encountered the problem on a pentest myself. Thanks for the PR!

NeffIsBack commented 1 week ago

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