Skip to content

Commit

Permalink
汽车之家口碑app端css字体加密逆向
Browse files Browse the repository at this point in the history
  • Loading branch information
freedom-wy committed Sep 15, 2019
1 parent 6ae6f01 commit 22619d8
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 43,657 deletions.
332 changes: 185 additions & 147 deletions .idea/workspace.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions autohome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 汽车之家爬虫
### 仅限学术交流,如有冒犯,请及时联系本人删除
***
#### 文件列表:
##### koubei 汽车之家app端口碑css加密字体逆向
***
#### bug:dazhuang_python@sina.com
Empty file added autohome/__init__.py
Empty file.
Binary file not shown.
14 changes: 14 additions & 0 deletions autohome/koubei/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 汽车之家app端口碑css加密字体破解
### 仅限学术交流,如有冒犯,请及时联系本人删除
***
#### 文件列表:
##### font_dict 大众点评页面字体对应关系---部分
***
#### 破解方法:
##### 1、通过浏览器开发者模式,找到页面中文字所使用的css样式
##### 2、通过抓包等方法找到加载的css文件,通过正则表达式取出字体文件URL
##### 3、通过[百度字体编辑器解析woff文件](http://fontstore.baidu.com/static/editor/index.html) 可以生成font_list.py文件
##### 4、使用fontTools处理字体文件,得出对应关系
##### 5、通过对应关系解析加密字体
***
#### bug:dazhuang_python@sina.com
Empty file added autohome/koubei/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions autohome/koubei/handle_autohome_app_koubei.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import requests
import json
from fontTools.ttLib import TTFont
from lxml import etree
import re


class AutohomeKoubei(object):
def __init__(self):
self.detail_url = "https://k.m.autohome.com.cn/detail/share_01dmqy8fa168vkae9h60vg0000.html"
self.header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'
}

def handle_font(self):
'''
首先获取ttf字体文件,写入本地
:return:
'''
response = requests.get(url=self.detail_url,headers=self.header)
# ttf_url_search = re.compile(r"src:url\('//(.*?)'\)\sformat\('woff'\);")
# ttf_url = 'http://'+ttf_url_search.search(response.text).group(1)
# ttf_response = requests.get(url=ttf_url,headers=self.header)
# with open('koubei.ttf','wb') as f:
# f.write(ttf_response.content)
self.detail = response.text

def handle_detail(self):
font_file = TTFont('koubei.ttf')
# 找出字体和字体文件中编码的对应关系,保存为字典
# font_dict = json.dumps(dict(zip(font_file.getGlyphOrder(), FONT_LIST)))
print(font_file.getGlyphOrder())


if __name__ == '__main__':
koubei = AutohomeKoubei()
# koubei.handle_font()
koubei.handle_detail()
Binary file added autohome/koubei/koubei.ttf
Binary file not shown.
Loading

0 comments on commit 22619d8

Please sign in to comment.