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

原理:查询脚本是否加密以及都请求了哪些URL
方法:登录青龙后台 ——> 进入脚本管理 ——> 右上角 + 新建,目录选择脚本库,不要选根目录 ——> 文件名:xxx.py ——> 复制下面源码粘贴 ——> 调试,运行 ——> 会打印所有的js、ts、py脚本名字,是否加密,以及都请求了哪些url
如果脚本加密了,可以自选是否运行;请求了非京东域名的脚本,就要注意了,可以看下用了什么方法都做了哪些动作

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)

ce41f26eaf598d74106c97d0a6453bfd

THE END