-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
executable file
·128 lines (112 loc) · 4.92 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" type="image/ico" href="https://cdn.jsdelivr.net/npm/skx@0.0.1">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimal-ui">
<title>Cloudflare Threat Score Test - Sukka's Lab</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/suka.css@0.2.1">
<style>
html {
font-size: 20px;
}
body {
background: #fff;
color: #50596c;
font-family: -apple-system,
system-ui,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
sans-serif;
font-size: .8rem;
overflow-x: hidden;
text-rendering: optimizeLegibility;
}
p {
margin: .2rem;
}
</style>
</head>
<body>
<section style="max-width: 600px; margin: 2rem auto; padding: 0 1rem; text-align: center">
<h1>Cloudflare Threat Score Test</h1>
<p>测试你当前在 Cloudflare 的声誉</p>
<br><br>
<div id="threat-score" style="text-align: center">正在测试中,大概需要 5 ~ 10 秒....</div>
<div style="text-align: left; margin: 30px 0;">
<p style="font-size: .7rem">Cloudflare 会对每个请求进行风险评估。0 表示 Cloudflare 判定为低风险,高于 10 代表 Cloudflare 判定为爬虫或者垃圾邮件发送者,高于 40 则代表 Cloudflare 判定为有严重不良行为的 IP(如僵尸网络等)。这个数值一般不会大于 60。</p>
</div>
<h3>当前请求信息</h3>
<div id="request-info" style="text-align: left; font-size: .65rem"></div>
<h3>在终端中使用</h3>
<p><code style="user-select: all">curl -o- https://lab.skk.moe/cf-threat/test.sh | bash</code></p>
</section>
<script>
((document) => {
const _get = (url, type) =>
fetch(url, { method: 'GET' }).then((resp) => {
if (type === 'text')
return Promise.all([resp.ok, resp.status, resp.text(), resp.headers]);
else {
return Promise.all([resp.ok, resp.status, resp.json(), resp.headers]);
}
}).then(([ok, status, data, headers]) => {
if (ok) {
let json = {
ok,
status,
data,
headers
}
return json;
} else {
throw new Error(JSON.stringify(json.error));
}
}).catch(error => {
throw error;
})
_get('https://cf-threat.sukkaw.com/cdn-cgi/trace', 'text')
.then(resp => {
let data = {};
for (let i of resp.data.split('\n')) {
let x = i.split('=');
data[x[0]] = x[1];
}
return data;
})
.then(data => {
document.getElementById('request-info').innerHTML = `<p><strong>IP:</strong> ${data.ip}</p><p><strong>Loc:</strong> ${data.loc}</p><p><strong>TLS:</strong> ${data.tls}</p><p><strong>User-Agent: </strong>${data.uag}</p>`
})
const output = (score) => {
let color = '';
if (score < 5) {
color = 'sk-text-success'
} else if (score < 20) {
color = 'sk-text-warning'
} else if (score < 100) {
color = 'sk-text-error'
}
return `<span class="${color}" style="font-size: 2rem; vertical-align: middle; margin: 0 8px;">${score}</span>`
}
const promises = [];
const runcheck = (level) => new Promise((resolve, reject) => {
let img = new Image;
img.onerror = () => resolve(level);
img.onload = () => resolve();
img.src = `https://cf-threat.sukkaw.com/i.gif?threat=${level}&${+(new Date)}`;
});
for (let i = 100; i >= 0; i--) {
promises.push(runcheck(i));
}
Promise.all(promises).then(fullfills => {
const score = fullfills.filter(n => n !== undefined)[0];
document.getElementById('threat-score').innerHTML = `<span style="vertical-align: middle;">你当前在 Cloudflare 的威胁指数是</span> ${output(score)}`;
});
})(document);
</script>
<script>window.ga_tid = "UA-122669675-3", window.ga_api = "https://d.skk.moe/p/"</script>
<script src="https://cdn.jsdelivr.net/npm/cfga@1.0.1"></script>
</body>
</html>