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 | : 18.119.159.212
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 /
lib /
python3 /
dist-packages /
cloudinit /
config /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
schemas
[ DIR ]
drwxr-xr-x
__init__.py
40
B
-rw-r--r--
cc_ansible.py
7.68
KB
-rw-r--r--
cc_apk_configure.py
4.23
KB
-rw-r--r--
cc_apt_configure.py
38.08
KB
-rw-r--r--
cc_apt_pipelining.py
1.85
KB
-rw-r--r--
cc_bootcmd.py
1.65
KB
-rw-r--r--
cc_byobu.py
2.73
KB
-rw-r--r--
cc_ca_certs.py
8.67
KB
-rw-r--r--
cc_chef.py
12.19
KB
-rw-r--r--
cc_disable_ec2_metadata.py
1.6
KB
-rw-r--r--
cc_disk_setup.py
29.61
KB
-rw-r--r--
cc_fan.py
1.95
KB
-rw-r--r--
cc_final_message.py
2.51
KB
-rw-r--r--
cc_growpart.py
18.37
KB
-rw-r--r--
cc_grub_dpkg.py
5.39
KB
-rw-r--r--
cc_install_hotplug.py
3.19
KB
-rw-r--r--
cc_keyboard.py
1.49
KB
-rw-r--r--
cc_keys_to_console.py
2.09
KB
-rw-r--r--
cc_landscape.py
3.06
KB
-rw-r--r--
cc_locale.py
1.19
KB
-rw-r--r--
cc_lxd.py
13.44
KB
-rw-r--r--
cc_mcollective.py
4.11
KB
-rw-r--r--
cc_mounts.py
18.16
KB
-rw-r--r--
cc_ntp.py
18.97
KB
-rw-r--r--
cc_package_update_upgrade_inst...
3.79
KB
-rw-r--r--
cc_phone_home.py
3.75
KB
-rw-r--r--
cc_power_state_change.py
5.92
KB
-rw-r--r--
cc_puppet.py
10.72
KB
-rw-r--r--
cc_reset_rmc.py
4.33
KB
-rw-r--r--
cc_resizefs.py
10.63
KB
-rw-r--r--
cc_resolv_conf.py
3.13
KB
-rw-r--r--
cc_rh_subscription.py
15.21
KB
-rw-r--r--
cc_rsyslog.py
11.55
KB
-rw-r--r--
cc_runcmd.py
1.6
KB
-rw-r--r--
cc_salt_minion.py
3.96
KB
-rw-r--r--
cc_scripts_per_boot.py
1.27
KB
-rw-r--r--
cc_scripts_per_instance.py
1.26
KB
-rw-r--r--
cc_scripts_per_once.py
1.24
KB
-rw-r--r--
cc_scripts_user.py
1.25
KB
-rw-r--r--
cc_scripts_vendor.py
1.26
KB
-rw-r--r--
cc_seed_random.py
3
KB
-rw-r--r--
cc_set_hostname.py
3.4
KB
-rw-r--r--
cc_set_passwords.py
9.36
KB
-rw-r--r--
cc_snap.py
3.32
KB
-rw-r--r--
cc_spacewalk.py
2.64
KB
-rw-r--r--
cc_ssh.py
11
KB
-rw-r--r--
cc_ssh_authkey_fingerprints.py
3.76
KB
-rw-r--r--
cc_ssh_import_id.py
5.43
KB
-rw-r--r--
cc_timezone.py
1.14
KB
-rw-r--r--
cc_ubuntu_autoinstall.py
2.95
KB
-rw-r--r--
cc_ubuntu_drivers.py
4.08
KB
-rw-r--r--
cc_ubuntu_pro.py
13.65
KB
-rw-r--r--
cc_update_etc_hosts.py
2.46
KB
-rw-r--r--
cc_update_hostname.py
2.18
KB
-rw-r--r--
cc_users_groups.py
2.86
KB
-rw-r--r--
cc_wireguard.py
6.67
KB
-rw-r--r--
cc_write_files.py
6
KB
-rw-r--r--
cc_write_files_deferred.py
1.28
KB
-rw-r--r--
cc_yum_add_repo.py
4.53
KB
-rw-r--r--
cc_zypper_add_repo.py
4.93
KB
-rw-r--r--
modules.py
13.23
KB
-rw-r--r--
schema.py
50.26
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : cc_set_passwords.py
# Copyright (C) 2009-2010 Canonical Ltd. # Copyright (C) 2012, 2013 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser <scott.moser@canonical.com> # Author: Juerg Haefliger <juerg.haefliger@hp.com> # # This file is part of cloud-init. See LICENSE file for license information. """Set Passwords: Set user passwords and enable/disable SSH password auth""" import logging import random import re import string from typing import List from cloudinit import features, lifecycle, subp, util from cloudinit.cloud import Cloud from cloudinit.config import Config from cloudinit.config.schema import MetaSchema from cloudinit.distros import ALL_DISTROS, Distro, ug_util from cloudinit.log import log_util from cloudinit.settings import PER_INSTANCE from cloudinit.ssh_util import update_ssh_config meta: MetaSchema = { "id": "cc_set_passwords", "distros": [ALL_DISTROS], "frequency": PER_INSTANCE, "activate_by_schema_keys": [], } LOG = logging.getLogger(__name__) def get_users_by_type(users_list: list, pw_type: str) -> list: """either password or type: RANDOM is required, user is always required""" return ( [] if not users_list else [ (item["name"], item.get("password", "RANDOM")) for item in users_list if item.get("type", "hash") == pw_type ] ) def _restart_ssh_daemon(distro, service): try: distro.manage_service("restart", service) LOG.debug("Restarted the SSH daemon.") except subp.ProcessExecutionError as e: LOG.warning( "'ssh_pwauth' configuration may not be applied. Cloud-init was " "unable to restart SSH daemon due to error: '%s'", e, ) def handle_ssh_pwauth(pw_auth, distro: Distro): """Apply sshd PasswordAuthentication changes. @param pw_auth: config setting from 'pw_auth'. Best given as True, False, or "unchanged". @param distro: an instance of the distro class for the target distribution @return: None""" service = distro.get_option("ssh_svcname", "ssh") cfg_name = "PasswordAuthentication" if isinstance(pw_auth, str): lifecycle.deprecate( deprecated="Using a string value for the 'ssh_pwauth' key", deprecated_version="22.2", extra_message="Use a boolean value with 'ssh_pwauth'.", ) if util.is_true(pw_auth): cfg_val = "yes" elif util.is_false(pw_auth): cfg_val = "no" else: bmsg = f"Leaving SSH config '{cfg_name}' unchanged." if pw_auth is None or pw_auth.lower() == "unchanged": LOG.debug("%s ssh_pwauth=%s", bmsg, pw_auth) else: LOG.warning("%s Unrecognized value: ssh_pwauth=%s", bmsg, pw_auth) return updated = update_ssh_config({cfg_name: cfg_val}) if not updated: LOG.debug("No need to restart SSH service, %s not updated.", cfg_name) return if distro.uses_systemd(): state = subp.subp( [ "systemctl", "show", "--property", "ActiveState", "--value", service, ] ).stdout.strip() if state.lower() in ["active", "activating", "reloading"]: _restart_ssh_daemon(distro, service) else: _restart_ssh_daemon(distro, service) def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: distro: Distro = cloud.distro if args: # if run from command line, and give args, wipe the chpasswd['list'] password = args[0] if "chpasswd" in cfg and "list" in cfg["chpasswd"]: del cfg["chpasswd"]["list"] else: password = util.get_cfg_option_str(cfg, "password", None) expire = True plist: List = [] users_list: List = [] if "chpasswd" in cfg: chfg = cfg["chpasswd"] users_list = util.get_cfg_option_list(chfg, "users", default=[]) if "list" in chfg and chfg["list"]: lifecycle.deprecate( deprecated="Config key 'lists'", deprecated_version="22.3", extra_message="Use 'users' instead.", ) if isinstance(chfg["list"], list): LOG.debug("Handling input for chpasswd as list.") plist = util.get_cfg_option_list(chfg, "list", plist) else: lifecycle.deprecate( deprecated="The chpasswd multiline string", deprecated_version="22.2", extra_message="Use string type instead.", ) LOG.debug("Handling input for chpasswd as multiline string.") multiline = util.get_cfg_option_str(chfg, "list") if multiline: plist = multiline.splitlines() expire = util.get_cfg_option_bool(chfg, "expire", expire) if not (users_list or plist) and password: (users, _groups) = ug_util.normalize_users_groups(cfg, distro) (user, _user_config) = ug_util.extract_default(users) if user: plist = ["%s:%s" % (user, password)] else: LOG.warning("No default or defined user to change password for.") errors = [] if plist or users_list: # This section is for parsing the data that arrives in the form of # chpasswd: # users: plist_in = get_users_by_type(users_list, "text") users = [user for user, _ in plist_in] hashed_plist_in = get_users_by_type(users_list, "hash") hashed_users = [user for user, _ in hashed_plist_in] randlist = [] for user, _ in get_users_by_type(users_list, "RANDOM"): password = rand_user_password() users.append(user) plist_in.append((user, password)) randlist.append(f"{user}:{password}") # This for loop is for parsing the data that arrives in the deprecated # form of # chpasswd: # list: # N.B. This regex is included in the documentation (i.e. the schema # docstring), so any changes to it should be reflected there. prog = re.compile(r"\$(1|2a|2y|5|6)(\$.+){2}") for line in plist: u, p = line.split(":", 1) if prog.match(p) is not None and ":" not in p: hashed_plist_in.append((u, p)) hashed_users.append(u) else: # in this else branch, we potentially change the password # hence, a deviation from .append(line) if p == "R" or p == "RANDOM": p = rand_user_password() randlist.append("%s:%s" % (u, p)) plist_in.append((u, p)) users.append(u) if users: try: LOG.debug("Changing password for %s:", users) distro.chpasswd(plist_in, hashed=False) except Exception as e: errors.append(e) util.logexc( LOG, "Failed to set passwords with chpasswd for %s", users ) if hashed_users: try: LOG.debug("Setting hashed password for %s:", hashed_users) distro.chpasswd(hashed_plist_in, hashed=True) except Exception as e: errors.append(e) util.logexc( LOG, "Failed to set hashed passwords with chpasswd for %s", hashed_users, ) if len(randlist): blurb = ( "Set the following 'random' passwords\n", "\n".join(randlist), ) log_util.multi_log( "%s\n%s\n" % blurb, stderr=False, fallback_to_stdout=False ) if expire: users_to_expire = users if features.EXPIRE_APPLIES_TO_HASHED_USERS: users_to_expire += hashed_users expired_users = [] for u in users_to_expire: try: distro.expire_passwd(u) expired_users.append(u) except Exception as e: errors.append(e) util.logexc(LOG, "Failed to set 'expire' for %s", u) if expired_users: LOG.debug("Expired passwords for: %s users", expired_users) handle_ssh_pwauth(cfg.get("ssh_pwauth"), distro) if len(errors): LOG.debug("%s errors occurred, re-raising the last one", len(errors)) raise errors[-1] def rand_user_password(pwlen=20): if pwlen < 4: raise ValueError("Password length must be at least 4 characters.") # There are often restrictions on the minimum number of character # classes required in a password, so ensure we at least one character # from each class. res_rand_list = [ random.choice(string.digits), random.choice(string.ascii_lowercase), random.choice(string.ascii_uppercase), random.choice(string.punctuation), ] res_rand_list.extend( list( util.rand_str( pwlen - len(res_rand_list), select_from=string.digits + string.ascii_lowercase + string.ascii_uppercase + string.punctuation, ) ) ) random.shuffle(res_rand_list) return "".join(res_rand_list)
Close