-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPowerShell.html
More file actions
119 lines (105 loc) · 3.9 KB
/
PowerShell.html
File metadata and controls
119 lines (105 loc) · 3.9 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
<!DOCTYPE html>
<html lang="en">
<!-- https://github.com/Javelinblog/PowerShell-Encoded-Commands-Tool -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PowerShell EncodedCommand Tool</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f5f5f5;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.container {
text-align: center;
max-width: 600px;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
textarea {
width: 100%;
padding: 10px;
margin: 10px 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
resize: none;
height: 30vh; /* Adjust the height as needed */
}
button {
padding: 10px 20px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.copy-button {
margin-top: 10px;
background-color: #3498db;
}
.copy-button:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<div class="container">
<h1>PowerShell EncodedCommand Tool</h1>
<textarea id="inputTextArea" placeholder="Enter text to encode or decode"></textarea>
<button id="encodeButton" onclick="encode()">Encode</button>
<button id="decodeButton" onclick="decode()">Decode</button>
<textarea id="outputTextArea" placeholder="Result will appear here" readonly></textarea>
<button class="copy-button" onclick="copyToClipboard()">Copy to Clipboard</button>
</div>
<script>
function encode() {
const inputText = document.getElementById('inputTextArea').value;
const outputTextArea = document.getElementById('outputTextArea');
// Encoding logic (to Base64 with UTF-16LE)
try {
const utf16leEncodedText = encodeToBase64WithUTF16LE(inputText);
outputTextArea.value = utf16leEncodedText;
} catch (error) {
outputTextArea.value = 'Invalid input for encoding';
}
}
function decode() {
const inputText = document.getElementById('inputTextArea').value;
const outputTextArea = document.getElementById('outputTextArea');
// Decoding logic (from Base64 with UTF-16LE)
try {
const utf16leDecodedText = new TextDecoder('utf-16le').decode(Uint8Array.from(atob(inputText), c => c.charCodeAt(0)));
outputTextArea.value = utf16leDecodedText;
} catch (error) {
outputTextArea.value = 'Invalid Base64 input';
}
}
function copyToClipboard() {
const outputTextArea = document.getElementById('outputTextArea');
outputTextArea.select();
document.execCommand('copy');
}
function encodeToBase64WithUTF16LE(text) {
const utf16leBytes = [];
for (let i = 0; i < text.length; i++) {
const charCode = text.charCodeAt(i);
utf16leBytes.push(charCode & 0xFF, (charCode >> 8) & 0xFF);
}
const utf16leArray = new Uint8Array(utf16leBytes);
return btoa(String.fromCharCode(...utf16leArray));
}
</script>
</body>
</html>