fca-shankar-bot 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. package/.cache/replit/env/latest +55 -0
  2. package/.cache/replit/env/latest.json +1 -0
  3. package/.cache/replit/modules/nodejs-14.res +1 -0
  4. package/.cache/replit/modules/replit.res +1 -0
  5. package/.cache/replit/modules/web.res +1 -0
  6. package/.cache/replit/modules.stamp +0 -0
  7. package/.cache/typescript/5.5/package.json +1 -0
  8. package/.config/configstore/update-notifier-npm.json +4 -0
  9. package/.gitattributes +2 -0
  10. package/.replit +8 -0
  11. package/Extra/Bypass/956/index.js +234 -0
  12. package/Extra/Bypass/test/aaaa.json +170 -0
  13. package/Extra/Bypass/test/index.js +188 -0
  14. package/Extra/Database/index.js +469 -0
  15. package/Extra/ExtraAddons.js +82 -0
  16. package/Extra/ExtraFindUID.js +62 -0
  17. package/Extra/ExtraGetThread.js +365 -0
  18. package/Extra/ExtraScreenShot.js +430 -0
  19. package/Extra/ExtraUptimeRobot.js +38 -0
  20. package/Extra/Html/Classic/script.js +119 -0
  21. package/Extra/Html/Classic/style.css +8 -0
  22. package/Extra/Security/AES_256_GCM/index.js +0 -0
  23. package/Extra/Security/Base/Step_1.js +6 -0
  24. package/Extra/Security/Base/Step_2.js +22 -0
  25. package/Extra/Security/Base/Step_3.js +22 -0
  26. package/Extra/Security/Base/index.js +191 -0
  27. package/Extra/Security/Index.js +5 -0
  28. package/Extra/Security/Step_1.js +6 -0
  29. package/Extra/Security/Step_2.js +22 -0
  30. package/Extra/Security/Step_3.js +22 -0
  31. package/Extra/Src/Change_Environment.js +24 -0
  32. package/Extra/Src/Check_Update.js +67 -0
  33. package/Extra/Src/History.js +115 -0
  34. package/Extra/Src/Instant_Update.js +65 -0
  35. package/Extra/Src/Last-Run.js +65 -0
  36. package/Extra/Src/Premium.js +81 -0
  37. package/Extra/Src/Release_Memory.js +160 -0
  38. package/Extra/Src/Websocket.js +213 -0
  39. package/Extra/Src/image/checkmate.jpg +0 -0
  40. package/Extra/Src/test.js +28 -0
  41. package/Extra/Src/uuid.js +137 -0
  42. package/Func/AcceptAgreement.js +31 -0
  43. package/Func/ClearCache.js +64 -0
  44. package/Func/ReportV1.js +54 -0
  45. package/LICENSE +21 -0
  46. package/Language/index.json +222 -0
  47. package/Main.js +1266 -0
  48. package/README.md +152 -0
  49. package/SECURITY.md +18 -0
  50. package/broadcast.js +44 -0
  51. package/index.js +448 -0
  52. package/logger.js +66 -0
  53. package/package.json +94 -0
  54. package/src/Dev_Horizon_Data.js +125 -0
  55. package/src/Dev_getThreadInfoOLD.js +422 -0
  56. package/src/Dev_shareTest2.js +68 -0
  57. package/src/Dev_shareTest3.js +71 -0
  58. package/src/Premium.js +25 -0
  59. package/src/Screenshot.js +83 -0
  60. package/src/addExternalModule.js +16 -0
  61. package/src/addUserToGroup.js +79 -0
  62. package/src/changeAdminStatus.js +79 -0
  63. package/src/changeArchivedStatus.js +41 -0
  64. package/src/changeAvt.js +85 -0
  65. package/src/changeBio.js +65 -0
  66. package/src/changeBlockedStatus.js +36 -0
  67. package/src/changeGroupImage.js +106 -0
  68. package/src/changeNickname.js +45 -0
  69. package/src/changeThreadColor.js +62 -0
  70. package/src/changeThreadEmoji.js +42 -0
  71. package/src/createNewGroup.js +70 -0
  72. package/src/createPoll.js +60 -0
  73. package/src/deleteMessage.js +45 -0
  74. package/src/deleteThread.js +43 -0
  75. package/src/editMessage.js +53 -0
  76. package/src/forwardAttachment.js +48 -0
  77. package/src/getAccessToken.js +28 -0
  78. package/src/getCurrentUserID.js +7 -0
  79. package/src/getEmojiUrl.js +27 -0
  80. package/src/getFriendsList.js +73 -0
  81. package/src/getMessage.js +103 -0
  82. package/src/getThreadHistory.js +537 -0
  83. package/src/getThreadInfo.js +424 -0
  84. package/src/getThreadInfoOLD.js +422 -0
  85. package/src/getThreadList.js +213 -0
  86. package/src/getThreadMain.js +220 -0
  87. package/src/getThreadPictures.js +59 -0
  88. package/src/getUID.js +59 -0
  89. package/src/getUserID.js +62 -0
  90. package/src/getUserInfo.js +112 -0
  91. package/src/getUserInfoMain.js +65 -0
  92. package/src/getUserInfoV2.js +32 -0
  93. package/src/getUserInfoV3.js +63 -0
  94. package/src/getUserInfoV4.js +55 -0
  95. package/src/getUserInfoV5.js +61 -0
  96. package/src/handleFriendRequest.js +46 -0
  97. package/src/handleMessageRequest.js +49 -0
  98. package/src/httpGet.js +49 -0
  99. package/src/httpPost.js +48 -0
  100. package/src/httpPostFormData.js +41 -0
  101. package/src/listenMqtt.js +936 -0
  102. package/src/listenMqttV1.js +846 -0
  103. package/src/logout.js +68 -0
  104. package/src/markAsDelivered.js +48 -0
  105. package/src/markAsRead.js +70 -0
  106. package/src/markAsReadAll.js +43 -0
  107. package/src/markAsSeen.js +51 -0
  108. package/src/muteThread.js +47 -0
  109. package/src/removeUserFromGroup.js +49 -0
  110. package/src/resolvePhotoUrl.js +37 -0
  111. package/src/searchForThread.js +43 -0
  112. package/src/sendMessage.js +386 -0
  113. package/src/sendMqttMessage.js +71 -0
  114. package/src/sendTypingIndicator.js +80 -0
  115. package/src/setMessageReaction.js +109 -0
  116. package/src/setPostReaction.js +102 -0
  117. package/src/setTitle.js +74 -0
  118. package/src/shareContact.js +55 -0
  119. package/src/shareLink.js +58 -0
  120. package/src/threadColors.js +39 -0
  121. package/src/unfriend.js +43 -0
  122. package/src/unsendMessage.js +40 -0
  123. package/test/Database_Test.js +4 -0
  124. package/test/Db2.js +530 -0
  125. package/test/Horizon_Database/A_README.md +1 -0
  126. package/test/Horizon_Database/Database.db +0 -0
  127. package/test/data/shareAttach.js +146 -0
  128. package/test/data/something.mov +0 -0
  129. package/test/data/test.png +0 -0
  130. package/test/data/test.txt +7 -0
  131. package/test/env/.env +0 -0
  132. package/test/example-config.json +18 -0
  133. package/test/example-db.db +0 -0
  134. package/test/memoryleak.js +18 -0
  135. package/test/test-page.js +140 -0
  136. package/test/test.js +385 -0
  137. package/test/testname.js +1342 -0
  138. package/test/testv2.js +3 -0
  139. package/utils.js +3038 -0
