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

fix: password login #119

Merged
merged 4 commits into from
Nov 11, 2024
Merged
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
19 changes: 12 additions & 7 deletions client/auth/sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ var (
)

type SigInfo struct {
Uin uint32
Sequence uint32
UID string
Tgtgt []byte
Tgt []byte
D2 []byte
D2Key []byte
Uin uint32
Sequence uint32
UID string

Tgtgt []byte
Tgt []byte
D2 []byte
D2Key []byte

Qrsig []byte
ExchangeKey []byte
KeySig []byte
Expand All @@ -29,6 +31,9 @@ type SigInfo struct {
TempPwd []byte
CaptchaInfo [3]string

CaptchaURL string
NewDeviceVerifyURL string

Nickname string
Age uint8
Gender uint8
Expand Down
17 changes: 12 additions & 5 deletions client/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
// 部分借鉴 https://github.com/Mrs4s/MiraiGo/blob/master/client/client.go

import (
"crypto/md5"
"errors"
"net/http"
"net/http/cookiejar"
Expand Down Expand Up @@ -30,11 +31,16 @@ import (
)

// NewClient 创建一个新的 QQ Client
func NewClient(uin uint32, appInfo *auth.AppInfo, signURL ...string) *QQClient {
func NewClient(uin uint32, password string, appInfo *auth.AppInfo, signURL ...string) *QQClient {
return NewClientMD5(uin, md5.Sum([]byte(password)), appInfo, signURL...)
}

func NewClientMD5(uin uint32, passwordMD5 [16]byte, appInfo *auth.AppInfo, signURL ...string) *QQClient {
cookieContainer, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
client := &QQClient{
Uin: uin,
oicq: oicq.NewCodec(int64(uin)),
Uin: uin,
oicq: oicq.NewCodec(int64(uin)),
passwordMD5: passwordMD5,
highwaySession: highway.Session{
AppID: uint32(appInfo.AppID),
SubAppID: uint32(appInfo.SubAppID),
Expand Down Expand Up @@ -65,8 +71,9 @@ type QQClient struct {

Online atomic.Bool

t106 []byte
t16a []byte
t106 []byte
t16a []byte
passwordMD5 [16]byte

UA string

Expand Down
Loading