mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix: use sandybox for webcrack
This commit is contained in:
1 parent
2c56bb3e59
commit
982ef5f465
3 files changed
+29
-2
No files matched your search
@@ -203,6 +203,7 @@
|
||||
"pythonstack.js": "^1.0.2",
|
||||
"qpdf-wasm-esm-embedded": "^1.1.1",
|
||||
"qrcode": "^1.5.1",
|
||||
"sandybox": "^1.1.2",
|
||||
"qrcode-parser": "^2.1.3",
|
||||
"qrcode-terminal-nooctal": "^0.12.1",
|
||||
"randexp": "^0.5.3",
|
||||
|
||||
Generated
+8
-1
@@ -524,6 +524,9 @@ dependencies:
|
||||
safe-license-list:
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
sandybox:
|
||||
specifier: ^1.1.2
|
||||
version: 1.1.2
|
||||
sanitize-html:
|
||||
specifier: ^2.13.1
|
||||
version: 2.14.0
|
||||
@@ -2403,7 +2406,7 @@ packages:
|
||||
'@babel/helper-split-export-declaration': 7.22.6
|
||||
'@babel/parser': 7.22.10
|
||||
'@babel/types': 7.22.10
|
||||
debug: 4.3.4
|
||||
debug: 4.4.0
|
||||
globals: 11.12.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -14422,6 +14425,10 @@ packages:
|
||||
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
|
||||
requiresBuild: true
|
||||
|
||||
/sandybox@1.1.2:
|
||||
resolution: {integrity: sha512-JNXfp5HnlrEXnwXqhN2Hnn+zacK+UvP4Cgxtcy3ydKqr17s9Ysp2E3xL1uBApPfIX9vxSCLvfCFK5XEGVXatdw==}
|
||||
dev: false
|
||||
|
||||
/sanitize-html@2.14.0:
|
||||
resolution: {integrity: sha512-CafX+IUPxZshXqqRaG9ZClSlfPVjSxI0td7n07hk8QO2oO+9JDnlcL8iM8TWeOXOIBFgIOx6zioTzM53AOMn3g==}
|
||||
dependencies:
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import Sandybox from 'sandybox';
|
||||
import { webcrack } from 'webcrack';
|
||||
|
||||
const input = ref('');
|
||||
const result = computedAsync(async () => {
|
||||
try {
|
||||
return await webcrack(input.value);
|
||||
const inputValue = input.value;
|
||||
const sandbox = await Sandybox.create();
|
||||
const iframe = document.querySelector('.sandybox') as HTMLIFrameElement;
|
||||
iframe?.contentDocument?.head.insertAdjacentHTML(
|
||||
'afterbegin',
|
||||
'<meta http-equiv="Content-Security-Policy" content="default-src \'none\';">',
|
||||
);
|
||||
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
async function evalCode(code: string) {
|
||||
const fn = await sandbox.addFunction(`() => ${code}`);
|
||||
return Promise.race([
|
||||
fn(),
|
||||
sleep(10_000).then(() => Promise.reject(new Error('Sandbox timeout'))),
|
||||
]).finally(() => sandbox.removeFunction(fn));
|
||||
}
|
||||
|
||||
return await webcrack(inputValue, { sandbox: evalCode });
|
||||
}
|
||||
catch (e: any) {
|
||||
return {
|
||||
@@ -16,6 +34,7 @@ const result = computedAsync(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<iframe class="sandybox" style="display:none" title="sandbox" />
|
||||
<CInputText
|
||||
v-model:value="input"
|
||||
placeholder="Your obfuscate Javascript code"
|
||||
|
||||
Reference in new issue
Block a user