237 lines
6.6 KiB
Go
237 lines
6.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"crypto/aes"
|
|
"crypto/cipher"
|
|
"crypto/hmac"
|
|
"crypto/rand"
|
|
"crypto/sha1"
|
|
"crypto/sha256"
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
"fmt"
|
|
mrand "math/rand"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/Sonelli/gojuice/crypto/pkcs7"
|
|
"github.com/google/uuid"
|
|
"golang.org/x/crypto/pbkdf2"
|
|
)
|
|
|
|
type FRC struct {
|
|
ApplicationName string `json:"ApplicationName"`
|
|
ApplicationVersion string `json:"ApplicationVersion"`
|
|
DeviceOSVersion string `json:"DeviceOSVersion"`
|
|
DeviceName string `json:"DeviceName"`
|
|
ThirdPartyDeviceId string `json:"ThirdPartyDeviceId"`
|
|
ScreenWidthPixels string `json:"ScreenWidthPixels"`
|
|
ScreenHeightPixels string `json:"ScreenHeightPixels"`
|
|
DeviceLanguage string `json:"DeviceLanguage"`
|
|
TimeZone string `json:"TimeZone"`
|
|
}
|
|
|
|
type Device struct {
|
|
Manu string
|
|
Model string
|
|
OSVer string
|
|
OSVer2 string
|
|
Product string
|
|
Width string
|
|
Height string
|
|
DevName string
|
|
DevOS string
|
|
UserAgent string
|
|
}
|
|
|
|
var Devices = []Device{
|
|
Device{
|
|
"samsung",
|
|
"SM-N960U",
|
|
"27",
|
|
"8.1.0",
|
|
"crownqltesq",
|
|
"1080",
|
|
"2094",
|
|
"qcom/samsung/SM-N960U",
|
|
"samsung/crownqltesq/crownqltesq:8.1.0/M1AJQ/N960USQU1ARL1:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; SM-N960U Build/M1AJQ)",
|
|
},
|
|
Device{
|
|
"HMD Global",
|
|
"TA-1025",
|
|
"27",
|
|
"8.1.0",
|
|
"TA-1025_00S0",
|
|
"1080",
|
|
"1920",
|
|
"qcom/HMD Global/TA-1025",
|
|
"Nokia/TA-1025_00S0/PLE:8.1.0/OPR1.170623.026/00S0_5_60I:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; TA-1025 Build/OPR1.170623.026)",
|
|
},
|
|
Device{
|
|
"Sony",
|
|
"G3123",
|
|
"26",
|
|
"8.0.0",
|
|
"G3123",
|
|
"720",
|
|
"1184",
|
|
"mt6757/Sony/G3123",
|
|
"Sony/G3123/G3123:8.0.0/48.1.A.2.21/3047602646:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 8.0.0; G3123 Build/48.1.A.2.21)",
|
|
},
|
|
Device{
|
|
"HMD Global",
|
|
"Nokia 2",
|
|
"25",
|
|
"7.1.1",
|
|
"Dynamo_00WW",
|
|
"720",
|
|
"1184",
|
|
"qcom/HMD Global/Nokia 2",
|
|
"Nokia/Dynamo_00WW/E1M:7.1.1/NMF26F/00WW_0_680:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nokia 2 Build/NMF26F)",
|
|
},
|
|
Device{
|
|
"OnePlus",
|
|
"ONEPLUS A6013",
|
|
"28",
|
|
"9",
|
|
"OnePlus6T",
|
|
"1080",
|
|
"2135",
|
|
"qcom/OnePlus/ONEPLUS A6013",
|
|
"OnePlus/OnePlus6T/OnePlus6T:9/PKQ1.180716.001/1901231231:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 9; ONEPLUS A6013 Build/PKQ1.180716.001)",
|
|
},
|
|
Device{
|
|
"LGE",
|
|
"Nexus 5X",
|
|
"25",
|
|
"7.1.2",
|
|
"bullhead",
|
|
"1080",
|
|
"1794",
|
|
"bullhead/LGE/Nexus 5X",
|
|
"google/bullhead/bullhead:7.1.2/N2G48C/4104010:user/release-keys",
|
|
"Dalvik/2.1.0 (Linux; U; Android 7.1.2; Nexus 5X Build/N2G48C)",
|
|
},
|
|
}
|
|
|
|
const (
|
|
AmazonPkg = "com.amazon.rabbit"
|
|
AmazonAppVer = "303559706"
|
|
AmazonAppVer2 = "3.7.145.0"
|
|
/* com.amazon.identity.auth.device.utils.aa */
|
|
AmazonMap = "20181011N"
|
|
/* com.amazon.identity.auth.device.utils.i */
|
|
AmazonSoftware = "130050002"
|
|
|
|
ITERATION_COUNT = 1000
|
|
KEY_LENGTH = 16
|
|
)
|
|
|
|
func (api *AmazonApi) Save(actpath string) {
|
|
api_file, _ := os.Create(path.Join(actpath, "amazon-api.json"))
|
|
json.NewEncoder(api_file).Encode(api)
|
|
api_file.Close()
|
|
}
|
|
|
|
func (api *AmazonApi) New() {
|
|
api.Payload.AuthData.Global = "true"
|
|
api.Payload.AuthData.User.Password = "password"
|
|
api.Payload.AuthData.User.UserId = "email"
|
|
api.Payload.RegistrationData.Domain = "Device"
|
|
api.Payload.RegistrationData.Type = "A1MPSLFC7L5AFK"
|
|
api.Payload.RegistrationData.Serial = ShortUUID()
|
|
api.Payload.RegistrationData.AppName = AmazonPkg
|
|
api.Payload.RegistrationData.AppVersion = AmazonAppVer
|
|
api.Payload.RegistrationData.SoftwareVersion = AmazonSoftware
|
|
api.Payload.RequestedToken = []string{"bearer", "mac_dms", "store_authentication_cookie", "website_cookies"}
|
|
api.Payload.Cookies.Domain = "amazon.com"
|
|
api.Payload.Cookies.Website = []string{}
|
|
api.Payload.Extenstions = []string{"device_info", "customer_info"}
|
|
mrand.Seed(time.Now().UnixNano())
|
|
newDevice := Devices[mrand.Intn(len(Devices))]
|
|
rando := ShortUUID()
|
|
frcPayload := FRC{
|
|
AmazonPkg,
|
|
AmazonAppVer,
|
|
newDevice.DevOS,
|
|
newDevice.DevName,
|
|
rando[0:16],
|
|
newDevice.Width,
|
|
newDevice.Height,
|
|
"en-US",
|
|
time.Now().Local().Format("-07:00"),
|
|
}
|
|
frcJson, _ := json.Marshal(frcPayload)
|
|
api.Payload.UserContext.Frc = Encrypt(string(frcJson), api.Payload.RegistrationData.Serial)
|
|
api.Payload.DeviceMetadata.DeviceOS = "android"
|
|
api.Payload.DeviceMetadata.DeviceType = "A1MPSLFC7L5AFK"
|
|
api.Payload.DeviceMetadata.DeviceSerial = api.Payload.RegistrationData.Serial
|
|
api.Payload.DeviceMetadata.Manufacturer = newDevice.Manu
|
|
api.Payload.DeviceMetadata.Model = newDevice.Model
|
|
api.Payload.RegistrationData.Model = newDevice.Model
|
|
api.Payload.RegistrationData.OSVersion = newDevice.DevOS
|
|
api.Payload.DeviceMetadata.OSVersion = newDevice.OSVer
|
|
api.Payload.DeviceMetadata.AndroidID = rando[0:16]
|
|
api.Payload.DeviceMetadata.BuildSerial = rando[16:]
|
|
api.Payload.DeviceMetadata.Product = newDevice.Product
|
|
h := sha256.Sum256([]byte(ShortUUID()))
|
|
api.Payload.DeviceMetadata.MacAddress = strings.ToUpper(fmt.Sprintf("%x", h))
|
|
j := sha256.Sum256([]byte(ShortUUID()))
|
|
api.Payload.DeviceMetadata.IMEI = strings.ToUpper(fmt.Sprintf("%x", j))
|
|
api.Headers.Login = newDevice.UserAgent
|
|
api.Headers.Refresh = fmt.Sprintf("AmazonWebView/MAPClientLib/%s/Android/%s/%s", AmazonSoftware, newDevice.OSVer2, newDevice.DevName)
|
|
api.Headers.Main = fmt.Sprintf("%s RabbitAndroid/%s", newDevice.UserAgent, AmazonAppVer2)
|
|
rando2, _ := uuid.NewRandom()
|
|
api.Headers.Instance = rando2.String()
|
|
api.Headers.MapVersion.Version = AmazonMap
|
|
api.Headers.MapVersion.Package = AmazonPkg
|
|
api.Headers.MapVersion.Platform = "Android"
|
|
}
|
|
|
|
func ShortUUID() string {
|
|
uuid, _ := uuid.NewRandom()
|
|
return strings.Replace(uuid.String(), "-", "", -1)
|
|
}
|
|
|
|
func Encrypt(thing string, seed string) (output string) {
|
|
var b bytes.Buffer
|
|
gz := gzip.NewWriter(&b)
|
|
gz.Write([]byte(thing))
|
|
gz.Flush()
|
|
gz.Close()
|
|
input := b.Bytes()
|
|
key := pbkdf2.Key([]byte(seed), []byte("AES/CBC/PKCS7Padding"), ITERATION_COUNT, KEY_LENGTH, sha1.New)
|
|
block, err := aes.NewCipher(key)
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
}
|
|
iv := make([]byte, block.BlockSize())
|
|
readIV, err := rand.Read(iv)
|
|
if err != nil || readIV != block.BlockSize() {
|
|
fmt.Println(err.Error())
|
|
}
|
|
padded := pkcs7.PadPKCS7(input, block.BlockSize())
|
|
cbc := cipher.NewCBCEncrypter(block, iv)
|
|
cbc.CryptBlocks(padded, padded)
|
|
testkey := pbkdf2.Key([]byte(seed), []byte("HmacSHA256"), ITERATION_COUNT, KEY_LENGTH, sha1.New)
|
|
mac := hmac.New(sha256.New, testkey)
|
|
mac.Write(iv)
|
|
mac.Write(padded)
|
|
fin_mac := mac.Sum(nil)
|
|
unencoded := []byte{0}
|
|
unencoded = append(unencoded, fin_mac[0:8]...)
|
|
unencoded = append(unencoded, iv...)
|
|
unencoded = append(unencoded, padded...)
|
|
output = base64.StdEncoding.EncodeToString(unencoded)
|
|
return
|
|
}
|