1.1.73: adapt DSH 0.2.1-rc.2, Apache-2.0, lab-only default-deny.

This commit is contained in:
叫我小杨同学 committed 2026-10-23 11:50:42 +08:00
1 parent 8df4406a7c
commit 1ea067189c
114 files changed
+21198 -5183

No files matched your search

+71 -3
View File
@@ -183,6 +183,66 @@ function bankHit(name) {
return false;
}
// 演练靶场:本机/内网之外,只认这些平台和实验室后缀。其它公网地址一律拦。
const RANGE_SUFFIXES = [
".htb",
".thm",
".lab",
".lan",
".internal",
".test",
".home.arpa",
];
const RANGE_HOSTS = new Set([
"host.docker.internal",
"gateway.docker.internal",
"kubernetes.docker.internal",
"hackthebox.com",
"hackthebox.eu",
"tryhackme.com",
"vulnhub.com",
"vulhub.org",
"overthewire.org",
"pentesterlab.com",
"root-me.org",
"picoctf.org",
"picoctf.com",
"pwn.college",
"247ctf.com",
"ctflearn.com",
"cryptohack.org",
"portswigger.net",
"ctfd.io",
"buuctf.com",
"ctfhub.com",
"ctf.show",
"bugku.com",
"ichunqiu.com",
"xctf.org.cn",
"nssctf.cn",
"qsnctf.com",
"vulnstack.com",
"vulntarget.com",
"ciscn.cn",
"mozhe.cn",
"hetianlab.com",
]);
function rangeHit(name) {
if (!name || typeof name !== "string") return false;
if (RANGE_HOSTS.has(name)) return true;
for (const suffix of RANGE_SUFFIXES) {
if (name === suffix.slice(1) || name.endsWith(suffix)) return true;
}
let dot = name.indexOf(".");
while (dot !== -1) {
if (RANGE_HOSTS.has(name.slice(dot + 1))) return true;
dot = name.indexOf(".", dot + 1);
}
return false;
}
const DENIAL = "不行,这是严令禁止的";
// 渗透(?!测试):「渗透测试 / IP 与渗透测试」不是攻击任务(#73)。
@@ -407,6 +467,10 @@ function allowDecision(dshHome) {
return readAllowExact(dshHome);
}
export function ownServerNote() {
return "";
}
function permittedHost(host, allow) {
return allow.exact.has(host);
}
@@ -461,14 +525,18 @@ function hostsInTask(text) {
return hosts;
}
function isRangeTarget(name, allow) {
return permittedHost(name, allow) || isOwnNetwork(name) || rangeHit(name);
}
export async function taskTargetHit(text, dshHome = findDshHome()) {
if (!isAttackTask(text)) return null;
const allow = allowDecision(dshHome);
for (const host of hostsInTask(text)) {
const name = hostOf(host);
if (!name || permittedHost(name, allow) || isOwnNetwork(name) || isIp(name)) continue;
if (regionOfSuffix(name)) return taskHit(name, "domain");
if (bankHit(name)) return taskHit(name, "bank");
if (!name) continue;
if (isRangeTarget(name, allow)) continue;
return taskHit(name, isIp(name) ? "ip" : bankHit(name) ? "bank" : "domain");
}
return null;
}