Commit 64f0b6c7 authored by anqi-wmm's avatar anqi-wmm

随机选择设备参数

parent c247aa3b
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,21 +9,14 @@ import ( ...@@ -9,21 +9,14 @@ import (
"log" "log"
"net/http" "net/http"
"path" "path"
"runtime"
"test/model" "test/model"
"test/util"
) )
func WelcomeHandler(w http.ResponseWriter, r *http.Request) { func WelcomeHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome!") fmt.Fprintf(w, "Welcome!")
} }
func getCurrentAbPathByCaller() string {
var abPath string
_, filename, _, ok := runtime.Caller(0)
if ok {
abPath = path.Dir(filename)
}
return abPath
}
func main() { func main() {
logrus.SetLevel(logrus.TraceLevel) logrus.SetLevel(logrus.TraceLevel)
//logrus.SetFormatter(&logrus.TextFormatter{ //logrus.SetFormatter(&logrus.TextFormatter{
...@@ -37,7 +30,7 @@ func main() { ...@@ -37,7 +30,7 @@ func main() {
TimestampFormat: "2006-01-02 15:04:05.000", //时间格式 TimestampFormat: "2006-01-02 15:04:05.000", //时间格式
NoColors: true, NoColors: true,
}) })
logFilePath := getCurrentAbPathByCaller() logFilePath := util.GetCurrentAbPathByCaller()
logFileName := "akm.log" logFileName := "akm.log"
fileName := path.Join(logFilePath, logFileName) fileName := path.Join(logFilePath, logFileName)
......
...@@ -132,7 +132,8 @@ func (akm *AkmClient) postSensor(times int) error { ...@@ -132,7 +132,8 @@ func (akm *AkmClient) postSensor(times int) error {
abck, bmsz := akm.GetCookie() abck, bmsz := akm.GetCookie()
t1 := time.Now() t1 := time.Now()
res := sensor.GenData(times, abck, bmsz, akm.ua, akm.postUrl) res, ua := sensor.GenData(times, abck, bmsz, akm.ua, akm.postUrl)
akm.ua = ua
t2 := time.Now() t2 := time.Now()
sensor_data := "{\"sensor_data\":\"" + res + "\"}" sensor_data := "{\"sensor_data\":\"" + res + "\"}"
akm.logger.Info("sensor", sensor_data) akm.logger.Info("sensor", sensor_data)
......
package env
import (
"encoding/json"
"io"
"os"
"path"
"test/util"
)
type Device struct {
AvailHeight int `json:"availHeight"`
AvailWidth int `json:"availWidth"`
Height int `json:"height"`
InnerHeight int `json:"innerHeight"`
InnerWidth int `json:"innerWidth"`
Navigator Navigator `json:"navigator"`
OuterWidth int `json:"outerWidth"`
Ua string `json:"ua"`
Width int `json:"width"`
}
var Devices []Device
func init() {
file, err := os.OpenFile(path.Join(util.GetCurrentAbPathByCaller(), "devices.json"), os.O_RDONLY, 0)
if err != nil {
return
}
defer file.Close()
bytess, _ := io.ReadAll(file)
// 序列化数据
json.Unmarshal(bytess, &Devices)
}
package env package env
import (
"crypto/rand"
"fmt"
"math/big"
"strconv"
)
type Env struct { type Env struct {
AddEventListener int `json:"addEventListener"` AddEventListener int `json:"addEventListener"`
XMLHttpRequest int `json:"XMLHttpRequest"` XMLHttpRequest int `json:"XMLHttpRequest"`
...@@ -22,6 +29,8 @@ type Env struct { ...@@ -22,6 +29,8 @@ type Env struct {
InnerHeight int `json:"innerHeight"` InnerHeight int `json:"innerHeight"`
InnerWidth int `json:"innerWidth"` InnerWidth int `json:"innerWidth"`
OuterWidth int `json:"outerWidth"` OuterWidth int `json:"outerWidth"`
Ua string `json:"ua"`
Nav Navigator `json:"nav"`
} }
func bd2(a, b int) int { func bd2(a, b int) int {
...@@ -37,6 +46,13 @@ func CO(a int, b int) int { ...@@ -37,6 +46,13 @@ func CO(a int, b int) int {
return a << b return a << b
} }
func NewEnv() *Env { func NewEnv() *Env {
rIdx, err := rand.Int(rand.Reader, big.NewInt(int64(len(Devices))))
if err != nil {
fmt.Println(err)
}
a := rIdx.String()
idx, _ := strconv.Atoi(a)
Device := Devices[idx]
return &Env{ return &Env{
AddEventListener: 1, AddEventListener: 1,
XMLHttpRequest: 1, XMLHttpRequest: 1,
...@@ -52,13 +68,15 @@ func NewEnv() *Env { ...@@ -52,13 +68,15 @@ func NewEnv() *Env {
PointerEvent: 1, PointerEvent: 1,
HasInnerWidth: 1, HasInnerWidth: 1,
HasOuterWidth: 1, HasOuterWidth: 1,
AvailWidth: 2560, AvailWidth: Device.AvailWidth,
AvailHeight: 980, AvailHeight: Device.AvailHeight,
Width: 2560, Width: Device.Width,
Height: 1080, Height: Device.Height,
InnerHeight: 901, InnerHeight: Device.InnerHeight,
InnerWidth: 2560, InnerWidth: Device.InnerWidth,
OuterWidth: 2560, OuterWidth: Device.OuterWidth,
Ua: Device.Ua,
Nav: Device.Navigator,
} }
} }
...@@ -68,12 +86,3 @@ type Navigator struct { ...@@ -68,12 +86,3 @@ type Navigator struct {
Product string `json:"product"` Product string `json:"product"`
Plugins string `json:"plugins"` Plugins string `json:"plugins"`
} }
func NewNavigator() *Navigator {
return &Navigator{
ProductSub: "20030107",
Language: "zh-CN",
Product: "Gecko",
Plugins: "5",
}
}
...@@ -40,16 +40,20 @@ func now() int64 { ...@@ -40,16 +40,20 @@ func now() int64 {
func NewAkmSign(times int, url, ua string, abck string, bmsz string) *AkmSign { func NewAkmSign(times int, url, ua string, abck string, bmsz string) *AkmSign {
return &AkmSign{Times: times, Url: url, Abck: abck, Bmsz: bmsz, UserAgent: ua, startTs: time.Now().UnixMilli()} return &AkmSign{Times: times, Url: url, Abck: abck, Bmsz: bmsz, UserAgent: ua, startTs: time.Now().UnixMilli()}
} }
func (a AkmSign) genData() string { func (a *AkmSign) genData() (string, string) {
Y8 := a.startTs / 2 Y8 := a.startTs / 2
f3 := now() f3 := now()
env := env2.NewEnv() env := env2.NewEnv()
a.UserAgent = env.Ua
envStr := env.GenEnvStr() envStr := env.GenEnvStr()
navigator := env2.NewNavigator() navigator := env.Nav
Rs := navigator.ProductSub Rs := navigator.ProductSub
ds := navigator.Language ds := navigator.Language
Ls := navigator.Product Ls := navigator.Product
Xs := navigator.Plugins Xs := navigator.Plugins
if Xs == "" {
Xs = "0"
}
qs := 0 qs := 0
Ys := 0 Ys := 0
Os := 0 Os := 0
...@@ -90,6 +94,7 @@ func (a AkmSign) genData() string { ...@@ -90,6 +94,7 @@ func (a AkmSign) genData() string {
randomStr := strconv.FormatFloat(Ds, 'f', 11, 64)[:11] + strconv.Itoa(Ns) randomStr := strconv.FormatFloat(Ds, 'f', 11, 64)[:11] + strconv.Itoa(Ns)
data2 = append(data2, q8, randomStr, Y8, Al, "loc") data2 = append(data2, q8, randomStr, Y8, Al, "loc")
arg100 := toString(data2) + ":" arg100 := toString(data2) + ":"
fmt.Println(arg100)
//arg102 := "" //arg102 := ""
//if a.Times > 3 { //if a.Times > 3 {
// arg102 = "0,-1,1,0,-1,-1,0;0,-1,1,0,-1,-1,0;0,0,1,1,2416,1765,0;0,0,0,1,2954,2303,0;-1,-1,1,1,1065,529,0;0,-1,0,0,2108,2108,0;" // arg102 = "0,-1,1,0,-1,-1,0;0,-1,1,0,-1,-1,0;0,0,1,1,2416,1765,0;0,0,0,1,2954,2303,0;-1,-1,1,1,1065,529,0;0,-1,0,0,2108,2108,0;"
...@@ -298,7 +303,7 @@ func (a AkmSign) genData() string { ...@@ -298,7 +303,7 @@ func (a AkmSign) genData() string {
dY["fpValStr"], "-80", arg80, "-90", arg90, "-116", 0, "-129", arg129) dY["fpValStr"], "-80", arg80, "-90", arg90, "-116", 0, "-129", arg129)
} }
return GenSensorData(toStringList(data), a.Bmsz, f3) return GenSensorData(toStringList(data), a.Bmsz, f3), a.UserAgent
} }
...@@ -515,7 +520,7 @@ func (a *AkmSign) funcWx() []int64 { ...@@ -515,7 +520,7 @@ func (a *AkmSign) funcWx() []int64 {
return res return res
} }
func (a AkmSign) genVc(Rc []int) int64 { func (a *AkmSign) genVc(Rc []int) int64 {
dc := Rc[0] - Rc[1] dc := Rc[0] - Rc[1]
Lc := Rc[2] - Rc[3] Lc := Rc[2] - Rc[3]
Xc := Rc[4] - Rc[5] Xc := Rc[4] - Rc[5]
...@@ -523,7 +528,7 @@ func (a AkmSign) genVc(Rc []int) int64 { ...@@ -523,7 +528,7 @@ func (a AkmSign) genVc(Rc []int) int64 {
return int64(math.Floor(qc)) return int64(math.Floor(qc))
} }
func (a AkmSign) genCanvas() []string { func (a *AkmSign) genCanvas() []string {
res := make([]string, 3) res := make([]string, 3)
res[0] = fmt.Sprintf("%d", -1338919844) res[0] = fmt.Sprintf("%d", -1338919844)
res[1] = fmt.Sprintf("%d", rand.Intn(400)+100) res[1] = fmt.Sprintf("%d", rand.Intn(400)+100)
...@@ -531,7 +536,7 @@ func (a AkmSign) genCanvas() []string { ...@@ -531,7 +536,7 @@ func (a AkmSign) genCanvas() []string {
return res return res
} }
func (a AkmSign) VE(wc string) int { func (a *AkmSign) VE(wc string) int {
var kc int = 0 var kc int = 0
for i := 0; i < len(wc); i++ { for i := 0; i < len(wc); i++ {
sc := wc[i] sc := wc[i]
...@@ -543,7 +548,7 @@ func (a AkmSign) VE(wc string) int { ...@@ -543,7 +548,7 @@ func (a AkmSign) VE(wc string) int {
return int(kc) return int(kc)
} }
func (a AkmSign) gen90() []int { func (a *AkmSign) gen90() []int {
randomInt := rand.Intn(20) randomInt := rand.Intn(20)
t := time.UnixMilli(a.startTs) t := time.UnixMilli(a.startTs)
month := int(int(t.Month())+1) * t.Day() month := int(int(t.Month())+1) * t.Day()
...@@ -551,7 +556,7 @@ func (a AkmSign) gen90() []int { ...@@ -551,7 +556,7 @@ func (a AkmSign) gen90() []int {
} }
func (a AkmSign) zNfunc() map[int]any { func (a *AkmSign) zNfunc() map[int]any {
abck, _ := url.QueryUnescape(a.Abck) abck, _ := url.QueryUnescape(a.Abck)
TXU := strings.Split(abck, "~") TXU := strings.Split(abck, "~")
if len(TXU) > 5 { if len(TXU) > 5 {
...@@ -705,7 +710,7 @@ func splitBmsz(bmsz string) []int { ...@@ -705,7 +710,7 @@ func splitBmsz(bmsz string) []int {
func bd(a, b string) string { func bd(a, b string) string {
return a + b return a + b
} }
func GenData(times int, abck, bmsz, ua, url string) string { func GenData(times int, abck, bmsz, ua, url string) (string, string) {
akm := NewAkmSign(times, url, ua, abck, bmsz) akm := NewAkmSign(times, url, ua, abck, bmsz)
return akm.genData() return akm.genData()
......
...@@ -85,8 +85,8 @@ func actVY() { ...@@ -85,8 +85,8 @@ func actVY() {
t1 := time.Now() t1 := time.Now()
//resp, err := http.Post("http://lcc.unififi.com/akamai/gen", //resp, err := http.Post("http://lcc.unififi.com/akamai/gen",
resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", resp, err := http.Post("http://127.0.0.1:59001/akamai/gen",
//"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \""+px+"\"}")) "application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \""+px+"\"}"))
"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \"http://127.0.0.1:8890\"}")) //"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \"http://127.0.0.1:8890\"}"))
//resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", "application/json", strings.NewReader("{\"type\": \"u2\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}")) //resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", "application/json", strings.NewReader("{\"type\": \"u2\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}"))
if err != nil { if err != nil {
//panic(err) //panic(err)
...@@ -130,8 +130,8 @@ func testVY(px string, data []byte) { ...@@ -130,8 +130,8 @@ func testVY(px string, data []byte) {
tls_client.WithTimeoutSeconds(30), tls_client.WithTimeoutSeconds(30),
tls_client.WithClientProfile(tls_client.Chrome_110), tls_client.WithClientProfile(tls_client.Chrome_110),
tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
tls_client.WithProxyUrl("http://127.0.0.1:8890"), //tls_client.WithProxyUrl("http://127.0.0.1:8890"),
//tls_client.WithProxyUrl(px), tls_client.WithProxyUrl(px),
tls_client.WithInsecureSkipVerify(), tls_client.WithInsecureSkipVerify(),
} }
uri, _ := url.Parse("https://m.vueling.com/") uri, _ := url.Parse("https://m.vueling.com/")
......
package main package main
import ( import (
"crypto/rand"
"fmt" "fmt"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
http "github.com/bogdanfinn/fhttp" http "github.com/bogdanfinn/fhttp"
tls_client "github.com/bogdanfinn/tls-client" tls_client "github.com/bogdanfinn/tls-client"
"io" "io"
"math/rand" "log"
"math/big"
"net/url" "net/url"
"strconv"
"strings" "strings"
"sync" "sync"
) )
...@@ -36,9 +39,11 @@ func abckSensor(client tls_client.HttpClient, sensorurl string) string { ...@@ -36,9 +39,11 @@ func abckSensor(client tls_client.HttpClient, sensorurl string) string {
r, _ := http.Post("http://127.0.0.1:3033/akm2t", "application/x-www-form-urlencoded", strings.NewReader(datas)) r, _ := http.Post("http://127.0.0.1:3033/akm2t", "application/x-www-form-urlencoded", strings.NewReader(datas))
rs, _ := io.ReadAll(r.Body) rs, _ := io.ReadAll(r.Body)
rsss := strings.Split(string(rs), "|||||") rsss := strings.Split(string(rs), "|||||")
//rs := sensor2.GenData(i, abck, bm_sz, "Mozilla/5.0 (Linux; Android 9; SM-N9500) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36", "https://www.spirit.com/") sensorData := rsss[0]
ua = rsss[1]
sensor := "{\"sensor_data\":\"" + rsss[0] + "\"}" //sensorData, ua := sensor.GenData(i, abck, bm_sz, "Mozilla/5.0 (Linux; Android 9; SM-N9500) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36", "https://www.spirit.com/")
//fmt.Println("ua", ua)
sensor := "{\"sensor_data\":\"" + sensorData + "\"}"
req, _ := http.NewRequest("POST", "https://www.spirit.com"+sensorurl, strings.NewReader(sensor)) req, _ := http.NewRequest("POST", "https://www.spirit.com"+sensorurl, strings.NewReader(sensor))
req.Header.Set("authority", "www.spirit.com") req.Header.Set("authority", "www.spirit.com")
req.Header.Set("accept", "*/*") req.Header.Set("accept", "*/*")
...@@ -48,14 +53,18 @@ func abckSensor(client tls_client.HttpClient, sensorurl string) string { ...@@ -48,14 +53,18 @@ func abckSensor(client tls_client.HttpClient, sensorurl string) string {
req.Header.Set("origin", "https://www.spirit.com") req.Header.Set("origin", "https://www.spirit.com")
req.Header.Set("pragma", "no-cache") req.Header.Set("pragma", "no-cache")
req.Header.Set("referer", "https://www.spirit.com/") req.Header.Set("referer", "https://www.spirit.com/")
req.Header.Set("user-agent", rsss[1]) req.Header.Set("user-agent", ua)
resp, _ := client.Do(req) resp, err := client.Do(req)
if err != nil {
log.Println("网络出错")
return ""
}
defer resp.Body.Close()
//readBytes, _ := io.ReadAll(resp.Body) //readBytes, _ := io.ReadAll(resp.Body)
//fmt.Println(string(readBytes)) //fmt.Println(string(readBytes))
for _, cookie := range resp.Cookies() { for _, cookie := range resp.Cookies() {
fmt.Println(cookie.Name, len(cookie.Value)) fmt.Println(cookie.Name, len(cookie.Value))
} }
ua = rsss[1]
} }
return ua return ua
} }
...@@ -75,8 +84,12 @@ func main() { ...@@ -75,8 +84,12 @@ func main() {
// }) // })
//} //}
//jar.SetCookies(uri, cookies) //jar.SetCookies(uri, cookies)
i := rand.Intn(149)
px := fmt.Sprintf("http://%s%d", "unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:", 10000+i) i, _ := rand.Int(rand.Reader, big.NewInt(149))
number := i.String() //转成string
num, err := strconv.Atoi(number)
px := fmt.Sprintf("http://%s%d", "unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:", 10000+num)
fmt.Println(px) fmt.Println(px)
options := []tls_client.HttpClientOption{ options := []tls_client.HttpClientOption{
tls_client.WithTimeoutSeconds(30), tls_client.WithTimeoutSeconds(30),
...@@ -84,9 +97,9 @@ func main() { ...@@ -84,9 +97,9 @@ func main() {
tls_client.WithNotFollowRedirects(), tls_client.WithNotFollowRedirects(),
tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
//tls_client.WithProxyUrl("http://127.0.0.1:8890"), //tls_client.WithProxyUrl("http://127.0.0.1:8890"),
tls_client.WithProxyUrl("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600"), //tls_client.WithProxyUrl("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600"),
tls_client.WithProxyUrl(px), tls_client.WithProxyUrl(px),
tls_client.WithInsecureSkipVerify(), //tls_client.WithInsecureSkipVerify(),
} }
client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...) client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
if err != nil { if err != nil {
...@@ -125,6 +138,7 @@ func main() { ...@@ -125,6 +138,7 @@ func main() {
} }
func nk(client tls_client.HttpClient, ua string) { func nk(client tls_client.HttpClient, ua string) {
fmt.Println("UA", ua)
//t1 := time.Now() //t1 := time.Now()
////resp, err := http.Post("http://lcc.unififi.com/akamai/gen", ////resp, err := http.Post("http://lcc.unififi.com/akamai/gen",
//resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", //resp, err := http.Post("http://127.0.0.1:59001/akamai/gen",
......
package util
import (
"path"
"runtime"
)
func GetCurrentAbPathByCaller() string {
var abPath string
_, filename, _, ok := runtime.Caller(0)
if ok {
abPath = path.Dir(filename)
}
return path.Join(abPath, "../")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment