-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
471 lines (439 loc) · 14.4 KB
/
index.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Nofuture Age Web Interface (Libsodium)</title>
<style>
:root {
--bg-color-day: #f0f0f0;
--text-color-day: #333;
--bg-color-night: #2e2e2e;
--text-color-night: #f0f0f0;
--primary-color: #0088cc;
--primary-hover: #007bb5;
--session-id-color: #ff4444;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: var(--bg-color-night);
color: var(--text-color-night);
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
background-color: var(--primary-color);
padding: 1rem;
text-align: center;
color: #fff;
}
header h1 { margin: 0; }
main {
flex: 1;
max-width: 800px;
margin: auto;
padding: 1rem;
}
.instructions {
margin-bottom: 1rem;
}
.session-buttons, .buttons {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1rem;
}
.session-buttons button, .buttons button {
flex: 1;
padding: 0.75rem;
border: none;
border-radius: 4px;
background-color: var(--primary-color);
color: #fff;
font-size: 1rem;
cursor: pointer;
}
.session-buttons button:hover, .buttons button:hover {
background-color: var(--primary-hover);
}
.row {
display: flex;
flex-direction: column;
margin-bottom: 1rem;
}
.row label { margin-bottom: 0.5rem; }
.row input[type="text"], .row textarea {
width: 100%;
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
textarea {
min-height: 300px;
resize: vertical;
}
#themeToggle {
position: fixed;
top: 1rem;
right: 1rem;
padding: 0.5rem;
cursor: pointer;
background-color: var(--primary-color);
border: none;
border-radius: 4px;
color: #fff;
}
@media (max-width: 600px) {
textarea { min-height: 200px; }
}
/* Container per visualizzare Session ID + pulsante copy */
#sessionIdContainer {
display: none; /* hidden finché non c'è una sessione */
margin-bottom: 1rem;
}
#sessionIdLabel {
font-weight: bold;
}
#sessionIdValue {
color: var(--session-id-color);
font-weight: bold;
margin-left: 0.5rem;
}
/* Footer semplice */
footer {
background-color: #333;
color: #ccc;
padding: 1rem;
font-size: 0.9rem;
text-align: center;
}
footer a {
color: #fff;
text-decoration: none;
}
/* Tastiera Virtuale */
#keyboardContainer {
position: fixed;
top: 100px;
left: 100px;
width: 400px;
background-color: #f9f9f9;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
z-index: 1000;
display: none;
}
#keyboardHeader {
background-color: #007acc;
color: white;
padding: 10px;
cursor: grab;
display: flex;
justify-content: space-between;
align-items: center;
}
#keyboardHeader span {
font-size: 16px;
font-weight: bold;
}
#closeKeyboardButton {
background: none;
border: none;
color: white;
font-size: 20px;
cursor: pointer;
}
#virtualKeyboard {
display: grid;
grid-template-columns: repeat(8, 1fr);
gap: 5px;
padding: 10px;
}
.key {
padding: 8px;
background-color: #0088cc;
color: white;
text-align: center;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
user-select: none;
font-weight: bold;
}
.key:hover {
background-color: #005f8c;
}
#keyboardTooltip {
position: absolute;
width: 300px;
background-color: #f9f9f9;
color: #333;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
padding: 10px;
z-index: 1000;
display: none;
font-size: 14px;
line-height: 1.5;
}
</style>
</head>
<body>
<button id="themeToggle">Giorno</button>
<header>
<h1>Nofuture Age Web Interface - Libsodium</h1>
</header>
<!-- Dove visualizziamo il Session ID e un pulsante Copy -->
<div id="sessionIdContainer">
<span id="sessionIdLabel">Session ID:</span>
<span id="sessionIdValue"></span>
<button id="copySessionIdBtn" style="margin-left: 0.5rem;">Copy</button>
</div>
<main>
<p class="instructions">
My idea is to use it alongside mainstream messaging applications without extensions to encrypt text.
As long as the session is active you will be able to encrypt text for your interlocutor and decrypt it.
Once the session is ended, the keys used in the previous session are lost making it impossible to retrieve the plaintexts.
Pair two sessions, then encrypt/decrypt messages.
<h3>How to Use the Interface</h3>
<ul>
<li><strong>Start a Session:</strong> Click the <em>Start Session</em> button to create a new cryptographic session.</li>
<li><strong>Copy Session ID:</strong> Once the session is started, your <em>Session ID</em> will be visible. Click <em>Copy</em> to copy it to your clipboard.</li>
<li><strong>Share Session ID:</strong> Share your <em>Session ID</em> with your buddy through a secure channel.</li>
<li><strong>Pair Sessions:</strong> Both participants must enter their buddy's <em>Session ID</em> in the <em>Buddy Session ID</em> field and click <em>Pair Sessions</em> to link their sessions.</li>
<li><strong>Encrypt Messages:</strong> Enter the text you wish to send in the text field and click <em>Buddy Encrypt</em> to encrypt it. The encrypted message will appear in the text field.</li>
<li><strong>Decrypt Messages:</strong> Paste an encrypted message into the text field and click <em>Buddy Decrypt</em> to decrypt it and view the plaintext content.</li>
</ul>
</p>
<!-- Pulsanti per creare/terminare la sessione -->
<div class="session-buttons">
<button id="startSessionBtn">Start Session</button>
<button id="endSessionBtn" style="display:none;">End Session</button>
</div>
<!-- Campo per inserire l'ID della sessione buddy -->
<div class="row">
<label for="buddySessionIdInput">Session ID:</label>
<input type="text" id="buddySessionIdInput" placeholder="Enter your buddy's session ID here...">
</div>
<div class="session-buttons">
<button id="pairSessionsBtn">Pair Sessions</button>
</div>
<!-- Campo di testo per scrivere (in chiaro o incollare ciphertext) -->
<div class="row">
<label for="textInput">Text (clear or encrypted):</label>
<textarea id="textInput" placeholder="Enter text here..."></textarea>
</div>
<!-- Pulsanti Buddy Encrypt/Decrypt -->
<div class="buttons">
<button id="buddyEncryptBtn">Encrypt</button>
<button id="buddyDecryptBtn">Decrypt</button>
</div>
<!-- Virtual Keyboard -->
<div style="text-align: center; margin-top: 50px; position: relative;">
<button id="showKeyboardButton">Virtual Keyboard</button>
<div id="keyboardTooltip">
<p>Our Virtual Keyboard helps avoid hardware keyloggers by letting you click characters instead of typing them physically.</p>
</div>
</div>
<div id="keyboardContainer">
<div id="keyboardHeader">
<span>Virtual Keyboard</span>
<button id="closeKeyboardButton">×</button>
</div>
<div id="virtualKeyboard"></div>
</div>
</main>
<footer>
<p>© <a href="https://yamn.virebent.art">Victor Hostile Communication Center</a> - <a href="https://github.com/gabrix73/Nofuture-Age">Nofuture/Age</a></p>
</footer>
<script>
/* GLOBALS & SELECTORS */
let currentSessionId = null;
const sessionIdContainer = document.getElementById('sessionIdContainer');
const sessionIdValue = document.getElementById('sessionIdValue');
const copySessionIdBtn = document.getElementById('copySessionIdBtn');
const themeToggle = document.getElementById('themeToggle');
let isNightMode = true;
const startSessionBtn = document.getElementById('startSessionBtn');
const endSessionBtn = document.getElementById('endSessionBtn');
const buddySessionIdInput= document.getElementById('buddySessionIdInput');
const pairSessionsBtn = document.getElementById('pairSessionsBtn');
const textInput = document.getElementById('textInput');
const buddyEncryptBtn = document.getElementById('buddyEncryptBtn');
const buddyDecryptBtn = document.getElementById('buddyDecryptBtn');
/* Adjust these if needed */
const API_START = "/start_session";
const API_END = "/end_session";
const API_PAIR = "/pair_sessions";
const API_BUDDY_ENCRYPT = "/buddy_encrypt";
const API_BUDDY_DECRYPT = "/buddy_decrypt";
/* THEME: day/night */
themeToggle.addEventListener('click', () => {
isNightMode = !isNightMode;
if (isNightMode) {
document.body.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--bg-color-night');
document.body.style.color = getComputedStyle(document.documentElement).getPropertyValue('--text-color-night');
themeToggle.textContent = "Giorno";
} else {
document.body.style.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue('--bg-color-day');
document.body.style.color = getComputedStyle(document.documentElement).getPropertyValue('--text-color-day');
themeToggle.textContent = "Notte";
}
});
/* START SESSION */
startSessionBtn.addEventListener("click", () => {
fetch(API_START, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({})
})
.then(r => r.json())
.then(data => {
if(data.session_id) {
currentSessionId = data.session_id;
// Show session ID in container
sessionIdValue.textContent = currentSessionId;
sessionIdContainer.style.display = "block";
startSessionBtn.style.display = "none";
endSessionBtn.style.display = "inline-block";
} else {
alert("Error starting session: " + JSON.stringify(data));
}
})
.catch(err => alert("Error: " + err));
});
/* COPY session ID */
copySessionIdBtn.addEventListener("click", () => {
if(!currentSessionId) {
alert("No session ID to copy!");
return;
}
navigator.clipboard.writeText(currentSessionId)
.then(() => {
alert("Session ID copied to clipboard!");
})
.catch(err => {
alert("Failed to copy session ID: " + err);
});
});
/* END SESSION */
endSessionBtn.addEventListener("click", () => {
if(!currentSessionId) return;
fetch(API_END, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ session_id: currentSessionId })
})
.then(r => r.json())
.then(data => {
currentSessionId = null;
sessionIdContainer.style.display = "none";
sessionIdValue.textContent = "";
startSessionBtn.style.display = "inline-block";
endSessionBtn.style.display = "none";
buddySessionIdInput.value = "";
textInput.value = "";
})
.catch(err => alert("Error ending session: " + err));
});
/* PAIR SESSIONS */
pairSessionsBtn.addEventListener("click", () => {
if(!currentSessionId) {
alert("Start your session first.");
return;
}
const buddySid = buddySessionIdInput.value.trim();
if(!buddySid) {
alert("Please enter a Buddy Session ID.");
return;
}
const payload = {
session_id_A: currentSessionId,
session_id_B: buddySid
};
fetch(API_PAIR, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(r => r.json())
.then(data => {
if(data.status === "paired") {
alert("Session " + data.session_id_A + " is now paired with " + data.session_id_B);
} else {
alert("Pair error: " + JSON.stringify(data));
}
})
.catch(err => alert("Pair sessions error: " + err));
});
/* BUDDY ENCRYPT */
buddyEncryptBtn.addEventListener("click", () => {
if(!currentSessionId) {
alert("Start a session first.");
return;
}
const plaintext = textInput.value.trim();
if(!plaintext) {
alert("Nothing to encrypt.");
return;
}
const payload = {
session_id: currentSessionId,
plaintext: plaintext
};
fetch(API_BUDDY_ENCRYPT, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(r => r.json())
.then(data => {
if(data.encrypted_b64) {
textInput.value = data.encrypted_b64;
} else {
alert("Buddy Encrypt error: " + JSON.stringify(data));
}
})
.catch(err => alert("Buddy Encrypt fetch error: " + err));
});
/* BUDDY DECRYPT */
buddyDecryptBtn.addEventListener("click", () => {
if(!currentSessionId) {
alert("Start a session first.");
return;
}
const encrypted_b64 = textInput.value.trim();
if(!encrypted_b64) {
alert("No ciphertext to decrypt!");
return;
}
const payload = {
session_id: currentSessionId,
encrypted_b64: encrypted_b64
};
fetch(API_BUDDY_DECRYPT, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(r => r.json())
.then(data => {
if(data.plaintext) {
textInput.value = data.plaintext;
} else {
alert("Buddy Decrypt error: " + JSON.stringify(data));
}
})
.catch(err => alert("Buddy Decrypt fetch error: " + err));
});
</script>
<!-- Carica la tastiera virtuale semplificata -->
<script src="js/keyboard2.js" defer></script>
</body>
</html>