# 记录解密大众点评数据加密过程

话不多说,上图片
在这里插入图片描述
上图就是解密的关键东西了,每个加密的文字和数字都有一个所属的类名,而这个类名对应着css里面的样式偏移量,偏移量又对应着文字图片和数字图片的位置

下面就是最新的文字图和数字图
在这里插入图片描述
在这里插入图片描述
直接上代码:

import re
import requests
import lxml.html


# 获取css页面的详情信息,用正则匹配得到css的定位数据
def css_info(info):
    # css 页面   这个网址是会变化的,修改为自己获取到的
    css_html = requests.get(
        'http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/f2b16ee92e4d503f1cc86db029f132e7.css').text
    # mty2pe{background:-180.0px -1664.0px;}
    # 正则,这里有个坑,刚开始使用+拼接,不能匹配
    str_css = r'%s{background:-(\d+).0px -(\d+).0px' % info
    css_re = re.compile(str_css)
    info_css = css_re.findall(css_html)
    # print(css_html)
    # print(str_css)
    # print(info_css)
    return info_css

#传入对应的属性类名
def get_info(class_name):
    try:
    #这是对应的svg文件
        res = requests.get(
            'http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/c795d545c25e6255fc57f30001eb4a8f.svg')
        # print(type(res.text))
        tree = etree.HTML('<html>' + res.text + '</html>')
        textPath = tree.xpath('//text//text()')
        textPath = [x.strip() for x in textPath if x.strip() != '']
        path = tree.xpath('//defs/path/@d')
        xx, yy = css_info(class_name)[0]
        xx, yy = int(xx), int(yy)
        chinese_list = []
        for c, n in zip(textPath, path):
            ch = c
            try:
                nu = re.findall('M0 (.*?) H600', n)[0]
            # print(xx, yy, nu)
            except:
                print('请更换MO,H600规则')

            try:
                if yy <= int(nu):
                    chinese = ch[xx // 12]
                    chinese_list.append(chinese)
                    break
            except:
                pass
        # print(chinese_list[0])
        return chinese_list[0]
    except:
        print('请更换svg,css文件')

上面是文字加密,下面是方块加密
在这里插入图片描述
方块解密在这个文章中解释了
https://www.jianshu.com/p/d0fb17ec0ef9

其中用fontcreator打开文件之后直接截图发到qq好友(不能是我的电脑),然后在手机上提取图片中的文字,将文字放入jiemi.txt中,将其中的特殊字符去掉,行与行之间的空行去掉,然后在读取格式化

with open('./jiemi.txt', 'r', encoding='utf8')as f:
    file = f.readlines()
    data_dict = {}
    for index, value in enumerate(file):
        data_dict[index] = value.replace('\n', '')
    my_dict = {}
    for k, v in data_dict.items():
        if k % 2 == 0:
            k_list = v.split(' ')
            v_list = ','.join(data_dict[k + 1]).split(',')
            # print(v_list)
            kk_list = []
            for a in k_list:
                if 'uni' in a:
                    kk_list.append(a)
            # print(kk_list, v_list)
            # print(len(kk_list), len(v_list))

            for n, m in zip(kk_list, v_list):
                my_dict[n] = m
    print(my_dict)

这样输出的就是全网站的方块加密的字典了(如果不是一套那真是太恶心了)

这是我的第一次写博客,博客用的还不熟
只是简单的记录一下解密的过程,可根据自己的项目进行修改

猜你喜欢

转载自blog.csdn.net/qq_43035475/article/details/90445270