Simply judge whether the Qinglong library you pulled is safe

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)

Remember to manually select the file according to the above figure and then debug and run, otherwise you may encounter the problem shown in the figure below

Guess you like

Origin blog.csdn.net/m0_58606834/article/details/124851542