I realize that this post is an edge case, but I recently used this method to bypass SEP (Symantec Endpoint Protection) during a pen test, so for my reference and that one person who runs into a similar scenario I am writing this. A little bit of backstory: I was able to acquire a shared local administrator’s credentials during a pen test. I was using them to gain access to other systems using psexec, but was thwarted by SEP in most cases (with a file not found error). So at this point I am most of the way there already, seeing as I had valid administrator credentials. There are probably other ways to skin this cat, but I learned something doing it this way so we will go with it!
How to Bypass the SEP HIDS
When psexec failed, my next idea was to use this beautiful dll / shellcode injector written by our very own steiner. By generating shellcode using msfvenom (or msfpayload if you’re behind the times), we can inject the first stage of a payload in memory and avoid AV. That is all well and good for AV, but Symantec also has a HIDS. This HIDS was picking off the meterpreter stages, causing the the stage to fail.
There are two options for getting around this. The first is to use a stageless payload. Instead of breaking up our payload into multiple stages and reducing the size, we can use one of the new stageless payloads which has the entirety of meterpreter contained in them. This could be a pain, given we are using syringe to inject them so the second method is the one I used. I generated the payload as usual but I changed the handler to EnableStateEncoding. This encodes each of the stages and in this instance bypasses the SEP HIDS.
How to Disable SEP
Now for disabling SEP. This requires RDP to be open, although you could enable that through psexec_command. To do so, it needs to have the registry key LocalAccountTokenFilterPolicy set to 1. To test it out set your remote desktop settings to not allow connections.
Then open up metasploit and use the auxiliary/admin/smb/psexec_command exploit. Set the SMBPass, SMBUser, and SMBDomain to whatever is correct for your system. Then do the following command:
set COMMAND ‘reg add “hklm\system\currentcontrolset\control\terminal server” /f /v fDenyTSConnections /t REG_DWORD /d 0’
Now run!
Which should produce the following result.
You may need to allow it through the firewall so run the following commands against the system:
- netsh firewall set service remoteadmin enable
- netsh firewall set service remotedesktop enable
Once you can RDP into the system, do so and bring up SEP. Go to change settings > tamper protection. Unselect the box that says “Protect Symantec security software from being tampered with or shut down”.
Then go to the command line and run “C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\smc.exe -stop”. Voila, it’s disabled! Now you can go about your business!
Pretty simple. Hopefully you will find something of value in this post, despite the limited use case. As always, keep hacking!
References
https://github.com/securestate/syringe
https://warroom.rsmus.com/index.php/author/steiner/
https://community.rapid7.com/community/metasploit/blog/2014/12/09/good-bye-msfpayload-and-msfencode
https://community.rapid7.com/community/metasploit/blog/2015/03/25/stageless-meterpreter-payloads
http://serverfault.com/questions/8805/psexec-access-is-denied
http://community.spiceworks.com/how_to/35529-enable-rdp-through-cmd-line