[mssql] fix ccache
Signed-off-by: XiaoliChan <30458572+XiaoliChan@users.noreply.github.com>main
parent
8a5d77b1d7
commit
93f3bccd7b
|
@ -139,15 +139,16 @@ class mssql(connection):
|
||||||
):
|
):
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
self.conn.disconnect()
|
self.conn.disconnect()
|
||||||
|
# When using ccache file, we must need to set target host to hostname when creating connection object.
|
||||||
|
self.host = self.hostname
|
||||||
self.create_conn_obj()
|
self.create_conn_obj()
|
||||||
|
|
||||||
kerb_pass = next(s for s in [self.nthash, password, aesKey] if s) if not all(s == "" for s in [self.nthash, password, aesKey]) else ""
|
kerb_pass = next(s for s in [self.nthash, password, aesKey] if s) if not all(s == "" for s in [self.nthash, password, aesKey]) else ""
|
||||||
|
|
||||||
if useCache and kerb_pass == "":
|
if useCache and kerb_pass == "":
|
||||||
ccache = CCache.loadFile(os.getenv("KRB5CCNAME"))
|
ccache = CCache.loadFile(os.getenv("KRB5CCNAME"))
|
||||||
principal = ccache.principal.toPrincipal()
|
username = ccache.credentials[0].header["client"].prettyPrint().decode().split("@")[0]
|
||||||
self.username = principal.components[0]
|
self.username = username
|
||||||
username = principal.components[0]
|
|
||||||
|
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
@ -206,7 +207,6 @@ class mssql(connection):
|
||||||
self.domain = domain
|
self.domain = domain
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# domain = "" is to prevent a decoding issue in impacket/ntlm.py:617 where it attempts to decode the domain
|
|
||||||
res = self.conn.login(None, username, password, domain, None, not self.args.local_auth)
|
res = self.conn.login(None, username, password, domain, None, not self.args.local_auth)
|
||||||
if res is not True:
|
if res is not True:
|
||||||
error_msg = self.handle_mssql_reply()
|
error_msg = self.handle_mssql_reply()
|
||||||
|
|
Loading…
Reference in New Issue