简单的域名检测脚本

简单的域名检测脚本,

通过利用网站工具检测

1,check-domain.sh 脚本内容

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
#!/bin/bash
script_dir=$( cd $(dirname "$0") && pwd )
echo "`date +"%Y-%m-%d-%R"`" >$script_dir/domain.txt
echo "`date +"%Y-%m-%d-%R"`" >$script_dir/有问题.txt

cat ${script_dir}/domain_ssl.info |while read line;do

code=`curl https://tool.chinaz.com/pagestatus/?url=https%3A%2F%2F${line}| egrep -o '(<span>[0-9]{1,4}</span>)'|egrep -o '([0-9]{1,4})'`

if [ $code -ne 200 ] && [ $code -ne 301 ] && [ $code -ne 302 ];then echo "可能有问题的域名是 ${line} 状态码是: ${code}" >>${script_dir}/有问题.txt;fi

echo "检测的域名是 ${line} 状态码是: ${code}" >>${script_dir}/domain.txt

done


cat ${script_dir}/domain.txt | egrep -v '状态码是: [0-9]{3,4}' >> ${script_dir}/等待二次过滤.txt

cat ${script_dir}/等待二次过滤.txt|awk '{print $2}' |while read line1;do

code1=`curl https://tool.chinaz.com/pagestatus/?url=https%3A%2F%2F${line1}| egrep -o '(<span>[0-9]{1,4}</span>)'|egrep -o '([0-9]{1,4})'`

if [ $code1 -ne 200 ] && [ $code1 -ne 301 ] && [ $code1 -ne 302 ];then echo "可能有问题的域名是 ${line1} 状态码是
: ${code1}" >>${script_dir}/有问题.txt;fi

echo "检测的域名是 ${line1} 状态码是: ${code1}" >>${script_dir}/domain1.txt

done

cat ${script_dir}/domain1.txt | egrep -v '状态码是: [0-9]{3,4}' >> ${script_dir}/有问题.txt


sh ${script_dir}/message.sh

2,发送信息给telegram机器人的脚本

message.sh内容为

1
2
3
4
5
6
7
8
9
#!/bin/bash

script_dir=$( cd $(dirname "$0") && pwd)
curl -X POST "https://api.telegram.org/bot709759784:AAF2Tff_lKOBLIXHPzfoM1WHQkXt-SqkAqo/sendMessage" -d "chat_id=-377237859&text=`cat ${script_dir}/有问题.txt`"

rm -rf ${script_dir}/有问题.txt
rm -rf ${script_dir}/domain.txt
rm -rf ${script_dir}/等待二次过滤.txt
rm -rf ${script_dir}/domain1.txt

3, 新建domain_ssl.info 文件,里面保存要检测的域名,

4,设置定时任务,每隔40分检测一次

1
2

*/40 * * * * sh /check-domain/check-domain.sh

评论


:D 一言句子获取中...

加载中,最新评论有1分钟缓存...