简单判断自己拉的青龙库是否安全

import os
import re
import sys
# 获取文件中的URL
def getUrls(file):
    f = open(file, 'r', encoding="utf-8")
    file_text = f.read()
    urls = re.findall(r'[a-zA-z]+://[^\s]*', file_text)
    if 'jsjiami.com' in file_text:
        urls.append('Encrypted')
    if urls:
        return urls
def getExt(file):
    scriptType = 'jstspy'
    file_ext = os.path.splitext(file)[1]
    file_ext = file_ext.split('.')[1]
    if file_ext in scriptType:
        return True
def getFile(file):
    Files = []
    if os.path.isdir(file) == True:
        print('当前目录: %s' % os.path.abspath(child))
        os.chdir(file)
        files = os.listdir()
        for i in files:
            getFile(i)
        os.chdir('../')
    else:
        Files.append(os.path.abspath(file))
    return Files
def load_send():
    global send
    cur_path = os.path.abspath(os.path.dirname(file))
    sys.path.append(cur_path)
    if os.path.exists(cur_path + "/sendNotify.py"):
        try:
            from sendNotify import send
        except:
            send=False
            print("加载通知服务失败~")
    else:
        send=False
        print("加载通知服务失败~")
load_send()
if name == "main":
    total_encrypted = 0
    print('当前目录 %s ' % os.getcwd())
    dir_childs = os.listdir()
    for child in dir_childs:
        # 判断是否目录
        # if os.path.isdir(child) == True:
        #     print('当前目录: %s' % os.path.abspath(child))
        #     os.chdir(child)
        #     # 获取文件
        #     os.chdir('../')
        total_files = getFile(child)
        try:
            for file in total_files:
                if getExt(file) == True:
                    print('###### %s ######' % file)
                    urls = getUrls(file)
                    for url in urls:
                        if 'jd.com' not in url:
                            print(url+'\n')
                            if url == 'Encrypted':
                                total_encrypted += 1
        except Exception as e:
            print(e)
    print('当前共查找到加密脚本 %d 个' % total_encrypted)
    msg = '当前共查找到加密脚本 %d 个' % total_encrypted
    send('加密脚本检测', msg)

记得按照上图手动选择一下那个文件再调试运行,否则可能会碰到下图显示的问题

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值