@@ -2,139 +2,138 @@ const https = require('https');
2
2
const fs = require ( 'fs' ) . promises ;
3
3
const { R_OK } = require ( 'fs' ) . constants ;
4
4
const vm = require ( 'vm' ) ;
5
+ const UA = require ( './USER_AGENTS.js' ) . USER_AGENT ;
5
6
6
7
const URL = 'https://wbbny.m.jd.com/babelDiy/Zeus/2rtpffK8wqNyPBH6wyUDuBKoAbCt/index.html' ;
7
8
// const REG_MODULE = /(\d+)\:function\(.*(?=smashUtils\.get_risk_result)/gm;
8
9
const SYNTAX_MODULE = '!function(n){var r={};function o(e){if(r[e])' ;
9
10
const REG_SCRIPT = / < s c r i p t t y p e = " t e x t \/ j a v a s c r i p t " s r c = " ( [ ^ > < ] + \/ ( a p p \. \w + \. j s ) ) \" > / gm;
10
- const REG_ENTRY = / ( _ _ w e b p a c k _ r e q u i r e _ _ \( _ _ w e b p a c k _ r e q u i r e _ _ .s = ) ( \d + ) (? = \) } ) / ;
11
- const needModuleId = 355
11
+ const REG_ENTRY = / ( _ _ w e b p a c k _ r e q u i r e _ _ \( _ _ w e b p a c k _ r e q u i r e _ _ \ .s = ) ( \d + ) (? = \) } ) / ;
12
+ const needModuleId = 356
12
13
const DATA = { appid :'50085' , sceneid :'OY217hPageh5' } ;
13
14
let smashUtils ;
14
15
15
- class MovementFaker {
16
- constructor ( cookie ) {
17
- // this.secretp = secretp;
18
- this . cookie = cookie ;
19
- this . ua = require ( './USER_AGENTS.js' ) . USER_AGENT ;
20
- }
16
+ class MoveMentFaker {
17
+ constructor ( cookie ) {
18
+ // this.secretp = secretp;
19
+ this . cookie = cookie ;
20
+ }
21
21
22
- async run ( ) {
23
- if ( ! smashUtils ) {
24
- await this . init ( ) ;
25
- }
26
-
27
- var t = Math . floor ( 1e7 + 9e7 * Math . random ( ) ) . toString ( ) ;
28
- var e = smashUtils . get_risk_result ( {
29
- id : t ,
30
- data : {
31
- random : t
32
- }
33
- } ) . log ;
34
- var o = JSON . stringify ( {
35
- extraData : {
36
- log : e || - 1 ,
37
- // log: encodeURIComponent(e),
38
- sceneid : DATA . sceneid ,
39
- } ,
40
- // secretp: this.secretp,
41
- random : t
42
- } )
43
-
44
- // console.log(o);
45
- return o ;
22
+ async run ( ) {
23
+ if ( ! smashUtils ) {
24
+ await this . init ( ) ;
46
25
}
47
26
48
- async init ( ) {
49
- try {
50
- console . time ( 'MovementFaker' ) ;
51
- process . chdir ( __dirname ) ;
52
- const html = await MovementFaker . httpGet ( URL ) ;
53
- const script = REG_SCRIPT . exec ( html ) ;
54
-
55
- if ( script ) {
56
- const [ , scriptUrl , filename ] = script ;
57
- const jsContent = await this . getJSContent ( filename , scriptUrl ) ;
58
- const fnMock = new Function ;
59
- const ctx = {
60
- window : { addEventListener : fnMock } ,
61
- document : {
62
- addEventListener : fnMock ,
63
- removeEventListener : fnMock ,
64
- cookie : this . cookie ,
65
- } ,
66
- navigator : { userAgent : this . ua } ,
67
- } ;
68
-
69
- vm . createContext ( ctx ) ;
70
- vm . runInContext ( jsContent , ctx ) ;
71
- smashUtils = ctx . window . smashUtils ;
72
- smashUtils . init ( DATA ) ;
73
-
74
- // console.log(ctx);
75
- }
76
-
77
- // console.log(html);
78
- // console.log(script[1],script[2]);
79
- console . timeEnd ( 'MovementFaker' ) ;
27
+ var t = Math . floor ( 1e7 + 9e7 * Math . random ( ) ) . toString ( ) ;
28
+ var e = smashUtils . get_risk_result ( {
29
+ id : t ,
30
+ data : {
31
+ random : t
32
+ }
33
+ } ) . log ;
34
+ var o = JSON . stringify ( {
35
+ extraData : {
36
+ log : e || - 1 ,
37
+ // log: encodeURIComponent(e),
38
+ sceneid : DATA . sceneid ,
39
+ } ,
40
+ // secretp: this.secretp,
41
+ random : t
42
+ } )
43
+
44
+ // console.log(o);
45
+ return o ;
46
+ }
47
+
48
+ async init ( ) {
49
+ try {
50
+ // console.time('MoveMentFaker');
51
+ process . chdir ( __dirname ) ;
52
+ const html = await MoveMentFaker . httpGet ( URL ) ;
53
+ const script = REG_SCRIPT . exec ( html ) ;
54
+
55
+ if ( script ) {
56
+ const [ , scriptUrl , filename ] = script ;
57
+ const jsContent = await this . getJSContent ( filename , scriptUrl ) ;
58
+ const fnMock = new Function ;
59
+ const ctx = {
60
+ window : { addEventListener : fnMock } ,
61
+ document : {
62
+ addEventListener : fnMock ,
63
+ removeEventListener : fnMock ,
64
+ cookie : this . cookie
65
+ } ,
66
+ navigator : { userAgent : UA }
67
+ } ;
68
+
69
+ vm . createContext ( ctx ) ;
70
+ vm . runInContext ( jsContent , ctx ) ;
71
+ smashUtils = ctx . window . smashUtils ;
72
+ smashUtils . init ( DATA ) ;
73
+
74
+ // console.log(ctx);
75
+ }
76
+
77
+ // console.log(html);
78
+ // console.log(script[1],script[2]);
79
+ // console.timeEnd('MoveMentFaker');
80
80
} catch ( e ) {
81
- console . log ( e )
82
- }
81
+ console . log ( e )
83
82
}
83
+ }
84
+
85
+ async getJSContent ( cacheKey , url ) {
86
+ try {
87
+ await fs . access ( cacheKey , R_OK ) ;
88
+ const rawFile = await fs . readFile ( cacheKey , { encoding : 'utf8' } ) ;
84
89
85
- async getJSContent ( cacheKey , url ) {
86
- try {
87
- await fs . access ( cacheKey , R_OK ) ;
88
- const rawFile = await fs . readFile ( cacheKey , { encoding : 'utf8' } ) ;
89
-
90
- return rawFile ;
91
- } catch ( e ) {
92
- let jsContent = await MovementFaker . httpGet ( url ) ;
93
- const moduleIndex = jsContent . indexOf ( SYNTAX_MODULE , 1 ) ;
94
- const findEntry = REG_ENTRY . test ( jsContent ) ;
95
- console . log ( jsContent )
96
- if ( ! ( moduleIndex && findEntry ) ) {
97
- throw new Error ( 'Module not found.' ) ;
98
- }
99
- // const needModuleId = jsContent.substring(moduleIndex-20, moduleIndex).match(/(\d+):function/)[1]
100
- jsContent = jsContent . replace ( REG_ENTRY , `$1${ needModuleId } ` ) ;
101
- fs . writeFile ( cacheKey , jsContent ) ;
102
- return jsContent ;
103
-
104
- REG_ENTRY . lastIndex = 0 ;
105
- const entry = REG_ENTRY . exec ( jsContent ) ;
106
-
107
- console . log ( moduleIndex , needModuleId ) ;
108
- console . log ( entry [ 1 ] , entry [ 2 ] ) ;
109
- }
90
+ return rawFile ;
91
+ } catch ( e ) {
92
+ let jsContent = await MoveMentFaker . httpGet ( url ) ;
93
+ const moduleIndex = jsContent . indexOf ( SYNTAX_MODULE , 1 ) ;
94
+ const findEntry = REG_ENTRY . test ( jsContent ) ;
95
+ if ( ! ( moduleIndex && findEntry ) ) {
96
+ throw new Error ( 'Module not found.' ) ;
97
+ }
98
+ // const needModuleId = jsContent.substring(moduleIndex-20, moduleIndex).match(/(\d+):function/)[1]
99
+ jsContent = jsContent . replace ( REG_ENTRY , `$1${ needModuleId } ` ) ;
100
+ fs . writeFile ( cacheKey , jsContent ) ;
101
+ return jsContent ;
102
+
103
+ REG_ENTRY . lastIndex = 0 ;
104
+ const entry = REG_ENTRY . exec ( jsContent ) ;
105
+
106
+ console . log ( moduleIndex , needModuleId ) ;
107
+ console . log ( entry [ 1 ] , entry [ 2 ] ) ;
110
108
}
109
+ }
111
110
112
- static httpGet ( url ) {
113
- return new Promise ( ( resolve , reject ) => {
114
- const protocol = url . indexOf ( 'http' ) !== 0 ? 'https:' : '' ;
115
- const req = https . get ( protocol + url , ( res ) => {
116
- res . setEncoding ( 'utf-8' ) ;
111
+ static httpGet ( url ) {
112
+ return new Promise ( ( resolve , reject ) => {
113
+ const protocol = url . indexOf ( 'http' ) !== 0 ? 'https:' : '' ;
114
+ const req = https . get ( protocol + url , ( res ) => {
115
+ res . setEncoding ( 'utf-8' ) ;
117
116
118
- let rawData = '' ;
117
+ let rawData = '' ;
119
118
120
- res . on ( 'error' , reject ) ;
121
- res . on ( 'data' , chunk => rawData += chunk ) ;
122
- res . on ( 'end' , ( ) => resolve ( rawData ) ) ;
123
- } ) ;
119
+ res . on ( 'error' , reject ) ;
120
+ res . on ( 'data' , chunk => rawData += chunk ) ;
121
+ res . on ( 'end' , ( ) => resolve ( rawData ) ) ;
122
+ } ) ;
124
123
125
- req . on ( 'error' , reject ) ;
126
- req . end ( ) ;
127
- } ) ;
128
- }
124
+ req . on ( 'error' , reject ) ;
125
+ req . end ( ) ;
126
+ } ) ;
127
+ }
129
128
}
130
129
131
130
async function getBody ( $ ) {
132
- const zf = new MovementFaker ( $ . cookie ) ;
133
- // const zf = new MovementFaker ($.secretp, $.cookie);
134
- const ss = await zf . run ( ) ;
131
+ const zf = new MoveMentFaker ( $ . cookie ) ;
132
+ // const zf = new MoveMentFaker ($.secretp, $.cookie);
133
+ const ss = await zf . run ( ) ;
135
134
136
- return ss ;
135
+ return ss ;
137
136
}
138
137
139
- MovementFaker . getBody = getBody ;
140
- module . exports = MovementFaker ;
138
+ MoveMentFaker . getBody = getBody ;
139
+ module . exports = MoveMentFaker ;
0 commit comments