2024-09-09 17:16:59 +08:00

49 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录页面</title>
<script>
function xorEncrypt(data, key) {
let out = '';
for (let i = 0; i < data.length; i++) {
out += String.fromCharCode(data.charCodeAt(i) ^ key.charCodeAt(i % key.length));
}
return out;
}
function login() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const key = 'FakeKey'; // localhost/dump.pcap
// 加密密码
const encryptedPassword = xorEncrypt(password, key);
// 发送请求
const xhr = new XMLHttpRequest();
xhr.open('POST', 'server.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
// 处理响应
const response = xhr.responseText;
alert(response);
}
};
xhr.send(`username=${encodeURIComponent(username)}&password=${encodeURIComponent(encryptedPassword)}`);
}
</script>
</head>
<body>
<h1>登录</h1>
<label for="username">用户名:</label>
<input type="text" id="username" required><br><br>
<label for="password">密码:</label>
<input type="password" id="password" required><br><br>
<button onclick="login()">登录</button>
</body>
</html>