@@ -0,0 +1,81 @@
1
+ module.exports = async function(SessionID) {
2
+ try {
3
+ var userName,Text;
4
+ var os = require('os');
5
+ var Database = require("../Database");
6
+ var { getAll,readyCreate,deleteAll } = require('../ExtraGetThread');
7
+ if (process.env.REPL_OWNER != undefined) userName = process.env.REPL_OWNER;
8
+ else if (os.hostname() != null || os.hostname() != undefined) userName = os.hostname();
9
+ else userName = os.userInfo().username;
10
+ if (Database(true).has('UserName')) {
11
+ if (Database(true).get('UserName') != userName) {
12
+ Database(true).set('Premium', false);
13
+ Database(true).set('PremiumKey', '');
14
+ Database(true).set('UserName', userName);
15
+ }
16
+ }
17
+ if (Database(true).has('PremiumKey') && Database(true).get('PremiumKey') != '' && Database(true).has('Premium') && Database(true).get('Premium') == true) {
18
+ try {
19
+ Database(true).set('Premium', true);
20
+ Database(true).set('PremiumKey', String(global.Fca.Require.FastConfig.PreKey));
21
+ Database(true).set('UserName', userName);
22
+ process.env.HalzionVersion = 1973
23
+ Text = "Bạn Đang Sài Phiên Bản: Premium Access";
24
+ }
25
+ catch (error) {
26
+ Text = "Lỗi Kết Nối";
27
+ }
28
+ } else if (global.Fca.Require.FastConfig.PreKey) {
29
+ try {
30
+ Database(true).set('Premium', true);
31
+ Database(true).set('PremiumKey', String(global.Fca.Require.FastConfig.PreKey));
32
+ Database(true).set('UserName', userName);
33
+ process.env.HalzionVersion = 1973
34
+ Text = "Bạn Đang Sài Phiên Bản: Premium Access";
35
+ }
36
+ catch (error) {
37
+ Text = "Lỗi Kết Nối";
38
+ }
39
+ }
40
+ else if (!global.Fca.Require.FastConfig.PreKey) {
41
+ try {
42
+ Database(true).set('Premium', true);
43
+ Database(true).set('PremiumKey', String(global.Fca.Require.FastConfig.PreKey));
44
+ Database(true).set('UserName', userName);
45
+ process.env.HalzionVersion = 1973
46
+ Text = "Bạn Đang Sài Phiên Bản: Premium Access";
47
+ }
48
+ catch (error) {
49
+ Text = "Lỗi Kết Nối";
50
+ }
51
+ }
52
+ } catch (e) {
53
+ try {
54
+ Database(true).set('Premium', true);
55
+ Database(true).set('PremiumKey', String(global.Fca.Require.FastConfig.PreKey));
56
+ Database(true).set('UserName', userName);
57
+ process.env.HalzionVersion = 1973
58
+ Text = "Bạn Đang Sài Phiên Bản: Premium Access";
59
+ }
60
+ catch (error) {
61
+ Text = "Lỗi Kết Nối";
62
+ }
63
+ }
64
+ if (process.env.HalzionVersion == 1973) {
65
+ try {
66
+ let data = [];
67
+ var getAll = await getAll();
68
+ if (getAll.length > 1) {
69
+ getAll.forEach((i) => {
70
+ if (i.data.messageCount !== undefined) {
71
+ data.push(i.data.threadID);
72
+ }
73
+ });
74
+ deleteAll(data);
75
+ }
76
+ } catch (e) {
77
+ console.log(e);
78
+ }
79
+ }
80
+ return Text;
81
+ }
@@ -0,0 +1,160 @@
1
+ /* eslint-disable linebreak-style */
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const v8 = require('v8');
5
+ const EventEmitter = require('events');
6
+
7
+ class MemoryManager extends EventEmitter {
8
+ constructor(options = {}) {
9
+ super();
10
+ this.thresholds = {
11
+ warning: options.warningThreshold || 0.7,
12
+ release: options.releaseThreshold || 0.8,
13
+ max: options.maxThreshold || 0.9,
14
+ };
15
+ this.interval = options.interval || 5000;
16
+ this.logLevel = options.logLevel || 'info';
17
+ this.logFile = options.logFile || path.join(__dirname, 'memory.log');
18
+ this.allowLog = options.allowLog || true;
19
+ this.weakRefs = new WeakMap();
20
+ this.smartReleaseEnabled = options.smartReleaseEnabled || false;
21
+ this.memoryUsageHistory = [];
22
+ }
23
+
24
+ start() {
25
+ this.intervalId = setInterval(() => {
26
+ const memoryUsage = this.getMemoryUsage();
27
+ this.logMemoryUsage(memoryUsage);
28
+
29
+ if (memoryUsage > this.thresholds.warning) {
30
+ this.emit('memoryWarning', memoryUsage);
31
+ }
32
+
33
+ if (memoryUsage > this.thresholds.release) {
34
+ this.releaseMemory(memoryUsage);
35
+ }
36
+
37
+ if (memoryUsage > this.thresholds.max) {
38
+ this.emit('memoryMax', memoryUsage);
39
+ }
40
+
41
+ if (this.smartReleaseEnabled) {
42
+ this.memoryUsageHistory.push(memoryUsage);
43
+ this.smartRelease();
44
+ }
45
+ }, this.interval);
46
+ }
47
+
48
+ stop() {
49
+ clearInterval(this.intervalId);
50
+ }
51
+
52
+ getMemoryUsage() {
53
+ const heapStats = v8.getHeapStatistics();
54
+ const totalHeapSize = heapStats.total_available_size / 1024 / 1024;
55
+ const usedHeapSize = heapStats.used_heap_size / 1024 / 1024;
56
+ return usedHeapSize / totalHeapSize;
57
+ }
58
+
59
+ releaseMemory(memoryUsage) {
60
+ if (global.gc) {
61
+ global.gc();
62
+ } else {
63
+ v8.setFlagsFromString('--expose_gc');
64
+ const vm = require('vm');
65
+ vm.runInNewContext('gc')();
66
+ }
67
+ this.emit('memoryReleased', memoryUsage);
68
+ }
69
+
70
+ logMemoryUsage(memoryUsage) {
71
+ const timestamp = new Date().toLocaleString("vi-vn", {timeZone: "Asia/Ho_Chi_Minh"});
72
+ const logMessage = `${timestamp} - Memory usage: ${(memoryUsage * 100).toFixed(2)}%`;
73
+
74
+ switch (this.logLevel) {
75
+ case 'debug':
76
+ console.debug(logMessage);
77
+ break;
78
+ case 'info':
79
+ global.Fca.Require.logger.Info(logMessage);
80
+ break;
81
+ case 'warn':
82
+ global.Fca.Require.logger.Normal(logMessage);
83
+ break;
84
+ case 'error':
85
+ global.Fca.Require.logger.Error(logMessage);
86
+ break;
87
+ default:
88
+ global.Fca.Require.logger.Normal(logMessage);
89
+ }
90
+ if (this.allowLog) {
91
+ fs.appendFile(this.logFile, `${logMessage}\n`, (err) => {
92
+ if (err) throw err;
93
+ });
94
+ }
95
+ }
96
+
97
+ onMaxMemory(callback) {
98
+ this.on('memoryMax', callback);
99
+ }
100
+
101
+ addMemoryUsageListener(callback) {
102
+ this.on('memoryWarning', callback);
103
+ this.on('memoryReleased', callback);
104
+ this.on('memoryMax', callback);
105
+ }
106
+
107
+ removeMemoryUsageListener(callback) {
108
+ this.off('memoryWarning', callback);
109
+ this.off('memoryReleased', callback);
110
+ this.off('memoryMax', callback);
111
+ }
112
+
113
+ addThreshold(type, value) {
114
+ if (type === 'warning' || type === 'release' || type === 'max') {
115
+ this.thresholds[type] = value;
116
+ } else {
117
+ throw new Error('Invalid threshold type');
118
+ }
119
+ }
120
+
121
+ removeThreshold(type) {
122
+ if (type === 'warning' || type === 'release' || type === 'max') {
123
+ delete this.thresholds[type];
124
+ } else {
125
+ throw new Error('Invalid threshold type');
126
+ }
127
+ }
128
+
129
+ smartRelease() {
130
+ const memoryUsageHistory = this.memoryUsageHistory.slice(-100);
131
+ const averageUsage = memoryUsageHistory.reduce((sum, usage) => sum + usage, 0) / memoryUsageHistory.length;
132
+ const maxUsage = Math.max(...memoryUsageHistory);
133
+
134
+ if (averageUsage > this.thresholds.release && maxUsage > this.thresholds.max) {
135
+ this.releaseMemory(maxUsage);
136
+ }
137
+ }
138
+
139
+ autoStart(interval) { //1h
140
+ this.stopMemoryManager();
141
+ this.startMemoryManager();
142
+ this.autoStartInterval = setInterval(() => {
143
+ this.stopMemoryManager();
144
+ this.startMemoryManager();
145
+ }, interval);
146
+ }
147
+
148
+ stopMemoryManager() {
149
+ this.stop();
150
+ clearInterval(this.intervalId);
151
+ clearInterval(this.autoStartInterval);
152
+ }
153
+
154
+ startMemoryManager() {
155
+ this.start();
156
+ }
157
+
158
+ }
159
+
160
+ module.exports = MemoryManager;
@@ -0,0 +1,213 @@
1
+ /* eslint-disable no-prototype-builtins */
2
+ /* eslint-disable linebreak-style */
3
+ /**
4
+ const Eval = require('eval');
5
+ const Database = require('../Database');
6
+ global.ws = new Object({
7
+ client: {},
8
+ });
9
+ const All_Session_ID = Database().get('Session_ID') || []; [ { Session_ID: ".", TimeStamp: "" }]
10
+ for (let v of All_Session_ID) {
11
+ if (v.TimeStamp <= Date.now()) {
12
+ const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
13
+ All_Session_ID.splice(index,1);
14
+ }
15
+ else {
16
+ setTimeout(() => {
17
+ const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
18
+ All_Session_ID.splice(index,1);
19
+ }, v.TimeStamp - Date.now());
20
+ }
21
+ }
22
+
23
+ Database().set("Session_ID", All_Session_ID);
24
+
25
+ function generateRandomString() {
26
+ var string = '';
27
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
28
+ for (var i = 0; i < 16; i++) {
29
+ if (i == 4 || i == 8 || i == 12) {
30
+ string += '-';
31
+ }
32
+ var randomIndex = Math.floor(Math.random() * characters.length);
33
+ string += characters.charAt(randomIndex);
34
+ }
35
+ return string;
36
+ }
37
+
38
+ const HowTo = {
39
+ AutoUpdate: "Automatically update if there is a new version. (Restart required)",
40
+ AutoLogin: "Automatically login and retrieve cookies to continue running the bot whenever kicked out of the account. (Restart required)",
41
+ Login2Fa: "Use two-factor authentication code to log in. (Restart required)",
42
+ Uptime: "Help your process to operate for a longer period of time.(Restart required)",
43
+ BroadCast: "Receive messages from the server.(Restart required)",
44
+ EncryptFeature: "Encrypt your account (appstate) to prevent it from being accessed or damaged by others.(Restart required)",
45
+ ResetDataLogin: "Used to reset autologin account and password.(Restart required)",
46
+ DevMode: "Developer mode, insider, testing untested features.(Restart required)",
47
+ AutoInstallNode: "Automatically download NodeJS version as per system's requirement.(Restart required)",
48
+ AntiSendAppState: "Check and prevent sending your account (appstate) via messages.",
49
+ HTML: "Display the website of FCA.(Restart required)",
50
+ Accept: "Is a part of stable_version, turned on to use a stable version without errors! (Restart required)",
51
+ AntiGetThreadInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
52
+ AntiGetUserInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
53
+ Status: "Turn on/off the websocket-extension feature. (Restart required)",
54
+ Language: "Select system language (Restart required)",
55
+ MainName: "Name on the top whenever log data. (Restart required)",
56
+ UserName: "Your name display in Express - HTML. (Restart required)",
57
+ MusicLink: "Your music link. (Restart required)",
58
+ AuthString: "Code to retrieve 2FA authenticator. (Restart required)",
59
+ PreKey: "Obsolete feature.",
60
+ Config: "Feature is delayed.",
61
+ Version: "stable version - Stable_Version Feature. (Restart required)",
62
+ Database_Type: "Type of database. (Restart required)",
63
+ AppState_Path: "Name of the file containing your appstate.",
64
+ AutoRestartMinutes: "Auto-restart after a certain number of minutes. (Restart required)",
65
+ RestartMQTT_Minutes: "Automatically restarting MQTT without restarting the bot helps prevent console hangups. (Restart required)",
66
+ Example: {
67
+ Language: "vi or en",
68
+ AuthString: "Like this SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png",
69
+ Version: "Valid version: https://github.com/KanzuXHorizon/Global_Horizon/blob/main/InstantAction.json",
70
+ Database_Type: "default or json",
71
+ AppState_Path: "fbstate.json, appstate.json,...",
72
+ AutoRestartMinutes: "Number 0 to turn off, Encourage number 60",
73
+ RestartMQTT_Minutes: "Number 0 to turn off, Encourage number 45"
74
+
75
+ }
76
+ };
77
+
78
+ module.exports.connect = function(WebSocket) {
79
+ WebSocket.on('connection', function (Websocket, req) {
80
+ var Ws_Client;
81
+ if (!global.ws.client.hasOwnProperty(req.socket.remoteAddress)) {
82
+ global.ws.client[req.socket.remoteAddress] = { Websocket, Status: false, ResetPassWordTime: 0 };
83
+ Ws_Client = global.ws.client[req.socket.remoteAddress];
84
+ }
85
+ else {
86
+ global.ws.client[req.socket.remoteAddress] = { Websocket, Status: global.ws.client[req.socket.remoteAddress].Status, ResetPassWordTime: global.ws.client[req.socket.remoteAddress].ResetPassWordTime };
87
+ Ws_Client = global.ws.client[req.socket.remoteAddress];
88
+ }
89
+ Ws_Client.Websocket.send(JSON.stringify({ Status: "Username&PassWord"}));
90
+ Ws_Client.Websocket.on('message', function(message) {
91
+ message = JSON.parse(message);
92
+ switch (message.type) {
93
+ case "login": {
94
+ if (!message.username || !message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 1 }));
95
+ const User_UserName = Database().get('Ws_UserName');
96
+ const User_PassWord = Database().get('Ws_PassWord');
97
+ if (message.username != User_UserName || User_PassWord != message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 2}));
98
+ const Format = {
99
+ Session_ID: generateRandomString(),
100
+ TimeStamp: Date.now() + 24 * 60 * 60 * 1000
101
+ };
102
+ All_Session_ID.push(Format);
103
+ Database().set("Session_ID", All_Session_ID);
104
+ global.ws.client[req.socket.remoteAddress].Status = true;
105
+ setTimeout(() => {
106
+ global.ws.client[req.socket.remoteAddress].Status = false;
107
+ }, (Date.now() + 24 * 60 * 60 * 1000) - Date.now());
108
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Session_ID: Format.Session_ID, TimeStamp: Format.TimeStamp }));
109
+ }
110
+ case "check": {
111
+ if (!message.Session_ID || !message.TimeStamp) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 3}));
112
+ const Format = {
113
+ Session_ID: message.Session_ID,
114
+ TimeStamp: message.TimeStamp
115
+ };
116
+ if (Format.TimeStamp <= Date.now()) {
117
+ let index = All_Session_ID.findIndex(i => i.Session_ID == Format.Session_ID);
118
+ All_Session_ID.splice(index,1);
119
+ Database().set("Session_ID", All_Session_ID);
120
+ Ws_Client.Status = false;
121
+ Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 4}));
122
+ return delete global.ws.client[Format.Session_ID];
123
+ }
124
+ if (All_Session_ID.some(i => i.Session_ID == message.Session_ID)) {
125
+ global.ws.client[req.socket.remoteAddress].Status = true;
126
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success" }));
127
+ }
128
+ else {
129
+ global.ws.client[req.socket.remoteAddress].Status = false;
130
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 5 }));
131
+ }
132
+ }
133
+ case "resetPassword": {
134
+ if (!message.Otp || !message.NewPassword) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 7 }));
135
+ if (global.ws.client[req.socket.remoteAddress].ResetPassWordTime == 3) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 9 }));
136
+ const speakeasy = require('speakeasy');
137
+ const secret = Database().get('Ws_2Fa');
138
+ if (message.Otp != speakeasy.totp({
139
+ secret: secret,
140
+ encoding: 'base32'
141
+ })) {
142
+ global.ws.client[req.socket.remoteAddress].ResetPassWordTime += 1;
143
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 8 }));
144
+ }
145
+ else {
146
+ Database().set('Ws_PassWord', message.NewPassword);
147
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: 'Success' }));
148
+ }
149
+ }
150
+ default: {
151
+ if (Ws_Client.Status != true) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 6 }));
152
+ switch (message.type) {
153
+ case "Command": {
154
+ if (message.Data == "Stop") {
155
+ return process.exit(0);
156
+ }
157
+ else Eval(message.Data, {} ,true);
158
+ }
159
+ break;
160
+ case "ChangeAppState": {
161
+ try {
162
+ const AppState = JSON.stringify(JSON.parse(message.Data), null ,2);
163
+ require('fs').writeFileSync(process.cwd() + `/${global.Fca.Require.FastConfig.Websocket_Extension.AppState_Path}`, AppState, 'utf-8');
164
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: 0 }));
165
+ }
166
+ catch (e) {
167
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: e }));
168
+ }
169
+ }
170
+ case "GetDocument": {
171
+
172
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: HowTo }));
173
+ }
174
+ case "getFastConfig": {
175
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: global.Fca.Require.FastConfig }));
176
+ }
177
+ case "ping": {
178
+ return Ws_Client.Websocket.send(JSON.stringify({ Status: "Pong" }));
179
+ }
180
+ case "FastConfig_Change": {
181
+ const FastConfig_Path = require(process.cwd() + "/FastConfigFca.json");
182
+ const FastConfig_Global = global.Fca.Require.FastConfig;
183
+ const SetConfig = function(Name, Value, Path, Main_Path) {
184
+ try {
185
+ if (Path && Main_Path) {
186
+ FastConfig_Path[Main_Path][Name] = Value;
187
+ (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig = FastConfig_Path : '';
188
+ }
189
+ else {
190
+ FastConfig_Path[Name] = Value;
191
+ (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig[Name] = Value : '';
192
+ }
193
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Path, null, "\t"));
194
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: `Success ${ (HowTo[Name]).includes('(Restart required)') == true ? 'RestartRequired' : ''}` }));
195
+ }
196
+ catch (e) {
197
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Global, null, "\t"));
198
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: e}));
199
+ }
200
+ };
201
+ return SetConfig(message.Data.Name, message.Data.Value, message.Data.Path, message.Data.Main_Path);
202
+ }
203
+ case "All_logs": {
204
+ return Ws_Client.Websocket.send(JSON.stringify({ Type: "Console", Data: console.history.join(" <br> ")}));
205
+ }
206
+ }
207
+ }
208
+ }
209
+ });
210
+ });
211
+ return { Client: global.ws.client, WSS: WebSocket };
212
+ };
213
+ */
Binary file
@@ -0,0 +1,28 @@
1
+ const MemoryManager = require('./Release_Memory');
2
+ const path = require('path');
3
+
4
+ // Tạo một đối tượng MemoryManager với các tùy chọn cấu hình tối ưu
5
+ const memoryManager = new MemoryManager({
6
+ warningThreshold: 0.6, // Ngưỡng cảnh báo sử dụng bộ nhớ (60%)
7
+ releaseThreshold: 0.7, // Ngưỡng giải phóng bộ nhớ (70%)
8
+ maxThreshold: 0.8, // Ngưỡng tối đa sử dụng bộ nhớ (80%)
9
+ interval: 30000, // Khoảng thời gian kiểm tra bộ nhớ (30 giây)
10
+ logLevel: 'warn', // Chỉ ghi nhật ký khi có cảnh báo hoặc lỗi
11
+ logFile: path.join(__dirname, 'memory.log'), // Tệp nhật ký
12
+ smartReleaseEnabled: true, // Bật tính năng giải phóng bộ nhớ thông minh
13
+ });
14
+
15
+ memoryManager.addMemoryUsageListener((memoryUsage) => {
16
+ console.log(`Memory released: ${(memoryUsage * 100).toFixed(2)}%`);
17
+ });
18
+
19
+
20
+ // Bắt đầu quá trình quản lý bộ nhớ tự động
21
+ memoryManager.autoStart(3600000); // 1 giờ
22
+
23
+
24
+ // Lưu trữ dữ liệu quan trọng trong WeakMap
25
+ const importantData = { sensitive: 'data' };
26
+ memoryManager.weakRefs.set('aaaaaaaaa', importantData);
27
+
28
+ console.log(memoryManager.weakRefs.get('aaaaaaaaa'))
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Credit: @chronosis | Github: https://github.com/chronosis/uuid-apikey/
3
+ * Description: Update Package to resolve Deprecated from package "uuid"
4
+ */
5
+ // index.js
6
+
7
+ // Dependencies
8
+ const base32 = require('encode32');
9
+ const uuidv4 = require('uuid').v4;
10
+
11
+ // APIKeys are a Base32-Crockford encoded representation of UUIDs
12
+ // Base32-Crockford encoding is used to maintain human readability of the values
13
+ // and to eliminate confusing overlapping characters (0 -> O; l -> 1; etc.)
14
+ class UUIDAPIKey {
15
+ constructor() {
16
+ this.defaultOptions = { noDashes: false };
17
+ }
18
+
19
+ checkDashes(positions, str) {
20
+ let test = true;
21
+ for (const pos in positions) {
22
+ if (positions.hasOwnProperty(pos)) {
23
+ const chr = str.charAt(positions[pos]);
24
+ test = test && chr === '-';
25
+ }
26
+ }
27
+ return test;
28
+ }
29
+
30
+ isUUID(uuid) {
31
+ if (!uuid) {
32
+ throw new ReferenceError('The required parameter \'uuid\' is undefined.');
33
+ }
34
+ const uuidCheck = this.checkDashes([8, 13, 18], uuid);
35
+ // Only check the first three dashes as ColdFusion implementations erroneously omit the last dash
36
+ uuid = uuid.replace(/-/g, '');
37
+ const re = /[0-9A-Fa-f]*/g;
38
+ return uuidCheck && uuid.length === 32 && re.test(uuid);
39
+ }
40
+
41
+ isAPIKey(apiKey) {
42
+ if (!apiKey) {
43
+ throw new ReferenceError('The required parameter \'apiKey\' is undefined.');
44
+ }
45
+ apiKey = apiKey.toUpperCase().replace(/-/g, '');
46
+ const re = /[0-9A-Z]*/g;
47
+ return apiKey.length === 28 && re.test(apiKey);
48
+ }
49
+
50
+ toAPIKey(uuid, options) {
51
+ if (!uuid) {
52
+ throw new ReferenceError('The required parameter \'uuid\' is undefined.');
53
+ }
54
+ options = options || this.defaultOptions;
55
+ if (this.isUUID(uuid)) {
56
+ uuid = uuid.replace(/-/g, '');
57
+ const s1 = uuid.substr(0, 8);
58
+ const s2 = uuid.substr(8, 8);
59
+ const s3 = uuid.substr(16, 8);
60
+ const s4 = uuid.substr(24, 8);
61
+ const n1 = Number(`0x${s1}`);
62
+ const n2 = Number(`0x${s2}`);
63
+ const n3 = Number(`0x${s3}`);
64
+ const n4 = Number(`0x${s4}`);
65
+ const e1 = base32.encode32(n1);
66
+ const e2 = base32.encode32(n2);
67
+ const e3 = base32.encode32(n3);
68
+ const e4 = base32.encode32(n4);
69
+ if (options.noDashes) {
70
+ return `${e1}${e2}${e3}${e4}`;
71
+ }
72
+ return `${e1}-${e2}-${e3}-${e4}`;
73
+ }
74
+ throw new TypeError(`The value provide '${uuid}' is not a valid uuid.`);
75
+ }
76
+
77
+ toUUID(apiKey) {
78
+ if (!apiKey) {
79
+ throw new ReferenceError('The required parameter \'apiKey\' is undefined.');
80
+ }
81
+ if (this.isAPIKey(apiKey)) {
82
+ apiKey = apiKey.replace(/-/g, '');
83
+ const e1 = apiKey.substr(0, 7);
84
+ const e2 = apiKey.substr(7, 7);
85
+ const e3 = apiKey.substr(14, 7);
86
+ const e4 = apiKey.substr(21, 7);
87
+ const n1 = base32.decode32(e1);
88
+ const n2 = base32.decode32(e2);
89
+ const n3 = base32.decode32(e3);
90
+ const n4 = base32.decode32(e4);
91
+ const s1 = n1.toString(16).padStart(8, '0');
92
+ const s2 = n2.toString(16).padStart(8, '0');
93
+ const s3 = n3.toString(16).padStart(8, '0');
94
+ const s4 = n4.toString(16).padStart(8, '0');
95
+ const s2a = s2.substr(0, 4);
96
+ const s2b = s2.substr(4, 4);
97
+ const s3a = s3.substr(0, 4);
98
+ const s3b = s3.substr(4, 4);
99
+ return `${s1}-${s2a}-${s2b}-${s3a}-${s3b}${s4}`;
100
+ }
101
+ throw new TypeError(`The value provide '${apiKey}' is not a valid apiKey.`);
102
+ }
103
+
104
+ check(apiKey, uuid) {
105
+ if (!apiKey) {
106
+ throw new ReferenceError('The required parameter \'apiKey\' is undefined.');
107
+ }
108
+ if (!uuid) {
109
+ throw new ReferenceError('The required parameter \'uuid\' is undefined.');
110
+ }
111
+ const apiTest = this.isAPIKey(apiKey.toUpperCase());
112
+ const uuidTest = this.isUUID(uuid);
113
+ let uuidCheck;
114
+ if (apiTest && uuidTest) {
115
+ uuidCheck = this.toUUID(apiKey);
116
+ return uuid === uuidCheck;
117
+ }
118
+ let errMsg = '';
119
+ if (!apiTest) {
120
+ errMsg += `The value provide '${apiKey}' is not a valid apiKey. `;
121
+ }
122
+ if (!uuidTest) {
123
+ errMsg += `The value provide '${uuid}' is not a valid uuid. `;
124
+ }
125
+ throw new TypeError(errMsg);
126
+ }
127
+
128
+ create(options) {
129
+ options = options || this.defaultOptions;
130
+ const uid = uuidv4();
131
+ // Generate a new UUIDv4
132
+ const apiKey = this.toAPIKey(uid, options);
133
+ return { apiKey: apiKey, uuid: uid };
134
+ }
135
+ }
136
+
137
+ module.exports = new UUIDAPIKey();
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ var database = require('../Extra/Database');
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function (args,callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+ if (database(true).get('agreement') == true) {
22
+ callback(null, "Accecpt");
23
+ }
24
+ else {
25
+ database(true).set('agreement', true);
26
+ var Form = "=== Horizon end-user license agreement ===\n\n Free to use and edited ✨";
27
+ callback(null, Form);
28
+ }
29
+ return returnPromise;
30
+ };
31
+ };