Decode emulator.js

This commit is contained in:
Ethan O'Brien 2021-09-18 22:08:28 -05:00
parent 42a7e129cf
commit 05be2e5bf9
6 changed files with 155 additions and 4 deletions

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@ fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').
if (response.ok) {
response.text().then(body => {
var version = JSON.parse(body);
var usingVersion = '0.4.23-01';
var usingVersion = '0.4.23-02';
if (usingVersion != version.current_version) {
console.log('Using emulatorjs version ' + usingVersion + ' but the newest version is ' + version.current_version);
};

View file

@ -1 +1 @@
{ "current_version": "0.4.23-01"}
{ "current_version": "0.4.23-02"}

7
decrypt tools/decrypt.js Normal file

File diff suppressed because one or more lines are too long

100
decrypt tools/index.html Normal file
View file

@ -0,0 +1,100 @@
<html>
<body>
<div id='app'>
<ul>
<br><br>
<p id='amountReplaced'>0</p><br><br>
<button style="display:none;" id='download'>Stop and download</button>
<input type='file' onchange='decryptButton()' id='file'></input><br><br><br>
<div id='out'></div>
</ul>
</div>
<script src='decrypt.js'></script>
<script>
window.stopped = false
window.amountReplaced = 0
window.checked = []
function updateAmountReplaced() {
document.getElementById('amountReplaced').innerHTML = window.amountReplaced.toString()
}
function decrypt(a, b) {
return _0x16a2(a, b)
}
function ask(value) {
return new Promise(function(resolve, reject) {
console.log(value)
document.getElementById('out').innerHTML = '#start#<br>' + value + '\n<br>#end#'
var button = document.createElement('button')
button.innerHTML = 'replace'
button.id = 'button'
button.onclick = function() {
document.getElementById('button').remove()
document.getElementById('button1').remove()
resolve(true)
}
document.body.appendChild(button)
var button1 = document.createElement('button')
button1.innerHTML = 'do not replace'
button1.id = 'button1'
button1.onclick = function() {
document.getElementById('button').remove()
document.getElementById('button1').remove()
resolve(false)
}
document.body.appendChild(button1)
})
}
function decryptButton() {
var finished = function() {
window.stopped = true
var a = document.createElement('a')
a.href = URL.createObjectURL(new Blob([body]))
a.download = 'emulator.js'
a.click()
}
document.getElementById('download').onclick = finished
var file = document.getElementById('file').files[0]
document.getElementById('file').remove()
var reader = new FileReader()
reader.onload = async function(e) {
document.getElementById('download').style = 'display:block;'
window.body = e.target.result
var encrypted = []
var a = body.split("_0x16a2('")
var b = []
for (var i=0; i<a.length; i++) {
var c = a[i].split("')")[0].split("','")
if (c.length == 2) {
b.push(c)
}
}
console.log(b.length)
for (var i=0; i<b.length; i++) {
var value = decrypt(b[i][0], b[i][1])
var value = value.replaceAll("'", "\\'").replaceAll('\n', '\\n').replaceAll('\r', '\\r')
if (! window.checked.includes(value)) {
var add = true
//var add = await ask(value)
//window.checked.push(value)
if (add) {
window.amountReplaced++
window.body = body.replaceAll("_0x16a2('" + b[i][0] + "','" + b[i][1] + "')", "'" + value + "'")
console.log(window.amountReplaced)
//updateAmountReplaced()
}
}
if (window.stopped) {
return
}
}
finished()
}
reader.readAsText(file)
}
</script>
</body>
</html>

44
decrypt tools/index2.html Normal file
View file

@ -0,0 +1,44 @@
<html>
<body>
<div id='app'>
<ul>
<br><br>
<input type='file' onchange='decryptButton()' id='file'></input><br><br><br>
</ul>
</div>
<script src='decrypt.js'></script>
<script>
function decryptButton() {
var finished = function() {
window.stopped = true
var a = document.createElement('a')
a.href = URL.createObjectURL(new Blob([window.body]))
a.download = 'emulator.js'
a.click()
}
window.finished = finished
var file = document.getElementById('file').files[0]
document.getElementById('file').remove()
var reader = new FileReader()
reader.onload = async function(e) {
window.body = e.target.result
var a = body.split('\\x')
for (var i=1; i<a.length; i++) {
var error = false
a[i] = a[i].substr(0, 2)
console.log(a[i])
try {var code = eval('"\\x'+a[i]+'"')} catch(e) {console.log(e, '"\\x'+a[i]+'"'); var error = true}
if (! error) {
if (code != '\n' && code != '\r') {
window.body = body.replaceAll('\\x'+a[i], code.replaceAll("'", "\\'").replaceAll('"', '\\"'))
}
}
}
}
reader.readAsText(file)
}
</script>
</body>
</html>