feat: Implement directory validation and shell command quoting
- Added is_valid_directory function to validate directory paths, ensuring they do not contain control characters and are within a specified length. - Introduced quote_shell_arg to safely quote shell arguments, preventing command injection. - Created build_cd_command to generate a command for changing directories in a shell. - Enhanced the LoginHandler to utilize a login rate limiter, preventing brute-force attacks by tracking failed login attempts. - Implemented an EncodingCache to optimize encoding detection for SSH connections. - Updated the UI to include an input field for specifying an initial directory upon login, with appropriate validation and hints. - Added a quickbar in the terminal interface for easy access to copy and paste functionality. - Introduced a toast notification system to provide feedback on copy actions. - Refactored connection storage to encrypt passwords at rest, improving security. - Updated various templates and styles to accommodate new features and improve user experience.
This commit is contained in:
+7
-2
@@ -20,6 +20,9 @@ print('Read key: ' + hexlify(host_key.get_fingerprint()).decode('utf-8'))
|
||||
|
||||
banner = u'\r\n\u6b22\u8fce\r\n'
|
||||
event_timeout = 5
|
||||
# clients that reuse a cached encoding never send the probe command, so this
|
||||
# wait must be short and non-fatal
|
||||
exec_timeout = 1
|
||||
|
||||
|
||||
class Server(paramiko.ServerInterface):
|
||||
@@ -41,6 +44,7 @@ class Server(paramiko.ServerInterface):
|
||||
self.shell_event = threading.Event()
|
||||
self.exec_event = threading.Event()
|
||||
self.cmd_to_enc = self.get_cmd2enc(encodings)
|
||||
self.encoding = 'UTF-8'
|
||||
self.password_verified = False
|
||||
self.key_verified = False
|
||||
|
||||
@@ -171,10 +175,11 @@ def run_ssh_server(port=2200, running=True, encodings=[]):
|
||||
print('*** Client never asked for a shell.')
|
||||
continue
|
||||
|
||||
server.exec_event.wait(timeout=event_timeout)
|
||||
server.exec_event.wait(timeout=exec_timeout)
|
||||
if not server.exec_event.is_set():
|
||||
# the client already knew this server's encoding and skipped the
|
||||
# probe; fall back to the default instead of dropping the session
|
||||
print('*** Client never asked for a command.')
|
||||
continue
|
||||
|
||||
# chan.send('\r\n\r\nWelcome!\r\n\r\n')
|
||||
print(server.encoding)
|
||||
|
||||
Reference in New Issue
Block a user