Linux web-conference.aiou.edu.pk 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64
Apache/2.4.41 (Ubuntu)
: 172.16.50.247 | : 3.135.212.80
Cant Read [ /etc/named.conf ]
7.4.3-4ubuntu2.28
appadmin
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
netplan /
netplan /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
cli
[ DIR ]
drwxr-xr-x
__init__.py
764
B
-rw-r--r--
_features.py
291
B
-rw-r--r--
configmanager.py
12.28
KB
-rw-r--r--
libnetplan.py
9.2
KB
-rw-r--r--
terminal.py
5.18
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : terminal.py
#!/usr/bin/python3 # # Copyright (C) 2018 Canonical, Ltd. # Author: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ Terminal / input handling """ import fcntl import os import termios import select import sys class Terminal(object): """ Do minimal terminal mangling to prompt users for input """ def __init__(self, fd): self.fd = fd self.orig_flags = None self.orig_term = None self.save() def enable_echo(self): if sys.stdin.isatty(): attrs = termios.tcgetattr(self.fd) attrs[3] = attrs[3] | termios.ICANON attrs[3] = attrs[3] | termios.ECHO termios.tcsetattr(self.fd, termios.TCSANOW, attrs) def disable_echo(self): if sys.stdin.isatty(): attrs = termios.tcgetattr(self.fd) attrs[3] = attrs[3] & ~termios.ICANON attrs[3] = attrs[3] & ~termios.ECHO termios.tcsetattr(self.fd, termios.TCSANOW, attrs) def enable_nonblocking_io(self): flags = fcntl.fcntl(self.fd, fcntl.F_GETFL) fcntl.fcntl(self.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) def disable_nonblocking_io(self): flags = fcntl.fcntl(self.fd, fcntl.F_GETFL) fcntl.fcntl(self.fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK) def get_confirmation_input(self, timeout=120, message=None): # pragma: nocover (requires user input) """ Get a "confirmation" input from the user, for at most (timeout) seconds. Optionally, customize the message to be displayed. timeout -- timeout to wait for input (default 120) message -- optional customized message ("Press ENTER to (message)") raises: InputAccepted -- the user confirmed the changes InputRejected -- the user rejected the changes """ print("Do you want to keep these settings?\n\n") settings = dict() self.save(settings) self.disable_echo() self.enable_nonblocking_io() if not message: message = "accept the new configuration" print("Press ENTER before the timeout to {}\n\n".format(message)) timeout_now = timeout while (timeout_now > 0): print("Changes will revert in {:>{}} seconds".format(timeout_now, len(str(timeout))), end='\r') # wait at most 1 second for usable input from stdin select.select([sys.stdin], [], [], 1) try: # retrieve any input from the terminal. select() either has # timed out with no input, or found something we can retrieve. c = sys.stdin.read() if (c == '\n'): self.reset(settings) # Yay, user has accepted the changes! raise InputAccepted() except TypeError: # read() above is non-blocking, if there is nothing to read it # will return TypeError, which we should ignore -- on to the # next iteration until timeout. pass timeout_now -= 1 # We reached the timeout for our loop, now revert our change for # non-blocking I/O and signal the caller the changes were essentially # rejected. self.reset(settings) raise InputRejected() def save(self, dest=None): """ Save the terminal's current attributes and flags Optional argument: - dest: if set, save settings to this dict """ orig_flags = fcntl.fcntl(self.fd, fcntl.F_GETFL) orig_term = None if sys.stdin.isatty(): orig_term = termios.tcgetattr(self.fd) if dest is not None: dest.update({'flags': orig_flags, 'term': orig_term}) else: self.orig_flags = orig_flags self.orig_term = orig_term def reset(self, orig=None): """ Reset the terminal to its original attributes and flags Optional argument: - orig: if set, reset to settings from this dict """ orig_term = None orig_flags = None if orig is not None: orig_term = orig.get('term') orig_flags = orig.get('flags') else: orig_term = self.orig_term orig_flags = self.orig_flags if sys.stdin.isatty(): termios.tcsetattr(self.fd, termios.TCSAFLUSH, orig_term) fcntl.fcntl(self.fd, fcntl.F_SETFL, orig_flags) class InputAccepted(Exception): """ Denotes has accepted input""" pass class InputRejected(Exception): """ Denotes that the user has rejected input""" pass
Close