204 lines
6.4 KiB
HTML
204 lines
6.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>反诈骗软件 Demo</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f4f4f9;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.container {
|
|
width: 80%;
|
|
margin: 50px auto;
|
|
background-color: white;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #333;
|
|
}
|
|
.section {
|
|
margin: 30px 0;
|
|
}
|
|
.section input,
|
|
.section button {
|
|
padding: 10px;
|
|
font-size: 16px;
|
|
width: 100%;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
margin: 10px 0;
|
|
}
|
|
.section input[type="file"] {
|
|
width: auto;
|
|
}
|
|
.section button {
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
cursor: pointer;
|
|
}
|
|
.section button:hover {
|
|
background-color: #45a049;
|
|
}
|
|
.result {
|
|
margin-top: 20px;
|
|
padding: 10px;
|
|
background-color: #f9f9f9;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
}
|
|
.result p {
|
|
margin: 5px 0;
|
|
}
|
|
.result.success {
|
|
border-color: #4CAF50;
|
|
color: #4CAF50;
|
|
}
|
|
.result.error {
|
|
border-color: #f44336;
|
|
color: #f44336;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container">
|
|
<h1>反诈骗软件 Demo</h1>
|
|
|
|
<!-- 钓鱼网站检测 -->
|
|
<div class="section">
|
|
<h2>钓鱼网站检测</h2>
|
|
<input type="text" id="urlInput" placeholder="输入网址进行检测">
|
|
<button onclick="checkPhishingWebsite()">检测网址</button>
|
|
<div id="urlResult" class="result"></div>
|
|
</div>
|
|
|
|
<!-- 聊天图片检测 -->
|
|
<div class="section">
|
|
<h2>聊天图片检测</h2>
|
|
<input type="file" id="imageInput">
|
|
<button onclick="checkChatImage()">检测图片</button>
|
|
<div id="imageResult" class="result"></div>
|
|
</div>
|
|
|
|
<!-- 话术检测 -->
|
|
<div class="section">
|
|
<h2>话术检测</h2>
|
|
<input type="text" id="textInput" placeholder="输入文本进行检测">
|
|
<button onclick="checkScript()">检测话术</button>
|
|
<div id="textResult" class="result"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 创建 WebSocket 连接
|
|
const socket = new WebSocket('ws://localhost:8080'); // 后端WebSocket服务器的地址
|
|
|
|
socket.onopen = () => {
|
|
console.log('WebSocket 连接已建立');
|
|
};
|
|
|
|
socket.onmessage = (event) => {
|
|
const data = JSON.parse(event.data);
|
|
if (data.type === 'urlResult') {
|
|
displayUrlResult(data.result);
|
|
} else if (data.type === 'imageResult') {
|
|
displayImageResult(data.result);
|
|
} else if (data.type === 'textResult') {
|
|
displayTextResult(data.result);
|
|
}
|
|
};
|
|
|
|
socket.onerror = (error) => {
|
|
console.error('WebSocket 错误:', error);
|
|
};
|
|
|
|
socket.onclose = () => {
|
|
console.log('WebSocket 连接关闭');
|
|
};
|
|
|
|
// 钓鱼网站检测
|
|
function checkPhishingWebsite() {
|
|
const url = document.getElementById('urlInput').value;
|
|
if (url) {
|
|
socket.send(JSON.stringify({ type: 'checkPhishing', url }));
|
|
} else {
|
|
alert("请输入网址");
|
|
}
|
|
}
|
|
|
|
// 聊天图片检测
|
|
function checkChatImage() {
|
|
const imageInput = document.getElementById('imageInput');
|
|
if (imageInput.files.length > 0) {
|
|
const file = imageInput.files[0];
|
|
const reader = new FileReader();
|
|
reader.onload = function(e) {
|
|
socket.send(JSON.stringify({ type: 'checkImage', imageData: e.target.result }));
|
|
};
|
|
reader.readAsDataURL(file);
|
|
} else {
|
|
alert("请上传图片进行检测");
|
|
}
|
|
}
|
|
|
|
// 话术检测
|
|
function checkScript() {
|
|
const text = document.getElementById('textInput').value;
|
|
if (text) {
|
|
socket.send(JSON.stringify({ type: 'checkScript', text }));
|
|
} else {
|
|
alert("请输入文本进行检测");
|
|
}
|
|
}
|
|
|
|
// 显示检测结果
|
|
function displayUrlResult(result) {
|
|
const resultDiv = document.getElementById('urlResult');
|
|
if (result.isPhishing) {
|
|
resultDiv.textContent = "警告!这是一个钓鱼网站。";
|
|
resultDiv.classList.remove('success');
|
|
resultDiv.classList.add('error');
|
|
} else {
|
|
resultDiv.textContent = "这个网站看起来安全。";
|
|
resultDiv.classList.remove('error');
|
|
resultDiv.classList.add('success');
|
|
}
|
|
}
|
|
|
|
function displayImageResult(result) {
|
|
const resultDiv = document.getElementById('imageResult');
|
|
if (result.isSuspicious) {
|
|
resultDiv.textContent = "警告!图片检测到可疑内容。";
|
|
resultDiv.classList.remove('success');
|
|
resultDiv.classList.add('error');
|
|
} else {
|
|
resultDiv.textContent = "图片通过检测。";
|
|
resultDiv.classList.remove('error');
|
|
resultDiv.classList.add('success');
|
|
}
|
|
}
|
|
|
|
function displayTextResult(result) {
|
|
const resultDiv = document.getElementById('textResult');
|
|
if (result.isSuspicious) {
|
|
resultDiv.textContent = "警告!检测到可疑话术。";
|
|
resultDiv.classList.remove('success');
|
|
resultDiv.classList.add('error');
|
|
} else {
|
|
resultDiv.textContent = "文本通过检测。";
|
|
resultDiv.classList.remove('error');
|
|
resultDiv.classList.add('success');
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|