python - H4sIA处理

最近在抓包时发现返回值为一个奇怪的字符串,都是由H4sIA开头,最后发现是gzip压缩后的字符串,例如:
H4sIAAAAAAAACqtWKkotLs0pUbKqViouSSwpLVayMtBRKi3IyU9McUxJAcoCRfJKc3JAgimJJak++ekwgcy8ktSissSckMzcVLC2stSi4sz8PL9EEB+kplZHKSmxOBNoRLVSbjFQo9Kzyb1P9s551jHhadd8JR2l4sz0PJhxMPuNDAxqawGSwLdymQAAAA==

解压缩代码如下

import gzip
import base64

pText = "H4sIAAAAAAAACqtWKkotLs0pUbKqViouSSwpLVayMtBRKi3IyU9McUxJAcoCRfJKc3JAgimJJak++ekwgcy8ktSissSckMzcVLC2stSi4sz8PL9EEB+kplZHKSmxOBNoRLVSbjFQo9Kzyb1P9s551jHhadd8JR2l4sz0PJhxMPuNDAxqawGSwLdymQAAAA=="
text = gzip.decompress(base64.b64decode(pText))
print(f"解压: {text}")
import gzip
import base64

# 压缩前
text = '{"result":{"status":0,"uploadAddress":null,"updateLog":null,"intervalTime":0,"versionName":null},"basis":{"msg":"操作成功","sign":null,"status":200}}'
text = text.encode("utf-8")
pText = base64.b64encode(gzip.compress(text)).decode("utf-8")
print(f"压缩: {pText}")
posted @ 2023-08-24 14:02  wstong  阅读(409)  评论(0编辑  收藏  举报