mobilecoder-mcp 2.0.1 → 2.1.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/dist/agent.d.ts +12 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +121 -24
- package/dist/agent.js.map +1 -1
- package/package.json +1 -1
- package/src/agent.ts +151 -25
package/dist/agent.d.ts
CHANGED
|
@@ -3,16 +3,27 @@ export declare class ZKRelayAgent {
|
|
|
3
3
|
private ptyProcess;
|
|
4
4
|
private secretCode;
|
|
5
5
|
private roomId;
|
|
6
|
-
private
|
|
6
|
+
private masterKey;
|
|
7
|
+
private sessionKey;
|
|
8
|
+
private sessionCounter;
|
|
9
|
+
private seenNonces;
|
|
10
|
+
private nonceCleanupInterval;
|
|
11
|
+
private keyRotationInterval;
|
|
7
12
|
private spinner;
|
|
8
13
|
constructor();
|
|
9
14
|
private setupSecurity;
|
|
15
|
+
private deriveSessionKey;
|
|
16
|
+
private rotateKey;
|
|
17
|
+
private startSecurityMaintenance;
|
|
10
18
|
private initPTY;
|
|
11
19
|
private connectToRelay;
|
|
20
|
+
private encrypt;
|
|
21
|
+
private decrypt;
|
|
12
22
|
private handleIncomingMessage;
|
|
13
23
|
private handleToolCall;
|
|
14
24
|
private sendSecurePayload;
|
|
15
25
|
private sendEnvInfo;
|
|
16
26
|
private printBanner;
|
|
27
|
+
destroy(): void;
|
|
17
28
|
}
|
|
18
29
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAoBA,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAS;IAGvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,oBAAoB,CAA+B;IAC3D,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,OAAO,CAAC,OAAO,CAAwC;;IAUvD,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,cAAc;IAwCtB,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,OAAO;IAyBf,OAAO,CAAC,qBAAqB;YAyEf,cAAc;IAyC5B,OAAO,CAAC,iBAAiB;IAqCzB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,WAAW;IAeZ,OAAO;CAMjB"}
|
package/dist/agent.js
CHANGED
|
@@ -1,34 +1,72 @@
|
|
|
1
1
|
import { io } from 'socket.io-client';
|
|
2
2
|
import * as os from 'os';
|
|
3
3
|
import * as pty from 'node-pty';
|
|
4
|
-
import
|
|
4
|
+
import * as crypto from 'crypto';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import ora from 'ora';
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
// 🚨 BURAYI KENDİ DOMAIN ADRESİNLE DEĞİŞTİR!
|
|
10
10
|
const RELAY_SERVER_URL = 'https://api.mobilecoder.xyz';
|
|
11
|
+
// Security Constants
|
|
12
|
+
const PBKDF2_ITERATIONS = 100000;
|
|
13
|
+
const KEY_LENGTH = 32; // 256 bits
|
|
14
|
+
const SALT = 'mobilecoder-salt-v2';
|
|
15
|
+
const KEY_ROTATION_INTERVAL = 600000; // 10 minutes
|
|
16
|
+
const MESSAGE_MAX_AGE = 300000; // 5 minutes
|
|
11
17
|
export class ZKRelayAgent {
|
|
12
18
|
socket;
|
|
13
19
|
ptyProcess;
|
|
14
20
|
secretCode;
|
|
15
21
|
roomId;
|
|
16
|
-
|
|
22
|
+
// 🔐 Güçlendirilmiş Güvenlik Değişkenleri
|
|
23
|
+
masterKey;
|
|
24
|
+
sessionKey;
|
|
25
|
+
sessionCounter = 0;
|
|
26
|
+
seenNonces = new Set();
|
|
27
|
+
nonceCleanupInterval = null;
|
|
28
|
+
keyRotationInterval = null;
|
|
17
29
|
spinner = ora('Initializing Secure Tunnel...');
|
|
18
30
|
constructor() {
|
|
19
31
|
this.setupSecurity();
|
|
20
32
|
this.initPTY();
|
|
21
33
|
this.connectToRelay();
|
|
34
|
+
this.startSecurityMaintenance();
|
|
22
35
|
}
|
|
23
|
-
// 1. Güvenlik Katmanı:
|
|
36
|
+
// 1. Güvenlik Katmanı: PBKDF2 ile Güçlendirilmiş Anahtar Türetme
|
|
24
37
|
setupSecurity() {
|
|
25
38
|
// 6 Haneli rastgele kod (Kullanıcının göreceği)
|
|
26
39
|
const randomNum = Math.floor(100000 + Math.random() * 900000);
|
|
27
40
|
this.secretCode = randomNum.toString();
|
|
28
41
|
// Oda ID'si: Kodun Hash'i (Sunucu sadece bunu görür, kodu göremez)
|
|
29
|
-
this.roomId =
|
|
30
|
-
//
|
|
31
|
-
this.
|
|
42
|
+
this.roomId = crypto.createHash('sha256').update(this.secretCode).digest('hex');
|
|
43
|
+
// 🔐 PBKDF2 ile Master Key Türetme (Brute-force'a karşı savunma)
|
|
44
|
+
this.masterKey = crypto.pbkdf2Sync(this.secretCode, SALT, PBKDF2_ITERATIONS, KEY_LENGTH, 'sha256');
|
|
45
|
+
// Session Key (PFS için rotasyonlu)
|
|
46
|
+
this.sessionKey = this.deriveSessionKey(0);
|
|
47
|
+
}
|
|
48
|
+
// 🔐 Session Key Türetme (Perfect Forward Secrecy)
|
|
49
|
+
deriveSessionKey(counter) {
|
|
50
|
+
return crypto.pbkdf2Sync(this.masterKey, `session-${counter}`, 10000, KEY_LENGTH, 'sha256');
|
|
51
|
+
}
|
|
52
|
+
// 🔄 Key Rotation (Her 10 dakikada bir)
|
|
53
|
+
rotateKey() {
|
|
54
|
+
this.sessionCounter++;
|
|
55
|
+
this.sessionKey = this.deriveSessionKey(this.sessionCounter);
|
|
56
|
+
console.log(chalk.cyan(`🔄 Session key rotated to #${this.sessionCounter}`));
|
|
57
|
+
// Notify peer about key rotation
|
|
58
|
+
this.sendSecurePayload('key_rotation', { counter: this.sessionCounter });
|
|
59
|
+
}
|
|
60
|
+
// 🧹 Güvenlik Bakımı
|
|
61
|
+
startSecurityMaintenance() {
|
|
62
|
+
// Nonce temizliği (5 dakikadan eski nonce'ları sil)
|
|
63
|
+
this.nonceCleanupInterval = setInterval(() => {
|
|
64
|
+
this.seenNonces.clear();
|
|
65
|
+
}, MESSAGE_MAX_AGE);
|
|
66
|
+
// Key rotation
|
|
67
|
+
this.keyRotationInterval = setInterval(() => {
|
|
68
|
+
this.rotateKey();
|
|
69
|
+
}, KEY_ROTATION_INTERVAL);
|
|
32
70
|
}
|
|
33
71
|
// 2. Terminal (PTY) Başlatma
|
|
34
72
|
initPTY() {
|
|
@@ -76,21 +114,67 @@ export class ZKRelayAgent {
|
|
|
76
114
|
// console.error(err);
|
|
77
115
|
});
|
|
78
116
|
}
|
|
117
|
+
// 🔐 AES-256-CBC ile Şifreleme (Nonce tabanlı)
|
|
118
|
+
encrypt(data) {
|
|
119
|
+
const nonce = crypto.randomBytes(16);
|
|
120
|
+
const cipher = crypto.createCipheriv('aes-256-cbc', this.sessionKey, nonce);
|
|
121
|
+
const encrypted = Buffer.concat([
|
|
122
|
+
cipher.update(data, 'utf8'),
|
|
123
|
+
cipher.final()
|
|
124
|
+
]);
|
|
125
|
+
return {
|
|
126
|
+
nonce: nonce.toString('base64'),
|
|
127
|
+
data: encrypted.toString('base64'),
|
|
128
|
+
timestamp: Date.now()
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// 🔐 AES-256-CBC ile Şifre Çözme (Replay Attack Korumalı)
|
|
132
|
+
decrypt(packet) {
|
|
133
|
+
// Timestamp kontrolü (5 dakikadan eski mesajları reddet)
|
|
134
|
+
if (Date.now() - packet.timestamp > MESSAGE_MAX_AGE) {
|
|
135
|
+
throw new Error('Message too old - potential replay attack');
|
|
136
|
+
}
|
|
137
|
+
// Nonce uniqueness kontrolü (Replay attack önleme)
|
|
138
|
+
if (this.seenNonces.has(packet.nonce)) {
|
|
139
|
+
throw new Error('Replay attack detected - duplicate nonce');
|
|
140
|
+
}
|
|
141
|
+
this.seenNonces.add(packet.nonce);
|
|
142
|
+
const decipher = crypto.createDecipheriv('aes-256-cbc', this.sessionKey, Buffer.from(packet.nonce, 'base64'));
|
|
143
|
+
return Buffer.concat([
|
|
144
|
+
decipher.update(Buffer.from(packet.data, 'base64')),
|
|
145
|
+
decipher.final()
|
|
146
|
+
]).toString('utf8');
|
|
147
|
+
}
|
|
79
148
|
// Gelen veriyi çöz ve işle
|
|
80
149
|
handleIncomingMessage(encryptedPayload) {
|
|
81
150
|
try {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (typeof encryptedPayload === 'object' && encryptedPayload.
|
|
85
|
-
|
|
151
|
+
let decryptedText;
|
|
152
|
+
// Yeni format: { nonce, data, timestamp }
|
|
153
|
+
if (typeof encryptedPayload === 'object' && encryptedPayload.nonce) {
|
|
154
|
+
decryptedText = this.decrypt(encryptedPayload);
|
|
86
155
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
156
|
+
// Legacy format: { e: ciphertext } (CryptoJS uyumluluğu)
|
|
157
|
+
else if (typeof encryptedPayload === 'object' && encryptedPayload.e) {
|
|
158
|
+
// Legacy CryptoJS decrypt fallback
|
|
159
|
+
const CryptoJS = require('crypto-js');
|
|
160
|
+
const bytes = CryptoJS.AES.decrypt(encryptedPayload.e, this.secretCode);
|
|
161
|
+
decryptedText = bytes.toString(CryptoJS.enc.Utf8);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!decryptedText)
|
|
90
167
|
return;
|
|
91
168
|
// Veri JSON mu? (Resize komutu vs olabilir)
|
|
92
169
|
try {
|
|
93
|
-
const cmd = JSON.parse(
|
|
170
|
+
const cmd = JSON.parse(decryptedText);
|
|
171
|
+
// Handle key rotation from peer
|
|
172
|
+
if (cmd.type === 'key_rotation') {
|
|
173
|
+
this.sessionCounter = cmd.counter;
|
|
174
|
+
this.sessionKey = this.deriveSessionKey(this.sessionCounter);
|
|
175
|
+
console.log(chalk.cyan(`🔄 Key synced to session #${this.sessionCounter}`));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
94
178
|
// 1. Terminal Input (Keystrokes)
|
|
95
179
|
if (cmd.type === 'input') {
|
|
96
180
|
this.ptyProcess.write(cmd.data);
|
|
@@ -119,11 +203,12 @@ export class ZKRelayAgent {
|
|
|
119
203
|
}
|
|
120
204
|
catch (e) {
|
|
121
205
|
// JSON değilse saf terminal girdisidir
|
|
122
|
-
this.ptyProcess.write(
|
|
206
|
+
this.ptyProcess.write(decryptedText);
|
|
123
207
|
}
|
|
124
208
|
}
|
|
125
209
|
catch (error) {
|
|
126
210
|
// Şifre çözülemezse (Yanlış anahtar vb.) sessizce yut
|
|
211
|
+
console.error(chalk.red('Decryption failed:'), error.message);
|
|
127
212
|
}
|
|
128
213
|
}
|
|
129
214
|
async handleToolCall(tool, args, id) {
|
|
@@ -163,13 +248,9 @@ export class ZKRelayAgent {
|
|
|
163
248
|
// Veriyi şifrele ve gönder
|
|
164
249
|
sendSecurePayload(type, data) {
|
|
165
250
|
let payloadStr = '';
|
|
166
|
-
if (type === 'meta' || type === 'tool_result') {
|
|
251
|
+
if (type === 'meta' || type === 'tool_result' || type === 'key_rotation') {
|
|
167
252
|
// Standardize format
|
|
168
|
-
// For tool_result, data already contains id/result/error
|
|
169
|
-
// We wrap it in the top level object structure expected by client
|
|
170
|
-
// Client expects: { type: 'result', id: ..., result: ... } OR { type: 'error', id: ..., error: ... }
|
|
171
253
|
if (type === 'tool_result') {
|
|
172
|
-
// data is { id, result } or { id, error, type: 'error' }
|
|
173
254
|
if (data.type === 'error') {
|
|
174
255
|
payloadStr = JSON.stringify({ ...data });
|
|
175
256
|
}
|
|
@@ -177,6 +258,9 @@ export class ZKRelayAgent {
|
|
|
177
258
|
payloadStr = JSON.stringify({ type: 'result', ...data });
|
|
178
259
|
}
|
|
179
260
|
}
|
|
261
|
+
else if (type === 'key_rotation') {
|
|
262
|
+
payloadStr = JSON.stringify({ type: 'key_rotation', ...data });
|
|
263
|
+
}
|
|
180
264
|
else {
|
|
181
265
|
payloadStr = JSON.stringify(data);
|
|
182
266
|
}
|
|
@@ -193,10 +277,11 @@ export class ZKRelayAgent {
|
|
|
193
277
|
// Fallback if empty (shouldn't happen with above logic)
|
|
194
278
|
if (!payloadStr)
|
|
195
279
|
payloadStr = JSON.stringify(data);
|
|
196
|
-
|
|
280
|
+
// 🔐 Yeni şifreleme formatı ile gönder
|
|
281
|
+
const encrypted = this.encrypt(payloadStr);
|
|
197
282
|
this.socket.emit('relay_data', {
|
|
198
283
|
room: this.roomId,
|
|
199
|
-
payload:
|
|
284
|
+
payload: encrypted
|
|
200
285
|
});
|
|
201
286
|
}
|
|
202
287
|
sendEnvInfo() {
|
|
@@ -210,8 +295,9 @@ export class ZKRelayAgent {
|
|
|
210
295
|
this.sendSecurePayload('meta', info);
|
|
211
296
|
}
|
|
212
297
|
printBanner() {
|
|
213
|
-
console.log('\n' + chalk.bgBlue.bold(' MOBILECODER ZK-RELAY v2.0
|
|
214
|
-
console.log(chalk.gray('
|
|
298
|
+
console.log('\n' + chalk.bgBlue.bold(' MOBILECODER ZK-RELAY v2.1.0 '));
|
|
299
|
+
console.log(chalk.gray('🔐 PBKDF2-SHA256 + AES-256-CBC + Nonce-Based Replay Protection'));
|
|
300
|
+
console.log(chalk.gray('🔄 Perfect Forward Secrecy with 10-min Key Rotation\n'));
|
|
215
301
|
console.log(chalk.yellow('┌──────────────────────────────────────┐'));
|
|
216
302
|
console.log(chalk.yellow('│ 🔑 CONNECTION CODE (ENTER ON APP) │'));
|
|
217
303
|
console.log(chalk.yellow('│ │'));
|
|
@@ -220,5 +306,16 @@ export class ZKRelayAgent {
|
|
|
220
306
|
console.log(chalk.yellow('└──────────────────────────────────────┘'));
|
|
221
307
|
console.log(chalk.cyan('\nWaiting for mobile connection...'));
|
|
222
308
|
}
|
|
309
|
+
// Cleanup
|
|
310
|
+
destroy() {
|
|
311
|
+
if (this.nonceCleanupInterval)
|
|
312
|
+
clearInterval(this.nonceCleanupInterval);
|
|
313
|
+
if (this.keyRotationInterval)
|
|
314
|
+
clearInterval(this.keyRotationInterval);
|
|
315
|
+
if (this.socket)
|
|
316
|
+
this.socket.disconnect();
|
|
317
|
+
if (this.ptyProcess)
|
|
318
|
+
this.ptyProcess.kill();
|
|
319
|
+
}
|
|
223
320
|
}
|
|
224
321
|
//# sourceMappingURL=agent.js.map
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAU,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,6CAA6C;AAC7C,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAEvD,MAAM,OAAO,YAAY;IACb,MAAM,CAAS;IACf,UAAU,CAAM;IAChB,UAAU,CAAS;IACnB,MAAM,CAAS;IACf,a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0C,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,UAAU;IACH,OAAO;QACV,IAAI,IAAI,CAAC,oBAAoB;YAAE,aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,mBAAmB;YAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACtE,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;CACJ"}
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { io, Socket } from 'socket.io-client';
|
|
3
3
|
import * as os from 'os';
|
|
4
4
|
import * as pty from 'node-pty';
|
|
5
|
-
import
|
|
5
|
+
import * as crypto from 'crypto';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import ora from 'ora';
|
|
8
8
|
import * as fs from 'fs';
|
|
@@ -11,31 +11,90 @@ import * as path from 'path';
|
|
|
11
11
|
// 🚨 BURAYI KENDİ DOMAIN ADRESİNLE DEĞİŞTİR!
|
|
12
12
|
const RELAY_SERVER_URL = 'https://api.mobilecoder.xyz';
|
|
13
13
|
|
|
14
|
+
// Security Constants
|
|
15
|
+
const PBKDF2_ITERATIONS = 100000;
|
|
16
|
+
const KEY_LENGTH = 32; // 256 bits
|
|
17
|
+
const SALT = 'mobilecoder-salt-v2';
|
|
18
|
+
const KEY_ROTATION_INTERVAL = 600000; // 10 minutes
|
|
19
|
+
const MESSAGE_MAX_AGE = 300000; // 5 minutes
|
|
20
|
+
|
|
14
21
|
export class ZKRelayAgent {
|
|
15
22
|
private socket: Socket;
|
|
16
23
|
private ptyProcess: any;
|
|
17
24
|
private secretCode: string;
|
|
18
25
|
private roomId: string;
|
|
19
|
-
|
|
26
|
+
|
|
27
|
+
// 🔐 Güçlendirilmiş Güvenlik Değişkenleri
|
|
28
|
+
private masterKey: Buffer;
|
|
29
|
+
private sessionKey: Buffer;
|
|
30
|
+
private sessionCounter: number = 0;
|
|
31
|
+
private seenNonces: Set<string> = new Set();
|
|
32
|
+
private nonceCleanupInterval: NodeJS.Timeout | null = null;
|
|
33
|
+
private keyRotationInterval: NodeJS.Timeout | null = null;
|
|
34
|
+
|
|
20
35
|
private spinner = ora('Initializing Secure Tunnel...');
|
|
21
36
|
|
|
22
37
|
constructor() {
|
|
23
38
|
this.setupSecurity();
|
|
24
39
|
this.initPTY();
|
|
25
40
|
this.connectToRelay();
|
|
41
|
+
this.startSecurityMaintenance();
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
// 1. Güvenlik Katmanı:
|
|
44
|
+
// 1. Güvenlik Katmanı: PBKDF2 ile Güçlendirilmiş Anahtar Türetme
|
|
29
45
|
private setupSecurity() {
|
|
30
46
|
// 6 Haneli rastgele kod (Kullanıcının göreceği)
|
|
31
47
|
const randomNum = Math.floor(100000 + Math.random() * 900000);
|
|
32
48
|
this.secretCode = randomNum.toString();
|
|
33
49
|
|
|
34
50
|
// Oda ID'si: Kodun Hash'i (Sunucu sadece bunu görür, kodu göremez)
|
|
35
|
-
this.roomId =
|
|
51
|
+
this.roomId = crypto.createHash('sha256').update(this.secretCode).digest('hex');
|
|
52
|
+
|
|
53
|
+
// 🔐 PBKDF2 ile Master Key Türetme (Brute-force'a karşı savunma)
|
|
54
|
+
this.masterKey = crypto.pbkdf2Sync(
|
|
55
|
+
this.secretCode,
|
|
56
|
+
SALT,
|
|
57
|
+
PBKDF2_ITERATIONS,
|
|
58
|
+
KEY_LENGTH,
|
|
59
|
+
'sha256'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Session Key (PFS için rotasyonlu)
|
|
63
|
+
this.sessionKey = this.deriveSessionKey(0);
|
|
64
|
+
}
|
|
36
65
|
|
|
37
|
-
|
|
38
|
-
|
|
66
|
+
// 🔐 Session Key Türetme (Perfect Forward Secrecy)
|
|
67
|
+
private deriveSessionKey(counter: number): Buffer {
|
|
68
|
+
return crypto.pbkdf2Sync(
|
|
69
|
+
this.masterKey,
|
|
70
|
+
`session-${counter}`,
|
|
71
|
+
10000,
|
|
72
|
+
KEY_LENGTH,
|
|
73
|
+
'sha256'
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 🔄 Key Rotation (Her 10 dakikada bir)
|
|
78
|
+
private rotateKey() {
|
|
79
|
+
this.sessionCounter++;
|
|
80
|
+
this.sessionKey = this.deriveSessionKey(this.sessionCounter);
|
|
81
|
+
console.log(chalk.cyan(`🔄 Session key rotated to #${this.sessionCounter}`));
|
|
82
|
+
|
|
83
|
+
// Notify peer about key rotation
|
|
84
|
+
this.sendSecurePayload('key_rotation', { counter: this.sessionCounter });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 🧹 Güvenlik Bakımı
|
|
88
|
+
private startSecurityMaintenance() {
|
|
89
|
+
// Nonce temizliği (5 dakikadan eski nonce'ları sil)
|
|
90
|
+
this.nonceCleanupInterval = setInterval(() => {
|
|
91
|
+
this.seenNonces.clear();
|
|
92
|
+
}, MESSAGE_MAX_AGE);
|
|
93
|
+
|
|
94
|
+
// Key rotation
|
|
95
|
+
this.keyRotationInterval = setInterval(() => {
|
|
96
|
+
this.rotateKey();
|
|
97
|
+
}, KEY_ROTATION_INTERVAL);
|
|
39
98
|
}
|
|
40
99
|
|
|
41
100
|
// 2. Terminal (PTY) Başlatma
|
|
@@ -96,23 +155,81 @@ export class ZKRelayAgent {
|
|
|
96
155
|
});
|
|
97
156
|
}
|
|
98
157
|
|
|
158
|
+
// 🔐 AES-256-CBC ile Şifreleme (Nonce tabanlı)
|
|
159
|
+
private encrypt(data: string): { nonce: string; data: string; timestamp: number } {
|
|
160
|
+
const nonce = crypto.randomBytes(16);
|
|
161
|
+
const cipher = crypto.createCipheriv('aes-256-cbc', this.sessionKey, nonce);
|
|
162
|
+
|
|
163
|
+
const encrypted = Buffer.concat([
|
|
164
|
+
cipher.update(data, 'utf8'),
|
|
165
|
+
cipher.final()
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
nonce: nonce.toString('base64'),
|
|
170
|
+
data: encrypted.toString('base64'),
|
|
171
|
+
timestamp: Date.now()
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 🔐 AES-256-CBC ile Şifre Çözme (Replay Attack Korumalı)
|
|
176
|
+
private decrypt(packet: { nonce: string; data: string; timestamp: number }): string {
|
|
177
|
+
// Timestamp kontrolü (5 dakikadan eski mesajları reddet)
|
|
178
|
+
if (Date.now() - packet.timestamp > MESSAGE_MAX_AGE) {
|
|
179
|
+
throw new Error('Message too old - potential replay attack');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Nonce uniqueness kontrolü (Replay attack önleme)
|
|
183
|
+
if (this.seenNonces.has(packet.nonce)) {
|
|
184
|
+
throw new Error('Replay attack detected - duplicate nonce');
|
|
185
|
+
}
|
|
186
|
+
this.seenNonces.add(packet.nonce);
|
|
187
|
+
|
|
188
|
+
const decipher = crypto.createDecipheriv(
|
|
189
|
+
'aes-256-cbc',
|
|
190
|
+
this.sessionKey,
|
|
191
|
+
Buffer.from(packet.nonce, 'base64')
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
return Buffer.concat([
|
|
195
|
+
decipher.update(Buffer.from(packet.data, 'base64')),
|
|
196
|
+
decipher.final()
|
|
197
|
+
]).toString('utf8');
|
|
198
|
+
}
|
|
199
|
+
|
|
99
200
|
// Gelen veriyi çöz ve işle
|
|
100
201
|
private handleIncomingMessage(encryptedPayload: any) {
|
|
101
202
|
try {
|
|
102
|
-
|
|
103
|
-
let ciphertext = encryptedPayload;
|
|
104
|
-
if (typeof encryptedPayload === 'object' && encryptedPayload.e) {
|
|
105
|
-
ciphertext = encryptedPayload.e;
|
|
106
|
-
}
|
|
203
|
+
let decryptedText: string;
|
|
107
204
|
|
|
108
|
-
|
|
109
|
-
|
|
205
|
+
// Yeni format: { nonce, data, timestamp }
|
|
206
|
+
if (typeof encryptedPayload === 'object' && encryptedPayload.nonce) {
|
|
207
|
+
decryptedText = this.decrypt(encryptedPayload);
|
|
208
|
+
}
|
|
209
|
+
// Legacy format: { e: ciphertext } (CryptoJS uyumluluğu)
|
|
210
|
+
else if (typeof encryptedPayload === 'object' && encryptedPayload.e) {
|
|
211
|
+
// Legacy CryptoJS decrypt fallback
|
|
212
|
+
const CryptoJS = require('crypto-js');
|
|
213
|
+
const bytes = CryptoJS.AES.decrypt(encryptedPayload.e, this.secretCode);
|
|
214
|
+
decryptedText = bytes.toString(CryptoJS.enc.Utf8);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
110
219
|
|
|
111
|
-
if (!
|
|
220
|
+
if (!decryptedText) return;
|
|
112
221
|
|
|
113
222
|
// Veri JSON mu? (Resize komutu vs olabilir)
|
|
114
223
|
try {
|
|
115
|
-
const cmd = JSON.parse(
|
|
224
|
+
const cmd = JSON.parse(decryptedText);
|
|
225
|
+
|
|
226
|
+
// Handle key rotation from peer
|
|
227
|
+
if (cmd.type === 'key_rotation') {
|
|
228
|
+
this.sessionCounter = cmd.counter;
|
|
229
|
+
this.sessionKey = this.deriveSessionKey(this.sessionCounter);
|
|
230
|
+
console.log(chalk.cyan(`🔄 Key synced to session #${this.sessionCounter}`));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
116
233
|
|
|
117
234
|
// 1. Terminal Input (Keystrokes)
|
|
118
235
|
if (cmd.type === 'input') {
|
|
@@ -146,10 +263,11 @@ export class ZKRelayAgent {
|
|
|
146
263
|
|
|
147
264
|
} catch (e) {
|
|
148
265
|
// JSON değilse saf terminal girdisidir
|
|
149
|
-
this.ptyProcess.write(
|
|
266
|
+
this.ptyProcess.write(decryptedText);
|
|
150
267
|
}
|
|
151
268
|
} catch (error) {
|
|
152
269
|
// Şifre çözülemezse (Yanlış anahtar vb.) sessizce yut
|
|
270
|
+
console.error(chalk.red('Decryption failed:'), (error as Error).message);
|
|
153
271
|
}
|
|
154
272
|
}
|
|
155
273
|
|
|
@@ -197,18 +315,16 @@ export class ZKRelayAgent {
|
|
|
197
315
|
private sendSecurePayload(type: string, data: any) {
|
|
198
316
|
let payloadStr = '';
|
|
199
317
|
|
|
200
|
-
if (type === 'meta' || type === 'tool_result') {
|
|
318
|
+
if (type === 'meta' || type === 'tool_result' || type === 'key_rotation') {
|
|
201
319
|
// Standardize format
|
|
202
|
-
// For tool_result, data already contains id/result/error
|
|
203
|
-
// We wrap it in the top level object structure expected by client
|
|
204
|
-
// Client expects: { type: 'result', id: ..., result: ... } OR { type: 'error', id: ..., error: ... }
|
|
205
320
|
if (type === 'tool_result') {
|
|
206
|
-
// data is { id, result } or { id, error, type: 'error' }
|
|
207
321
|
if (data.type === 'error') {
|
|
208
322
|
payloadStr = JSON.stringify({ ...data });
|
|
209
323
|
} else {
|
|
210
324
|
payloadStr = JSON.stringify({ type: 'result', ...data });
|
|
211
325
|
}
|
|
326
|
+
} else if (type === 'key_rotation') {
|
|
327
|
+
payloadStr = JSON.stringify({ type: 'key_rotation', ...data });
|
|
212
328
|
} else {
|
|
213
329
|
payloadStr = JSON.stringify(data);
|
|
214
330
|
}
|
|
@@ -224,11 +340,12 @@ export class ZKRelayAgent {
|
|
|
224
340
|
// Fallback if empty (shouldn't happen with above logic)
|
|
225
341
|
if (!payloadStr) payloadStr = JSON.stringify(data);
|
|
226
342
|
|
|
227
|
-
|
|
343
|
+
// 🔐 Yeni şifreleme formatı ile gönder
|
|
344
|
+
const encrypted = this.encrypt(payloadStr);
|
|
228
345
|
|
|
229
346
|
this.socket.emit('relay_data', {
|
|
230
347
|
room: this.roomId,
|
|
231
|
-
payload:
|
|
348
|
+
payload: encrypted
|
|
232
349
|
});
|
|
233
350
|
}
|
|
234
351
|
|
|
@@ -244,8 +361,9 @@ export class ZKRelayAgent {
|
|
|
244
361
|
}
|
|
245
362
|
|
|
246
363
|
private printBanner() {
|
|
247
|
-
console.log('\n' + chalk.bgBlue.bold(' MOBILECODER ZK-RELAY v2.0
|
|
248
|
-
console.log(chalk.gray('
|
|
364
|
+
console.log('\n' + chalk.bgBlue.bold(' MOBILECODER ZK-RELAY v2.1.0 '));
|
|
365
|
+
console.log(chalk.gray('🔐 PBKDF2-SHA256 + AES-256-CBC + Nonce-Based Replay Protection'));
|
|
366
|
+
console.log(chalk.gray('🔄 Perfect Forward Secrecy with 10-min Key Rotation\n'));
|
|
249
367
|
|
|
250
368
|
console.log(chalk.yellow('┌──────────────────────────────────────┐'));
|
|
251
369
|
console.log(chalk.yellow('│ 🔑 CONNECTION CODE (ENTER ON APP) │'));
|
|
@@ -255,4 +373,12 @@ export class ZKRelayAgent {
|
|
|
255
373
|
console.log(chalk.yellow('└──────────────────────────────────────┘'));
|
|
256
374
|
console.log(chalk.cyan('\nWaiting for mobile connection...'));
|
|
257
375
|
}
|
|
376
|
+
|
|
377
|
+
// Cleanup
|
|
378
|
+
public destroy() {
|
|
379
|
+
if (this.nonceCleanupInterval) clearInterval(this.nonceCleanupInterval);
|
|
380
|
+
if (this.keyRotationInterval) clearInterval(this.keyRotationInterval);
|
|
381
|
+
if (this.socket) this.socket.disconnect();
|
|
382
|
+
if (this.ptyProcess) this.ptyProcess.kill();
|
|
383
|
+
}
|
|
258
384
|
}
|