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 (
"log"
"net/http"
"path"
"runtime"
"test/model"
"test/util"
)
func WelcomeHandler(w http.ResponseWriter, r *http.Request) {
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() {
logrus.SetLevel(logrus.TraceLevel)
//logrus.SetFormatter(&logrus.TextFormatter{
......@@ -37,7 +30,7 @@ func main() {
TimestampFormat: "2006-01-02 15:04:05.000", //时间格式
NoColors: true,
})
logFilePath := getCurrentAbPathByCaller()
logFilePath := util.GetCurrentAbPathByCaller()
logFileName := "akm.log"
fileName := path.Join(logFilePath, logFileName)
......
......@@ -132,7 +132,8 @@ func (akm *AkmClient) postSensor(times int) error {
abck, bmsz := akm.GetCookie()
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()
sensor_data := "{\"sensor_data\":\"" + res + "\"}"
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
import (
"crypto/rand"
"fmt"
"math/big"
"strconv"
)
type Env struct {
AddEventListener int `json:"addEventListener"`
XMLHttpRequest int `json:"XMLHttpRequest"`
XDomainRequest int `json:"XDomainRequest"`
Emit int `json:"emit"`
DeviceOrientationEvent int `json:"DeviceOrientationEvent"`
DeviceMotionEvent int `json:"DeviceMotionEvent"`
TouchEvent int `json:"TouchEvent"`
Spawn int `json:"spawn"`
Chrome int `json:"chrome"`
FunctionPrototypeBind int `json:"functionPrototypeBind"`
Buffer int `json:"Buffer"`
PointerEvent int `json:"PointerEvent"`
HasInnerWidth int `json:"innerWidth"`
HasOuterWidth int `json:"outerWidth"`
AvailWidth int `json:"availWidth"`
AvailHeight int `json:"availHeight"`
Width int `json:"width"`
Height int `json:"height"`
InnerHeight int `json:"innerHeight"`
InnerWidth int `json:"innerWidth"`
OuterWidth int `json:"outerWidth"`
AddEventListener int `json:"addEventListener"`
XMLHttpRequest int `json:"XMLHttpRequest"`
XDomainRequest int `json:"XDomainRequest"`
Emit int `json:"emit"`
DeviceOrientationEvent int `json:"DeviceOrientationEvent"`
DeviceMotionEvent int `json:"DeviceMotionEvent"`
TouchEvent int `json:"TouchEvent"`
Spawn int `json:"spawn"`
Chrome int `json:"chrome"`
FunctionPrototypeBind int `json:"functionPrototypeBind"`
Buffer int `json:"Buffer"`
PointerEvent int `json:"PointerEvent"`
HasInnerWidth int `json:"innerWidth"`
HasOuterWidth int `json:"outerWidth"`
AvailWidth int `json:"availWidth"`
AvailHeight int `json:"availHeight"`
Width int `json:"width"`
Height int `json:"height"`
InnerHeight int `json:"innerHeight"`
InnerWidth int `json:"innerWidth"`
OuterWidth int `json:"outerWidth"`
Ua string `json:"ua"`
Nav Navigator `json:"nav"`
}
func bd2(a, b int) int {
......@@ -37,6 +46,13 @@ func CO(a int, b int) int {
return a << b
}
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{
AddEventListener: 1,
XMLHttpRequest: 1,
......@@ -52,13 +68,15 @@ func NewEnv() *Env {
PointerEvent: 1,
HasInnerWidth: 1,
HasOuterWidth: 1,
AvailWidth: 2560,
AvailHeight: 980,
Width: 2560,
Height: 1080,
InnerHeight: 901,
InnerWidth: 2560,
OuterWidth: 2560,
AvailWidth: Device.AvailWidth,
AvailHeight: Device.AvailHeight,
Width: Device.Width,
Height: Device.Height,
InnerHeight: Device.InnerHeight,
InnerWidth: Device.InnerWidth,
OuterWidth: Device.OuterWidth,
Ua: Device.Ua,
Nav: Device.Navigator,
}
}
......@@ -68,12 +86,3 @@ type Navigator struct {
Product string `json:"product"`
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 {
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()}
}
func (a AkmSign) genData() string {
func (a *AkmSign) genData() (string, string) {
Y8 := a.startTs / 2
f3 := now()
env := env2.NewEnv()
a.UserAgent = env.Ua
envStr := env.GenEnvStr()
navigator := env2.NewNavigator()
navigator := env.Nav
Rs := navigator.ProductSub
ds := navigator.Language
Ls := navigator.Product
Xs := navigator.Plugins
if Xs == "" {
Xs = "0"
}
qs := 0
Ys := 0
Os := 0
......@@ -90,6 +94,7 @@ func (a AkmSign) genData() string {
randomStr := strconv.FormatFloat(Ds, 'f', 11, 64)[:11] + strconv.Itoa(Ns)
data2 = append(data2, q8, randomStr, Y8, Al, "loc")
arg100 := toString(data2) + ":"
fmt.Println(arg100)
//arg102 := ""
//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;"
......@@ -298,7 +303,7 @@ func (a AkmSign) genData() string {
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 {
return res
}
func (a AkmSign) genVc(Rc []int) int64 {
func (a *AkmSign) genVc(Rc []int) int64 {
dc := Rc[0] - Rc[1]
Lc := Rc[2] - Rc[3]
Xc := Rc[4] - Rc[5]
......@@ -523,7 +528,7 @@ func (a AkmSign) genVc(Rc []int) int64 {
return int64(math.Floor(qc))
}
func (a AkmSign) genCanvas() []string {
func (a *AkmSign) genCanvas() []string {
res := make([]string, 3)
res[0] = fmt.Sprintf("%d", -1338919844)
res[1] = fmt.Sprintf("%d", rand.Intn(400)+100)
......@@ -531,7 +536,7 @@ func (a AkmSign) genCanvas() []string {
return res
}
func (a AkmSign) VE(wc string) int {
func (a *AkmSign) VE(wc string) int {
var kc int = 0
for i := 0; i < len(wc); i++ {
sc := wc[i]
......@@ -543,7 +548,7 @@ func (a AkmSign) VE(wc string) int {
return int(kc)
}
func (a AkmSign) gen90() []int {
func (a *AkmSign) gen90() []int {
randomInt := rand.Intn(20)
t := time.UnixMilli(a.startTs)
month := int(int(t.Month())+1) * t.Day()
......@@ -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)
TXU := strings.Split(abck, "~")
if len(TXU) > 5 {
......@@ -705,7 +710,7 @@ func splitBmsz(bmsz string) []int {
func bd(a, b string) string {
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)
return akm.genData()
......
......@@ -85,8 +85,8 @@ func actVY() {
t1 := time.Now()
//resp, err := http.Post("http://lcc.unififi.com/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\": \"http://127.0.0.1:8890\"}"))
"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \""+px+"\"}"))
//"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\"}"))
if err != nil {
//panic(err)
......@@ -130,8 +130,8 @@ func testVY(px string, data []byte) {
tls_client.WithTimeoutSeconds(30),
tls_client.WithClientProfile(tls_client.Chrome_110),
tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
tls_client.WithProxyUrl("http://127.0.0.1:8890"),
//tls_client.WithProxyUrl(px),
//tls_client.WithProxyUrl("http://127.0.0.1:8890"),
tls_client.WithProxyUrl(px),
tls_client.WithInsecureSkipVerify(),
}
uri, _ := url.Parse("https://m.vueling.com/")
......
package main
import (
"crypto/rand"
"fmt"
"github.com/PuerkitoBio/goquery"
http "github.com/bogdanfinn/fhttp"
tls_client "github.com/bogdanfinn/tls-client"
"io"
"math/rand"
"log"
"math/big"
"net/url"
"strconv"
"strings"
"sync"
)
......@@ -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))
rs, _ := io.ReadAll(r.Body)
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/")
sensor := "{\"sensor_data\":\"" + rsss[0] + "\"}"
sensorData := rsss[0]
ua = rsss[1]
//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.Header.Set("authority", "www.spirit.com")
req.Header.Set("accept", "*/*")
......@@ -48,14 +53,18 @@ func abckSensor(client tls_client.HttpClient, sensorurl string) string {
req.Header.Set("origin", "https://www.spirit.com")
req.Header.Set("pragma", "no-cache")
req.Header.Set("referer", "https://www.spirit.com/")
req.Header.Set("user-agent", rsss[1])
resp, _ := client.Do(req)
req.Header.Set("user-agent", ua)
resp, err := client.Do(req)
if err != nil {
log.Println("网络出错")
return ""
}
defer resp.Body.Close()
//readBytes, _ := io.ReadAll(resp.Body)
//fmt.Println(string(readBytes))
for _, cookie := range resp.Cookies() {
fmt.Println(cookie.Name, len(cookie.Value))
}
ua = rsss[1]
}
return ua
}
......@@ -75,8 +84,12 @@ func main() {
// })
//}
//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)
options := []tls_client.HttpClientOption{
tls_client.WithTimeoutSeconds(30),
......@@ -84,9 +97,9 @@ func main() {
tls_client.WithNotFollowRedirects(),
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://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.WithInsecureSkipVerify(),
//tls_client.WithInsecureSkipVerify(),
}
client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
if err != nil {
......@@ -125,6 +138,7 @@ func main() {
}
func nk(client tls_client.HttpClient, ua string) {
fmt.Println("UA", ua)
//t1 := time.Now()
////resp, err := http.Post("http://lcc.unififi.com/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