HQBSH.com的whois记录显示注册于2013年1月18日,至今已经持续运营了:0年0个月0天零0小时0分钟0秒

最新报价
 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 85|回复: 3

自动检测网站有没有被入侵,百度收录是否正常,并发邮件给指定帐户 。

[复制链接]

3333

主题

493

回帖

1579

银子

管理员

积分
18439
QQ
发表于 | 显示全部楼层 |阅读模式
自动检测网站有没有被入侵,百度,360,sogou,bing收录是否正常,并发邮件给指定帐户
2020-06-28_163705.jpg 2020-06-28_163721.jpg

  1. import requests
  2. import yh_dl,time,os
  3. import yh_email

  4. def save(html):
  5.         name="1.html"
  6.         html1=html.content
  7.         with open(name,"wb") as f:
  8.                 f.write(html1)


  9. def baidu_test(i,headers,txt_mail):

  10.         #循环读取所有所有域名进行凭拼接
  11.         baidu_domain = "https://www.baidu.com/s?ie=UTF-8&wd=site%3A"+i
  12.         #指定访问all_urls中的所有域名
  13.         html = requests.get(baidu_domain,headers=headers).text
  14.         if "风险" in html:
  15.                 txt=i+' 域名百度已报:风险,请快速处理'
  16.         else:
  17.                 txt=i+' 百度快照状态正常。'
  18.         print(txt)
  19.         txt_mail=txt_mail+txt+'\n'
  20.         return txt_mail

  21. def test_360(i,headers,txt_mail):
  22.         html_360='https://www.so.com/s?q=site%3A'+i+'&src=srp&fr=none'
  23.         html = requests.get(html_360,headers=headers)
  24.         html_1=html.text
  25.         if "虚假" in html_1:
  26.                 # print(html_1)
  27.                 save(html)
  28.                 # os.exit
  29.                 txt=i+' 域名360已报:风险,请快速处理'
  30.         else:
  31.                 txt=i+' 360快照状态正常。'
  32.         print(txt)
  33.         txt_mail=txt_mail+txt+'\n'
  34.         return txt_mail

  35. def test_bing(i,headers,txt_mail):
  36.         for ii in (0,1):
  37.                 if ii==0:
  38.                         txt1='Bing国内版'
  39.                 else:
  40.                         txt1='Bing国际版'
  41.                 html_url='https://cn.bing.com/search?q=site%3A'+i+'&FORM=BESBTB&ensearch='+str(ii)
  42.                 html = requests.get(html_url,headers=headers)
  43.                 html_1=html.text
  44.                 if "风险" in html_1:
  45.                         # print(html_1)
  46.                         save(html)
  47.                         # os.exit
  48.                         txt=i+' 域名%s已报:风险,请快速处理'%txt1
  49.                 else:
  50.                         txt=i+' %s状态正常。'%txt1
  51.                 print(txt)
  52.                 txt_mail=txt_mail+txt+'\n'
  53.         return txt_mail


  54. def test_sogou(i,headers,txt_mail):
  55.         txt1='搜狗'
  56.         headers={
  57.         'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
  58.         'Accept-Encoding': 'gzip, deflate, br',
  59.         'Accept-Language': 'zh,zh-CN;q=0.9',
  60.         'Connection': 'keep-alive',
  61.         'Cookie': 'CXID=716ABD167F96C2985337CB890C9E7462; ad=gkllllllll2Wdk$alllllVELjo7lllllVGwlLlllll9lllllpOxlw@@@@@@@@@@@; SUID=D800C2141824A00A5EF60A8B00048552; ABTEST=1|1593237758|v17; SUV=1593237750045371; browerV=3; osV=1; sct=1; SNUID=A0779B96E1E548EB72E449DFE19BDB78; sst0=768; taspeed=taspeedexist; pgv_pvi=3457337344; pgv_si=s3333383168; IPLOC=KR; ld=pkllllllll2Wdm99lllllVELiallllllNTmQyyllll6lllllpZlll5@@@@@@@@@@; LSTMV=718%2C24; LCLKINT=180423',
  62.         'Host': 'www.sogou.com',
  63.         'Referer': 'https://www.sogou.com/web?query=site%3Awww.hqbsh.com&_asf=www.sogou.com&_ast=&w=01019900&p=40040100&ie=utf8&from=index-nologin&s_from=index&sut=3818&sst0=1593237755768&lkt=18%2C1593237751951%2C1593237755510&sugsuv=1593237750045371&sugtime=1593237755768',
  64.         'Sec-Fetch-Dest': 'document',
  65.         'Sec-Fetch-Mode': 'navigate',
  66.         'Sec-Fetch-Site': 'same-origin',
  67.         'Sec-Fetch-User': '?1',
  68.         'Upgrade-Insecure-Requests':'1',
  69.         'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
  70.         }
  71.         t=str(int(time.time()*1000))
  72.         html_url='https://www.sogou.com/web?query=site%3A'+i
  73.         # html_url='https://www.sogou.com/web?query=site%3A'+i+'&_ast='+t+'&_asf=www.sogou.com&w=01029901&p=40040100&dp=1&cid=&s_from=result_up'
  74.         html = requests.get(html_url,headers=headers)
  75.         html_1=html.text
  76.         if "安全风险" in html_1:
  77.                 print(html_1)
  78.                 save(html)
  79.                 # os.exit
  80.                 txt=i+' 域名%s已报:风险,请快速处理'%txt1
  81.         else:
  82.                 txt=i+' %s状态正常。'%txt1
  83.         print(txt)
  84.         txt_mail=txt_mail+txt
  85.         return txt_mail

  86. def main():
  87.         # 列出所有查询的网址域名

  88.         all_urls =[
  89.         "www.hqbsh.com",
  90.         "www.sj868.cn",
  91.         'www.hqbdiy.com',
  92.         'www.xgibm.com',
  93.         'www.hkbjb.com',
  94.         'www.xgbjb.com',
  95.         'www.zhenlongprint.com',
  96.         ]

  97.         user_agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
  98.         headers={"User-Agent":user_agent}

  99.         # headers={
  100.         # "Referer":'www.baidu.com',
  101.         # "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
  102.         # "Accept-Encoding":"gzip, deflate",
  103.         # "Accept-Language":"zh-CN,zh;q=0.8",
  104.         # "Connection":"keep-alive"
  105.         # }
  106.         txt_mail=''
  107.         for i in all_urls:
  108.                 print('\n')
  109.                 txt_mail=txt_mail+'\n'
  110.                 domain = "http://" + i
  111.                 try:
  112.                         code = requests.get(domain)
  113.                         txt_temp=i+' 网站访问正常。 '+str(code.status_code)
  114.                         txt_mail=txt_mail+'\n'
  115.                         print(txt_temp)
  116.                 except:
  117.                         #调试异常情况
  118.                         txt_temp=i+ " 域名出现无法访问问题,请及时排查问题"
  119.                         #跳出当前循环
  120.                         print(txt_temp)
  121.                         txt_mail=txt_mail+'\n'
  122.                         continue
  123.                 else:
  124.                         if code.status_code == 200:
  125.                                 #循环读取每一个网站的情况
  126.                                 html = code.text
  127.                                 if "<script>document.title=" in html:
  128.                                         print("您的网站:",i,"已出现疑似入侵信息,请快速处理")
  129.                                         txt_mail=txt_mail+"您的网站:"+i+"已出现疑似入侵信息,请快速处理"+'\n'
  130.                                 txt_mail=baidu_test(i,headers,txt_mail)
  131.                                 txt_mail=test_360(i,headers,txt_mail)
  132.                                 txt_mail=test_bing(i,headers,txt_mail)
  133.                                 txt_mail=test_sogou(i,headers,txt_mail)


  134.         print("\n\n检测完成。\n\n")
  135.         txt_mail=txt_mail+'\n\n检测完成\n'
  136.         yh_email.email_txt(txt_mail,'每日网站检查')
  137.         os.system('pause')

  138. yh_dl.kill_system_dl()
  139. main()
复制代码


2020-06-28_163012.jpg
呼号:BG2ITE 电话:18938079527 qq:78950405
回复

使用道具 举报

0

主题

1639

回帖

0

银子

初级会员

积分
1587

活跃会员热心会员

发表于 | 显示全部楼层
这么多年了,还是商行一直在。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 QQ登录

本版积分规则

在线客服
马上联系
加好友78950405
微信联系8618938079527
微信联系
电话联系
联系电话18938079527
工作时间
11:00-22:00