How can I remotely administrate after accidentally disabling SMBv1 and SMBv2 Protocol?

Question

I been hardening things up as my division is under audit and the report mentioned how SMBv1 needs to be disabled and something about signing SMB2 too. Instead, I disabled both SMBv1 and SMBv2.

Is there another way to gain access to the systems so I don't need to drive in, not able to use RDP if they're using it, or TeamViewer.

I like to do is psexec \host cmd, then ran powershell, then Set-SmbServerConfiguration -EnableSMB2Protocol $true -force but b/c the host or IP cant be discovered, it won't work.

There must be another way I can gain entry to these systems.
Ideas? I tried Remote Computer Management, PDQ, ...

Posted Oct 27, 2022, 8:18 PM UTC

115
jantari•

I think you should still be able to use remote WMI over DCOM in a default Windows server install, even today. So unless you've already disabled that as well (you should) then you can still remotely create powershell processes with arguments which is all you need to get yourself out of this.

Invoke-WmiMethod -ComputerName server -Class Win32_Process -Name Create -ArgumentList "powershell.exe -ExecutionPolicy Bypass -Command ..."
3
BurnadonStat•

If it is disabled - you can also push out a group policy to turn it back on.

2
jantari•

I don't think group policies can be read / applied from domain controllers as long as SMB is completely broken across the domain

1
captainjonOPSysadmin•

To be sure I followed you correctly, I did this: PS C:\Windows\system32> invoke-wmimethod -computername jsmith-lt -class win32_process -name create -argumentlist "powershell.exe -executionpolicybypass -command Set-SmbServerConfiguration -EnableSMB2Protocol $true -force"

This was outputted:

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 2
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ProcessId        : 17856
ReturnValue      : 0
PSComputerName   :

Afterwards, I went to Start > Run on my desktop and \\jsmith-lt\c$ was still not found. If I go to the PC directly, or TeamView in, run the powershell directly in an administrative shell, it took immediate effect (no reboot needed).

1
jantari•

The problem with this method is that other than the fact that a process was started, you don't get any information or output back. So you have to make sure in advance that your quoting and escaping and parameters are correct.

In this specific case I'd try wrapping the -Command you're passing in nested, escaped quotes and I'd also escape the dollar sign in front of true so that that doesn't get evaluated prematurely by your local shell.

1
captainjonOPSysadmin•

I think I understand what you meant but it seems to not be working still:

-argumentlist "powershell.exe -executionpolicybypass -command \`"Set-SmbServerConfiguration -EnableSMB2Protocol `$true -force\`""

Was everything escaped correctly? Powershell escaping is kinda weird and I am not used to it.

1
jantari•

You're forgetting a space after ExecutionPolicy and I'm also not sure whether you need the backslashes, I wouldn't think so.

2
polypolymanJack of All Trades•

psexec will work fine with SMB3. PSRemoting is also a very good option for remote management.

What is left in your environment that's still using SMB2?

2
captainjonOPSysadmin•

I get hosts not found even with \host\c$ after I accidentally disabled smbv2. It seems pdq, et al use it.

1
Ad-1316•

Windows Admin Center?

1
usbeef•

I would like to know what you did exactly. The SMBv2 service in Windows also includes SMBv3 which means you effectively disabled SMB. The Workstation service is dependent on the MRxSmb20 service which includes SMBv3. If the Workstation service can't start then the Netlogon service can't start because the Netlogon service is dependent on the Workstation service. With the Netlogon service unable to start, domain authentication on those machines would be completely disabled.

1
[deleted]•

[deleted]

1
captainjonOPSysadmin•

I put Set-SmbServerConfiguration -EnableSMB2Protocol $false -force into PDQ Deploy and pushed it out to several hosts at once. Then I got a report that Engineering couldn't access random hosts that has their toolsets on and I went into that machine with TeamViewer, and undid that command by setting it to true. However, at that point, SMB1Protocol was previously disabled and I lost UNC access as \\host\share is how that, and how some other tools worked. Even going to Start Run \\host\c$ returned host not found. I can still ping it, but was no longer able to access its shares remotely.

1
usbeef•

The official way to disable SMBv1 is to do so through group policy. There are MS Security Guide ADMX files that come with the Security Compliance Toolkit. Once those are imported you will have the option for "Configure SMB v1 client driver". Set that to "Disable Driver" and "Configure SMB v1 server", set that to disabled. You can also uninstall SMBv1 with this command.

Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

1
captainjonOPSysadmin•

If corporate handled a fraction of this shit my life would be better. But instead I get to go through a 1600 page report from fucking Nexpose where most of the criticals are fucking printers and then I get my arse reamed by the CFO bc she doesn’t understand a goddamn thing except that the report just shows x critical y severe hits and it needs to be an unrealistic zero. Every. Fucking. Month.

I can’t waste 90% of my day doing horseshit fucking corporate should be doing.

So yes, I am starting the job search. Bc fuck this shit.

1