# Ghost Shadow Discovery (`wonderful_beluga/ghost-shadow-discovery`) Actor

- **URL**: https://apify.com/wonderful\_beluga/ghost-shadow-discovery.md
- **Developed by:** [Zaher el siddik](https://apify.com/wonderful_beluga) (community)
- **Categories:** Automation
- **Stats:** 3 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Ghost-Target: Shadow Discovery

**Actor 1 of 3 in the Ghost-Target Autonomous Red Team Pipeline.**

Performs fully passive external reconnaissance against a target domain. Pulls data from certificate transparency logs, Wayback Machine archives, passive subdomain enumeration, live HTTP probing, GitHub code search, and optional Shodan/Censys enrichment — building a structured "Ghost Inventory" of every asset the target has ever exposed on the internet.

No active scanning. No packets sent to the target. Pure intelligence gathering.

***

### What It Does

#### Phase 1 — Subdomain Enumeration

Queries three independent passive sources in parallel:

| Source | Method | What It Finds |
|---|---|---|
| **crt.sh** | Certificate Transparency logs | Subdomains issued SSL certificates (including wildcards) |
| **Wayback CDX API** | Internet Archive index | Historical subdomains and paths the target ever published |
| **subfinder** | 50+ passive APIs (VirusTotal, Shodan, Chaos, etc.) | Aggregated subdomain intelligence |

#### Phase 2 — GitHub Leak Detection

Searches GitHub for public repositories containing sensitive references to the target domain using 9 dorks:

- Exposed `.env` files with credentials
- `docker-compose.yml` files with passwords
- `.npmrc` files with auth tokens
- API keys, secret keys, access tokens
- PEM certificates

#### Phase 3 — Live HTTP Probing

Probes every discovered subdomain over both HTTP and HTTPS using native Node.js:

- HTTP status codes and redirect chains
- Page titles
- Web server headers (`Server`, `X-Powered-By`)
- Technology fingerprinting (WordPress, Jenkins, Jira, Confluence, GitLab, phpMyAdmin)

#### Phase 4 — Shodan Enrichment (Optional)

If a Shodan API key is provided, resolves each live host's IP and fetches:

- Open ports
- Operating system
- Organization
- Known CVEs (Shodan's own database)

#### Phase 5 — Risk Scoring

Each asset gets a 0–100 risk score:

| Factor | Points |
|---|---|
| Sensitive ports open (22, 3306, 6379, 27017...) | +30 |
| Dev/staging subdomain pattern | +25 |
| Exposed vulnerable stack (WordPress, Jenkins, etc.) | +20–35 |
| GitHub leak reference | +40 |
| Shodan CVEs | +10 per CVE |

#### Phase 6 — Recursive OSINT (Optional)

When `recursiveDepth > 0`, newly discovered high-risk subdomains (riskScore ≥ 30) automatically trigger sub-recon. Useful for discovering deeply nested infrastructure (e.g. `dev.api.internal.example.com`).

***

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `targetDomain` | string | ✅ | — | Root domain to recon. No scheme, no path. e.g. `example.com` |
| `logicEngineActorId` | string | — | — | Actor ID of Actor 2 to auto-trigger on completion |
| `globalKvsName` | string | — | `ghost-target-brain` | Shared Key-Value Store name. Must match across all three actors |
| `waybackLimit` | integer | — | `5000` | Max URLs to pull from Wayback CDX per domain |
| `recursiveDepth` | integer | — | `1` | Recursive sub-recon depth (0 = disabled, max 3) |
| `githubToken` | string | — | — | GitHub personal access token for leak detection |
| `shodanApiKey` | string | — | — | Shodan API key for port and CVE enrichment |
| `censysApiId` | string | — | — | Censys API ID (reserved for future use) |
| `censysApiSecret` | string | — | — | Censys API secret |
| `apifyApiToken` | string | — | — | Your Apify API token. Required for cross-actor KVS sharing when triggered by another actor |
| `proxyEnabled` | boolean | — | `false` | Route requests through Apify residential proxies |

> **Tip:** When running Actor 1 manually and chaining to Actor 2, pass your `apifyApiToken` so that downstream actors can access the shared KVS.

***

### Output

#### Dataset

One row per discovered subdomain:

```json
{
  "subdomain": "dev.example.com",
  "isLive": true,
  "ip": "1.2.3.4",
  "sources": ["crt.sh", "wayback", "subfinder"],
  "statusCode": 200,
  "title": "Dev Portal - Example Inc",
  "webServer": "nginx/1.18.0",
  "technologies": ["nginx/1.18.0", "PHP/7.4"],
  "openPorts": [22, 80, 443, 3306],
  "shodanVulns": ["CVE-2021-44228"],
  "org": "Example Inc",
  "highValuePaths": ["/.env", "/admin"],
  "isNew": true,
  "firstSeen": "2026-05-15T09:44:56.000Z",
  "lastSeen": "2026-05-15T09:44:56.000Z",
  "riskScore": 85
}
```

#### Key-Value Store (`ghost-target-brain`)

Saves the full brain state to `surface__{domain}`:

```json
{
  "domain": "example.com",
  "subdomains": { "dev.example.com": { "firstSeen": "...", "riskScore": 85 } },
  "waybackPaths": ["/.env", "/admin/login", "/api/v2/users"],
  "githubLeaks": [{ "repo": "user/leaked-repo", "file": ".env", "url": "..." }],
  "lastRunSummary": {
    "totalSubdomains": 47,
    "newAssets": 3,
    "liveAssets": 31,
    "highRiskAssets": 5
  },
  "runCount": 2
}
```

#### Actor Output (`OUTPUT`)

```json
{
  "domain": "example.com",
  "totalSubdomains": 47,
  "newAssets": 3,
  "liveAssets": 31,
  "highRiskAssets": 5,
  "githubLeakRefs": 2,
  "waybackPathsIndexed": 4821,
  "kvsKey": "surface__example.com"
}
```

***

### Automatic Pipeline Chaining

When `logicEngineActorId` is set, this actor automatically triggers **Actor 2 (Logic Engine)** via the Apify API as soon as it completes — passing the `targetDomain`, `globalKvsName`, and `apifyApiToken` so the scan continues without manual intervention.

```
Actor 1 finishes → webhook → Actor 2 starts → webhook → Actor 3 starts
```

***

### Prerequisites

This actor uses two Go binaries bundled in the Docker image:

- **[subfinder v2.6.6](https://github.com/projectdiscovery/subfinder)** — passive subdomain enumeration
- **[httpx v1.6.10](https://github.com/projectdiscovery/httpx)** — HTTP probing and tech fingerprinting

Both are downloaded as pre-built binaries at Docker build time — no Go compiler needed at runtime.

***

### Usage Example

#### Standalone run

```json
{
  "targetDomain": "example.com",
  "waybackLimit": 5000,
  "recursiveDepth": 1,
  "githubToken": "ghp_xxxxxxxxxxxx",
  "shodanApiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "globalKvsName": "ghost-target-brain"
}
```

#### With full pipeline chaining

```json
{
  "targetDomain": "example.com",
  "logicEngineActorId": "YOUR_USERNAME/ghost-logic-engine",
  "globalKvsName": "ghost-target-brain",
  "apifyApiToken": "apify_api_xxxxxxxxxxxxxxxxxxxxxxxx",
  "githubToken": "ghp_xxxxxxxxxxxx",
  "shodanApiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
```

***

### Safe Test Targets

| Domain | Why |
|---|---|
| `demo.testfire.net` | IBM Altoro Mutual — intentional vuln demo bank |
| `testphp.vulnweb.com` | Acunetix intentional vuln PHP app |
| `juice-shop.herokuapp.com` | OWASP Juice Shop |
| Your own domain | Best for real results |

***

### Legal Notice

This tool is for **authorized penetration testing and security research only**. Always obtain written permission before running reconnaissance against any domain. Unauthorized use may violate computer fraud and abuse laws in your jurisdiction.

# Actor input Schema

## `targetDomain` (type: `string`):

Root domain to recon (e.g. example.com). No scheme or path.

## `shodanApiKey` (type: `string`):

Optional. Shodan API key to enrich IP/port data.

## `censysApiId` (type: `string`):

Optional. Censys API ID for certificate search.

## `censysApiSecret` (type: `string`):

Optional. Censys API secret.

## `githubToken` (type: `string`):

Optional. Used to search GitHub for leaked credentials and mentions of the domain.

## `waybackLimit` (type: `integer`):

Max URLs to pull from Wayback Machine CDX API per domain.

## `recursiveDepth` (type: `integer`):

When new subdomains are found, re-run recon on them up to this depth.

## `logicEngineActorId` (type: `string`):

Actor ID of Actor 2 (ghost-logic-engine) to trigger via webhook on completion.

## `globalKvsName` (type: `string`):

Name of the shared Key-Value Store acting as the pipeline brain.

## `proxyEnabled` (type: `boolean`):

Route requests through Apify residential proxies to avoid rate-limiting.

## Actor input object example

```json
{
  "targetDomain": "example.com",
  "waybackLimit": 5000,
  "recursiveDepth": 1,
  "globalKvsName": "ghost-target-brain",
  "proxyEnabled": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "targetDomain": "example.com",
    "waybackLimit": 5000,
    "recursiveDepth": 1,
    "globalKvsName": "ghost-target-brain"
};

// Run the Actor and wait for it to finish
const run = await client.actor("wonderful_beluga/ghost-shadow-discovery").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "targetDomain": "example.com",
    "waybackLimit": 5000,
    "recursiveDepth": 1,
    "globalKvsName": "ghost-target-brain",
}

# Run the Actor and wait for it to finish
run = client.actor("wonderful_beluga/ghost-shadow-discovery").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "targetDomain": "example.com",
  "waybackLimit": 5000,
  "recursiveDepth": 1,
  "globalKvsName": "ghost-target-brain"
}' |
apify call wonderful_beluga/ghost-shadow-discovery --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wonderful_beluga/ghost-shadow-discovery"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/0zgNLrH21sQTbAoUj/builds/ryAdS0qnnYGFhSCGL/openapi.json
