fix ruff alerts

This commit is contained in:
zblurx
2023-11-01 19:47:38 +01:00
parent 4853942fee
commit 2c1f30a276
3 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -389,7 +389,7 @@ class smb(connection):
kerb_pass = ""
self.username = self.args.delegate
serverName = Principal(f"cifs/{self.hostname}", type=constants.PrincipalNameType.NT_SRV_INST.value)
tgs = kerberos_login_with_S4U(domain, self.hostname, username, password, nthash, lmhash, aesKey,kdcHost, self.args.delegate, serverName, useCache, no_s4u2proxy=self.args.no_s4u2proxy)
tgs = kerberos_login_with_S4U(domain, self.hostname, username, password, nthash, lmhash, aesKey, kdcHost, self.args.delegate, serverName, useCache, no_s4u2proxy=self.args.no_s4u2proxy)
self.logger.debug(f"Got TGS for {self.args.delegate} through S4U")
self.conn.kerberosLogin(self.username, password, domain, lmhash, nthash, aesKey, kdcHost, useCache=useCache, TGS=tgs)
+6 -8
View File
@@ -41,7 +41,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
ap_req["pvno"] = 5
ap_req["msg-type"] = int(constants.ApplicationTagNumbers.AP_REQ.value)
opts = list()
opts = []
ap_req["ap-options"] = constants.encodeFlags(opts)
seq_set(ap_req, "ticket", ticket.to_asn1)
@@ -112,7 +112,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
req_body = seq_set(tgs_req, "req-body")
opts = list()
opts = []
opts.append(constants.KDCOptions.forwardable.value)
opts.append(constants.KDCOptions.renewable.value)
opts.append(constants.KDCOptions.canonicalize.value)
@@ -152,8 +152,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
# Creating new cipher based on received keytype
cipher = _enctype_table[enc_tgs_rep_part["key"]["keytype"]]
# return r, cipher, session_key, new_session_key
tgs_formated = dict()
tgs_formated = {}
tgs_formated["KDC_REP"] = r
tgs_formated["cipher"] = cipher
tgs_formated["sessionKey"] = new_session_key
@@ -174,7 +173,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
ap_req["pvno"] = 5
ap_req["msg-type"] = int(constants.ApplicationTagNumbers.AP_REQ.value)
opts = list()
opts = []
ap_req["ap-options"] = constants.encodeFlags(opts)
seq_set(ap_req, "ticket", ticket_tgt.to_asn1)
@@ -224,7 +223,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
req_body = seq_set(tgs_req, "req-body")
opts = list()
opts = []
# This specified we"re doing S4U
opts.append(constants.KDCOptions.cname_in_addl_tkt.value)
opts.append(constants.KDCOptions.canonicalize.value)
@@ -272,8 +271,7 @@ def kerberos_login_with_S4U(domain, hostname, username, password, nthash, lmhash
# Creating new cipher based on received keytype
cipher = _enctype_table[enc_tgs_rep_part["key"]["keytype"]]
# return r, cipher, session_key, new_session_key
tgs_formated = dict()
tgs_formated = {}
tgs_formated["KDC_REP"] = r
tgs_formated["cipher"] = cipher
tgs_formated["sessionKey"] = new_session_key
+3 -3
View File
@@ -83,13 +83,13 @@ def proto_args(parser, std_parser, module_parser):
def get_conditional_action(baseAction):
class ConditionalAction(baseAction):
def __init__(self, option_strings, dest, **kwargs):
x = kwargs.pop('make_required', [])
super(ConditionalAction, self).__init__(option_strings, dest, **kwargs)
x = kwargs.pop("make_required", [])
super().__init__(option_strings, dest, **kwargs)
self.make_required = x
def __call__(self, parser, namespace, values, option_string=None):
for x in self.make_required:
x.required = True
super(ConditionalAction, self).__call__(parser, namespace, values, option_string)
super().__call__(parser, namespace, values, option_string)
return ConditionalAction