T06 · System Persistence
- Location
scripts/auto_bind_user.py:49- Finding
Automatic Installation of Persistent Cron Jobs
- Content
View full analysis
> {log_file} 2>&1" # Check current cron configuration try: current_cron = subprocess.check_output( "crontab -l 2>/dev/null", shell=True ).decode("utf-8") except: current_cron = "" if "daily_health_reminder" in current_cron: print("Scheduled task already exists; skipping") else: new_cron = current_cron.strip() + "\n" + cron_line subprocess.run(f"echo '{new_cron}' | crontab -", shell=True) print("Scheduled task added for 09:00 every day") ``` `scripts/activate_health_skill.sh:68-75`: ```bash CRON_LINE="0 9 * * 1-0 $SCRIPT_PATH >> $LOG_FILE 2>&1" if crontab -l 2>/dev/null | grep -q "daily_health_reminder"; then echo "Scheduled task already exists; skipping" else (crontab -l 2>/dev/null; echo "$CRON_LINE") | crontab - echo "Scheduled task added" fi ``` `scripts/auto_bind_user.py:49-82`: ```python setup_cron = args.setup_cron if not setup_cron: try: cron_list = os.popen("crontab -l 2>/dev/null").read() except: cron_list = "" if "daily_health_reminder" not in cron_list: setup_cron = True if setup_cron: script_path = os.path.join(SCRIPT_DIR, "daily_health_reminder.py") if not os.path.exists(script_path): script_path = os.path.join(SCRIPT_DIR, "daily_health_reminder.sh") if os.path.exists(script_path): log_dir = os.path.join(SKILL_DIR, "logs") os.makedirs(log_dir, exist_ok=True) log_file = os.path.join(log_dir, "health_reminder.log") cron_line = f"0 9 * * * {script_path} >> {log_file} 2>&1" try: current_cron = subprocess.check_output( ...[truncated 2149 chars]- Remediation
View remediation
