Fix for account verifications
This commit is contained in:
75
token.go
75
token.go
@@ -209,11 +209,11 @@ func login() {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
client3 := &http.Client{Jar: cookieJar, CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}}
|
||||
if response.Response.Challenge.Reason == "MissingRequiredAuthenticationData" {
|
||||
if response.Response.Challenge.Method == "OTPCode" {
|
||||
client3 := &http.Client{Jar: cookieJar, CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}}
|
||||
fmt.Println("Account set for 2 Factor Authentication")
|
||||
fmt.Print("Enter One Time Code: ")
|
||||
scanner.Scan()
|
||||
@@ -222,10 +222,10 @@ func login() {
|
||||
stuff := re.FindAllStringSubmatch(string(body), -1)
|
||||
data2 := url.Values{}
|
||||
for _, value := range stuff {
|
||||
data2.Add(value[1], value[2])
|
||||
data2.Set(value[1], value[2])
|
||||
}
|
||||
data2.Add("otpCode", otp)
|
||||
data2.Add("rememberDevice", "")
|
||||
data2.Set("otpCode", otp)
|
||||
data2.Set("rememberDevice", "")
|
||||
req3, _ := http.NewRequest("POST", "https://www.amazon.com/ap/signin", strings.NewReader(data2.Encode()))
|
||||
req3.Header.Add("x-amzn-identity-auth-domain", ".amazon.com")
|
||||
req3.Header.Add("User-Agent", api.Headers.Login)
|
||||
@@ -248,19 +248,82 @@ func login() {
|
||||
} else {
|
||||
fmt.Println(response.Response.Challenge)
|
||||
fmt.Println("MissingRequiredAuthenticationData - Unknown Method")
|
||||
os.Exit(0)
|
||||
}
|
||||
} else if response.Response.Challenge.Reason == "HandleOnWebView" {
|
||||
fmt.Println("HandleOnWebView")
|
||||
if strings.Contains(referer, "CAPTCHA") {
|
||||
fmt.Println("CAPTCHA Verification Required")
|
||||
} else {
|
||||
fmt.Println("Verification Code Required")
|
||||
re := regexp.MustCompile(`<input type="hidden" name="(.+?)" value="(.+?)"`)
|
||||
stuff := re.FindAllStringSubmatch(string(body), -1)
|
||||
data2 := url.Values{}
|
||||
for _, value := range stuff {
|
||||
data2.Set(value[1], value[2])
|
||||
}
|
||||
data2.Set("option", "email")
|
||||
req3, _ := http.NewRequest("POST", "https://www.amazon.com/ap/cvf/verify", strings.NewReader(data2.Encode()))
|
||||
req3.Header.Add("x-amzn-identity-auth-domain", ".amazon.com")
|
||||
req3.Header.Add("User-Agent", api.Headers.Login)
|
||||
req3.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
resp3, err := client2.Do(req3)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if resp3.StatusCode == 200 {
|
||||
fmt.Println("Code Sent to Email")
|
||||
fmt.Print("Verification Code: ")
|
||||
scanner.Scan()
|
||||
data2.Del("option")
|
||||
data2.Set("code", scanner.Text())
|
||||
data2.Set("action", "code")
|
||||
req4, _ := http.NewRequest("POST", "https://www.amazon.com/ap/cvf/verify", strings.NewReader(data2.Encode()))
|
||||
req4.Header.Add("x-amzn-identity-auth-domain", ".amazon.com")
|
||||
req4.Header.Add("User-Agent", api.Headers.Login)
|
||||
req4.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
resp4, err := client3.Do(req4)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if resp4.StatusCode == 302 {
|
||||
redir := resp4.Header.Get("Location")
|
||||
if strings.Contains(redir, "signin") {
|
||||
req5, _ := http.NewRequest("GET", redir, nil)
|
||||
req5.Header.Add("x-amzn-identity-auth-domain", ".amazon.com")
|
||||
req5.Header.Add("User-Agent", api.Headers.Login)
|
||||
resp5, err := client3.Do(req5)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if resp5.StatusCode == 302 {
|
||||
redir2 := resp5.Header.Get("Location")
|
||||
if strings.Contains(redir2, "maplanding") {
|
||||
fmt.Println("Verification Successful")
|
||||
redir_url, _ := url.Parse(redir2)
|
||||
data3 := redir_url.Query()
|
||||
token := data3.Get("openid.oa2.access_token")
|
||||
api.Payload.AuthData.AccessToken = token
|
||||
login()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if response.Response.Challenge.Reason == "AuthenticationFailed" {
|
||||
fmt.Println("Login Failed - Incorrect User/Pass")
|
||||
os.Exit(0)
|
||||
} else {
|
||||
fmt.Println(response.Response.Challenge)
|
||||
fmt.Println("Login Failed due to Challenge")
|
||||
os.Exit(0)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Login Failed for unknown reason")
|
||||
fmt.Println(resp.Status)
|
||||
io.Copy(os.Stdout, resp.Body)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user