feat: complete multi-microservice project deployment, internal DNS, raw TCP and security penetration report

This commit is contained in:
2026-10-13 00:01:14 +03:00
parent bdcd2d44f5
commit 2cea9f25ba
15 changed files with 1405 additions and 54 deletions
+8 -12
View File
@@ -1,14 +1,15 @@
const WSS_URL = 'wss://client-terminal-0f1fe89209a8.hosted.ghaymah.systems/ws';
const DEFAULT_URL = 'wss://soc-tester-9b6540e2d4ed.hosted.ghaymah.systems/ws';
class RemoteTerminal {
constructor() {
constructor(url = DEFAULT_URL) {
this.url = url;
this.ws = null;
this.ready = false;
}
async connect() {
return new Promise((resolve, reject) => {
this.ws = new WebSocket(WSS_URL, ['tty']);
this.ws = new WebSocket(this.url, ['tty']);
this.ws.onopen = () => {
this.ws.send(JSON.stringify({ AuthToken: '' }));
@@ -19,11 +20,11 @@ class RemoteTerminal {
}, 800);
};
this.ws.onerror = (e) => reject(new Error('WS error: ' + e.message));
this.ws.onerror = (e) => reject(new Error('WS error: ' + (e.message || JSON.stringify(e))));
});
}
async exec(command, timeoutMs = 10000) {
async exec(command, timeoutMs = 12000) {
if (!this.ready) await this.connect();
return new Promise((resolve, reject) => {
@@ -43,7 +44,6 @@ class RemoteTerminal {
if (text.startsWith('0')) text = text.substring(1);
rawOutput += text;
// Match \n__RET__<code|marker>__END__ when printed by echo, NOT during command typing
const regex = new RegExp(`\r?\n__RET__(\\d+)_${markerId}__END__`);
const match = rawOutput.match(regex);
@@ -56,9 +56,7 @@ class RemoteTerminal {
const exitCode = parseInt(match[1]);
const lines = clean.split('\n');
// Find the line where the command was echoed
const cmdIdx = lines.findIndex(l => l.includes(markerId) && l.includes('echo'));
// Find the line where the result marker is
const retIdx = lines.findIndex(l => l.startsWith(`__RET__${exitCode}_${markerId}__END__`));
let outLines = [];
@@ -70,7 +68,6 @@ class RemoteTerminal {
outLines = lines;
}
// Filter out prompt lines
const filtered = outLines.filter(l => !l.endsWith('~#') && !l.endsWith('$') && !l.includes('bash ('));
resolve({
@@ -99,7 +96,6 @@ class RemoteTerminal {
this.ws.addEventListener('message', messageHandler);
// Execute command and output return marker
const fullCmd = `${command}; echo __RET__$?_${markerId}__END__\n`;
this.ws.send('0' + fullCmd);
});
@@ -124,8 +120,8 @@ if (require.main === module) {
console.log(res1.output);
console.log('Exit code:', res1.exitCode);
console.log('\nTesting cat /etc/resolv.conf...');
const res2 = await term.exec('cat /etc/resolv.conf');
console.log('\nTesting hostname & ip...');
const res2 = await term.exec('hostname -i || ip addr');
console.log('--- OUTPUT 2 ---');
console.log(res2.output);
console.log('Exit code:', res2.exitCode);