From a908d31fc5307eca3d5d79e859d2b8e1b11f3c71 Mon Sep 17 00:00:00 2001 From: Shreya Date: Sun, 31 Jan 2021 21:45:53 +0530 Subject: [PATCH] Remove unused imports and variable --- monkey/infection_monkey/exploit/zerologon.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/monkey/infection_monkey/exploit/zerologon.py b/monkey/infection_monkey/exploit/zerologon.py index 770118e04..844bdcaa1 100644 --- a/monkey/infection_monkey/exploit/zerologon.py +++ b/monkey/infection_monkey/exploit/zerologon.py @@ -5,34 +5,25 @@ Implementation based on https://github.com/dirkjanm/CVE-2020-1472/ and https://g from __future__ import division, print_function -import argparse import cmd -import codecs import io import logging import ntpath import os -import re import sys import time import traceback -from binascii import hexlify, unhexlify +from binascii import unhexlify import impacket -from Cryptodome.Cipher import AES, ARC4, DES -from impacket import crypto, version from impacket.dcerpc.v5 import epm, nrpc, transport from impacket.dcerpc.v5.dcom import wmi from impacket.dcerpc.v5.dcomrt import DCOMConnection from impacket.dcerpc.v5.dtypes import NULL -from impacket.dcerpc.v5.ndr import NDRCALL -from impacket.examples import logger from impacket.examples.secretsdump import (LocalOperations, LSASecrets, NTDSHashes, RemoteOperations, SAMHashes) -from impacket.krb5.keytab import Keytab -from impacket.smbconnection import (SMB2_DIALECT_002, SMB2_DIALECT_21, - SMB_DIALECT, SMBConnection) +from impacket.smbconnection import SMBConnection from common.utils.exploit_enum import ExploitType from infection_monkey.exploit.HostExploiter import HostExploiter @@ -350,8 +341,7 @@ class ZerologonExploiter(HostExploiter): request["Authenticator"] = authenticator pwd_data = impacket.crypto.SamEncryptNTLMHash(unhexlify(original_pwd_nthash), session_key) request["UasNewPassword"] = pwd_data - resp = rpc_con.request(request) - # resp.dump() + rpc_con.request(request) except Exception as e: LOG.info(f"Unexpected error: {e}") @@ -561,7 +551,7 @@ class DumpSecrets: os.unlink(resume_file) try: self.cleanup() - except: + except Exception: pass finally: dumped_secrets = _unset_stdout_and_return_captured() # includes hashes and kerberos keys