forked from foxundermoon/WechatHelper708
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
74 lines (67 loc) · 1.72 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package wxxx
import (
"wxxx/mm_pb"
)
var Log = &logger{}
const shortUrl = "http://szshort.weixin.qq.com"
type client struct {
shortLink HttpCli
clientVersion int32
loginRsaVersion uint32
osType string
}
func newClient(shortLink HttpCli) *client {
cli := &client{
shortLink: shortLink,
clientVersion: 0x17000523,
loginRsaVersion: 174,
osType: "iPad iPhone OS9.3.3",
}
return cli
}
func (this *client) GetLoginQrCode(deviceId string) (*GetLoginQrCodeResponse, error) {
var deviceIdBytes []byte
if deviceId == "" {
deviceId = this.newRandomDeviceId()
deviceIdBytes = Md5Bytes(deviceId)
deviceIdBytes[0] = 0x49
} else {
deviceIdBytes = []byte(deviceId)
}
//generate a random aes key
//rsaLen := uint32(2048)
aesKey := this.newRandomAesKey()
req := &mm_pb.GetLoginQRCodeRequest{
BaseRequest: this.newBasRequest(aesKey.Key, deviceIdBytes, 0, 0),
Aes: aesKey,
Opcode: new(uint32),
DeviceName: nil,
UserName: nil,
ExtDevLoginType: new(uint32),
HardwareExtra: nil,
SoftType: nil,
//Rsa: &mm_pb.RSAPem{
// Len: rsaLen,
// Pem: kRsaPubKeyModules,
//},
}
resp := &mm_pb.GetLoginQRCodeResponse{}
pkg, err := this.shortLinkExecute(shortUrl,
req,
mm_pb.CGI_TYPE_GETLOGINQRCODE, mm_pb.CGI_URL_GETLOGINQRCODE,
7, aesKey.Key, nil, 0, resp)
if err != nil {
return nil, err
}
//fmt.Println(resp)
return &GetLoginQrCodeResponse{
QRCodeId: *resp.Uuid,
Uin: pkg.uin,
AesKey: resp.AESKey.Key,
Cookies: pkg.cookie,
QRCodeContent: resp.QRCode.Src,
}, nil
}
func (this *client) CheckLoginQrCode(qrCodeId string, aesKey []byte) (*CheckLoginQrCodeResponse, error) {
panic("implement me")
}