The discovery system can find Clawdbot Gateway instances using two methods:
- Shodan API - Search internet-facing instances
- mDNS - Discover instances on local network
npm install
npm run buildCreate a .env file with your Shodan API key:
cp .env.example .env
# Edit .env and add your Shodan API keyGet a free Shodan API key at: https://account.shodan.io/
# Basic search (default limit: 100)
node dist/cli-discover.js --source shodan
# Custom limit
node dist/cli-discover.js --source shodan --limit 20
# Save to file
node dist/cli-discover.js --source shodan --limit 50 --output targets.json# Basic search (default timeout: 30s)
node dist/cli-discover.js --source mdns
# Custom timeout
node dist/cli-discover.js --source mdns --timeout 60
# Save to file
node dist/cli-discover.js --source mdns --output local-targets.json| Option | Description | Default |
|---|---|---|
--source |
Discovery source: shodan or mdns |
shodan |
--limit |
Maximum results from Shodan | 100 |
--timeout |
mDNS discovery timeout (seconds) | 30 |
--output |
Output file path (JSON) | stdout |
[
{
"id": "shodan-192.168.1.100",
"ip": "192.168.1.100",
"port": 18789,
"source": "shodan",
"location": {
"country": "United States",
"city": "New York"
},
"discovered": "2024-01-01T00:00:00.000Z",
"metadata": {
"version": "1.2.3",
"hostname": "gateway-1",
"service": "websocket"
}
}
]- Honeypot IPs: Automatically filters out
178.62.226.116 - Deduplication: Removes duplicate IPs
- Validation: Ensures valid target format
The system tries multiple queries in order:
- Primary:
port:18789 "_clawdbot-gw._tcp" - Secondary:
port:18789 "Clawdbot" - Fallback:
port:18789 websocket
Searches for services with type _clawdbot-gw._tcp.local and parses:
- Hostname and port
- TXT records (version, service info, etc.)
The discovery system outputs JSON that can be consumed by the Protocol Agent for probing:
# Discover targets
node dist/cli-discover.js --source shodan --output targets.json
# Protocol Agent can read targets.json for probing
# (Protocol Agent integration to be implemented)Run the test suite:
npm testTest coverage includes:
- Target list management
- Shodan client (banner parsing, filtering)
- mDNS discovery (output parsing)
- CLI argument parsing
src/discovery/
├── types.ts # TypeScript interfaces
├── targets.ts # Target list management
├── shodan.ts # Shodan API client
└── mdns.ts # mDNS discovery wrapper
src/cli-discover.ts # CLI tool
src/__tests__/
└── discovery/ # Test suites
- Shodan API: Free tier has rate limits (1 request/second, 100 results max)
- mDNS: Only discovers services on local network
- dns-sd: Requires
dns-sdcommand-line tool (comes with macOS/Avahi on Linux)
The system gracefully handles:
- Missing Shodan API key
- Network errors
- Invalid responses
- Timeout conditions
- Add your Shodan API key to
.env - Run discovery to find Clawdbot instances
- Save targets to JSON file
- Pass targets to Protocol Agent for probing