lintonxue00 commited on
Commit
75eb7e2
1 Parent(s): 835aa42

Upload device.js

Browse files
Files changed (1) hide show
  1. 不知道/回收站/1/device.js +320 -0
不知道/回收站/1/device.js ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getApkInfo = exports.Platform = exports.Device = exports.generateFullDevice = exports.generateShortDevice = void 0;
7
+ const crypto_1 = require("crypto");
8
+ const constants_1 = require("./constants");
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const algo_1 = require("./algo");
11
+ function generateImei() {
12
+ let imei = `86${(0, constants_1.randomString)(12, '0123456789')}`;
13
+ function calcSP(imei) {
14
+ let sum = 0;
15
+ for (let i = 0; i < imei.length; ++i) {
16
+ if (i % 2) {
17
+ let j = parseInt(imei[i]) * 2;
18
+ sum += j % 10 + Math.floor(j / 10);
19
+ }
20
+ else {
21
+ sum += parseInt(imei[i]);
22
+ }
23
+ }
24
+ return (100 - sum) % 10;
25
+ }
26
+ return imei + calcSP(imei);
27
+ }
28
+ /** 生成短设备信息 */
29
+ function generateShortDevice() {
30
+ const randstr = (length, num = false) => {
31
+ const map = num ? '0123456789' : '0123456789abcdef';
32
+ return (0, constants_1.randomString)(length, map);
33
+ };
34
+ return {
35
+ "--begin--": "该设备为随机生成,丢失后不能得到原先配置",
36
+ product: `ILPP-${randstr(5).toUpperCase()}`,
37
+ device: `${randstr(5).toUpperCase()}`,
38
+ board: `${randstr(5).toUpperCase()}`,
39
+ brand: `${randstr(4).toUpperCase()}`,
40
+ model: `ILPP ${randstr(4).toUpperCase()}`,
41
+ wifi_ssid: `HUAWEI-${randstr(7)}`,
42
+ bootloader: `U-boot`,
43
+ android_id: `IL.${randstr(7, true)}.${randstr(4, true)}`,
44
+ boot_id: `${randstr(8)}-${randstr(4)}-${randstr(4)}-${randstr(4)}-${randstr(12)}`,
45
+ proc_version: `Linux version 5.10.101-android12-${randstr(8)}`,
46
+ mac_address: `2D:${randstr(2).toUpperCase()}:${randstr(2).toUpperCase()}:${randstr(2).toUpperCase()}:${randstr(2).toUpperCase()}:${randstr(2).toUpperCase()}`,
47
+ ip_address: `192.168.${randstr(2, true)}.${randstr(2, true)}`,
48
+ imei: `${generateImei()}`,
49
+ incremental: `${randstr(10).toUpperCase()}`,
50
+ "--end--": "修改后可能需要重新验证设备。"
51
+ };
52
+ }
53
+ exports.generateShortDevice = generateShortDevice;
54
+ /** 生成完整设备信息 */
55
+ function generateFullDevice(apk, d) {
56
+ if (!d)
57
+ d = generateShortDevice();
58
+ return {
59
+ display: d.android_id,
60
+ product: d.product,
61
+ device: d.device,
62
+ board: d.board,
63
+ brand: d.brand,
64
+ model: d.model,
65
+ bootloader: d.bootloader,
66
+ fingerprint: `${d.brand}/${d.product}/${d.device}:10/${d.android_id}/${d.incremental}:user/release-keys`,
67
+ boot_id: d.boot_id,
68
+ proc_version: d.proc_version,
69
+ baseband: "",
70
+ sim: "T-Mobile",
71
+ os_type: "android",
72
+ mac_address: d.mac_address,
73
+ ip_address: d.ip_address,
74
+ wifi_bssid: d.mac_address,
75
+ wifi_ssid: d.wifi_ssid,
76
+ imei: d.imei,
77
+ android_id: d.android_id,
78
+ apn: "wifi",
79
+ version: {
80
+ incremental: d.incremental,
81
+ release: "10",
82
+ codename: "REL",
83
+ sdk: 29,
84
+ },
85
+ imsi: (0, crypto_1.randomBytes)(16),
86
+ guid: (0, constants_1.md5)(Buffer.concat([Buffer.from(d.imei), Buffer.from(d.mac_address)])),
87
+ };
88
+ }
89
+ exports.generateFullDevice = generateFullDevice;
90
+ class Device {
91
+ constructor(apk, d) {
92
+ this.apk = apk;
93
+ this.secret = 'ZdJqM15EeO2zWc08';
94
+ this.publicKey = `-----BEGIN PUBLIC KEY-----
95
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEIxgwoutfwoJxcGQeedgP7FG9
96
+ qaIuS0qzfR8gWkrkTZKM2iWHn2ajQpBRZjMSoSf6+KJGvar2ORhBfpDXyVtZCKpq
97
+ LQ+FLkpncClKVIrBwv6PHyUvuCb0rIarmgDnzkfQAqVufEtR64iazGDKatvJ9y6B
98
+ 9NMbHddGSAUmRTCrHQIDAQAB
99
+ -----END PUBLIC KEY-----`;
100
+ if (!d)
101
+ d = generateShortDevice();
102
+ Object.assign(this, generateFullDevice(apk, d));
103
+ }
104
+ async getQIMEI() {
105
+ if (this.apk.app_key === "") {
106
+ return;
107
+ }
108
+ const k = (0, constants_1.randomString)(16);
109
+ const key = (0, algo_1.encryptPKCS1)(this.publicKey, k);
110
+ const time = Date.now();
111
+ const nonce = (0, constants_1.randomString)(16);
112
+ const payload = this.genRandomPayloadByDevice();
113
+ const params = (0, algo_1.aesEncrypt)(JSON.stringify(payload), k).toString('base64');
114
+ try {
115
+ const { data } = await axios_1.default.post("https://snowflake.qq.com/ola/android", {
116
+ key,
117
+ params,
118
+ time, nonce,
119
+ sign: (0, constants_1.md5)(key + params + time + nonce + this.secret).toString("hex"),
120
+ extra: ''
121
+ }, {
122
+ headers: {
123
+ 'User-Agent': `Dalvik/2.1.0 (Linux; U; Android ${this.version.release}; PCRT00 Build/N2G48H)`,
124
+ 'Content-Type': "application/json"
125
+ }
126
+ });
127
+ if (data?.code !== 0) {
128
+ return;
129
+ }
130
+ const { q16, q36 } = JSON.parse((0, algo_1.aesDecrypt)(data.data, k));
131
+ this.qImei16 = q16;
132
+ this.qImei36 = q36;
133
+ }
134
+ catch {
135
+ }
136
+ }
137
+ genRandomPayloadByDevice() {
138
+ const fixedRand = (max = 1, min = 0) => {
139
+ if (max < min)
140
+ [max, min] = [min, max];
141
+ const diff = max - min;
142
+ return Math.floor(Math.random() * diff) + min;
143
+ };
144
+ const reserved = {
145
+ "harmony": "0",
146
+ "clone": Math.random() > 0.5 ? "1" : "0",
147
+ "containe": "",
148
+ "oz": "",
149
+ "oo": "",
150
+ "kelong": Math.random() > 0.5 ? "1" : "0",
151
+ "uptimes": (0, constants_1.formatTime)(new Date()),
152
+ "multiUser": Math.random() > 0.5 ? "1" : "0",
153
+ "bod": this.board,
154
+ "brd": this.brand,
155
+ "dv": this.device,
156
+ "firstLevel": "",
157
+ "manufact": this.brand,
158
+ "name": this.model,
159
+ "host": "se.infra",
160
+ "kernel": this.fingerprint
161
+ };
162
+ const timestamp = Date.now();
163
+ this.mtime = this.mtime || Date.now();
164
+ const mtime1 = new Date(this.mtime || Date.now());
165
+ const dateFormat = (fmt, time = Date.now()) => (0, constants_1.formatTime)(time, fmt);
166
+ const mtimeStr1 = dateFormat("YYYY-mm-ddHHMMSS", mtime1) + "." + this.imei.slice(2, 11);
167
+ const mtime2 = new Date(this.mtime - parseInt(this.imei.slice(2, 4)));
168
+ const mtimeStr2 = dateFormat("YYYY-mm-ddHHMMSS", mtime2) + "." + this.imei.slice(5, 14);
169
+ let beaconIdArr = [
170
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
171
+ mtimeStr1,
172
+ '0000000000000000',
173
+ (0, constants_1.md5)(this.android_id + this.imei).toString("hex").slice(0, 16),
174
+ ...new Array(4).fill(false).map((_) => fixedRand(10000000, 1000000)),
175
+ this.boot_id,
176
+ '1',
177
+ fixedRand(5, 0),
178
+ fixedRand(5, 0),
179
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
180
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
181
+ fixedRand(5, 0),
182
+ fixedRand(100, 10),
183
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
184
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
185
+ fixedRand(50000, 10000),
186
+ fixedRand(100, 10),
187
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
188
+ mtimeStr2,
189
+ fixedRand(10000, 1000),
190
+ fixedRand(5, 0),
191
+ `${dateFormat("YYYY-mm-ddHHMMSS")}.${String(((10 + parseInt(this.imei.slice(5, 7))) % 100)).padStart(2, "0")}0000000`,
192
+ `${dateFormat("YYYY-mm-ddHHMMSS")}.${String(((11 + parseInt(this.imei.slice(5, 7))) % 100)).padStart(2, "0")}0000000`,
193
+ fixedRand(10000, 1000),
194
+ fixedRand(100, 10),
195
+ `${dateFormat("YYYY-mm-ddHHMMSS")}.${String(((11 + parseInt(this.imei.slice(5, 7))) % 100)).padStart(2, "0")}0000000`,
196
+ `${dateFormat("YYYY-mm-ddHHMMSS")}.${String(((11 + parseInt(this.imei.slice(5, 7))) % 100)).padStart(2, "0")}0000000`,
197
+ fixedRand(10000, 1000),
198
+ fixedRand(5, 0),
199
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
200
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
201
+ fixedRand(5, 0),
202
+ fixedRand(100, 10),
203
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
204
+ `${(0, constants_1.formatTime)(new Date(timestamp + fixedRand(60, 0)))}.${String(fixedRand(99, 0)).padStart(2, '0')}0000000`,
205
+ fixedRand(5, 0),
206
+ fixedRand(5, 0),
207
+ ].map((str, idx) => `k${idx + 1}:${str}`);
208
+ return {
209
+ "androidId": this.android_id,
210
+ "platformId": 1,
211
+ "appKey": this.apk.app_key,
212
+ "appVersion": this.apk.version,
213
+ "beaconIdSrc": beaconIdArr.join(';'),
214
+ "brand": this.brand,
215
+ "channelId": "2017",
216
+ "cid": "",
217
+ "imei": this.imei,
218
+ "imsi": this.imsi.toString("hex"),
219
+ "mac": this.mac_address,
220
+ "model": this.model,
221
+ "networkType": "unknown",
222
+ "oaid": "",
223
+ "osVersion": `Android ${this.version.release},level ${this.version.sdk}`,
224
+ "qimei": "",
225
+ "qimei36": "",
226
+ "sdkVersion": "1.2.13.6",
227
+ "targetSdkVersion": "26",
228
+ "audit": "",
229
+ "userId": "{}",
230
+ "packageId": this.apk.id,
231
+ "deviceType": this.display,
232
+ "sdkName": "",
233
+ "reserved": JSON.stringify(reserved),
234
+ };
235
+ }
236
+ }
237
+ exports.Device = Device;
238
+ /** 支持的登录设备平台 */
239
+ var Platform;
240
+ (function (Platform) {
241
+ Platform[Platform["Android"] = 1] = "Android";
242
+ Platform[Platform["aPad"] = 2] = "aPad";
243
+ Platform[Platform["Watch"] = 3] = "Watch";
244
+ Platform[Platform["iMac"] = 4] = "iMac";
245
+ Platform[Platform["iPad"] = 5] = "iPad";
246
+ })(Platform = exports.Platform || (exports.Platform = {}));
247
+ const mobile = {
248
+ id: "com.tencent.mobileqq",
249
+ app_key: '0S200MNJT807V3GE',
250
+ name: "A8.9.50.f5a7d351",
251
+ version: "8.9.50.10650",
252
+ ver: "8.9.50",
253
+ sign: Buffer.from([0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D]),
254
+ buildtime: 1676531414,
255
+ appid: 16,
256
+ subid: 537118044,
257
+ bitmap: 150470524,
258
+ main_sig_map: 16724722,
259
+ sub_sig_map: 0x10400,
260
+ sdkver: "6.0.0.2535",
261
+ display: "Android",
262
+ ssover: 19,
263
+ };
264
+ const watch = {
265
+ id: "com.tencent.qqlite",
266
+ app_key: '0S200MNJT807V3GE',
267
+ name: "A2.0.8",
268
+ version: "2.0.8",
269
+ ver: "2.0.8",
270
+ sign: Buffer.from([166, 183, 69, 191, 36, 162, 194, 119, 82, 119, 22, 246, 243, 110, 182, 141]),
271
+ buildtime: 1559564731,
272
+ appid: 16,
273
+ subid: 537118044,
274
+ bitmap: 16252796,
275
+ main_sig_map: 16724722,
276
+ sub_sig_map: 0x10400,
277
+ sdkver: "6.0.0.2365",
278
+ display: "Watch",
279
+ ssover: 5
280
+ };
281
+ const hd = {
282
+ id: "com.tencent.minihd.qq",
283
+ app_key: '0S200MNJT807V3GE',
284
+ name: "A5.9.3.3468",
285
+ version: "5.9.3.3468",
286
+ ver: "5.9.3",
287
+ sign: Buffer.from([0xAA, 0x39, 0x78, 0xF4, 0x1F, 0xD9, 0x6F, 0xF9, 0x91, 0x4A, 0x66, 0x9E, 0x18, 0x64, 0x74, 0xC7]),
288
+ buildtime: 1637427966,
289
+ appid: 16,
290
+ subid: 537118044,
291
+ bitmap: 150470524,
292
+ main_sig_map: 1970400,
293
+ sub_sig_map: 66560,
294
+ sdkver: "6.0.0.2433",
295
+ display: "iMac",
296
+ ssover: 12
297
+ };
298
+ const apklist = {
299
+ [Platform.Android]: mobile,
300
+ [Platform.aPad]: {
301
+ ...mobile,
302
+ subid: 537118044,
303
+ display: 'aPad'
304
+ },
305
+ [Platform.Watch]: watch,
306
+ [Platform.iMac]: { ...hd },
307
+ [Platform.iPad]: {
308
+ ...mobile,
309
+ subid: 537118044,
310
+ sign: hd.sign,
311
+ name: 'A8.9.50.611',
312
+ version: 'A8.9.50.611',
313
+ sdkver: '6.0.0.2535',
314
+ display: 'iPad'
315
+ },
316
+ };
317
+ function getApkInfo(p) {
318
+ return apklist[p] || apklist[Platform.Android];
319
+ }
320
+ exports.getApkInfo = getApkInfo;