@@ -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
@@ -168,11 +167,13 @@ def plaintext_login(self, domain, username, password):
168167
169168 self .logger .debug (f"Adding credential: { domain } /{ self .username } :{ self .password } " )
170169 self .db .add_credential ("plaintext" , domain , self .username , self .password )
171- # TODO: when we can easily get the host_id via RETURNING statements, readd this in
170+ user_id = self .db .get_credential ("plaintext" , domain , self .username , self .password )
171+ host_id = self .db .get_hosts (self .host )[0 ].id
172+ self .db .add_loggedin_relation (user_id , host_id )
172173
173174 if self .admin_privs :
174175 self .logger .debug ("Inside admin privs" )
175- self .db .add_admin_user ("plaintext" , domain , self .username , self .password , self .host ) # , user_id=user_id)
176+ self .db .add_admin_user ("plaintext" , domain , self .username , self .password , self .host , user_id = user_id ) # , user_id=user_id)
176177 add_user_bh (f"{ self .hostname } $" , domain , self .logger , self .config )
177178
178179 if not self .args .local_auth and self .username != "" :
@@ -217,8 +218,13 @@ def hash_login(self, domain, username, ntlm_hash):
217218 self .check_if_admin ()
218219 self .logger .success (f"{ self .domain } \\ { self .username } :{ process_secret (nthash )} { self .mark_pwned ()} " )
219220
221+ self .db .add_credential ("hash" , domain , self .username , ntlm_hash )
222+ user_id = self .db .get_credential ("hash" , domain , self .username , ntlm_hash )
223+ host_id = self .db .get_hosts (self .host )[0 ].id
224+ self .db .add_loggedin_relation (user_id , host_id )
225+
220226 if self .admin_privs :
221- self .db .add_admin_user ("hash" , domain , self .username , nthash , self .host )
227+ self .db .add_admin_user ("hash" , domain , self .username , nthash , self .host , user_id = user_id )
222228 add_user_bh (f"{ self .hostname } $" , domain , self .logger , self .config )
223229
224230 if not self .args .local_auth and self .username != "" :
0 commit comments