# Internal listener

Internal Listener defines the protocol for pivot connections (SMB pipe, TCP). Does not open ports on the server.

### Flow Diagram

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fl3ekQ6qa6COmRjczk390%2FScreenshot_20260120_205625.png?alt=media&#x26;token=7429f64f-04cb-4d77-8158-aa98b8449967" alt=""><figcaption></figcaption></figure>

```
┌──────────────────────────────────────────────────────────────────────────────────┐
│                          INTERNAL LISTENER FLOW                                  │
├──────────────────────────────────────────────────────────────────────────────────┤
│                                                                                  │
│  ╔════════════════════════════════════════════════════════════════════════════╗  │
│  ║                          CREATE INTERNAL LISTENER                          ║  │
│  ╚════════════════════════════════════════════════════════════════════════════╝  │
│                                                                                  │
│  GUI ──> POST /listener/create                                                   │
│                   │                                                              │
│                   V                                                              │
│  ┌─────────────────────────────────────────────────────────────────────────────┐ │
│  │ TEAMSERVER                                                                  │ │
│  │         │                                                                   │ │
│  │         V                                                                   │ │
│  │  TsListenerCreate(listenerType, name, config)                               │ │
│  │         │                                                                   │ │
│  │         V                                                                   │ │
│  │  ┌───────────────────────────────────────────────────────────────────────┐  │ │
│  │  │ EXTENDER                                                              │  │ │
│  │  │         │                                                             │  │ │
│  │  │         V                                                             │  │ │
│  │  │  PluginListener.Create(name, config, customData)                      │  │ │
│  │  │         │                                                             │  │ │
│  │  │         └──> Save configuration (pipename, encrypt_key, etc.)         │  │ │
│  │  │              Does NOT open ports/pipes on the server!                 │  │ │
│  │  │                                                                       │  │ │
│  │  └───────────────────────────────────────────────────────────────────────┘  │ │
│  │                                                                             │ │
│  └─────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                  │
│  ╔════════════════════════════════════════════════════════════════════════════╗  │
│  ║                          PIVOT AGENT CONNECTION                            ║  │
│  ╚════════════════════════════════════════════════════════════════════════════╝  │
│                                                                                  │
│  Child Agent ──> COMMAND_LINK via Parent Agent                                   │
│                   │                                                              │
│                   V                                                              │
│  ┌─────────────────────────────────────────────────────────────────────────────┐ │
│  │ EXTENDER (Agent Plugin)                                                     │ │
│  │         │                                                                   │ │
│  │         V                                                                   │ │
│  │  ExtenderAgent.ProcessData() ──> ProcessTasksResult()                       │ │
│  │         │                                                                   │ │
│  │         V                                                                   │ │
│  │  case COMMAND_LINK:                                                         │ │
│  │         │                                                                   │ │
│  │         ├──> watermark := packer.ParseInt32()                               │ │
│  │         ├──> data := packer.ParseBytes()                                    │ │
│  │         │                                                                   │ │
│  │         V                                                                   │ │
│  │  ┌───────────────────────────────────────────────────────────────────────┐  │ │
│  │  │ TEAMSERVER                                                            │  │ │
│  │  │         │                                                             │  │ │
│  │  │         V                                                             │  │ │
│  │  │  TsListenerInteralHandler(watermark, data)                            │  │ │
│  │  │         │                                                             │  │ │
│  │  │         V                                                             │  │ │
│  │  │  ┌─────────────────────────────────────────────────────────────────┐  │  │ │
│  │  │  │ EXTENDER (Listener Plugin)                                      │  │  │ │
│  │  │  │         │                                                       │  │  │ │
│  │  │  │         V                                                       │  │  │ │
│  │  │  │  ExtenderListener.InternalHandler(data)                         │  │  │ │
│  │  │  │         │                                                       │  │  │ │
│  │  │  │         ├──> parse AgentId and data                             │  │  │ │
│  │  │  │         ├──> TsAgentCreate(...)  ←── Create child agent         │  │  │ │
│  │  │  │         │                                                       │  │  │ │
│  │  │  │         └──> return childAgentId                                │  │  │ │
│  │  │  │                                                                 │  │  │ │
│  │  │  └─────────────────────────────────────────────────────────────────┘  │  │ │
│  │  │         │                                                             │  │ │
│  │  │         V                                                             │  │ │
│  │  │  TsPivotCreate(pivotId, parentAgentId, childAgentId)                  │  │ │
│  │  │                                                                       │  │ │
│  │  └───────────────────────────────────────────────────────────────────────┘  │ │
│  │                                                                             │ │
│  └─────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────┘
```

### Differences from External Listener

<table><thead><tr><th width="192">Aspect</th><th width="273">External Listener</th><th>Internal Listener</th></tr></thead><tbody><tr><td>Opens ports</td><td>Yes (HTTP, DNS)</td><td>No</td></tr><tr><td>Connection</td><td>Agent → Server directly</td><td>Via parent agent</td></tr><tr><td><code>InternalHandler()</code></td><td>Returns empty string</td><td>Creates child agent</td></tr><tr><td>Examples</td><td>HTTP, HTTPS, DNS</td><td>SMB, TCP (pivot)</td></tr></tbody></table>

***
