File size: 2,140 Bytes
7d06702
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package proofofwork

import (
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"github.com/google/uuid"
	"github.com/zbronya/free-chat-to-api/model"
	"golang.org/x/crypto/sha3"
	"math/rand"
	"time"
	_ "time/tzdata"
)

var (
	cores   = []int{1, 2, 4, 8}
	screens = []int{3000, 4000, 6000}
	script  = "https://cdn.oaistatic.com/_next/static/chunks/2565-9cf19ba0b7d24a5d.js?dpl=4811fd1c94b550c8f03fcc863ee6c1a99940efc5"

	dpl = "4811fd1c94b550c8f03fcc863ee6c1a99940efc5"

	errorPrefix = "gAAAAABwQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D"
)

func getParseTime() string {
	loc, _ := time.LoadLocation("America/Los_Angeles")
	now := time.Now().In(loc)
	return now.Format("Mon Jan 02 2006 15:04:05") + " GMT-0800 (Pacific Time)"
}

func GetConfig(ua string) []interface{} {
	rand.New(rand.NewSource(time.Now().UnixNano()))
	core := cores[rand.Intn(4)]
	rand.New(rand.NewSource(time.Now().UnixNano()))
	screen := screens[rand.Intn(3)]
	rand.New(rand.NewSource(time.Now().UnixNano()))
	return []interface{}{core + screen,
		getParseTime(),
		int64(4294705152),
		0,
		ua,
		script,
		dpl,
		"en-US",
		"en-US,en",
		0,
		"updateAdInterestGroups−function updateAdInterestGroups() { [native code] }",
		"location",
		"__NEXT_PRELOADREADY",
		885.6999999880791,
	}
}

func GetChatRequirementReq(config []interface{}) model.ChatRequirementReq {
	//randomFloat := rand.Float64()
	//seed := fmt.Sprintf("%.6f", randomFloat)
	//token := CalcProofToken(config, seed, "0")
	return model.ChatRequirementReq{
		P: "hello openai" + uuid.NewString(),
	}

}

func CalcProofToken(config []interface{}, seed string, diff string) string {

	diffLen := len(diff) / 2
	hasher := sha3.New512()
	startTime := time.Now()
	for i := 0; i < 1000000; i++ {
		config[3] = i
		endTime := time.Now()
		elapsed := endTime.Sub(startTime)
		config[9] = elapsed.Milliseconds()
		j, _ := json.Marshal(config)
		base := base64.StdEncoding.EncodeToString(j)
		hasher.Write([]byte(seed + base))
		hash := hasher.Sum(nil)
		hasher.Reset()
		if hex.EncodeToString(hash[:diffLen]) <= diff {
			return base
		}
	}
	return errorPrefix + base64.StdEncoding.EncodeToString([]byte(`"`+seed+`"`))
}