-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirus.html
More file actions
129 lines (113 loc) · 4.71 KB
/
Copy pathvirus.html
File metadata and controls
129 lines (113 loc) · 4.71 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
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP Reputation Checker - VirusTotal</title>
<style>
body {
font-family: Arial, sans-serif;
background: #121212;
color: #00ff00;
text-align: center;
padding: 20px;
}
input, button {
padding: 10px;
margin: 10px;
font-size: 16px;
border-radius: 5px;
border: none;
outline: none;
}
button {
background: #1f1f1f;
color: #00ff00;
cursor: pointer;
}
button:hover {
background: #333;
}
.result {
margin-top: 20px;
text-align: left;
display: inline-block;
}
</style>
</head>
<body>
<h1>IP Reputation Checker - VirusTotal</h1>
<input type="text" id="ipInput" placeholder="Enter IP Address">
<button type="button" id="checkVirusBtn">Check VirusTotal</button>
<div class="result" id="result"></div>
<script>
// IP address validation regex
const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})$/;
function isValidIP(ip) {
return ipv4Regex.test(ip) || ipv6Regex.test(ip);
}
document.getElementById("checkVirusBtn").addEventListener("click", checkVirusTotal);
document.getElementById("ipInput").addEventListener("keydown", (event) => {
if (event.key === "Enter") {
checkVirusTotal();
}
});
async function checkVirusTotal() {
const ip = document.getElementById("ipInput").value.trim();
const resultDiv = document.getElementById("result");
// Client-side validation
if (!ip) {
resultDiv.textContent = "Please enter an IP address.";
return;
}
if (!isValidIP(ip)) {
resultDiv.textContent = "Invalid IP address format. Please enter a valid IPv4 or IPv6 address.";
return;
}
if (ip.length > 45) {
resultDiv.textContent = "IP address is too long.";
return;
}
resultDiv.textContent = "Checking VirusTotal...";
try {
const virusResponse = await fetch(`/api/virustotal?ip=${encodeURIComponent(ip)}`);
if (!virusResponse.ok) {
const errorData = await virusResponse.json();
resultDiv.textContent = errorData.error || "Error fetching data from VirusTotal.";
return;
}
const virusData = await virusResponse.json();
resultDiv.textContent = ""; // Clear previous results
const title = document.createElement('h3');
title.textContent = `Results for IP: ${ip}`;
resultDiv.appendChild(title);
const virusHeader = document.createElement('h4');
virusHeader.textContent = 'VirusTotal';
resultDiv.appendChild(virusHeader);
const addLabeledValue = (label, value) => {
const p = document.createElement("p");
const strong = document.createElement("b");
strong.textContent = `${label}: `;
p.appendChild(strong);
p.appendChild(document.createTextNode(value ?? "N/A"));
resultDiv.appendChild(p);
};
addLabeledValue("Reputation", String(virusData.data?.attributes?.reputation ?? "N/A"));
addLabeledValue("Network", virusData.data?.attributes?.network ?? "N/A");
addLabeledValue(
"Last Analysis Stats",
virusData.data?.attributes?.last_analysis_stats
? JSON.stringify(virusData.data.attributes.last_analysis_stats)
: "N/A"
);
addLabeledValue("Tags", virusData.data?.attributes?.tags?.join(", ") ?? "N/A");
addLabeledValue("Whois", virusData.data?.attributes?.whois ?? "N/A");
} catch (error) {
console.error(error);
resultDiv.textContent = 'Error fetching data from VirusTotal.';
}
}
</script>
</body>
</html>