HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //proc/self/root/usr/local/ucloud/reset_account.sh
#!/bin/sh -e

# centos 8.x, rocky 8.5 supports custom python, which is located in "/usr/libexec/platform-python";
# others, include redhat and debian, supports normal python.
if [ -x /usr/libexec/platform-python ]; then
    sys_python=/usr/libexec/platform-python
else
    sys_python=$(which python python3 python2 2>/dev/null | head -n1)
fi

if [ -z "${sys_python}" ]; then
    echo "[WARNING]no available python, change passwd failed."
    exit 1
fi

# send feedback to UCloud first
#curl -s http://100.80.80.80/uhost/feedback -d "reset-account=ok"
${sys_python} - <<EOF
def http_post(url, data):
    try:
        import urllib, urllib2
        body = urllib2.urlopen(url, urllib.urlencode(data)).read()
    except ImportError:
        import urllib.request as request, urllib.parse as parse
        req = request.Request(url, parse.urlencode(data).encode('utf-8'))
        body = request.urlopen(req).read()
    return body.decode('utf-8')

import sys
sys.stdout.write(http_post('http://100.80.80.80/uhost/feedback', {'reset-account': 'ok'}))
EOF

# reset users & passwords & ssh pubkeys
cloud-init single --frequency always --name cc_users_groups
cloud-init single --frequency always --name cc_set_passwords
cloud-init single --frequency always --name cc_ssh

# restart sshd
service sshd restart 2>/dev/null || service ssh restart