-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbake.go
147 lines (141 loc) · 3.4 KB
/
bake.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package main
import (
"encoding/json"
"fmt"
"io"
"math/rand"
"strings"
"github.com/gin-gonic/gin"
"github.com/obfio/px-grubhub-mobile/px"
)
type input struct {
PXID string `json:"pxid"`
Proxy string `json:"proxy"`
SDKVersion string `json:"sdkVersion"`
AppVersion string `json:"appVersion"`
AppName string `json:"appName"`
PackageName string `json:"packageName"`
IsInstantApp bool `json:"isInstantApp"`
}
type output struct {
Cookie string `json:"cookie"`
Error string `json:"error"`
}
func bake(c *gin.Context) {
o := &output{}
b, err := io.ReadAll(c.Request.Body)
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
i := &input{}
err = json.Unmarshal(b, &i)
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
client, err := px.MakeClient(i.PXID, i.Proxy, i.SDKVersion, i.AppVersion, i.AppName, i.PackageName, i.IsInstantApp, devices[rand.Intn(len(devices))])
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
err = client.GetConfig()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
client.PXPayload.Populate(client.DeviceData, levels[fmt.Sprint(client.DeviceData.AndroidVersion)], client.SDKVersion, client.AppVersion, client.AppName, client.PackageName, client.IsInstantApp)
err = client.PXPayload.UUIDSection()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
instructions, err := client.GetInstructions()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
if len(instructions.Do) < 4 {
for i := 0; i < 3; i++ {
client.PXPayload.Populate(client.DeviceData, levels[fmt.Sprint(client.DeviceData.AndroidVersion)], client.SDKVersion, client.AppVersion, client.AppName, client.PackageName, client.IsInstantApp)
err = client.PXPayload.UUIDSection()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
instructions, err = client.GetInstructions()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
if len(instructions.Do) == 4 {
break
}
}
if len(instructions.Do) != 4 {
o.Error = "unable to get instructions"
c.AbortWithStatusJSON(500, o)
return
}
}
for _, instruction := range instructions.Do {
parts := strings.Split(instruction, "|")
if len(parts) < 1 {
continue
}
if parts[0] == "sid" {
client.SID = parts[1]
continue
}
if parts[0] == "vid" {
client.VID = parts[1]
continue
}
if parts[0] == "appc" && parts[1] == "2" {
client.PXPayload.AppcInstruction(instruction)
continue
}
}
instructions, err = client.GetCookie()
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
for _, instruction := range instructions.Do {
parts := strings.Split(instruction, "|")
if len(parts) < 1 {
continue
}
if parts[0] == "bake" {
o.Cookie = parts[3]
}
}
if o.Cookie == "" {
o.Error = "unable to get cookie"
c.AbortWithStatusJSON(500, o)
return
}
err = client.TestCookie(o.Cookie, randStr(20)+"@gmail.com", randStr(10)+"3463456!")
if err != nil {
o.Error = err.Error()
c.AbortWithStatusJSON(500, o)
return
}
c.JSON(200, o)
}
func randStr(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[rand.Intn(52)]
}
return string(b)
}