-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoded.html
More file actions
221 lines (208 loc) · 8.05 KB
/
Copy pathdecoded.html
File metadata and controls
221 lines (208 loc) · 8.05 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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Decoded XOR String - Blue Team Pro</title>
<style>
body {
background-color: #1c1f26;
color: #e0e0e0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.main-container {
width: 100%;
max-width: 600px;
background-color: #2a2d37;
padding: 30px;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
display: flex;
flex-direction: column;
gap: 15px;
}
h1 {
font-size: 1.8em;
color: #00b4d8;
text-align: center;
}
.input-field, .output-field {
width: 100%;
padding: 12px;
background-color: #3b3f4a;
color: #e0e0e0;
border: 1px solid #0077b6;
border-radius: 8px;
}
button {
width: 100%;
padding: 12px;
background-color: #0077b6;
color: #ffffff;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 1em;
}
button:hover {
background-color: #005f87;
}
.salt-row {
display: flex;
gap: 10px;
}
.salt-row .input-field {
flex: 1;
}
.salt-button {
padding: 12px 16px;
background-color: #0077b6;
color: #ffffff;
font-size: 0.85em;
font-weight: bold;
border: none;
border-radius: 8px;
cursor: pointer;
white-space: nowrap;
}
.salt-button:hover {
background-color: #005f87;
}
.nav-link {
color: #00b4d8;
text-align: center;
text-decoration: none;
}
.salt-info {
color: #a0a0b0;
font-size: 0.8em;
text-align: center;
}
.footer {
text-align: center;
color: #666;
}
</style>
</head>
<body>
<div class="main-container">
<h1>Decoded XOR String - Blue Team Pro</h1>
<form name="formx">
<input id="encodedInp" class="input-field" name="encodedInp" type="text" placeholder="Digite a string codificada" style="margin-bottom: 10px;">
<div class="salt-row" style="margin-bottom: 10px;">
<input id="decodeSalt" class="input-field" name="decodeSalt" type="text" value="01 01 01 01" placeholder="Salt (hex bytes, e.g. DE AD BE EF)">
<button type="button" class="salt-button" onclick="randomizeDecodeSalt();">Random Salt</button>
</div>
<p class="salt-info" style="margin-bottom: 15px;">Salt is auto-extracted from encoded string. Override manually if needed.</p>
<button type="button" onclick="decodeXorString();">Decodificar XOR String</button>
<textarea id="decodedAns" class="output-field" name="decodedAns" rows="6" readonly placeholder="Resultado aparecerá aqui" style="margin-top: 15px;"></textarea>
</form>
<a href="index.html" class="nav-link">← Voltar para Codificação</a>
<div class="footer">
Desenvolvido por Lyon - Adaptações e melhorias © 2024<br>
Código original do XorGen.js por D4rC.nEt (http://d4rc.net)
</div>
</div>
<script>
function Dec2Hex(d) {
var hexChars = "0123456789ABCDEF";
var a = d % 16;
var b = (d - a) / 16;
return "" + hexChars.charAt(b) + hexChars.charAt(a);
}
function randByte() { return Math.floor(Math.random() * 256 % 256); }
function randomizeDecodeSalt() {
var bytes = [];
for (var j = 0; j < 4; j++) {
bytes.push(Dec2Hex(randByte()));
}
document.getElementById('decodeSalt').value = bytes.join(" ");
}
function parseSaltFromField() {
var saltStr = document.getElementById('decodeSalt').value.trim();
if (saltStr === "") { return [1, 1, 1, 1]; }
var parts = saltStr.split(/[\s,]+/);
var salt = [];
for (var j = 0; j < parts.length; j++) {
var val = parseInt(parts[j], 16);
if (isNaN(val) || val < 0 || val > 255) {
alert("Invalid salt byte: " + parts[j] + ". Use hex values 00-FF.");
return null;
}
salt.push(val);
}
if (salt.length === 0) { return [1, 1, 1, 1]; }
return salt;
}
function extractSaltFromString(inputText) {
// New format: XorStr<0xNN,[DE,AD,BE,EF],len,0xNNNNNNNN>
var saltMatch = inputText.match(/XorStr<0x[0-9A-Fa-f]{2},\[([0-9A-Fa-f]{2}(?:,[0-9A-Fa-f]{2})*)\]/);
if (saltMatch) {
var parts = saltMatch[1].split(",");
var salt = [];
for (var j = 0; j < parts.length; j++) {
salt.push(parseInt(parts[j], 16));
}
return salt;
}
return null; // Old format, no embedded salt
}
function decodeXorString() {
const inputText = document.getElementById('encodedInp').value;
const outputText = document.getElementById('decodedAns');
if (inputText.trim() === '') {
alert('Por favor, digite uma string codificada para decodificar.');
return;
}
try {
// Extract initial XOR key
const initialXorMatch = inputText.match(/XorStr<0x([0-9A-Fa-f]{2})/);
if (!initialXorMatch) {
alert('Formato inválido. Certifique-se de usar a sequência codificada correta.');
return;
}
let xvalue = parseInt(initialXorMatch[1], 16);
// Try to extract salt from the encoded string first
var salt = extractSaltFromString(inputText);
if (salt) {
// Auto-fill the salt field with extracted salt
var saltHexParts = [];
for (var j = 0; j < salt.length; j++) {
saltHexParts.push(Dec2Hex(salt[j]));
}
document.getElementById('decodeSalt').value = saltHexParts.join(" ");
} else {
// No salt in string (old format) - use salt from input field
salt = parseSaltFromField();
if (salt === null) { return; }
}
// Extract hex sequence
const hexSequenceMatch = inputText.match(/"((?:\\x[0-9A-Fa-f]{2})+)"/);
if (!hexSequenceMatch) {
alert('Formato inválido. Certifique-se de que a sequência codificada está correta.');
return;
}
const hexSequence = hexSequenceMatch[1].match(/\\x[0-9A-Fa-f]{2}/g);
let decodedString = '';
for (let i = 0; i < hexSequence.length; i++) {
const hexValue = parseInt(hexSequence[i].slice(2), 16);
const charCode = hexValue ^ xvalue;
decodedString += String.fromCharCode(charCode);
xvalue = (xvalue + salt[i % salt.length]) % 256;
}
outputText.value = decodedString;
outputText.focus();
outputText.select();
} catch (error) {
alert('Erro ao decodificar a string XOR. Verifique o console para mais detalhes.');
console.error(error);
}
}
</script>
</body>
</html>