Skip to content

Commit f6da059

Browse files
Copilot0x5t4l1n
andauthored
Fix DOM XSS vectors across pages and prepare 2.0.1 bugfix release
Agent-Logs-Url: https://github.com/th30d4y/IP/sessions/6013f9b8-efa5-4d7e-a703-44d539e8bb47 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com>
1 parent df218ee commit f6da059

16 files changed

Lines changed: 2165 additions & 1946 deletions

SECURITY_FIXES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,5 +276,6 @@ curl -I http://localhost:3000
276276

277277
---
278278

279+
**Release:** 2.0.1 (bugfix)
279280
**Last Updated:** April 17, 2026
280281
**Status:** All vulnerabilities patched and tested

both.html

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,48 +42,84 @@ <h1>IP Reputation Checker - Both Services</h1>
4242
<div class="result" id="result"></div>
4343

4444
<script>
45+
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]?)$/;
46+
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})$/;
47+
48+
function isValidIP(ip) {
49+
return ipv4Regex.test(ip) || ipv6Regex.test(ip);
50+
}
51+
52+
function addLabeledValue(container, label, value) {
53+
const p = document.createElement("p");
54+
const strong = document.createElement("b");
55+
strong.textContent = `${label}: `;
56+
p.appendChild(strong);
57+
p.appendChild(document.createTextNode(value ?? "N/A"));
58+
container.appendChild(p);
59+
}
60+
4561
async function checkBoth() {
4662
const ip = document.getElementById("ipInput").value.trim();
4763
const resultDiv = document.getElementById("result");
4864

4965
if (!ip) {
50-
resultDiv.innerHTML = "<p>Please enter a valid IP address.</p>";
66+
resultDiv.textContent = "Please enter a valid IP address.";
67+
return;
68+
}
69+
70+
if (!isValidIP(ip)) {
71+
resultDiv.textContent = "Invalid IP address format. Please enter a valid IPv4 or IPv6 address.";
5172
return;
5273
}
5374

54-
resultDiv.innerHTML = "<p>Checking AbuseIPDB and VirusTotal...</p>";
75+
if (ip.length > 45) {
76+
resultDiv.textContent = "IP address is too long.";
77+
return;
78+
}
79+
80+
resultDiv.textContent = "Checking AbuseIPDB and VirusTotal...";
5581

5682
try {
57-
const abuseResponse = await fetch(`/api/abuseipdb?ip=${ip}`);
83+
const abuseResponse = await fetch(`/api/abuseipdb?ip=${encodeURIComponent(ip)}`);
5884
const abuseData = await abuseResponse.json();
5985

60-
const virusResponse = await fetch(`/api/virustotal?ip=${ip}`);
86+
const virusResponse = await fetch(`/api/virustotal?ip=${encodeURIComponent(ip)}`);
6187
const virusData = await virusResponse.json();
6288

63-
resultDiv.innerHTML = `
64-
<h3>Results for IP: ${ip}</h3>
65-
66-
<h4>AbuseIPDB</h4>
67-
<p><b>Abuse Confidence Score:</b> ${abuseData.data?.abuseConfidenceScore || "N/A"}</p>
68-
<p><b>Categories:</b> ${abuseData.data?.category?.join(", ") || "N/A"}</p>
69-
<p><b>Country:</b> ${abuseData.data?.countryCode || "N/A"}</p>
70-
<p><b>ISP:</b> ${abuseData.data?.isp || "N/A"}</p>
71-
<p><b>Domain:</b> ${abuseData.data?.domain || "N/A"}</p>
72-
73-
<h4>VirusTotal</h4>
74-
<p><b>Reputation:</b> ${virusData.data?.attributes?.reputation || "N/A"}</p>
75-
<p><b>Network:</b> ${virusData.data?.attributes?.network || "N/A"}</p>
76-
<p><b>Last Analysis Stats:</b> ${
77-
virusData.data?.attributes?.last_analysis_stats
78-
? JSON.stringify(virusData.data.attributes.last_analysis_stats)
79-
: "N/A"
80-
}</p>
81-
<p><b>Tags:</b> ${virusData.data?.attributes?.tags?.join(", ") || "N/A"}</p>
82-
<p><b>Whois:</b> ${virusData.data?.attributes?.whois || "N/A"}</p>
83-
`;
89+
resultDiv.textContent = "";
90+
91+
const title = document.createElement("h3");
92+
title.textContent = `Results for IP: ${ip}`;
93+
resultDiv.appendChild(title);
94+
95+
const abuseHeader = document.createElement("h4");
96+
abuseHeader.textContent = "AbuseIPDB";
97+
resultDiv.appendChild(abuseHeader);
98+
99+
addLabeledValue(resultDiv, "Abuse Confidence Score", String(abuseData.data?.abuseConfidenceScore ?? "N/A"));
100+
addLabeledValue(resultDiv, "Categories", abuseData.data?.category?.join(", ") ?? "N/A");
101+
addLabeledValue(resultDiv, "Country", abuseData.data?.countryCode ?? "N/A");
102+
addLabeledValue(resultDiv, "ISP", abuseData.data?.isp ?? "N/A");
103+
addLabeledValue(resultDiv, "Domain", abuseData.data?.domain ?? "N/A");
104+
105+
const virusHeader = document.createElement("h4");
106+
virusHeader.textContent = "VirusTotal";
107+
resultDiv.appendChild(virusHeader);
108+
109+
addLabeledValue(resultDiv, "Reputation", String(virusData.data?.attributes?.reputation ?? "N/A"));
110+
addLabeledValue(resultDiv, "Network", virusData.data?.attributes?.network ?? "N/A");
111+
addLabeledValue(
112+
resultDiv,
113+
"Last Analysis Stats",
114+
virusData.data?.attributes?.last_analysis_stats
115+
? JSON.stringify(virusData.data.attributes.last_analysis_stats)
116+
: "N/A"
117+
);
118+
addLabeledValue(resultDiv, "Tags", virusData.data?.attributes?.tags?.join(", ") ?? "N/A");
119+
addLabeledValue(resultDiv, "Whois", virusData.data?.attributes?.whois ?? "N/A");
84120
} catch (error) {
85121
console.error(error);
86-
resultDiv.innerHTML = "<p>Error fetching data from both services.</p>";
122+
resultDiv.textContent = "Error fetching data from both services.";
87123
}
88124
}
89125
</script>

