-
Notifications
You must be signed in to change notification settings - Fork 2
/
ducky.js
117 lines (95 loc) · 3.38 KB
/
ducky.js
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
document.getElementById('bottoneString').addEventListener('click', stringAte);
document.getElementById('bottoneAltcode').addEventListener('click', altcodeAte);
document.getElementById('bottoneRemark').addEventListener('click', remarkAte);
document.getElementById('bottoneAltchar').addEventListener('click', insertChar);
document.getElementById('tastoSalva').addEventListener('click', saveOutput);
function stringAte() {
const input = document.getElementById('inputz');
const output = document.getElementById('output');
let translatedInput = '';
const lines = input.value.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line === '') {
continue;
} else {
translatedInput += `STRING ${line}\n`;
}
}
if (input.value[input.value.length - 1] !== '\n') {
translatedInput += '\n';
}
output.value += translatedInput.trim() + '\n';
input.value = '';
}
function altcodeAte() {
const input = document.getElementById('inputz');
const output = document.getElementById('output');
let translatedInput = '';
const lines = input.value.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line === '') {
continue;
} else {
translatedInput += `ALTCODE ${line}\n`;
}
}
if (input.value[input.value.length - 1] !== '\n') {
translatedInput += '\n';
}
output.value += translatedInput.trim() + '\n';
input.value = '';
}
function remarkAte() {
const input = document.getElementById('input');
const output = document.getElementById('output');
let translatedInput = '';
const lines = input.value.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line === '') {
continue;
} else {
translatedInput += `REM ${line}\n`;
}
}
if (input.value[input.value.length - 1] !== '\n') {
translatedInput += '\n';
}
output.value += translatedInput.trim() + '\n';
input.value = '';
}
function inserisciEVai(value) {
const output = document.getElementById('output');
output.value += value + '\n';
}
function insertChar() {
const input = document.getElementById('charInput');
const output = document.getElementById('output');
let translatedInput = '';
const lines = input.value.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line === '') {
continue;
} else {
translatedInput += `ALTCHAR ${line}\n`;
}
}
if (input.value[input.value.length - 1] !== '\n') {
translatedInput += '\n';
}
output.value += translatedInput.trim() + '\n';
input.value = '';
}
function saveOutput() {
const output = document.getElementById('output');
const filename = prompt("Enter the payload name", "payload.txt");
const blob = new Blob([output.value], { type: 'text/plain' });
const anchor = document.createElement('a');
anchor.download = filename || 'payload.txt';
anchor.href = window.URL.createObjectURL(blob);
anchor.click();
anchor.remove();
}