吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 33547|回复: 24
收起左侧

[Python 转载] 快手解析作品/用户信息[字体反爬]

[复制链接]
ermao 发表于 2020-10-25 20:29
本帖最后由 ermao 于 2022-7-26 08:47 编辑

功能已失效,原内容已删除,仅保留字体反爬部分,思路还可以供人参考,勿回复

字体反爬部分代码

# -*- encoding: utf-8 -*-
'''
home.php?mod=space&uid=402414 File    :   kuaishou.py
@ Time    :   2020年09月27日 15:08:24 星期天
@ Author  :   ermao
@ Version :   1.0
@ Link    :   https://erma0.gitee.io
@ Desc    :   快手字体反爬
'''

print('start kuaishou.py')

import requests
import re
import time
import os
import json
# import hashlib
# from hashlib import md5
from io import BytesIO
from fontTools.ttLib import TTFont

def get_timestamp(long=13):
    if long == 10:
        timestamp = str(int(time.time()))
    else:  # long == 13:
        timestamp = str(int(time.time() * 1000))
    return timestamp

def user_info(id):
    u = {'kuaiId': id}
    url = 'https://c.kuaishou.com/fw/user/' + id
    try:
        res = requests.get(url, headers=headers).text
        user_json = htmlRe.search(res).group(1)
        userinfo = json.loads(user_json)
        u['userId'] = userinfo['userIdInfo']['userId']
        u['userName'] = userinfo['share']['title'][4:-12]
        u['desc'] = userinfo['share']['desc']
        u['imgUrl'] = userinfo['share']['imgUrl']
        u['count'] = userinfo['pageTabs'][0]['count']
        fontCdnUrl = userinfo['obfuseData']['fontCdnUrl']
        # u['fontCdnUrl'] = userinfo['obfuseData']['fontCdnUrl']

        # 映射表 网页字符:明文
        key_map = {}
        # 动态获取字体
        font_content = requests.get(fontCdnUrl).content
        font = TTFont(BytesIO(font_content))  # 从内存加载
        code = font.getGlyphOrder()[1:]  # 固定顺序的字符编码列表(去除第一个无效字符)
        nums = [  # 固定顺序明文列表
            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'w', 'k',
            'm', '+'
        ]
        temp = dict(zip(code, nums))  # 临时映射(固定顺序),字符编码uni****:明文
        res = font.getBestCmap()  # 获取关键映射,网页字符转码:字符编码uni****
        for k, v in res.items():
            # 网页字符去除前缀,再从16进制转10进制,就得到k,这里逆向写,即k转16进制后拼接前缀
            kk = '&#' + str(hex(k))[1:]
            # 从临时映射中根据字符编码uni****取出明文
            key_map[kk] = temp[v]
        # print(len(key_map), key_map)
        re_html_code = re.compile(r'&#x[\da-f]{4}')
        # for word in ['fan', 'follow', 'photo', 'collect']:  # 遍历需要用到的字体加密的参数
        for word in ['fan', 'follow']:  # 遍历需要用到的字体加密的参数
            # ('photo', 'collect'这两个重复了,可以不要)
            text = userinfo['obfuseData'][word]
            words = re_html_code.findall(text)
            u[word] = ''.join(key_map[i] for i in words)
        return u
    except Exception:
        return {'error': '出错!'}

免费评分

参与人数 4吾爱币 +15 热心值 +4 收起 理由
苏紫方璇 + 10 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
yjn866y + 1 + 1 我很赞同!
caidada + 1 + 1 我很赞同!
geniusrot + 3 + 1 大佬加油

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| ermao 发表于 2021-3-11 08:38
kiopc 发表于 2021-3-10 18:11
import fc2  
这个是啥?

阿里云的SDK,用于设置环境变量,本地运行的或者不用环境变量的可以删掉
hsfy1990 发表于 2020-10-25 20:45
jinhuiyi521 发表于 2020-10-25 20:46
mzhsohu 发表于 2020-10-25 21:11
感谢分享~!
薛定谔与猫 发表于 2020-10-25 21:11
太优秀了,谢谢分享
我是破解小白 发表于 2020-10-25 21:31
小白看不明白,感觉很厉害的样子
Βigbang 发表于 2020-10-25 21:37
感谢感谢感谢
geniusrot 发表于 2020-10-25 22:01
二毛大佬二逼,就是,我也看不懂phyton
jqdgjj 发表于 2020-10-25 22:02
看起来不错。
lidong963812 发表于 2020-10-25 23:29
谢谢楼主
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-5 14:09

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表