Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update liqi.json and liqi.py #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ $npm install -g protobufjs
$pbjs -t proto3 liqi.json > liqi.proto
```
然后使用protobuf将liqi.proto编译为liqi_pb2.py将旧版proto替换即可。
>注意,本项目使用protobuf==3.10.0,你同样应该使用[这个版本](https://github.com/protocolbuffers/protobuf/releases?expanded=true&page=7)提供的protoc
>注意,本项目使用protobuf==3.14.0,你同样应该使用[这个版本](https://github.com/protocolbuffers/protobuf/releases?expanded=true&page=7)提供的protoc
```
protoc --python_out=. liqi.proto
```
Expand Down
12 changes: 11 additions & 1 deletion liqi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ class MsgType(Enum):
Req = 2
Res = 3

keys = [0x84, 0x5e, 0x4e, 0x42, 0x39, 0xa2, 0x1f, 0x60, 0x1c]


def decode(data: bytes):
data = bytearray(data)
for i in range(len(data)):
u = (23 ^ len(data)) + 5 * i + keys[i % len(keys)] & 255
data[i] ^= u
return bytes(data)


class LiqiProto:

Expand Down Expand Up @@ -63,7 +73,7 @@ def parse(self, flow_msg) -> bool:
dict_obj = MessageToDict(proto_obj)
if 'data' in dict_obj:
B = base64.b64decode(dict_obj['data'])
action_proto_obj = getattr(pb, dict_obj['name']).FromString(B)
action_proto_obj = getattr(pb, dict_obj['name']).FromString(decode(B))
action_dict_obj = MessageToDict(action_proto_obj)
dict_obj['data'] = action_dict_obj
msg_id = self.tot
Expand Down
2 changes: 1 addition & 1 deletion proto/liqi.json

Large diffs are not rendered by default.

Loading