-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.html
128 lines (118 loc) · 3.92 KB
/
tester.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<html lang="en">
<head>
<title>SmartC Signum Decompiler</title>
<meta charset="utf-8">
<style>
body {
font-size: 100%;
}
h1 {
text-align: center;
}
h3 {
margin-bottom: 5px;
}
textarea {
width: 100%;
height: 50px;
padding: 5px 5px 5px 5px;
min-height: 75px;
}
pre {
font-family: "Lucida Console", "Courier New", 'monospace';
border: solid 1px black;
padding: 5px;
white-space: pre-wrap;
word-wrap: anywhere;
min-height: 75px;
}
output {
font-family: "Lucida Console", "Courier New", 'monospace';
}
button {
margin: 20px 0px 20px 0px;
padding: 5px 20px 5px 20px;
}
footer {
font-size: 0.875em;
}
</style>
<script type="module">
import decompiler from './dist/index.js'
function ClickDecompile() {
let codeString = document.getElementById("codeString").value;
let outputMAP = document.getElementById("map_obj").value;
let mapObj = {}
try {
if (outputMAP.length > 5) {
mapObj = JSON.parse(outputMAP);
}
} catch (e) {
document.getElementById("decompiled_assembly").innerHTML = e.message;
return;
}
const Options = {
machineCode: '',
creationBytes : '',
attachmentBytes: '',
variables: mapObj.Memory,
labels: mapObj.Labels
}
const inputType = document.querySelector('input[name="input_type"]:checked').value;
switch (inputType) {
case 'attachment':
Options.attachmentBytes = codeString.trim();
break;
case 'creation':
Options.creationBytes = codeString.trim();
break;
case 'code':
Options.machineCode = codeString.trim();
break;
default:
return;
}
try {
const decomp = new decompiler(Options);
const decomp_output = decomp.decompile();
document.getElementById("decompiled_assembly").innerText = decomp_output.assemblyProgram;
document.getElementById("map_obj").value = JSON.stringify({
Memory: decomp_output.variables,
Labels: decomp_output.labels
}, null, 2);
} catch(err) {
document.getElementById("decompiled_assembly").innerHTML = "Error in decompilation process: " + err.message;
}
}
window.onload = function () {
document.getElementById('codeDecompile').addEventListener('click',ClickDecompile);
}
</script>
</head>
<body>
<div>
<h1>SmartC Decompiler</h1>
<h3>Paste here the hexadecimal string:</h3>
<textarea id="codeString" placeholder="Bytecode here"></textarea>
<h3>String is:</h3>
<label><input type="radio" name="input_type" value="attachment" checked="true">Attachment bytes </label>
<label><input type="radio" name="input_type" value="creation">Creation bytes </label>
<label><input type="radio" name="input_type" value="code">Code bytes </label><br>
<button id="codeDecompile">Decompile</button>
</div>
<div>
<h3>Map object</h3>
<textarea id="map_obj" placeholder="Paste here a map object"></textarea>
</div>
<div>
<h3>Decompiled assembly:</h3>
<pre id="decompiled_assembly"></pre>
</div>
<div>
<br/><br/>
<footer>Assembly output can be compiled with <a href="https://github.com/deleterium/SmartC">SmartC</a><br />
• May 2022 • <a href="https://github.com/deleterium/smartc-signum-decompiler">Project page</a> • S-DKVF-VE8K-KUXB-DELET<br/>
</footer>
</div>
</body>
</html>