-
Notifications
You must be signed in to change notification settings - Fork 3
/
pass_port.go
57 lines (47 loc) · 1.78 KB
/
pass_port.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
package bingauth
import (
"fmt"
"net/url"
"strings"
"github.com/Harry-zklcdc/bing-lib/lib/hex"
"github.com/Harry-zklcdc/bing-lib/lib/request"
)
func (a *AuthStruct) passport() (cookie string, err error) {
a.reqClient = request.NewRequest().SetUserAgent(USER_AGENT)
a.reqClient.Get().SetUrl("https://www.bing.com/").Do()
if a.reqClient.GetStatusCode() != 200 {
return "", fmt.Errorf("passport failed, status code: %v", a.reqClient.Result.Status)
}
postdata := url.Values{}
postdata.Add("url", "https://www.bing.com/")
postdata.Add("V", "web")
a.reqClient.Post().SetUrl("https://www.bing.com/rewardsapp/reportActivity?IG=%s&IID=SERP.5026&&src=hp", strings.ToUpper(strings.ReplaceAll(hex.NewUUID(), "-", ""))).
SetContentType("application/x-www-form-urlencoded").
SetBody(strings.NewReader(postdata.Encode())).
Do()
if a.reqClient.GetStatusCode() != 200 {
return "", fmt.Errorf("passport failed, status code: %v", a.reqClient.Result.Status)
}
postdata = url.Values{}
postdata.Add("NAPExp", a.PassportData.NAPExp)
postdata.Add("pprid", a.PassportData.PPRID)
postdata.Add("NAP", a.PassportData.NAP)
postdata.Add("ANON", a.PassportData.ANON)
postdata.Add("ANONExp", a.PassportData.ANONExp)
postdata.Add("t", a.PassportData.T)
a.reqClient.Post().SetUrl("%v", a.ActionUrl).
SetContentType("application/x-www-form-urlencoded").
SetHeader("Origin", "https://login.live.com").
SetHeader("Referer", "https://login.live.com/").
SetBody(strings.NewReader(postdata.Encode())).
Do()
if a.reqClient.GetStatusCode() != 200 {
return "", fmt.Errorf("passport failed, status code: %v", a.reqClient.Result.Status)
}
for _, v := range a.reqClient.Cookies {
values := strings.Split(v.Value, ";")
cookie += v.Name + "=" + values[0] + "; "
}
cookie = strings.Trim(cookie, "; ")
return
}