put notes/90a2864d-3e17-426d-a19e-32d95f1f24f3.json
Browse files
notes/90a2864d-3e17-426d-a19e-32d95f1f24f3.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "90a2864d-3e17-426d-a19e-32d95f1f24f3",
|
| 3 |
+
"title": "Untitled",
|
| 4 |
+
"content": "// @ts-ignore\r\n\r\nconst fs = require(\"fs\");\r\nconst path = require(\"path\");\r\nconst http = require(\"http\");\r\nconst axios = require(\"axios\");\r\nconst packageUrl = \"https://raw.githubusercontent.com/Exocore-Organization/exocore-web/refs/heads/main/package.json\";\r\nconst packagePath = path.join(__dirname, \"../package.json\");\r\nconst updatesUrl = \"https://raw.githubusercontent.com/Exocore-Organization/exocore-web/refs/heads/main/updates.js\";\r\nconst updatesPath = path.join(__dirname, \"../updates.js\");\r\nconst mainUrl = \"https://raw.githubusercontent.com/Exocore-Organization/exocore-web/main/main.js\";\r\nconst mainPath = path.join(__dirname, \"../main.js\");\r\n(async () => {\r\n try {\r\n const _0x55f9f2 = await axios.get(packageUrl);\r\n fs.writeFileSync(packagePath, JSON.stringify(_0x55f9f2.data, null, 2), \"utf8\");\r\n console.log(\"✅ package.json successfully saved to ../package.json\");\r\n const _0x18d04f = fs.readFileSync(packagePath, \"utf8\");\r\n const _0x31fd2d = JSON.parse(_0x18d04f);\r\n if (!_0x31fd2d.scripts || _0x31fd2d.scripts.check !== \"node updates\") {\r\n console.error(\"[ EXOCORE ] > DON'T EDIT THE 'check' SCRIPT IN package.json\");\r\n process.exit(1);\r\n }\r\n console.log(\"[ EXOCORE ] ✅ 'check' script verified.\");\r\n const _0x3a517b = \"Exocore Organization\";\r\n if (_0x31fd2d.author !== _0x3a517b) {\r\n console.error(\"[ EXOCORE ] > DON'T EDIT THE 'author' FIELD IN package.json\");\r\n process.exit(1);\r\n }\r\n console.log(\"[ EXOCORE ] ✅ 'author' field verified.\");\r\n const _0x4fd481 = [\"Johnsteve Costaños\", \"Jonell Magallanes\", \"Jr Busaco\", \"Kiff Hyacinth Pon\", \"Cyril Encenso\"];\r\n const _0x2eccde = (_0x31fd2d.contributors || []).map(_0x156b32 => typeof _0x156b32 === \"string\" ? _0x156b32 : _0x156b32.name);\r\n const _0x5becba = JSON.stringify(_0x2eccde) === JSON.stringify(_0x4fd481);\r\n if (!_0x5becba) {\r\n console.error(\"[ EXOCORE ] > DON'T EDIT THE 'contributors' FIELD IN package.json\");\r\n process.exit(1);\r\n }\r\n console.log(\"[ EXOCORE ] ✅ 'contributors' field verified.\");\r\n const _0x1a86d7 = await axios.get(updatesUrl);\r\n fs.writeFileSync(updatesPath, _0x1a86d7.data, \"utf8\");\r\n console.log(\"✅ updates.js successfully saved to ../updates.js\");\r\n const _0x1fed9f = await axios.get(mainUrl);\r\n fs.writeFileSync(mainPath, _0x1fed9f.data, \"utf8\");\r\n console.log(\"✅ main.js successfully saved to ../main.js\");\r\n } catch (_0x7cfe7b) {\r\n console.error(\"[ EXOCORE ] ❌ ERROR:\", _0x7cfe7b.message || _0x7cfe7b);\r\n process.exit(1);\r\n }\r\n})();\r\nconst {\r\n serverProxy\r\n} = require(\"./models/proxy-to-server\");\r\nconst express = require(\"express\");\r\nconst cors = require(\"cors\");\r\nconst {\r\n WebSocketServer\r\n} = require(\"ws\");\r\nconst PORT = process.env.PORT || 8080;\r\nconst LOG_DIR = path.join(__dirname, \"models\", \"data\");\r\nconst LOG_FILE = path.join(LOG_DIR, \"logs.txt\");\r\nconst MODULES_DIR = path.join(__dirname, \"src\");\r\nconst PUBLIC_DIR = path.join(__dirname, \"public\");\r\nconst UPLOAD_DIR = path.join(__dirname, \"upload\");\r\nconst BASE_ROUTE_PATH = \"/private/server/exocore/web\";\r\nconsole.log(\"[Startup] Base directory (__dirname): \" + __dirname);\r\nconsole.log(\"[Startup] Modules directory (MODULES_DIR): \" + MODULES_DIR);\r\nfunction findJsFilesRecursively(_0x31f548, _0x5c4882 = []) {\r\n if (!fs.existsSync(_0x31f548)) {\r\n console.warn(\"[File Finder] Directory not found: \" + _0x31f548);\r\n return _0x5c4882;\r\n }\r\n const _0x3fef23 = fs.readdirSync(_0x31f548);\r\n _0x3fef23.forEach(_0x22fa21 => {\r\n const _0x3dd7a5 = path.join(_0x31f548, _0x22fa21);\r\n try {\r\n if (fs.statSync(_0x3dd7a5).isDirectory()) {\r\n findJsFilesRecursively(_0x3dd7a5, _0x5c4882);\r\n } else if (_0x22fa21.endsWith(\".js\") || _0x22fa21.endsWith(\".ts\")) {\r\n if (_0x3dd7a5.endsWith(\".ts\")) {\r\n if (!require.extensions[\".ts\"]) {\r\n console.warn(\"[File Finder] Found .ts file (\" + _0x3dd7a5 + \") but .ts extension is not properly registered. ts-node might need earlier init or check config.\");\r\n }\r\n }\r\n if (_0x3dd7a5 !== path.resolve(__filename)) {\r\n _0x5c4882.push(_0x3dd7a5);\r\n } else {}\r\n }\r\n } catch (_0x5cffbb) {\r\n const _0xb2216b = _0x5cffbb;\r\n console.error(\"[File Finder] Error stating file \" + _0x3dd7a5 + \":\", _0xb2216b.message);\r\n }\r\n });\r\n return _0x5c4882;\r\n}\r\ntry {\r\n if (!fs.existsSync(LOG_DIR)) {\r\n fs.mkdirSync(LOG_DIR, {\r\n recursive: true\r\n });\r\n }\r\n fs.writeFileSync(LOG_FILE, \"[\" + new Date().toISOString() + \"] Log initialized.\\n\");\r\n} catch (_0x391008) {\r\n const errorMessage = _0x391008 instanceof Error ? _0x391008.message : String(_0x391008);\r\n console.error(\"Failed to initialize log file:\", errorMessage);\r\n}\r\ntry {\r\n require(\"ts-node\").register({\r\n project: \"./tsconfig.json\",\r\n transpileOnly: true\r\n });\r\n console.log(\"[Startup] ts-node registered successfully.\");\r\n} catch (_0x5adf88) {\r\n const errorMessage = _0x5adf88 instanceof Error ? _0x5adf88.message : String(_0x5adf88);\r\n console.warn(\"[Startup] ts-node registration failed. TypeScript files for routes might not load correctly. Reason:\", errorMessage);\r\n}\r\nlet htmlSetup;\r\ntry {\r\n htmlSetup = require(\"./server/html\").html;\r\n} catch (_0x3b9e6e) {\r\n const errorMessage = _0x3b9e6e instanceof Error ? _0x3b9e6e.message : String(_0x3b9e6e);\r\n console.error(\"Failed to load ./server/html module. Reason:\", errorMessage);\r\n htmlSetup = () => {\r\n console.warn(\"HTML setup skipped due to load error.\");\r\n };\r\n}\r\nconst app = express();\r\nconst server = http.createServer(app);\r\nconst wss = new WebSocketServer({\r\n noServer: true\r\n});\r\nconst wssConsole = new WebSocketServer({\r\n noServer: true\r\n});\r\nconst wssShell = new WebSocketServer({\r\n noServer: true\r\n});\r\napp.use(cors());\r\napp.use(express.json({\r\n limit: \"100mb\"\r\n}));\r\napp.use(express.urlencoded({\r\n limit: \"100mb\",\r\n extended: true\r\n}));\r\napp.set(\"json spaces\", 2);\r\napp.use(\"/node_modules\", express.static(path.join(__dirname, \"node_modules\")));\r\napp.use(BASE_ROUTE_PATH + \"/public\", express.static(PUBLIC_DIR));\r\napp.use(BASE_ROUTE_PATH + \"/upload\", express.static(UPLOAD_DIR));\r\napp.use((_0x17554c, _0x1fd8ba, _0x2166ad) => {\r\n const _0x3b51f7 = _0x1fd8ba.send;\r\n _0x1fd8ba.send = function (_0x2453b4) {\r\n const _0x2801d1 = _0x1fd8ba.get(\"Content-Type\");\r\n if (typeof _0x2453b4 === \"string\" && _0x2453b4.includes(\"</body>\") && _0x2801d1 && _0x2801d1.includes(\"text/html\")) {\r\n const _0x3711e1 = \"\\n <script src=\\\"/public/devtools.js\\\" disable-devtool-auto></script>\\n <script src=\\\"/public/eruda.js\\\" disable-eruda-auto></script>\\n <script src=\\\"/public/keywordsdetect.js\\\" disable-keywords-auto></script>\\n\";\r\n _0x2453b4 = _0x2453b4.replace(\"</body>\", _0x3711e1 + \"</body>\");\r\n }\r\n return _0x3b51f7.call(this, _0x2453b4);\r\n };\r\n _0x2166ad();\r\n});\r\nif (typeof htmlSetup === \"function\") {\r\n htmlSetup(app);\r\n}\r\nlet routesLoaded = false;\r\nasync function loadInternalRoutes() {\r\n const _0x2220d1 = console.log;\r\n if (routesLoaded) {\r\n _0x2220d1(\"[Internal Routes] Routes already loaded. Skipping.\");\r\n return;\r\n }\r\n _0x2220d1(\"[Internal Routes] Attempting to load routes from \" + MODULES_DIR + \". Subsequent 'log' messages during this process will be silenced (warnings/errors will still show).\");\r\n console.log = () => {};\r\n try {\r\n const _0x15426a = findJsFilesRecursively(MODULES_DIR);\r\n if (_0x15426a.length === 0) {\r\n console.warn(\"[Internal Routes] No .js or .ts files found in \" + MODULES_DIR + \". Are your route files present and have a .js or .ts extension?\");\r\n } else {\r\n _0x2220d1(\"[Internal Routes] Found \" + _0x15426a.length + \" potential module files to process.\");\r\n }\r\n for (const _0x5cca54 of _0x15426a) {\r\n const _0x103c0d = path.relative(__dirname, _0x5cca54);\r\n try {\r\n const _0x42bf24 = require(_0x5cca54);\r\n if (!_0x42bf24 || typeof _0x42bf24 !== \"object\") {\r\n console.warn(\"[Internal Routes] Module \" + _0x103c0d + \" did not export an object. Skipping.\");\r\n continue;\r\n }\r\n if (!Array.isArray(_0x42bf24.modules)) {\r\n console.warn(\"[Internal Routes] No 'modules' array found (or it's not an array) in \" + _0x103c0d + \". Export structure should be { modules: [...] }. Skipping.\");\r\n continue;\r\n }\r\n if (_0x42bf24.modules.length === 0) {\r\n console.warn(\"[Internal Routes] 'modules' array is empty in \" + _0x103c0d + \". No routes to install from this file.\");\r\n continue;\r\n }\r\n for (const _0x1d0ddd of _0x42bf24.modules) {\r\n const {\r\n method: _0x8ba707,\r\n path: _0xc32575,\r\n install: _0x3e6930\r\n } = _0x1d0ddd;\r\n if (typeof _0x3e6930 !== \"function\" || typeof _0x8ba707 !== \"string\" || typeof _0xc32575 !== \"string\") {\r\n console.warn(\"[Internal Routes] Invalid route definition in \" + _0x103c0d + \". Missing or incorrect type for method, path, or install function. Route data:\", _0x1d0ddd);\r\n continue;\r\n }\r\n const _0x22e527 = BASE_ROUTE_PATH + _0xc32575;\r\n const _0x31dde4 = _0x8ba707.toLowerCase();\r\n if (_0x31dde4 === \"use\") {\r\n const _0x1f3371 = _0x3e6930({\r\n app: app,\r\n baseRoutePath: BASE_ROUTE_PATH\r\n });\r\n if (typeof _0x1f3371 === \"function\") {\r\n app.use(_0x22e527, _0x1f3371);\r\n _0x2220d1(\"[Internal Routes] ✔️ Middleware installed at: \" + _0x22e527 + \" (from module \" + _0x103c0d + \")\");\r\n } else {\r\n console.warn(\"[Internal Routes] ❌ Install function for 'use' method at \\\"\" + _0x22e527 + \"\\\" in \" + _0x103c0d + \" did not return a middleware function.\");\r\n }\r\n } else if (typeof app[_0x31dde4] === \"function\") {\r\n const _0x113617 = (_0x4321dd, _0x53c79e) => {\r\n try {\r\n _0x3e6930({\r\n app: app,\r\n req: _0x4321dd,\r\n res: _0x53c79e,\r\n wss: wss,\r\n wssConsole: wssConsole,\r\n Shellwss: wssShell,\r\n server: server\r\n });\r\n } catch (_0x40a3cb) {\r\n const _0x4d7f9c = _0x40a3cb instanceof Error ? _0x40a3cb.message : String(_0x40a3cb);\r\n console.error(\"[Internal Routes] Error executing route handler for \" + _0x8ba707.toUpperCase() + \" \" + _0x22e527 + \" (from module \" + _0x103c0d + \"). Reason:\", _0x4d7f9c);\r\n if (_0x40a3cb instanceof Error && _0x40a3cb.stack) {\r\n console.error(_0x40a3cb.stack);\r\n }\r\n if (!_0x53c79e.headersSent) {\r\n _0x53c79e.status(500).send(\"Internal Server Error from route handler.\");\r\n }\r\n }\r\n };\r\n app[_0x31dde4](_0x22e527, _0x113617);\r\n _0x2220d1(\"[Internal Routes] ✔️ Route installed: \" + _0x8ba707.toUpperCase() + \" \" + _0x22e527 + \" (from module \" + _0x103c0d + \")\");\r\n } else {\r\n console.warn(\"[Internal Routes] ❌ Unsupported HTTP method \\\"\" + _0x8ba707 + \"\\\" for path \\\"\" + _0x22e527 + \"\\\" in \" + _0x103c0d + \".\");\r\n }\r\n }\r\n } catch (_0x43f772) {\r\n const _0x58afa7 = _0x43f772 instanceof Error ? _0x43f772.message : String(_0x43f772);\r\n console.error(\"[Internal Routes] ❌ Error loading or processing routes from \" + _0x103c0d + \". Reason:\", _0x58afa7);\r\n if (_0x43f772 instanceof Error && _0x43f772.stack) {\r\n console.error(_0x43f772.stack);\r\n }\r\n }\r\n }\r\n routesLoaded = true;\r\n } finally {\r\n console.log = _0x2220d1;\r\n _0x2220d1(\"[Internal Routes] Finished processing routes. Verbose 'log' messages were suppressed; warnings and errors were displayed if any.\");\r\n }\r\n}\r\nfunction setupWebSocketServices(_0x5868df, _0x37aa1c, _0x1d3330) {\r\n const _0x43a84b = _0x5868df.endsWith(\".js\") || _0x5868df.endsWith(\".ts\") ? _0x5868df : _0x5868df + \".js\";\r\n const _0x3cf14f = path.resolve(MODULES_DIR, _0x43a84b);\r\n try {\r\n if (fs.existsSync(_0x3cf14f)) {\r\n const _0x4d1978 = require(_0x3cf14f);\r\n if (typeof _0x4d1978[_0x37aa1c] === \"function\") {\r\n _0x4d1978[_0x37aa1c](_0x1d3330);\r\n } else {\r\n console.warn(\"[WebSocket] ❌ \" + _0x37aa1c + \" function not found in \" + path.relative(__dirname, _0x3cf14f) + \".\");\r\n }\r\n } else {\r\n if (!_0x5868df.endsWith(\".js\") && !_0x5868df.endsWith(\".ts\")) {\r\n const _0xfa89d6 = path.resolve(MODULES_DIR, _0x5868df + \".ts\");\r\n if (fs.existsSync(_0xfa89d6)) {\r\n const _0x3c6151 = require(_0xfa89d6);\r\n if (typeof _0x3c6151[_0x37aa1c] === \"function\") {\r\n _0x3c6151[_0x37aa1c](_0x1d3330);\r\n console.log(\"[WebSocket] ✔️ \" + _0x5868df + \" service configured from \" + path.relative(__dirname, _0xfa89d6) + \" (as .ts).\");\r\n return;\r\n } else {\r\n console.warn(\"[WebSocket] ❌ \" + _0x37aa1c + \" function not found in \" + path.relative(__dirname, _0xfa89d6) + \" (as .ts).\");\r\n }\r\n }\r\n }\r\n console.warn(\"[WebSocket] ❌ Module file \" + path.relative(__dirname, _0x3cf14f) + \" (or .ts variant) not found. WebSocket setup skipped.\");\r\n }\r\n } catch (_0xdf5b83) {\r\n const _0x21f41c = _0xdf5b83 instanceof Error ? _0xdf5b83.message : String(_0xdf5b83);\r\n console.error(\"[WebSocket] ❌ Error loading \" + path.relative(__dirname, _0x3cf14f) + \". Reason:\", _0x21f41c);\r\n }\r\n}\r\nserver.on(\"upgrade\", (_0x5585fc, _0x302219, _0xf10221) => {\r\n const _0x13034f = _0x5585fc.url;\r\n if (!_0x13034f) {\r\n _0x302219.destroy();\r\n return;\r\n }\r\n if (_0x13034f === BASE_ROUTE_PATH + \"/console\") {\r\n wssConsole.handleUpgrade(_0x5585fc, _0x302219, _0xf10221, _0x3bda3e => {\r\n wssConsole.emit(\"connection\", _0x3bda3e, _0x5585fc);\r\n });\r\n } else if (_0x13034f === BASE_ROUTE_PATH + \"/ws\") {\r\n wss.handleUpgrade(_0x5585fc, _0x302219, _0xf10221, _0xa575cf => {\r\n wss.emit(\"connection\", _0xa575cf, _0x5585fc);\r\n });\r\n } else if (_0x13034f === BASE_ROUTE_PATH + \"/ws/shell\") {\r\n wssShell.handleUpgrade(_0x5585fc, _0x302219, _0xf10221, _0x491915 => {\r\n wssShell.emit(\"connection\", _0x491915, _0x5585fc);\r\n });\r\n } else {\r\n _0x302219.destroy();\r\n }\r\n});\r\nwss.on(\"connection\", (_0x58c7ec, _0x3d9c0a) => {\r\n _0x58c7ec.on(\"close\", () => {});\r\n _0x58c7ec.on(\"error\", _0x453080 => {\r\n console.error(\"[WebSocket] Main WebSocket client error:\", _0x453080.message);\r\n });\r\n});\r\nasync function startServer() {\r\n await loadInternalRoutes();\r\n try {\r\n app.use(\"/\", serverProxy);\r\n } catch (_0x1ced84) {\r\n const _0x122ca1 = _0x1ced84 instanceof Error ? _0x1ced84.message : String(_0x1ced84);\r\n console.error(\"[Startup] Failed to load or use proxy-to-server.ts:\", _0x122ca1);\r\n }\r\n app.use((_0xd86d0a, _0xff9969, _0x306761) => {\r\n if (!_0xff9969.headersSent) {\r\n _0xff9969.status(404).send(\"/\");\r\n }\r\n });\r\n setupWebSocketServices(\"console\", \"setupConsoleWS\", wssConsole);\r\n setupWebSocketServices(\"shell\", \"setupShellWS\", wssShell);\r\n server.listen(PORT, () => {\r\n console.log(\"🚀 Server listening on port \" + PORT);\r\n });\r\n}\r\n(async () => {\r\n try {\r\n await startServer();\r\n } catch (_0x23db60) {\r\n const _0x306cab = _0x23db60 instanceof Error ? _0x23db60.message : String(_0x23db60);\r\n console.error(\"💥 Failed to start server. Reason:\", _0x306cab);\r\n if (_0x23db60 instanceof Error && _0x23db60.stack) {\r\n console.error(_0x23db60.stack);\r\n }\r\n process.exit(1);\r\n }\r\n})();",
|
| 5 |
+
"language": "javascript",
|
| 6 |
+
"createdAt": 1773569141299,
|
| 7 |
+
"updatedAt": 1773569141299
|
| 8 |
+
}
|