-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
delic1ous
committed
Feb 5, 2025
1 parent
1f70719
commit b107caf
Showing
2 changed files
with
2,795 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,382 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>My Website</title> | ||
</head> | ||
<title>JS混淆代码还原</title> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/codemirror.min.css"> | ||
<style> | ||
body { | ||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
margin: 10px; | ||
background-color: #f5f5f5; | ||
} | ||
|
||
.container { | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
background: white; | ||
padding: 20px; | ||
border-radius: 12px; | ||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.editor { | ||
height: 400px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.tab-container { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.tab { | ||
flex: 1; | ||
background: #a9a9f5; /* 柔和的蓝色 */ | ||
color: white; | ||
padding: 15px; | ||
text-align: center; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
border: none; | ||
font-weight: bold; | ||
font-size: 20px; | ||
} | ||
|
||
.tab:hover { | ||
background-color: #9999e6; /* 悬停时颜色加深 */ | ||
} | ||
|
||
.tab.active { | ||
background-color: #8989e0; /* 激活时颜色更深 */ | ||
} | ||
|
||
.CodeMirror { | ||
height: 100%; | ||
border: 1px solid #ddd; | ||
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); | ||
font-size: 18px; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
} | ||
|
||
.tab-container { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.region-group { | ||
display: flex; | ||
gap: 0; | ||
margin-bottom: 20px; | ||
padding: 0; | ||
overflow: hidden; | ||
border: 1px solid #ccc; | ||
} | ||
|
||
.region { | ||
flex: 1; | ||
background-color: #ffffff; | ||
color: #333333; | ||
padding: 15px; | ||
text-align: center; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
font-size: 20px; | ||
font-weight: bold; | ||
border-right: 1px solid #cccccc; | ||
} | ||
|
||
.region:last-child { | ||
border-right: none; | ||
} | ||
|
||
.region.active { | ||
background-color: #e0e0e0; | ||
} | ||
|
||
.region:hover { | ||
background-color: #f0f0f0; | ||
} | ||
|
||
.toggle-switch { | ||
margin: 15px 0; | ||
display: flex; | ||
align-items: center; /* 垂直对齐 */ | ||
gap: 10px; /* 开关按钮和文字之间的间距 */ | ||
justify-content: center; /* 水平居中 */ | ||
} | ||
|
||
.switch { | ||
position: relative; | ||
display: inline-block; | ||
width: 40px; /* 保持或调整宽度 */ | ||
height: 20px; /* 保持或调整高度 */ | ||
} | ||
|
||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
|
||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: #ccc; | ||
transition: 0.4s; | ||
border-radius: 20px; | ||
} | ||
|
||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 16px; | ||
width: 16px; | ||
left: 2px; | ||
bottom: 2px; | ||
background-color: white; | ||
transition: 0.4s; | ||
border-radius: 50%; | ||
} | ||
|
||
input:checked + .slider { | ||
background-color: #a9a9f5; | ||
} | ||
|
||
input:checked + .slider:before { | ||
transform: translateX(18px); | ||
} | ||
|
||
.toggle-switch span { | ||
font-size: 20px; | ||
font-weight: bold; | ||
color: #333; | ||
} | ||
|
||
.toggle-switch span.text { | ||
display: inline-block; | ||
width: 100px; /* 设置固定宽度 */ | ||
color: #555; | ||
font-size: 18px; | ||
} | ||
|
||
.button-group { | ||
text-align: center; | ||
} | ||
|
||
.button-group button { | ||
background: #a9a9f5; /* 柔和的蓝色 */ | ||
color: white; | ||
border: none; | ||
padding: 8px; | ||
border-radius: 8px; | ||
cursor: pointer; | ||
font-size: 20px; | ||
font-weight: bold; | ||
transition: background-color 0.3s; | ||
min-width: 100px; | ||
display: inline-block; | ||
margin: 0 5px; | ||
} | ||
|
||
.button-group button:hover { | ||
background-color: #9999e6; /* 悬停时颜色加深 */ | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>TEST!!!</h1> | ||
</body> | ||
<div class="container"> | ||
<h1>JS代码混淆还原</h1> | ||
<div class="region-group"> | ||
<div class="region active" id="static-deobfuscation" onclick="handleButtonClick(this)">静态反混淆</div> | ||
<div class="region" id="obfuscator.io" onclick="handleButtonClick(this)">obfuscator.io</div> | ||
<div class="region" id="jsjiami.com.v6" onclick="handleButtonClick(this)">jsjiami.com.v6</div> | ||
<div class="region" id="jsjiami.com.v7" onclick="handleButtonClick(this)">jsjiami.com.v7</div> | ||
</div> | ||
<div class="tab-container"> | ||
<div class="tab active" onclick="showInputEditor()">输入</div> | ||
<div class="tab" onclick="showOutputEditor()">输出</div> | ||
</div> | ||
<div class="editor" id="input-editor"></div> | ||
<div class="editor" id="output-editor"></div> | ||
|
||
<div class="toggle-switch"> | ||
<span>变量重命名:</span> | ||
<label class="switch"> | ||
<input type="checkbox" id="highlight-toggle"> | ||
<span class="slider"></span> | ||
</label> | ||
<span class="text">仅十六进制</span> | ||
</div> | ||
|
||
<div class="button-group"> | ||
<button id="process-button" onclick="processCode()">还原</button> | ||
<button id="copy-paste-button" onclick="copyPasteCode()">复制/粘贴</button> | ||
</div> | ||
</div> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/codemirror.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/mode/javascript/javascript.min.js"></script> | ||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script src="../github.io/script.js"></script> | ||
<script> | ||
// 初始化 CodeMirror 编辑器 | ||
const editorInput = CodeMirror(document.querySelector('#input-editor'), { | ||
value: demoCode1, | ||
mode: 'javascript', | ||
theme: 'default', | ||
lineNumbers: true, | ||
lineWrapping: true, | ||
}); | ||
|
||
const editorOutput = CodeMirror(document.querySelector('#output-editor'), { | ||
mode: 'javascript', | ||
theme: 'default', | ||
lineNumbers: true, | ||
readOnly: true, | ||
lineWrapping: true, | ||
}); | ||
|
||
function showInputEditor() { | ||
document.querySelector('#input-editor').style.display = 'block'; | ||
document.querySelector('#output-editor').style.display = 'none'; | ||
editorInput.refresh(); | ||
|
||
document.querySelectorAll('.tab').forEach(tab => { | ||
tab.classList.remove('active'); | ||
}); | ||
document.querySelector('.tab:nth-child(1)').classList.add('active'); | ||
} | ||
|
||
function showOutputEditor() { | ||
document.querySelector('#input-editor').style.display = 'none'; | ||
document.querySelector('#output-editor').style.display = 'block'; | ||
editorOutput.refresh(); | ||
|
||
document.querySelectorAll('.tab').forEach(tab => { | ||
tab.classList.remove('active'); | ||
}); | ||
document.querySelector('.tab:nth-child(2)').classList.add('active'); | ||
} | ||
|
||
function handleButtonClick(button) { | ||
document.querySelectorAll('.region').forEach(region => { | ||
region.classList.remove('active'); | ||
}); | ||
button.classList.add('active'); | ||
|
||
switch (button.id) { | ||
case'static-deobfuscation': | ||
editorInput.setValue(demoCode1); | ||
break; | ||
case 'obfuscator.io': | ||
editorInput.setValue(demoCode2); | ||
break; | ||
case 'jsjiami.com.v6': | ||
editorInput.setValue(demoCode3); | ||
break; | ||
case 'jsjiami.com.v7': | ||
editorInput.setValue(demoCode4); | ||
break; | ||
} | ||
} | ||
|
||
document.getElementById('highlight-toggle').addEventListener('change', function () { | ||
const isChecked = this.checked; | ||
const textElement = document.querySelector('.toggle-switch span.text'); | ||
textElement.textContent = isChecked ? '全部' : '仅十六进制'; | ||
}); | ||
|
||
function copyPasteCode() { | ||
const isInputVisible = document.querySelector('#input-editor').style.display === 'block'; | ||
if (isInputVisible) { | ||
// 如果当前显示的是输入框,粘贴代码 | ||
navigator.clipboard.readText().then(text => { | ||
editorInput.setValue(text); | ||
}); | ||
} else { | ||
const code = editorOutput.getValue(); | ||
navigator.clipboard.writeText(code).then(() => { | ||
alert('复制成功!'); | ||
}) | ||
} | ||
} | ||
|
||
function processCode() { | ||
const id = document.querySelector('.region.active').id; | ||
const isChecked = document.getElementById('highlight-toggle').checked; | ||
switch (id) { | ||
case 'static-deobfuscation': | ||
transform(ast => { | ||
static_deobfuscate(ast, { | ||
rename: true, | ||
hexadecimal_only: !isChecked, | ||
}); | ||
}); | ||
break; | ||
case 'obfuscator.io': | ||
transform(ast => { | ||
static_deobfuscate(ast); | ||
const [return_array_function_name, code_str1] = handleReturnArrayFunction(ast); | ||
const [decrypt_string_function_name, code_str2] = handleDecryptStringFunction(ast, return_array_function_name); | ||
const code_str3 = handleChangeArrayIIFE(ast, return_array_function_name) | ||
restoreCallExpression(ast, decrypt_string_function_name, code_str1, code_str2, code_str3); | ||
restoreMemberExpression(ast); | ||
static_deobfuscate(ast); | ||
removeSelfDefending(ast); | ||
deControlFlowFlatten(ast); | ||
static_deobfuscate(ast, { | ||
rename: true, | ||
hexadecimal_only: !isChecked, | ||
}); | ||
}); | ||
break; | ||
case 'jsjiami.com.v6': | ||
transform(ast => { | ||
static_deobfuscate(ast); | ||
const [array_name, code_str1] = handleArrayDeclaration_v6(ast); | ||
const [decrypt_string_function_name, code_str2] = handleDecryptStringFunctionDeclaration_v6(ast, array_name); | ||
const code_str3 = handleChangeArrayIIFE_v6(ast, array_name); | ||
restoreCallExpression(ast, decrypt_string_function_name, code_str1, code_str2, code_str3); | ||
restoreMemberExpression(ast); | ||
static_deobfuscate(ast); | ||
removeSelfDefending(ast); | ||
deControlFlowFlatten(ast); | ||
static_deobfuscate(ast, { | ||
rename: true, | ||
hexadecimal_only: !isChecked, | ||
}); | ||
}); | ||
break; | ||
case 'jsjiami.com.v7': | ||
transform(ast => { | ||
static_deobfuscate(ast); | ||
const [return_array_function_name, code_str1] = handleReturnArrayFunction_v7(ast); | ||
const [decrypt_string_function_name, code_str2] = handleDecryptStringFunction(ast, return_array_function_name); | ||
const code_str3 = handleChangeArrayIIFE_v7(ast, return_array_function_name); | ||
restoreCallExpression(ast, decrypt_string_function_name, code_str1, code_str2, code_str3); | ||
restoreMemberExpression(ast); | ||
static_deobfuscate(ast); | ||
removeSelfDefending(ast); | ||
deControlFlowFlatten(ast); | ||
static_deobfuscate(ast, { | ||
rename: true, | ||
hexadecimal_only: !isChecked, | ||
}); | ||
}); | ||
break; | ||
} | ||
showOutputEditor(); | ||
} | ||
|
||
showInputEditor(); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.