├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── abck.go /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | 17 | *.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ZedDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Abck 2 | 3 | Abck is a library that makes generating akamai cookies easier. 4 | 5 | Currently does not support all of the functions/methods. Expect much more in an upcoming update. 6 | 7 | 8 | ## Installation 9 | 10 | ```bash 11 | go get github.com/zedd3v/abck-go 12 | ``` 13 | 14 | ## Usage 15 | 16 | ```go 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | abck "github.com/zedd3v/abck-go" 22 | ) 23 | 24 | func main() { 25 | fmt.Println(abck.GetCfDate()) // Equivalent of Date.now() 26 | } 27 | ``` 28 | 29 | ```go 30 | func D3() int64 31 | 32 | func Getmr() string // Broken, make a pr if you find a fix 33 | 34 | func Ab(t string) int 35 | 36 | func O9(d3 int64) int 37 | 38 | func GetCfDate() int64 39 | 40 | func GetType(t string) int 41 | 42 | func Sed(browser string) string 43 | 44 | func Uar(userAgent string) string 45 | 46 | func Jrs(t int) ([]float64, error) 47 | 48 | func Od(t string, a string) string 49 | 50 | func Z1(startTimestamp int64) int64 51 | 52 | func Fas(browser string) (int, error) 53 | 54 | func Np(browser string) (string, error) 55 | 56 | func Gd(browser string, browserData BrowserData, startTimestamp int64, d3 int64) (string, error) 57 | ``` 58 | 59 | ## Maintainer 60 | 61 | [![ZedDev](https://github.com/zedd3v.png?size=100)](https://abck.dev/) 62 | 63 | ## Contributing 64 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 65 | 66 | ## License 67 | [MIT](https://choosealicense.com/licenses/mit/) -------------------------------------------------------------------------------- /abck.go: -------------------------------------------------------------------------------- 1 | package abck 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "math" 7 | "math/rand" 8 | "reflect" 9 | "regexp" 10 | "sort" 11 | "strconv" 12 | "strings" 13 | "time" 14 | ) 15 | 16 | func randomNumberInt(min int, max int) int { 17 | rand.Seed(time.Now().UnixNano()) 18 | return rand.Intn(max-min) + min 19 | } 20 | 21 | func randomNumberFloat() float64 { 22 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 23 | return r.Float64() 24 | } 25 | 26 | func GetCfDate() int64 { 27 | t := time.Now() 28 | tUnixMilli := int64(time.Nanosecond) * t.UnixNano() / int64(time.Millisecond) 29 | return tUnixMilli 30 | } 31 | 32 | func D3() int64 { 33 | return GetCfDate() % 1e7 34 | } 35 | 36 | func rir(t int, a int, e int, n int) int { 37 | if t > a && t <= e { 38 | t += n % (e - a) 39 | if t > e { 40 | t = t - e + a 41 | } 42 | } 43 | return t 44 | } 45 | 46 | func Od(t string, a string) string { 47 | var e []string 48 | n := len(a) 49 | if n > 0 { 50 | for o := 0; o < len(t); o++ { 51 | m := []rune(t)[o] 52 | r := string(t[o]) 53 | i := a[(o % n)] 54 | m = rune(rir(int(m), 47, 57, int(i))) 55 | if m != []rune(t)[o] { 56 | r = string(m) 57 | } 58 | e = append(e, r) 59 | } 60 | if len(e) > 0 { 61 | return strings.Join(e[:], "") 62 | } 63 | } 64 | return t 65 | } 66 | 67 | func Ab(t string) int { 68 | a := 0 69 | for e := 0; e < len(t); e++ { 70 | n := []rune(t)[e] 71 | if n < 128 { 72 | a += int(n) 73 | } 74 | } 75 | return a 76 | } 77 | 78 | func Uar(userAgent string) string { 79 | return regexp.MustCompile(`/\\|"/g`).ReplaceAllString(userAgent, "") 80 | } 81 | 82 | func Fas(browser string) (int, error) { 83 | if browser == "chrome" { 84 | return 30261693, nil 85 | } else if browser == "firefox" { 86 | return 26067385, nil 87 | } else { 88 | return 0, errors.New("Unsupported browser specified (use \"chrome\" or \"firefox\")") 89 | } 90 | } 91 | 92 | func mrjp(flt float64) float64 { 93 | return flt 94 | } 95 | 96 | func mrinf(flt float64) bool { 97 | return math.IsInf(flt, 0) 98 | } 99 | 100 | func invoke(fn interface{}, args ...float64) { 101 | v := reflect.ValueOf(fn) 102 | rargs := make([]reflect.Value, len(args)) 103 | for i, a := range args { 104 | rargs[i] = reflect.ValueOf(a) 105 | } 106 | v.Call(rargs) 107 | } 108 | 109 | func Getmr() string { 110 | t := "" 111 | var e []interface{} 112 | e = append(e, math.Abs, math.Acos, math.Asin, math.Atanh, math.Cbrt, math.Exp, mrjp, math.Sqrt, mrinf, math.IsNaN, mrjp, mrjp, mrjp, mrjp) 113 | for n := 0; n < len(e); n++ { 114 | var o []float64 115 | var m float64 116 | m = 0.0 117 | r := time.Now() 118 | c := 0 119 | for i := 0; i < 1000 && m < .6; i++ { 120 | b := time.Now() 121 | for d := 0; d < 4e3; d++ { 122 | invoke(e[n], 3.14) 123 | } 124 | k := time.Now() 125 | o = append(o, 1000*math.Round(float64(k.UnixNano()/1000000)-float64(b.UnixNano()/1000000))) 126 | m = float64(k.UnixNano()/1000000) - float64(r.UnixNano()/1000000) 127 | s := o 128 | sort.Float64s(s) 129 | c = int(s[int(math.Floor(float64(len(s)/2)))]) / 5 130 | t = fmt.Sprintf("%v%v,", t, c) 131 | } 132 | } 133 | return t 134 | } 135 | 136 | func Sed(browser string) string { 137 | return "0,0,0,0,1,0,0" 138 | } 139 | 140 | func Np(browser string) (string, error) { 141 | if browser == "chrome" { 142 | return "10321144241322243122", nil 143 | } else if browser == "firefox" { 144 | return "11133333331333333333", nil 145 | } else { 146 | return "", errors.New("Unsupported browser specified (use \"chrome\" or \"firefox\")") 147 | } 148 | } 149 | 150 | func calDis(t []int) float64 { 151 | a := t[0] - t[1] 152 | e := t[2] - t[3] 153 | n := t[4] - t[5] 154 | return math.Floor(math.Sqrt(float64(a*a + e*e + n*n))) 155 | } 156 | 157 | func Jrs(t int) ([]float64, error) { 158 | a := int(math.Floor(100000*randomNumberFloat() + 10000)) 159 | e := strconv.Itoa(t * a) 160 | m := len(e) >= 18 161 | n := 0 162 | var o []int 163 | for len(o) < 6 { 164 | num, err := strconv.Atoi(e[n:(n + 2)]) 165 | if err != nil { 166 | return []float64{}, err 167 | } 168 | o = append(o, num) 169 | if m { 170 | n = n + 3 171 | } else { 172 | n = n + 2 173 | } 174 | } 175 | return []float64{float64(a), calDis(o)}, nil 176 | } 177 | 178 | func cc(t int) func(int, int) int { 179 | a := t % 4 180 | if 2 == a { 181 | a = 3 182 | } 183 | e := 42 + a 184 | var n func(int, int) int 185 | n = func(t int, a int) int { 186 | return 0 187 | } 188 | if 42 == e { 189 | n = func(t int, a int) int { 190 | return t * a 191 | } 192 | } else if 43 == e { 193 | n = func(t int, a int) int { 194 | return t + a 195 | } 196 | } else { 197 | n = func(t int, a int) int { 198 | return t - a 199 | } 200 | } 201 | return n 202 | } 203 | 204 | func O9(d3 int64) int { 205 | a := int(d3) 206 | for n := 0; n < 5; n++ { 207 | o := math.Mod(math.Floor(float64(d3)/math.Pow(10, float64(n))), 10) 208 | m := o + 1 209 | op := cc(int(o)) 210 | a = op(int(a), int(m)) 211 | } 212 | return a * 3 213 | } 214 | 215 | func GetType(t string) int { 216 | t = strings.ToLower(t) 217 | if "text" == t || "search" == t || "url" == t || "email" == t || "tel" == t || "number" == t { 218 | return 0 219 | } else if "password" == t { 220 | return 1 221 | } else { 222 | return 2 223 | } 224 | } 225 | 226 | func Z1(startTimestamp int64) int64 { 227 | return startTimestamp / (2016 * 2016) 228 | } 229 | 230 | func floatToString(flt float64, precision int) string { 231 | return strconv.FormatFloat(flt, 'f', precision, 64) 232 | } 233 | 234 | type ScreenData struct { 235 | AvailWidth int 236 | AvailHeight int 237 | Width int 238 | Height int 239 | InnerWidth int 240 | InnerHeight int 241 | OuterWidth int 242 | } 243 | 244 | type BrowserData struct { 245 | Lang string 246 | UserAgent string 247 | ScreenData ScreenData 248 | } 249 | 250 | func Gd(browser string, browserData BrowserData, startTimestamp int64, d3 int64) (string, error) { 251 | userAgent := Uar(browserData.UserAgent) 252 | d := randomNumberFloat() 253 | xagg := 0 254 | psub := 0 255 | plen := 0 256 | bd := "" 257 | if browser == "chrome" { 258 | xagg = 12147 259 | psub = 20030107 260 | plen = 3 261 | bd = ",cpen:0,i1:0,dm:0,cwen:0,non:1,opc:0,fc:0,sc:0,wrc:1,isc:0,vib:1,bat:1,x11:0,x12:1" 262 | } else if browser == "firefox" { 263 | xagg = 11059 264 | psub = 20100101 265 | plen = 0 266 | bd = fmt.Sprintf(",cpen:0,i1:0,dm:0,cwen:0,non:1,opc:0,fc:1,sc:0,wrc:1,isc:%v,vib:1,bat:0,x11:0,x12:1", randomNumberInt(60, 100)) 267 | } else { 268 | return "", errors.New("Unsupported browser specified (use \"chrome\" or \"firefox\")") 269 | } 270 | return fmt.Sprintf( 271 | "%v,uaend,%v,%v,%v,Gecko,%v,0,0,0,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,loc:", 272 | userAgent, 273 | xagg, 274 | psub, 275 | browserData.Lang, 276 | plen, 277 | Z1(startTimestamp), 278 | d3, 279 | browserData.ScreenData.AvailWidth, 280 | browserData.ScreenData.AvailHeight, 281 | browserData.ScreenData.Width, 282 | browserData.ScreenData.Height, 283 | browserData.ScreenData.InnerWidth, 284 | browserData.ScreenData.InnerHeight, 285 | browserData.ScreenData.OuterWidth, 286 | bd, 287 | Ab(userAgent), 288 | floatToString(d, 16)[0:11]+floatToString(math.Floor(1000*d/2), -1), 289 | startTimestamp/2), nil 290 | } 291 | --------------------------------------------------------------------------------