@@ -31,7 +31,6 @@ def __init__(self, args, db, host):
3131 self .server_os = None
3232 self .output_filename = None
3333 self .endpoint = None
34- self .hash = None
3534 self .lmhash = ""
3635 self .nthash = ""
3736 self .ssl = False
@@ -165,11 +164,13 @@ def plaintext_login(self, domain, username, password):
165164
166165 self .logger .debug (f"Adding credential: { domain } /{ self .username } :{ self .password } " )
167166 self .db .add_credential ("plaintext" , domain , self .username , self .password )
168- # TODO: when we can easily get the host_id via RETURNING statements, readd this in
167+ user_id = self .db .get_credential ("plaintext" , domain , self .username , self .password )
168+ host_id = self .db .get_hosts (self .host )[0 ].id
169+ self .db .add_loggedin_relation (user_id , host_id )
169170
170171 if self .admin_privs :
171172 self .logger .debug ("Inside admin privs" )
172- self .db .add_admin_user ("plaintext" , domain , self .username , self .password , self .host ) # , user_id=user_id)
173+ self .db .add_admin_user ("plaintext" , domain , self .username , self .password , self .host , user_id = user_id ) # , user_id=user_id)
173174 add_user_bh (f"{ self .hostname } $" , domain , self .logger , self .config )
174175
175176 if not self .args .local_auth and self .username != "" :
@@ -211,8 +212,13 @@ def hash_login(self, domain, username, ntlm_hash):
211212 self .check_if_admin ()
212213 self .logger .success (f"{ self .domain } \\ { self .username } :{ process_secret (nthash )} { self .mark_pwned ()} " )
213214
215+ self .db .add_credential ("hash" , domain , self .username , ntlm_hash )
216+ user_id = self .db .get_credential ("hash" , domain , self .username , ntlm_hash )
217+ host_id = self .db .get_hosts (self .host )[0 ].id
218+ self .db .add_loggedin_relation (user_id , host_id )
219+
214220 if self .admin_privs :
215- self .db .add_admin_user ("hash" , domain , self .username , nthash , self .host )
221+ self .db .add_admin_user ("hash" , domain , self .username , nthash , self .host , user_id = user_id )
216222 add_user_bh (f"{ self .hostname } $" , domain , self .logger , self .config )
217223
218224 if not self .args .local_auth and self .username != "" :
0 commit comments