Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
xtekky
GitHub Repository: xtekky/tiktok-viewbot
Path: blob/main/old/v1/to update/golang/main.go
621 views
1
package main
2
3
import (
4
"encoding/base64"
5
"encoding/json"
6
"fmt"
7
"io/ioutil"
8
"net/http"
9
"net/url"
10
"regexp"
11
"strings"
12
)
13
14
func sessid() string {
15
client := &http.Client{}
16
req, _ := http.NewRequest("GET", "https://zefoy.com/", nil)
17
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36")
18
resp, _ := client.Do(req)
19
20
re := regexp.MustCompile(`[a-z0-9]{26}`)
21
sessid := string(re.Find([]byte(resp.Header.Get("set-cookie"))))
22
23
return sessid
24
}
25
26
func solve_captcha(sessid string) string {
27
client := &http.Client{}
28
captcha_req, _ := http.NewRequest(
29
"GET",
30
"https://zefoy.com/a1ef290e2636bf553f39817628b6ca49.php?_CAPTCHA&t=0.04316800+1657582034",
31
nil,
32
)
33
34
captcha_req.Header.Set("cookie", fmt.Sprintf("PHPSESSID=%s", sessid))
35
captcha_req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36")
36
37
captcha_res, _ := client.Do(captcha_req)
38
captcha_bytes, _ := ioutil.ReadAll(captcha_res.Body)
39
40
captcha_image := string(base64.StdEncoding.EncodeToString([]byte(captcha_bytes)))
41
42
type Response struct {
43
Captcha struct {
44
Answer string `json:"answer"`
45
Confidence int `json:"confidence"`
46
Latency float64 `json:"latency"`
47
} `json:"captcha"`
48
StatusCode int `json:"status_code"`
49
StatusMsg string `json:"status_msg"`
50
}
51
52
captcha_data := strings.NewReader(fmt.Sprintf(`{"image": "%s"}`, captcha_image))
53
solve_req, _ := http.NewRequest("POST", "https://api.xtekky.com/ocr", captcha_data)
54
55
solve_res, _ := client.Do(solve_req)
56
solve_body, _ := ioutil.ReadAll(solve_res.Body)
57
58
var result Response
59
if err := json.Unmarshal(solve_body, &result); err != nil {
60
solve_captcha(sessid)
61
}
62
63
var xdata = strings.NewReader(fmt.Sprintf(`captcha_secure=%s&r75619cf53f5a5d7aa6af82edfec3bf0=`, string(result.Captcha.Answer)))
64
req, _ := http.NewRequest("POST", "https://zefoy.com/", xdata)
65
66
req.Header.Set("content-type", "application/x-www-form-urlencoded")
67
req.Header.Set("cookie", fmt.Sprintf("PHPSESSID=%s", string(sessid)))
68
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36")
69
resp, _ := client.Do(req)
70
71
req_text, _ := ioutil.ReadAll(resp.Body)
72
73
if strings.Contains(string(req_text), "c2VuZF9mb2xsb3dlcnNfdGlrdG9r") {
74
fmt.Println("Success | Captcha: " + result.Captcha.Answer)
75
} else {
76
solve_captcha(sessid)
77
}
78
79
re := regexp.MustCompile(`"([a-z0-9]{16})`)
80
return re.FindStringSubmatch(string(req_text))[1]
81
}
82
83
func reverse(s string) (result string) {
84
for _, v := range s {
85
result = string(v) + result
86
}
87
return
88
}
89
90
func decrypt(encryped string) string {
91
reversed, _ := url.QueryUnescape(reverse(encryped))
92
decrypted, _ := base64.StdEncoding.DecodeString(reversed)
93
94
return string(decrypted)
95
}
96
97
func send_views(phpsessid, alpha_key, aweme_id string) {
98
client := &http.Client{}
99
data := strings.NewReader(fmt.Sprintf(`%s=https://www.tiktok.com/@onlp/video/%s/`, alpha_key, aweme_id))
100
req, _ := http.NewRequest("POST", "https://zefoy.com/c2VuZC9mb2xsb3dlcnNfdGlrdG9V", data)
101
102
req.Header.Set("cookie", fmt.Sprintf("PHPSESSID=%s", phpsessid))
103
req.Header.Set("origin", "https://zefoy.com")
104
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36")
105
req.Header.Set("x-requested-with", "XMLHttpRequest")
106
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
107
108
resp, _ := client.Do(req)
109
bodyText, _ := ioutil.ReadAll(resp.Body)
110
_data := decrypt(string(bodyText))
111
112
re := regexp.MustCompile(`"([a-z0-9]{16})`)
113
beta_key := re.FindStringSubmatch(string(_data))[1]
114
115
fmt.Println("Beta | " + beta_key)
116
117
}
118
119
func main() {
120
aweme_id := "7114598963977751814"
121
122
phpsessid := sessid()
123
fmt.Println("Sessid | " + phpsessid)
124
alpha_key := solve_captcha(phpsessid)
125
fmt.Println("Alpha | " + alpha_key)
126
send_views(phpsessid, alpha_key, aweme_id)
127
}
128
129