mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-06-20 10:21:04 +00:00
Keep sub-domains in meta, remove from deny (#1801)
* Keep sub-domains in meta, remove from deny * Multi-layer subdomains * isSubdomain check
This commit is contained in:
+22
-2
@@ -25,6 +25,23 @@ function sortSection (list) {
|
|||||||
.sort((a, b) => a.localeCompare(b));
|
.sort((a, b) => a.localeCompare(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSubdomain (list, url) {
|
||||||
|
const parts = url.split('.');
|
||||||
|
|
||||||
|
for (let i = 1; i < parts.length - 1; i++) {
|
||||||
|
if (list.includes(parts.slice(i).join('.'))) {
|
||||||
|
// this is a sub-domain of a domain that alreeady exists
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSubs (list) {
|
||||||
|
return list.filter((url) => !isSubdomain(list, url));
|
||||||
|
}
|
||||||
|
|
||||||
function sortAddresses (values) {
|
function sortAddresses (values) {
|
||||||
return Object
|
return Object
|
||||||
.entries(values)
|
.entries(values)
|
||||||
@@ -107,7 +124,7 @@ const deny = sortSection(addSites(all, addr));
|
|||||||
|
|
||||||
// rewrite with all our entries (newline included)
|
// rewrite with all our entries (newline included)
|
||||||
writeJson('address.json', sortAddresses(addr));
|
writeJson('address.json', sortAddresses(addr));
|
||||||
writeJson('all.json', { allow: sortSection(all.allow), deny });
|
writeJson('all.json', { allow: sortSection(all.allow), deny: removeSubs(deny) });
|
||||||
|
|
||||||
// find out what we don't have
|
// find out what we don't have
|
||||||
const urls = meta.map(({ url }) => url);
|
const urls = meta.map(({ url }) => url);
|
||||||
@@ -123,6 +140,9 @@ writeMeta(
|
|||||||
.filter((url) => !urls.includes(url))
|
.filter((url) => !urls.includes(url))
|
||||||
.map((url) => ({ date: ymd, url }))
|
.map((url) => ({ date: ymd, url }))
|
||||||
)
|
)
|
||||||
.filter(({ url }) => deny.includes(url))
|
.filter(({ url }) =>
|
||||||
|
deny.includes(url) ||
|
||||||
|
isSubdomain(deny, url)
|
||||||
|
)
|
||||||
.sort((a, b) => b.date.localeCompare(a.date) || a.url.localeCompare(b.url))
|
.sort((a, b) => b.date.localeCompare(a.date) || a.url.localeCompare(b.url))
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user