@@ -85,7 +85,6 @@ def plaintext_login(self, username, password, private_key=""):
8585 try :
8686 if self .args .key_file or private_key :
8787 self .logger .debug (f"Logging { self .host } with username: { username } , keyfile: { self .args .key_file } " )
88-
8988 self .conn .connect (
9089 self .host ,
9190 port = self .port ,
@@ -97,13 +96,7 @@ def plaintext_login(self, username, password, private_key=""):
9796 allow_agent = False ,
9897 banner_timeout = self .args .ssh_timeout ,
9998 )
100-
101- cred_id = self .db .add_credential (
102- "key" ,
103- username ,
104- password if password != "" else "" ,
105- key = private_key ,
106- )
99+ cred_id = self .db .add_credential ("key" , username , password , key = private_key )
107100 else :
108101 self .logger .debug (f"Logging { self .host } with username: { self .username } , password: { self .password } " )
109102 self .conn .connect (
@@ -151,6 +144,7 @@ def check_shell(self, cred_id):
151144 self .server_os_platform = "Linux"
152145 self .logger .debug (f"Linux detected for user: { stdout } " )
153146 self .shell_access = True
147+ self .db .add_loggedin_relation (cred_id , host_id , shell = self .shell_access )
154148 self .check_linux_priv ()
155149 if self .admin_privs :
156150 self .logger .debug (f"User { self .username } logged in successfully and is root!" )
@@ -166,8 +160,14 @@ def check_shell(self, cred_id):
166160 self .server_os_platform = "Windows"
167161 self .logger .debug ("Windows detected" )
168162 self .shell_access = True
169- self .check_windows_priv (stdout )
170163 self .db .add_loggedin_relation (cred_id , host_id , shell = self .shell_access )
164+ self .check_windows_priv (stdout )
165+ if self .admin_privs :
166+ self .logger .debug (f"User { self .username } logged in successfully and is admin!" )
167+ if self .args .key_file :
168+ self .db .add_admin_user ("key" , self .username , self .password , host_id = host_id , cred_id = cred_id )
169+ else :
170+ self .db .add_admin_user ("plaintext" , self .username , self .password , host_id = host_id , cred_id = cred_id )
171171 return
172172
173173 # No shell access
0 commit comments