firebaseauth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const db = getFirestore();
2222
function showMessage(message, divId) {
2323
const messageDiv = document.getElementById(divId);
2424
messageDiv.style.display = "block";
25-
messageDiv.innerHTML = message;
25+
messageDiv.textContent = message;
2626
messageDiv.style.opacity = 1;
2727
setTimeout(() => {
2828
messageDiv.style.opacity = 0;
@@ -104,4 +104,4 @@ signIn.addEventListener('click', async (event) => {
104104
showMessage("An error occurred during login. Please try again.", "signInMessage");
105105
}
106106
}
107-
});
107+
});

homepage.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ <h2>Hacker's Toolkit</h2>
128128
// Simulate checking connection and user's access pattern (e.g., rate limiting or IP blocking)
129129
const suspiciousIP = ['malicious_ip_here']; // List of malicious IPs (to be managed on server-side)
130130
if (suspiciousIP.includes(userIP)) {
131-
document.body.innerHTML = "<div class='blocked'>Your IP has been blocked due to suspicious activity.</div>";
131+
const blockedMessage = document.createElement("div");
132+
blockedMessage.className = "blocked";
133+
blockedMessage.textContent = "Your IP has been blocked due to suspicious activity.";
134+
document.body.replaceChildren(blockedMessage);
132135
return; // Stop further execution for malicious users
133136
}
134137

login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h1 class="form-title">Sign In</h1>
9090
const messageDiv = document.getElementById(divId);
9191
messageDiv.style.color = isError ? "red" : "green";
9292
messageDiv.style.display = "block";
93-
messageDiv.innerHTML = message;
93+
messageDiv.textContent = message;
9494
setTimeout(() => {
9595
messageDiv.style.display = "none";
9696
}, 5000);

0 commit comments

Comments
 (0)