-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
263 lines (222 loc) · 8.43 KB
/
index.html
File metadata and controls
263 lines (222 loc) · 8.43 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400..900&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css"
/>
<title>Cerastes</title>
<style>
* {
box-sizing: border-box;
font-family: "Orbitron", sans-serif;
}
body {
background-color: black;
color: #00ff00;
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}
body,
h1 {
margin: 0;
padding: 0;
}
h1 {
font-size: 3rem;
}
textarea,
input {
font-family: "Courier New", Courier, monospace;
background-color: #333;
border: 1px solid #00ff00;
width: 700px;
}
a,
textarea,
input,
#output {
color: #00ff00;
}
textarea {
height: 300px;
}
input {
padding: 10px;
border-radius: 5px;
}
form {
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.75rem;
}
button {
padding: 10px 20px;
background-color: #00ff00;
color: black;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #fff;
}
p {
max-width: 700px;
text-align: center;
}
span {
display: flex;
gap: 1rem;
}
a {
text-decoration: none;
font-size: 2rem;
}
a:hover {
color: #fff;
}
</style>
</head>
<body>
<form id="obfuscationForm">
<h1>Cerastes</h1>
<span>
<a
href="https://github.com/aaron-iz/Cerastes/tree/main"
title="Source Code"
>
<i class="bi bi-github"></i>
</a>
<a
href="https://buymeacoffee.com/aaroniz"
title="Buy me a coffee"
>
<i class="bi bi-cup-hot"></i>
</a>
</span>
<p>
<b>Cerastes</b> is a genus of small vipers, often hiding by
burying themselves in the sand. These are ambush predators that
lie buried in the sand, waiting for prey to pass by.
<br />
This tool generates an obfuscated version of your code using
simple XOR-based encryption. If you're using JavaScript, you can
also use the generated injection snippet below. It dynamically
inserts the encrypted code into the DOM at runtime.
</p>
<textarea
id="code"
rows="20"
cols="80"
placeholder="alert('Boo! 👻')"
></textarea>
<button id="obfuscate">Obfuscate</button>
</form>
<div id="output">
<h2>-Your output will be down here-</h2>
</div>
<script>
const EncryptedPlaceholder = "DDD";
const KeyPlaceholder = "KKK";
const Template = `const d=${EncryptedPlaceholder};const k=${KeyPlaceholder};const s=document.createElement("script");const y=d.map((v,i)=>String.fromCharCode(v^k.charCodeAt(i%k.length))).join("");const z=new TextDecoder("utf-8").decode(Uint8Array.from(y,(c)=>c.charCodeAt(0)));s.innerHTML=z;document.body.appendChild(s);`;
const codeElement = document.getElementById("code");
function generateKey(length) {
let key = "";
while (key.length < length) {
key += Math.random().toString(36).substring(2, 15);
}
return key.substring(0, length);
}
function encrypt(bytes, key) {
return bytes.map((byte, index) => byte ^ key.charCodeAt(index));
}
function createMiniHeading(text) {
const h = document.createElement("h3");
h.textContent = text;
return h;
}
function addElements(encrypted, key) {
const outputElement = document.getElementById("output");
outputElement.replaceChildren();
const keyElement = document.createElement("input");
keyElement.type = "text";
keyElement.value = key;
keyElement.id = "key";
keyElement.disabled = true;
keyElement.title = "Click to copy the key";
keyElement.onclick = function () {
this.select();
document.execCommand("copy");
alert("Key copied to clipboard!");
};
const encryptedElement = document.createElement("textarea");
encryptedElement.id = "encrypted";
encryptedElement.rows = 20;
encryptedElement.cols = 80;
encryptedElement.value = encrypted;
encryptedElement.disabled = true;
encryptedElement.title = "Click to copy the encrypted code";
encryptedElement.onclick = function () {
this.select();
document.execCommand("copy");
alert("Encrypted code copied to clipboard!");
};
const scriptCode = Template.replace(
EncryptedPlaceholder,
JSON.stringify(encrypted).substring(
1,
JSON.stringify(encrypted).length - 1
)
).replace(KeyPlaceholder, JSON.stringify(key));
const scriptElement = document.createElement("textarea");
scriptElement.id = "scriptCode";
scriptElement.rows = 20;
scriptElement.cols = 80;
scriptElement.value = scriptCode;
scriptElement.disabled = true;
scriptElement.title = "Click to copy the script code";
scriptElement.onclick = function () {
this.select();
document.execCommand("copy");
alert("Script code copied to clipboard!");
};
outputElement.appendChild(createMiniHeading("Key:"));
outputElement.appendChild(keyElement);
outputElement.appendChild(createMiniHeading("Encrypted Code:"));
outputElement.appendChild(encryptedElement);
outputElement.appendChild(
createMiniHeading("JS Injecting Code:")
);
outputElement.appendChild(scriptElement);
}
function obfuscate(e) {
e.preventDefault();
const code = codeElement.value;
if (!code || code.trim() === "") {
alert("Please enter some code to obfuscate.");
return;
}
const encode = new TextEncoder().encode(code);
const key = generateKey(encode.length);
const encrypted = JSON.stringify([...encrypt(encode, key)]);
addElements(encrypted, key);
}
document
.getElementById("obfuscationForm")
.addEventListener("submit", obfuscate);
</script>
</body>
</html>