Files
kami_itunes_june/AppleBatch_June/AppleManageWebUtlis2.cs
danial cb905409f8 Refactor AppleBatch_June project:
- Removed DotRas library dependency in RasTools.cs, providing empty implementations for Connect and Disconnect methods.
- Updated context menu implementation in ReddemHelp.cs to use ToolStripMenuItem and ContextMenuStrip.
- Replaced caching mechanism in SiteHelper.cs with a custom dictionary-based implementation, removing reliance on HttpRuntime.Cache.
- Switched from JavaScriptSerializer to Newtonsoft.Json for JSON serialization/deserialization in multiple files (Tools.cs, addMaterial.cs).
- Added WebHeaderCollection property to HttpItem.cs for better header management.
- Deleted obsolete AssemblyInfo.cs file.
- Introduced apple_balance_query.py for querying Apple ID balance via Privacy Center, implementing authentication and balance retrieval logic.
2025-11-10 17:38:18 +08:00

3963 lines
179 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using Newtonsoft.Json;
using AppleBatch_June.Domain;
using AppleBatch_June.ExecuteTasks;
using AppleBatch_June.Model;
using AppleBatch_June.Utils;
using DotNet.Utilities;
namespace AppleBatch_June
{
public class AppleManageWebUtlis2
{
private List<CookieItem> listCookie = new List<CookieItem>();
private Dictionary<string, string> handelDic = new Dictionary<string, string>();
private static string homeLanguage = "zh_CN";
private string Apple_Widget_Key = "af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3";
private string DomainId = "1";
private string loginAuthUrl = "https://idmsa.apple.com/appleauth/auth/signin?isRememberMeEnabled=true";
private string verifyquestionsUrl = "https://idmsa.apple.com/appleauth/auth/verify/questions";
private string appleHomeUrl = "https://appleid.apple.com/account/manage";
private string apiKey = "cbf64fd6843ee630b463f358ea0b707b";
private AvailableSecurityQuestions securityQuestions;
private LoginAppleInfo loginAppleInfo;
protected Action<string, DisplyType, string> action;
protected Action<string, DisplyType, string> applyAtion;
public ITaskRunState taskState;
public AppleChangeItem _changeItem;
private bool isPwdViey;
private bool isViey;
private bool isVieyBirthday;
protected bool openVpn;
private AppleAcount acount;
private string X_Apple_Auth_Attributes = "";
private Func<string, int, string> getCodeAct_;
private bool isError;
public string checkDisableScnt = "";
public string widgKey = string.Empty;
private string dataR = "";
private static readonly object lockSendMsmObj = new object();
private string redirectURI = "https://appleid.apple.com";
private string iframeId = "auth-w78m90aa-d7ll-rirf-04xy-rsvumkpw";
private string language = "zh_CN";
private string userAgent { get; set; }
private string authUrl => "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=" + Apple_Widget_Key + "&language=" + homeLanguage;
private string appleId { get; set; }
public string noticeKey { get; set; }
public bool idIsNormal { get; set; }
private string accountFirstName { get; set; }
private string accountLastName { get; set; }
private string XAppleIDAccountCountry { get; set; } = "";
public bool openHsa2 { get; set; }
public bool isChangAppleId { get; set; }
private string Apple_ID_Account_Country { get; set; } = "";
private string ProxyIp { get; set; }
private string scnt { get; set; }
public AppleManageWebUtlis2(Action<string, DisplyType, string> _action, Action<string, DisplyType, string> _applyAtion, ITaskRunState _taskState)
{
taskState = _taskState ?? throw new Exception("任务运行状态不能是空的");
action = _action;
applyAtion = _applyAtion;
userAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36";
AppleUtlis.getAppleWenUserAgent();
}
public bool applyChangeAcount(AppleAcount acount, AppleChangeItem changeItem, bool errorGoint, bool _openVpn, ref string accountName)
{
if (string.IsNullOrEmpty(ProxyIp))
{
ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
}
openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
this.acount = acount;
appleId = acount.appleId;
accountName = appleId;
try
{
_changeItem = changeItem;
string errMsg = "";
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg))
{
if (!handelDic.ContainsKey("scnt"))
{
ProxyIp = "";
authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg);
if (!handelDic.ContainsKey("scnt"))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "登录初始化失败,请重试");
return false;
}
}
if (isPwdViey)
{
changeItem.newPwd = "";
}
if (isViey)
{
acount.appleQt1 = changeItem.newQt1;
acount.appleQt2 = changeItem.newQt2;
acount.appleQt3 = changeItem.newQt3;
handelDic.Clear();
changeItem.newQt1 = "";
isViey = false;
return applyChangeAcount(this.acount, _changeItem, errorGoint, openVpn, ref accountName);
}
if (appleauthAuth(acount))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "登录成功");
ProxyAccountCache.addProxyIp(acount.appleId, ProxyIp);
if (intoHome())
{
manageFamily();
bool flag = true;
getSecuritydevices();
if (!string.IsNullOrEmpty(changeItem.newQt1))
{
if (!(flag = changQuestions(changeItem.newQt1, changeItem.newQt2, changeItem.newQt3)))
{
flag = false;
}
if (!flag && !errorGoint)
{
return false;
}
}
if (!string.IsNullOrEmpty(changeItem.newPwd))
{
if (!(flag = changePwd(acount.applePwd, changeItem.newPwd)))
{
flag = false;
}
if (!flag && !errorGoint)
{
return false;
}
}
if (!string.IsNullOrEmpty(changeItem.newshengri) && !isVieyBirthday)
{
if (!(flag = changeBirthDate(changeItem.newshengri)))
{
flag = false;
}
if (!flag && !errorGoint)
{
return false;
}
}
if (!string.IsNullOrEmpty(changeItem.editAddrs))
{
flag = editAddrs(changeItem.editAddrs);
}
if (!string.IsNullOrEmpty(acount.newAppleId) && !isChangAppleId)
{
flag = setAccnount(acount.newAppleId, acount.newApplePopPwd, "cbf64fd6843ee630b463f358ea0b707b");
}
if (changeItem.pay != null)
{
flag = changenPayment(changeItem.pay);
}
if (flag && !string.IsNullOrEmpty(ProxyIp))
{
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = ProxyIp,
applyDate = DateTime.Now
});
}
return flag;
}
}
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(noticeKey, DisplyType.xinxi, ex.Message);
}
finally
{
try
{
signout();
}
catch (Exception)
{
}
}
return false;
}
private bool getInitWeb()
{
HttpResult webContent = getWebContent("https://appleid.apple.com", "", null, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "text/html");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string text = new Regex(AppSysConfig.getConfig("Regex_WebIframeId")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
string text2 = new Regex(AppSysConfig.getConfig("Regex_WebState")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
string url = "https://idmsa.apple.com/appleauth/auth/authorize/signin?frame_id=" + text + "&language=zh_CN&iframeId=" + text + "&client_id=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&redirect_uri=" + Tools.ToUrlEncode(redirectURI) + "&response_type=code&response_mode=web_message&state=" + text2 + "&rv=1&authVersion=latest";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
if (getWebContent(url, "https://appleid.apple.com", webHeaderCollection, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "text/html").StatusCode == HttpStatusCode.OK)
{
string[] allKeys = webContent.Header.AllKeys;
for (int i = 0; i < allKeys.Length; i++)
{
X_Apple_Auth_Attributes = webContent.Header["X-Apple-Auth-Attributes"];
}
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "页面加载失败");
}
return false;
}
private string NowUCTFormat()
{
return DateTime.Now.ToString("yyyy/MM/dd ttHH:mm:ss");
}
private string getDate()
{
return ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000L) / 10000L).ToString();
}
public string GetAdditionaFieldsn(string Account_Country)
{
string[] array = new SelectShippingOptionNullData().getSelectShippingAdditionaFieldsn().Split('\n');
int num = 0;
string[] array2;
while (true)
{
if (num < array.Length)
{
string text = array[num];
if (!string.IsNullOrEmpty(text))
{
array2 = text.Split(':');
if (array2.Length == 2 && array2[0].Trim() == Account_Country)
{
break;
}
}
num++;
continue;
}
return "";
}
return array2[1].Trim();
}
public string SelectShippingOptionNullData(string rreustHtml, NationalList payment, string redirectURI, WebHeaderCollection webHeader)
{
try
{
string text = "";
string result = "";
string selectShippingOption = new SelectShippingOptionNullData().getSelectShippingOption();
foreach (Match item in new Regex("#st([\\s\\S]*?)#end").Matches(selectShippingOption))
{
string value = item.Groups[1].Value;
if (string.IsNullOrEmpty(value))
{
continue;
}
string value2 = "";
string text2 = "";
string text3 = "";
string text4 = "";
string text5 = "";
string text6 = "";
string[] array = value.Split(';');
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Split('!');
if (array2.Length == 2)
{
string text7 = array2[1].Trim();
switch (array2[0].Trim())
{
case "r":
text6 = text7;
break;
case "value":
text5 = text7;
break;
case "param":
text4 = text7;
break;
case "post":
text3 = text7;
break;
case "url":
text2 = text7;
break;
case "key":
value2 = text7;
break;
}
}
}
if (string.IsNullOrEmpty(value2) || !rreustHtml.Contains(value2) || payment == null)
{
continue;
}
text = text3;
PropertyInfo[] properties = payment.payment.billingAddress.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
int num = 0;
string[] array3 = text5.Split(',');
array = text4.Split(',');
foreach (string text8 in array)
{
string valueItem = array3[num];
string value3 = "";
if (valueItem.Contains("p."))
{
PropertyInfo propertyInfo = properties.Where((PropertyInfo c) => c.Name == valueItem.Replace("p.", "")).FirstOrDefault();
if (propertyInfo != null)
{
value3 = propertyInfo.GetValue(payment.payment.billingAddress, null) as string;
}
}
if (valueItem.Contains("r.") && int.TryParse(valueItem.Replace("r.", ""), out var result2))
{
string[] array4 = text6.Split('|')[result2].Split('-');
if (array4.Length == 1)
{
string value4 = new Regex(array4[0]).Match(rreustHtml).Groups[1].Value;
if (!string.IsNullOrEmpty(value4))
{
value3 = value4;
}
}
if (array4.Length == 2)
{
string value5 = new Regex(array4[0]).Match(rreustHtml).Groups[1].Value;
if (!string.IsNullOrEmpty(value5))
{
foreach (Match item2 in new Regex(array4[1]).Matches(value5))
{
string value6 = item2.Groups[1].Value;
if (!string.IsNullOrEmpty(value6))
{
value3 = value6;
break;
}
}
}
}
}
if (!string.IsNullOrEmpty(value3))
{
text = text.Replace("{" + text8 + "}", Tools.ToUrlEncode(value3));
}
num++;
}
if (!text.Contains("{"))
{
result = postWebContent(redirectURI + text2, text, redirectURI + "/shop/checkout?_s=Shipping-init", webHeader, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded").Html;
break;
}
}
return result;
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
Console.WriteLine(ex.Message);
return rreustHtml;
}
}
public bool AppleQueryStoreBalance(AppleAcount acount, bool _openVpn, bool agent = false)
{
if (string.IsNullOrEmpty(ProxyIp))
{
ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
}
listCookie.Clear();
handelDic.Clear();
Apple_Widget_Key = "a797929d224abb1cc663bb187bbcd02f7172ca3a84df470380522a7c6092118b";
DomainId = "21";
openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
listCookie.Add(new CookieItem
{
Key = "geo",
Value = "CN"
});
action?.Invoke(noticeKey, DisplyType.xinxi, "正在登录..");
this.acount = acount;
appleId = acount.appleId;
iframeId = "auth-" + Guid.NewGuid().ToString("n").Substring(0, 8) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 8);
try
{
string errMsg = "";
string text = "";
if (!authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg, "https://idmsa.apple.com/"))
{
return false;
}
string apple_ID_Account_Country = Apple_ID_Account_Country;
text = AppleUtlis.GetAreaCodeByCode(apple_ID_Account_Country);
if (AppSysConfig.getConfig("ShopBanalNotSupportedCountries").Split(',').Contains(apple_ID_Account_Country))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "该 ID 国家不支持");
return false;
}
text = ((!(text == "us")) ? (text + "/") : "");
string text2 = "https://www.apple.com/" + text + "shop/";
int num = 0;
do
{
HttpResult webContent = getWebContent(text2 + "beacon/atb", text2 + "beacon/atb");
if (webContent.StatusCode != HttpStatusCode.MovedPermanently)
{
break;
}
text2 = webContent.RedirectUrl.Replace("beacon/atb", "");
}
while (num < 3);
WebHeaderCollection webHeader = new WebHeaderCollection
{
{ "Sec-Fetch-Site", "same-origin" },
{ "Sec-Fetch-Mode", "navigate" },
{ "Sec-Fetch-Dest", "document" },
{ "Sec-Fetch-User", "?1" }
};
HttpResult webContent2 = getWebContent(text2 + "watch/bands", text2 + "watch/bands");
AppSysConfig.getConfig("partNumberRegex");
string text3 = new Regex("\"partNumber\":\"([\\s\\S]*?)\"").Match(webContent2.Html).Groups[1].Value.Trim();
string text4 = Tools.ToUrlEncode(text3);
CookieItem cookieItem = listCookie.Where((CookieItem c) => c.Key == "as_atb").FirstOrDefault();
string text5 = ((cookieItem != null) ? cookieItem.Value.Split('|')[2] : null);
string postData = "add-to-cart=add-to-cart&product=" + text4 + "&atbtoken=" + text5;
postWebContent(text2 + "pdpAddToBag/" + text3, postData, text2 + "product/" + text3 + "/49mm-kumquat-solo-loop-size-1", webHeader, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
action?.Invoke(noticeKey, DisplyType.xinxi, "加载登录页面.");
HttpResult webContent3 = getWebContent(text2 + "bag", text2 + "bag");
bool flag2;
object obj4;
if (webContent3.StatusCode == HttpStatusCode.OK)
{
string value = new Regex("x-aos-stk\":\"([\\s\\S]*?)\"").Match(webContent3.Html).Groups[1].Value;
string value2 = new Regex("cart-items-item-([\\s\\S]*?)\"").Match(webContent3.Html).Groups[1].Value;
WebHeaderCollection webHeaderCollection = new WebHeaderCollection
{
{ "syntax", "graviton" },
{ "X-Requested-With", "Fetch" },
{ "modelVersion", "v2" }
};
webHeaderCollection.Add("x-aos-stk", value);
webHeaderCollection.Add("x-aos-model-page", "cart");
string postData2 = "shoppingCart.recommendations.recommendedItem.part=&shoppingCart.items.item-" + value2 + ".isIntentToGift=false&shoppingCart.items.item-" + value2 + ".itemQuantity.quantity=1&shoppingCart.locationConsent.locationConsent=false&shoppingCart.summary.promoCode.promoCode=&shoppingCart.actions.fcscounter=&shoppingCart.actions.fcsdata=";
dynamic val = Tools.Todejosn<object>(postWebContent(text2 + "bagx/checkout_now?_a=checkout&_m=shoppingCart.actions", postData2, text2 + "bag", webHeaderCollection, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded").Html);
string text6 = val["head"]["data"]["url"];
HttpResult webContent4 = getWebContent(text6, text2 + "bag");
if (webContent4.StatusCode == HttpStatusCode.Found || webContent4.StatusCode == HttpStatusCode.SeeOther)
{
getWebContent(webContent4.RedirectUrl, text6);
text6 = webContent4.RedirectUrl;
}
redirectURI = text6.Substring(0, text6.IndexOf("/shop/"));
text = new Regex("apple.com/([\\s\\S]*?)shop").Match(text6).Groups[1].Value.Trim();
string errMsg2 = "";
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg2, "https://idmsa.apple.com/"))
{
string postData3 = "";
WebHeaderCollection webHeaderCollection2 = new WebHeaderCollection
{
{ "syntax", "graviton" },
{ "X-Requested-With", "Fetch" },
{ "modelVersion", "v2" }
};
webHeaderCollection2.Add("x-aos-stk", value);
webHeaderCollection2.Add("x-aos-model-page", "signInPage");
string text7 = text6.Replace("signIn", "signIn/idms/authx");
HttpResult httpResult = postWebContent(text7 + "&up=true", postData3, text6, webHeaderCollection2, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "登录成功");
dynamic val2 = Tools.Todejosn<object>(httpResult.Html);
string text8 = val2["head"]["data"]["url"];
string text9 = val2["head"]["data"]["args"]["pltn"];
string url = text8;
postData2 = "pltn=" + text9;
WebHeaderCollection webHeader2 = new WebHeaderCollection
{
{ "Sec-Fetch-Site", "same-origin" },
{ "Upgrade-Insecure-Requests", "1" },
{ "Sec-Fetch-Mode", "navigate" },
{ "Sec-Fetch-Dest", "document" },
{ "Sec-Fetch-User", "?1" }
};
HttpResult httpResult2 = postWebContent(url, postData2, text6, webHeader2, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
action?.Invoke(noticeKey, DisplyType.xinxi, "正在查询余额");
if (httpResult2.StatusCode != HttpStatusCode.Found && webContent4.StatusCode != HttpStatusCode.SeeOther)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "查询失败");
if (!agent)
{
return AppleQueryStoreBalance(acount, _openVpn, agent: true);
}
}
else
{
HttpResult webContent5 = getWebContent(httpResult2.RedirectUrl, text6);
if (webContent5.StatusCode == HttpStatusCode.OK)
{
string text10 = webContent5.Html;
value = new Regex("x-aos-stk\":\"([\\s\\S]*?)\"").Match(webContent5.Html).Groups[1].Value;
WebHeaderCollection webHeaderCollection3 = new WebHeaderCollection
{
{ "Sec-Fetch-Site", "same-origin" },
{ "Upgrade-Insecure-Requests", "1" },
{ "Sec-Fetch-Mode", "cors" },
{ "Sec-Fetch-Dest", "empty" },
{ "syntax", "graviton" },
{ "X-Requested-With", "Fetch" },
{ "modelVersion", "v2" }
};
webHeaderCollection3.Add("x-aos-stk", value);
webHeaderCollection3.Add("x-aos-model-page", "checkoutPage");
string value3 = new Regex("\"selectShippingOption\":\"([\\s\\S]*?)\"").Match(text10).Groups[1].Value.Trim();
NationalList nationalList = (from c in new NationalData().getMation()
where c.payment?.billingAddress?.countryCode == Apple_ID_Account_Country
select c).FirstOrDefault();
if (string.IsNullOrEmpty(value3))
{
text10 = SelectShippingOptionNullData(text10, nationalList, redirectURI, webHeaderCollection3);
}
value3 = new Regex("\"selectShippingOption\":\"([\\s\\S]*?)\"").Match(text10).Groups[1].Value.Trim();
if (string.IsNullOrEmpty(value3))
{
value3 = "E2";
}
postData2 = "checkout.fulfillment.deliveryTab.delivery.shipmentGroups.shipmentGroup-1.shipmentOptionsGroups.shipmentOptionsGroup-1.shippingOptions.selectShippingOption=" + value3 + "&checkout.fulfillment.fulfillmentOptions.selectFulfillmentLocation=HOME";
HttpResult httpResult3 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromFulfillmentToShipping&_m=checkout.fulfillment", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection3, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
if (nationalList != null)
{
postData2 = "checkout.shipping.addressContactEmail.address.emailAddress=" + Tools.ToUrlEncode(acount.appleId) + "&checkout.shipping.addressContactPhone.address.fullDaytimePhone=(334)%20334-4334&checkout.shipping.addressNotification.address.emailAddress=&checkout.shipping.addressSelector.selectAddress=newAddr&checkout.shipping.addressSelector.newAddress.saveToAddressBook=true&checkout.shipping.addressSelector.newAddress.address.street2=&checkout.shipping.addressSelector.newAddress.address.lastName=wu&checkout.shipping.addressSelector.newAddress.address.firstName=wang&checkout.shipping.addressSelector.newAddress.address.companyName=&checkout.shipping.addressSelector.newAddress.address.street=109%23&checkout.shipping.addressSelector.newAddress.address.isBusinessAddress=false&checkout.shipping.addressSelector.newAddress.address.zipLookup.postalCode=70068-2260&checkout.shipping.addressSelector.newAddress.address.zipLookup.zipLookupCityState=La%20Place%2C%20LA&checkout.shipping.addressSelector.newAddress.address.zipLookup.countryCode=US";
string value4 = new Regex("/abs.Address([\\s\\S]*?)}}}},").Match(httpResult3.Html).Groups[1].Value;
List<string> list = new List<string>();
string text11 = "checkout.shipping.addressSelector.newAddress.address";
if (!string.IsNullOrEmpty(value4))
{
foreach (Match item in new Regex("\"name\":\"([\\s\\S]*?)\"").Matches(value4))
{
string value5 = item.Groups[1].Value;
if (!string.IsNullOrEmpty(value5))
{
list.Add(value5);
}
if (list.Count > 15)
{
break;
}
}
string value6 = new Regex("\"id\":\"([\\s\\S]*?)\"").Match(value4).Groups[1].Value;
if (!string.IsNullOrEmpty(value6))
{
text11 = value6.Replace("-", ".") + ".address";
}
}
if (string.IsNullOrEmpty(nationalList.payment.billingAddress.line2))
{
nationalList.payment.billingAddress.line2 = "aabbcc";
}
StringBuilder stringBuilder = new StringBuilder();
if (string.IsNullOrEmpty(nationalList.payment.phoneNumber.areaCode))
{
stringBuilder.Append("checkout.shipping.addressContactPhone.address.fullDaytimePhone=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.number));
}
else
{
stringBuilder.Append("checkout.shipping.addressContactPhone.address.daytimePhoneAreaCode=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.areaCode));
stringBuilder.Append("&checkout.shipping.addressContactPhone.address.daytimePhone=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.number));
stringBuilder.Append("&checkout.shipping.addressContactPhone.address.isDaytimePhoneSelected=true");
}
stringBuilder.Append("&checkout.shipping.addressNotification.address.emailAddress=");
stringBuilder.Append("&checkout.shipping.addressSelector.selectAddress=newAddr");
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.street2=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.line2));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.lastName=" + Tools.ToUrlEncode(nationalList.payment.ownerName.lastName));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.firstName=" + Tools.ToUrlEncode(nationalList.payment.ownerName.firstName));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.companyName=");
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.street=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.line1));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.isBusinessAddress=false");
if (list.Contains("state"))
{
stringBuilder.Append("&" + text11 + ".state=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
}
if (list.Contains("postalCode"))
{
stringBuilder.Append("&" + text11 + ".postalCode=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.postalCode));
}
if (list.Contains("city"))
{
stringBuilder.Append("&" + text11 + ".city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.city));
}
if (httpResult3.Html.Contains("checkout-shipping-addressSelector-newAddress-cityTypeAhead"))
{
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.cityTypeAhead.city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
}
if (httpResult3.Html.Contains("zipLookup"))
{
if (Apple_ID_Account_Country == "USA")
{
text = "US";
}
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.state=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.postalCode=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.postalCode));
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.countryCode=" + text.TrimEnd('/').ToUpper());
}
string[] array = GetAdditionaFieldsn(Apple_ID_Account_Country).Split('&');
foreach (string text12 in array)
{
if (string.IsNullOrEmpty(text12))
{
continue;
}
string value7 = "&" + text12;
bool flag = false;
string[] array2 = stringBuilder.ToString().Split('&');
foreach (string text13 in array2)
{
if (text13.StartsWith(text12.Split('=')[0]))
{
stringBuilder.Replace(text13, text12);
flag = true;
break;
}
}
if (!flag)
{
stringBuilder.Append(value7);
}
}
postData2 = stringBuilder.ToString();
}
HttpResult httpResult4 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromShippingToBilling&_m=checkout.shipping", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection3, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
string config = AppSysConfig.getConfig("ContinueWithSelectedAddressKeyWord");
if (!httpResult4.Html.Contains(config) && !httpResult4.Html.Contains("availableAppleBalance"))
{
postData2 = "checkout.shipping.addressContactPhone.address.isDaytimePhoneSelected=true&checkout.shipping.addressNotification.address.emailAddress=&checkout.shipping.addressSelector.selectAddress=address-0";
string additionaFieldsn = GetAdditionaFieldsn(Apple_ID_Account_Country);
if (!string.IsNullOrEmpty(additionaFieldsn))
{
string[] array = additionaFieldsn.Split('&');
foreach (string text14 in array)
{
postData2 = postData2 + "&" + text14;
}
}
httpResult4 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromShippingToBilling&_m=checkout.shipping", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection3, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
}
postData2 = "";
string text15 = new Regex(AppSysConfig.getConfig("ContinueWithSelectedAddressRegex")).Match(httpResult4.Html).Groups[1].Value.Trim();
HttpResult httpResult5 = postWebContent(string.Concat(str1: (!string.IsNullOrEmpty(text15)) ? text15.Replace(text, "") : "/shop/checkoutx?_a=continueWithSelected&_m=checkout.shipping.addressVerification.selectedAddress", str0: redirectURI), postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection3, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
if (httpResult5.StatusCode == HttpStatusCode.OK)
{
flag2 = false;
ShopBillModel shopBillModel = Tools.Todejosn<ShopBillModel>(httpResult5.Html);
string text16 = shopBillModel?.body?.checkout?.billing?.billingOptions?.selectedBillingOptions?.appleBalance?.appleBalanceInput?.d?.availableAppleBalance;
if (!string.IsNullOrEmpty(text16))
{
Action<string, DisplyType, string> obj2 = action;
if (obj2 == null)
{
if (shopBillModel == null)
{
goto IL_1672;
}
}
else
{
obj2(noticeKey, DisplyType.balance, text16);
if (shopBillModel == null)
{
goto IL_1672;
}
}
}
else
{
Action<string, DisplyType, string> obj3 = action;
if (obj3 == null)
{
if (shopBillModel == null)
{
goto IL_1672;
}
}
else
{
obj3(noticeKey, DisplyType.balance, "");
if (shopBillModel == null)
{
goto IL_1672;
}
}
}
obj4 = shopBillModel.body?.checkout?.billing?.billingOptions?.d?.options;
goto IL_16b7;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "余额获取失败");
if (!agent)
{
return AppleQueryStoreBalance(acount, _openVpn, agent: true);
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "查询失败#2");
if (!agent)
{
return AppleQueryStoreBalance(acount, _openVpn, agent: true);
}
}
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "商城页面登录失败");
if (!agent)
{
return AppleQueryStoreBalance(acount, _openVpn, agent: true);
}
}
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "页面加载失败");
if (!agent)
{
return AppleQueryStoreBalance(acount, _openVpn, agent: true);
}
}
goto end_IL_01a6;
IL_1672:
obj4 = null;
goto IL_16b7;
IL_16b7:
ShopBillModel.Option[] array3 = (ShopBillModel.Option[])obj4;
if (array3 != null)
{
ShopBillModel.Option[] array4 = array3;
foreach (ShopBillModel.Option option in array4)
{
if (!(option.value.ToUpper() == "APPLE_BALANCE".ToUpper()))
{
continue;
}
if (option.disabled)
{
action?.Invoke(noticeKey, DisplyType.error, "不可用");
flag2 = true;
}
else if (option.disabledMessage != null)
{
bool flag3 = false;
string[] array = AppSysConfig.getConfig("ShopBanaldisabledMessage").Split(',');
foreach (string value8 in array)
{
if (option.disabledMessage.Contains(value8))
{
action?.Invoke(noticeKey, DisplyType.error, "不可用");
flag3 = true;
flag2 = true;
break;
}
}
if (!flag3)
{
action?.Invoke(noticeKey, DisplyType.forbidden, "正常");
flag2 = true;
}
}
else
{
action?.Invoke(noticeKey, DisplyType.forbidden, "正常");
flag2 = true;
}
break;
}
if (!flag2)
{
action?.Invoke(noticeKey, DisplyType.forbidden, "正常");
}
}
else
{
action?.Invoke(noticeKey, DisplyType.reddemUNlock, "未知");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
end_IL_01a6:;
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(noticeKey, DisplyType.xinxi, ex.Message);
}
return false;
}
public bool applyQueryAuthBalance(AppleAcount acount, bool _openVpn, string _notityKey)
{
Apple_Widget_Key = "04659e25236376d440c224638c1cdd6a001abdd7f186cdcfa120abf35417efab";
redirectURI = "https://privacy.apple.com";
openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
listCookie.Add(new CookieItem
{
Key = "geo",
Value = "CN"
});
this.acount = acount;
string text2 = (appleId = acount.appleId);
noticeKey = text2;
noticeKey = _notityKey;
iframeId = "auth-" + Guid.NewGuid().ToString("n").Substring(0, 8) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 4) + "-" + Guid.NewGuid().ToString("n").Substring(0, 8);
try
{
HttpResult webContent = getWebContent("https://privacy.apple.com/account", "");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string errMsg = "";
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg, "https://privacy.apple.com/account") && appleauthAuth(acount))
{
string value = new Regex(AppSysConfig.getConfig("Regex_apply_CsrfToken")).Match(webContent.Html).Groups[1].Value.Trim();
string value2 = "";
handelDic.TryGetValue("X-Apple-OAuth-Grant-Code", out value2);
string value3 = Tools.EncodeBase64(Encoding.UTF8.GetBytes(Apple_Widget_Key + ":" + value2));
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("x-csrf-token", value);
webHeaderCollection.Add("x-apple-authentication", value3);
action?.Invoke(noticeKey, DisplyType.xinxi, "正在获取余额");
HttpResult webJsonContent = getWebJsonContent("https://privacy.apple.com/session/create", "https://privacy.apple.com/", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK || webJsonContent.StatusCode == HttpStatusCode.Created)
{
WebHeaderCollection webHeaderCollection2 = new WebHeaderCollection();
webHeaderCollection2.Add("x-csrf-token", value);
HttpResult webJsonContent2 = getWebJsonContent("https://privacy.apple.com/section/delete-account", "https://privacy.apple.com/account", webHeaderCollection2);
if (webJsonContent2.Html.Contains("store_balance"))
{
string text3 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent2.Html).Groups[1].Value.Trim().TrimEnd(',');
if (string.IsNullOrEmpty(text3))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "余额解析失败");
return false;
}
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text3 + "}");
decimal num = (dynamic)dictionary["balance"];
string text4 = (dynamic)dictionary["currency"];
action?.Invoke(noticeKey, DisplyType.balance, num + " " + text4);
}
else
{
action?.Invoke(noticeKey, DisplyType.balance, "0");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "正在重新获取余额");
webJsonContent = getWebJsonContent("https://privacy.apple.com/session/create", "https://privacy.apple.com/", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK || webJsonContent.StatusCode == HttpStatusCode.Created)
{
WebHeaderCollection webHeaderCollection3 = new WebHeaderCollection();
webHeaderCollection3.Add("x-csrf-token", value);
HttpResult webJsonContent3 = getWebJsonContent("https://privacy.apple.com/section/delete-account", "https://privacy.apple.com/account", webHeaderCollection3);
if (webJsonContent3.Html.Contains("store_balance"))
{
string text5 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent3.Html).Groups[1].Value.Trim().TrimEnd(',');
if (string.IsNullOrEmpty(text5))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "余额解析失败");
return false;
}
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text5 + "}");
decimal num2 = (dynamic)dictionary2["balance"];
string text6 = (dynamic)dictionary2["currency"];
action?.Invoke(noticeKey, DisplyType.balance, num2 + " " + text6);
}
else
{
action?.Invoke(noticeKey, DisplyType.balance, "0");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "余额获取失败");
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "页面加载失败");
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(noticeKey, DisplyType.xinxi, ex.Message);
}
finally
{
try
{
priveSignout();
}
catch (Exception)
{
}
}
return false;
}
public bool OpenAuthen(AppleAcount acount, AppleChangeItem changeItem, bool _openVpn, Func<string, int, string> getCodeAct)
{
openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
this.acount = acount;
appleId = acount.appleId;
_changeItem = changeItem;
string errMsg = "";
getCodeAct_ = getCodeAct;
openHsa2 = true;
try
{
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg))
{
return appleauthAuth(acount);
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(noticeKey, DisplyType.xinxi, ex.Message);
}
finally
{
try
{
signout();
}
catch (Exception)
{
}
}
return false;
}
public bool editAddrs(string addres)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
string[] array = addres.Split(',');
foreach (string text in array)
{
if (string.IsNullOrEmpty(text))
{
continue;
}
string[] array2 = text.Split(':');
if (array2.Length != 2)
{
continue;
}
string text2 = array2[0];
if (!(text2 == "姓氏"))
{
if (!(text2 == "名字"))
{
dictionary2.Add(ConverUTF8(array2[0].Trim()), ConverUTF8(array2[1].Trim()));
}
else
{
dictionary.Add("firstName", ConverUTF8(array2[1].Trim()));
}
}
else
{
dictionary.Add("lastName", ConverUTF8(array2[1].Trim()));
}
}
if (dictionary.Count > 0)
{
if (dictionary.Count == 1)
{
if (dictionary.ContainsKey("firstName"))
{
dictionary.Add("lastName", accountLastName);
}
else
{
dictionary.Add("firstName", accountFirstName);
}
}
dictionary.Add("middleName", "");
EditMangName(JsonConvert.SerializeObject(dictionary));
}
return EditAddres(dictionary2);
}
public bool EditMangName(string putJson)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7Afyz.sUAuyPBDK43xhDnmccbguaDeyjaY2ftckuyPBDjaY1HGOg3ZLQ0ISNFmau_WuevMurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lrCU.6elV2pNK1e3sdmHzL0TFc4NO7TjOz1_y_WFQ_v9NA14WX3NlY5DuY25BNnOVgw24uy.4dS\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/name", putJson, appleHomeUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "名称修改失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "名称修改失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "名称修改完成");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "名称修改失败,请求错误");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "名称修改失败,未知异常");
return false;
}
public string getDicValue(Dictionary<string, string> suos, string key, string dfValue)
{
if (suos.ContainsKey(key))
{
return suos[key].Trim();
}
return dfValue;
}
private string ConverUTF8(string value)
{
return Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(value)));
}
public bool EditAddres(Dictionary<string, string> pairs)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJldTeF_C90GfxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3NvWjV2pNk0ug97SYY642xN4t1VKWZWumjkeUd_icCmx_B4W1kl1BNlY6SGWY5BOgkLT0XxU..3mj\"}");
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/manage/payment", "https://appleid.apple.com/account/manage", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在修改内容");
ManagePayment managePayment = JsonConvert.DeserializeObject<ManagePayment>(webJsonContent.Html);
string text = "";
if (pairs.ContainsKey("税号"))
{
text = "\"taxId\":\"" + getDicValue(pairs, "税号", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.taxId != null)
{
text = "\"taxId\":\"" + managePayment.primaryPaymentMethod.taxId + "\",";
}
string text2 = "";
if (pairs.ContainsKey("卡号"))
{
text2 = text2 + "\"number\":\"" + getDicValue(pairs, "卡号", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.number != null)
{
text2 = text2 + "\"number\":\"" + managePayment.primaryPaymentMethod.number + "\",";
}
if (pairs.ContainsKey("有效期限年"))
{
text2 = text2 + "\"expirationYear\":\"" + getDicValue(pairs, "有效期限年", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.expirationYear.HasValue)
{
text2 = text2 + "\"expirationYear\":\"" + managePayment.primaryPaymentMethod.expirationYear + "\",";
}
if (pairs.ContainsKey("有效期限月"))
{
text2 = text2 + "\"expirationMonth\":\"" + getDicValue(pairs, "有效期限月", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.expirationMonth.HasValue)
{
text2 = text2 + "\"expirationMonth\":\"" + managePayment.primaryPaymentMethod.expirationMonth + "\",";
}
if (pairs.ContainsKey("安全码"))
{
text2 = text2 + "\"cvv\":\"" + getDicValue(pairs, "安全码", "") + "\",";
}
string text3 = "ownerName";
if (managePayment.primaryPaymentMethod.nameOnCard != null)
{
text3 = "nameOnCard";
}
string putData = string.Concat("{\"" + text3 + "\":{\"firstName\":\"" + getDicValue(pairs, "账单名字", managePayment.primaryPaymentMethod.ownerName.firstName) + "\",\"lastName\":\"" + getDicValue(pairs, "账单姓氏", managePayment.primaryPaymentMethod.ownerName.lastName) + "\"},\"phoneNumber\":{\"areaCode\":\"" + getDicValue(pairs, "区号", managePayment.primaryPaymentMethod.phoneNumber.areaCode) + "\",\"number\":\"" + getDicValue(pairs, "电话", managePayment.primaryPaymentMethod.phoneNumber.number) + "\",\"countryCode\":\"" + managePayment.primaryPaymentMethod.phoneNumber.countryCode + "\"},\"billingAddress\":{\"line1\":\"" + getDicValue(pairs, "街道地址", managePayment.primaryPaymentMethod.billingAddress.line1) + "\",\"line2\":\"" + getDicValue(pairs, "楼号单元", managePayment.primaryPaymentMethod.billingAddress.line2) + "\",\"line3\":\"", "\",\"suburb\":\"", getDicValue(pairs, "区", managePayment.primaryPaymentMethod.billingAddress.suburb), "\",\"county\":\"", getDicValue(pairs, "县", managePayment.primaryPaymentMethod.billingAddress.county), "\",\"city\":\"", getDicValue(pairs, "城市", managePayment.primaryPaymentMethod.billingAddress.city), "\",\"countryCode\":\"", managePayment.primaryPaymentMethod.billingAddress.countryCode, "\",\"postalCode\":\"", getDicValue(pairs, "邮编", managePayment.primaryPaymentMethod.billingAddress.postalCode), "\",\"stateProvinceName\":\"", getDicValue(pairs, "省/市", managePayment.primaryPaymentMethod.billingAddress.stateProvinceCode), "\"},", text, text2, "\"id\":1}");
WebHeaderCollection webHeaderCollection2 = new WebHeaderCollection();
webHeaderCollection2.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection2.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection2.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection2.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection2.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection2.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfbAAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuL5raZmTiRgjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJkHaKqu3aAqjpidPNs0ojpVMZ90L5H6fqUdHz15tTma1kxNGYiJhw.Tf5.EKWG2eRJdojpVMZBHgBZEKIx8buZrJ5tTma1kWNNW5BNlYicklY5BqNAE.lTjV.2nd\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/" + managePayment.primaryPaymentMethod.paymentMethodOption.name + "/1", putData, appleHomeUrl, webHeaderCollection2);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "账单信息修改失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "账单信息修改失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "信息修改完成");
action?.Invoke(noticeKey, DisplyType.lostBillNo, "");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "账单信息修改失败,请求错误");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "信息修改失败,未知异常:" + httpResult.StatusCode);
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "网络异常,修改失败");
return false;
}
public bool checkDisable(bool _openVpn, string appleId, string pwd)
{
this.appleId = appleId;
openVpn = _openVpn;
string postData = "{\"accountName\":\"" + appleId + "\",\"password\":\"" + pwd + "\",\"rememberMe\":false}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Apple-App-Id", "1879");
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Locale", "ZH-CN");
webHeaderCollection.Add("Origin", "https://idmsa.apple.com");
webHeaderCollection.Add("X-Apple-Widget-Key", "16452abf721961a1728885bef033f28e");
widgKey = "16452abf721961a1728885bef033f28e";
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"kOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfbAAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuL5raZmTiRgjhO3f9p_nH1uzjkD6myjaY2hDpBtOtJJIqSI6KUMnGWpwoNSUC56MnGW87gq1HACVdVe9ZjN6NdVMurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lr91y.EKY.6ekcWpD9JscUf.j7N_NO7TdMtinxMPuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.EDJ\"}");
HttpResult httpResult = postWebContent("https://idmsa.apple.com/appleauth/auth/signin", postData, "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=16452abf721961a1728885bef033f28e&language=ZH-CN&appId=1879", webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "ID 或密码不正确");
string.IsNullOrEmpty(ProxyIp);
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
RespErrorJson respErrorJson = JsonConvert.DeserializeObject<RespErrorJson>(httpResult.Html);
if (respErrorJson != null && respErrorJson.serviceErrors != null && respErrorJson.serviceErrors.Length != 0)
{
string message = respErrorJson.serviceErrors[0].message;
action?.Invoke(noticeKey, DisplyType.xinxi, message);
return false;
}
return false;
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "X-Apple-ID-Session-Id")
{
handelDic.TryAddDic("X-Apple-ID-Session-Id", httpResult.Header[text]);
}
if (text == "X-Apple-ID-Account-Country")
{
handelDic.TryAddDic("X-Apple-ID-Account-Country", httpResult.Header[text]);
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密码验证成功");
if (httpResult.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
action?.Invoke(noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(httpResult.Header["X-Apple-ID-Account-Country"].ToString()));
}
return reportaproblem(appleId);
}
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "阅读协议");
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text2 in allKeys)
{
if (text2 == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
if (text2 == "scnt")
{
checkDisableScnt = httpResult.Header[text2];
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
if (text2 == "X-Apple-App-Id")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
if (text2 == "X-Apple-Frame-Id")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
if (text2 == "X-Apple-Locale")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
}
try
{
if (repair())
{
return reportaproblem(appleId);
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
if (isError)
{
action?.Invoke(noticeKey, DisplyType.xinxi, ex.Message);
return false;
}
isError = true;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
public bool priveSignout()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
getWebContent("https://privacy.apple.com/signout", "https://privacy.apple.com/account", webHeaderCollection);
return true;
}
public bool signout()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
getWebContent("https://appleid.apple.com/signout?signOutMessage", "https://appleid.apple.com/account/manage", webHeaderCollection);
return true;
}
public bool reportSingOut()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
getWebContent("https://reportaproblem.apple.com/logout", "https://reportaproblem.apple.com/", webHeaderCollection);
getWebContent("https://reportaproblem.apple.com/", "https://reportaproblem.apple.com/", webHeaderCollection);
return true;
}
public bool sponsorRefund(string appleId, string amountSpik)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在查询订单");
HttpResult webJsonContent = getWebJsonContent("https://reportaproblem.apple.com/invoices/weborderIds.json?size=60&entityType=invoices&category=all&batchSize=60&r=" + dataR, "https://reportaproblem.apple.com");
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
string text = "";
string text2 = "";
foreach (KeyValuePair<string, object> item in Tools.Todejosn<Dictionary<string, object>>(webJsonContent.Html)["idToHint"] as Dictionary<string, object>)
{
text = text + item.Key + ",";
text2 = (string)(text2 + ((dynamic)item.Value + ","));
}
text = text.TrimEnd(',');
text2 = text2.TrimEnd(',');
string url = "https://reportaproblem.apple.com/invoices/summaries/" + text + ".html?h=" + text2 + "&t=-480&r=" + dataR;
webJsonContent = getWebJsonContent(url, "https://reportaproblem.apple.com");
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
decimal result2;
decimal[] array = (from c in amountSpik.Split(',')
where decimal.TryParse(c, out result2)
select decimal.Parse(c)).ToArray();
List<PurchaseLineItems> list = new List<PurchaseLineItems>();
foreach (Match item2 in Regex.Matches(webJsonContent.Html, "ph-row([\\s\\S]*?)invoice-container"))
{
string value = new Regex("data-id=\"([\\s\\S]*?)\"").Match(item2.Groups[1].Value).Groups[1].Value;
string value2 = new Regex("data-t=\"([\\s\\S]*?)\"").Match(item2.Groups[1].Value).Groups[1].Value;
string value3 = new Regex("class=\"extra\">([\\s\\S]*?)</li>").Match(item2.Groups[1].Value).Groups[1].Value;
string value4 = new Regex("class=\"total\">([\\s\\S]*?)</div>").Match(item2.Groups[1].Value).Groups[1].Value;
PurchaseLineItems purchaseLineItems = new PurchaseLineItems
{
dataT = value2,
extra = value3,
title = value,
total = value4
};
string text3 = value4.Replace(",", ".");
if (value4.Contains(","))
{
purchaseLineItems.monetary = ",";
}
else
{
purchaseLineItems.monetary = ".";
}
string text4 = Regex.Replace(text3, "[^\\d.\\d]", "");
if (Regex.IsMatch(text4, "^[+-]?\\d*[.]?\\d*$"))
{
Regex regex = new Regex("(\\p{Sc})?");
string currency = text3.Replace(text4, "").TrimStart();
if (decimal.TryParse(regex.Replace(text4, ""), out var result))
{
purchaseLineItems.currency = currency;
purchaseLineItems.money = result;
if (result <= 0m || (array.Length != 0 && !array.Contains(result)))
{
continue;
}
}
}
list.Add(purchaseLineItems);
}
string text5 = "";
foreach (IGrouping<string, PurchaseLineItems> item3 in from c in list
group c by c.extra)
{
foreach (IGrouping<string, PurchaseLineItems> item4 in from c in item3
group c by c.total)
{
text5 = text5 + item3.Key + " " + item4.Key + ":";
foreach (PurchaseLineItems item5 in item4)
{
text5 = text5 + item5.title + ",";
}
text5 = text5.TrimEnd(',') + " ";
}
}
action?.Invoke(noticeKey, DisplyType.lostBillNo, text5);
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "网络异常,请重新检测");
return false;
}
public bool reportaproblem(string appleId)
{
HttpResult webContent = getWebContent("https://reportaproblem.apple.com", "https://idmsa.apple.com/IDMSWebAuth/signin?appIdKey=6f59402f11d3e2234be5b88bf1c96e1e453a875aec205272add55157582a9f61&language=US-EN");
if (webContent.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.normal, "正常");
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
string.IsNullOrEmpty(ProxyIp);
idIsNormal = true;
dataR = new Regex(AppSysConfig.getConfig("Regex_reportaproblem")).Match(webContent.Html).Groups[1].Value;
return true;
}
if (webContent.StatusCode != HttpStatusCode.Found && webContent.StatusCode != HttpStatusCode.MovedPermanently)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "未知异常,请重新检测");
return false;
}
string.IsNullOrEmpty(ProxyIp);
if (webContent.RedirectUrl.ToLower().Contains("accountdisabled"))
{
applyAtion?.Invoke(appleId, DisplyType.forbidden, "禁用");
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
if (webContent.RedirectUrl.ToLower().Contains("https://reportaproblem.apple.com"))
{
applyAtion?.Invoke(appleId, DisplyType.normal, "正常");
action?.Invoke(noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "未知异常,请重新检测");
return false;
}
private void manageSecurity()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"VOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_CQnIAA2OfUPm8LKfAaZ4pAJZ7OQuyPBB2SCXw2SCVL6yXyjaY1WMsiZRPrwVL6tqAhbrmQmkqlE4Ww.GEFF0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6Hahtd__WgpjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJrN9HmkVJ_EPzLu_dYV6HzL0TFc4NO7TjOy_Aw7Q_v9NA2pW5DzPy.EKY.6eke4J8odlNUf.j7N_NO7TdMtXjsKMJ5tTma1kWNNW5BNlYicklY5BqNAE.lTjV.4x4\"}");
getWebContent("https://appleid.apple.com/account/manage/security", "https://appleid.apple.com/account/manage", webHeaderCollection, "application/json");
}
private void manageFamily()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"VOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJldTeFWudukgSQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3NvdjV2pNk0ug97SYY642xN4t1VKWZWumjkxMw9Qe2RjOI0NFgBFY5BNlrJNNlY5QB4bVNjMk.8ob\"}");
getWebJsonContent("https://appleid.apple.com/account/manage/family", "https://appleid.apple.com/account/manage", webHeaderCollection);
}
private bool changQuestions(string newqt1, string newqt2, string newqt3)
{
string text = "";
try
{
AothQuestions aothQuestions = new AothQuestions();
aothQuestions.questions = new AothQuestions.Question[3];
aothQuestions.questions[0] = new AothQuestions.Question
{
id = 130,
answer = newqt1,
number = 1,
question = securityQuestions.availableSecurityQuestions[0][0].question
};
aothQuestions.questions[1] = new AothQuestions.Question
{
id = 136,
answer = newqt2,
number = 2,
question = securityQuestions.availableSecurityQuestions[1][0].question
};
aothQuestions.questions[2] = new AothQuestions.Question
{
id = 142,
answer = newqt3,
number = 3,
question = securityQuestions.availableSecurityQuestions[2][0].question
};
text = JsonConvert.SerializeObject(aothQuestions);
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
text = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes("{\"questions\":[{\"id\":130,\"question\":\"你少年时代最好的朋友叫什么名字?\",\"number\":1,\"answer\":\"" + newqt1 + "\"},{\"id\":136,\"question\":\"你的理想工作是什么?\",\"number\":2,\"answer\":\"" + newqt2 + "\"},{\"id\":142,\"question\":\"你的父母是在哪里认识的?\",\"number\":3,\"answer\":\"" + newqt3 + "\"}]}"));
}
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"VOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfbAAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuL5raZmTiRgjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJkHW2A92g4A6Lu_dYV6HzL0TFc4NO7TjOy_Aw7Q_v9NA2pW5Dwhw.Tf5.EKWG2eRJdkEf.j7N_NO7TeMtVEsTpp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.8wj\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/questions", text, appleHomeUrl, webHeaderCollection, "application/json");
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.qt1, newqt1);
applyAtion?.Invoke(appleId, DisplyType.qt2, newqt2);
applyAtion?.Invoke(appleId, DisplyType.qt3, newqt3);
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败");
return false;
}
private bool changenPayment(PaymentInfo pay)
{
string putData = "{\"ownerName\":{\"firstName\":\"" + pay.ownerName.firstName + "\",\"lastName\":\"" + pay.ownerName.lastName + "\"},\"phoneNumber\":{\"areaCode\":\"" + pay.phoneNumber.areaCode + "\",\"number\":\"" + pay.phoneNumber.number + "\",\"countryCode\":\"" + pay.phoneNumber.countryCode + "\"},\"billingAddress\":{\"line1\":\"" + pay.billingAddress.line1 + "\",\"line2\":\"" + pay.billingAddress.line2 + "\",\"line3\":\"" + pay.billingAddress.line3 + "\",\"suburb\":\"" + pay.billingAddress.suburb + "\",\"county\":\"" + pay.billingAddress.county + "\",\"city\":\"" + pay.billingAddress.city + "\",\"countryCode\":\"" + pay.billingAddress.countryCode + "\",\"postalCode\":\"" + pay.billingAddress.postalCode + "\",\"stateProvinceName\":\"" + pay.billingAddress.stateProvinceName + "\"},\"id\":1}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfbAAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuL5raZmTiRgjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJkHaKqu3aAqjpidPNs0ojpVMZ90L5H6fqUdHz15tTma1kxNGYiJhw.Tf5.EKWG2eRJdojpVMZBHgBZEKIx8buZrJ5tTma1kWNNW5BNlYicklY5BqNAE.lTjV.2nd\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/none/1", putData, appleHomeUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.guojia, pay.billingAddress.countryCode);
action?.Invoke(noticeKey, DisplyType.xinxi, "国家修改完成");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "国家修改失败,请求错误");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "国家修改失败,未知异常");
return false;
}
private bool changeBirthDate(string fullBirthDate)
{
string putData = "{\"fullBirthDate\":\"" + fullBirthDate + "\"}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"VOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfOkexf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnWKvLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4B4FOTWPfePzLu_dYV6HzL0TFc4NO7TjOy_Aw7Q_v9NA2pW5DzLy.EKY.6ekcWpD9JsjMukAm58L5H6eKIw76sL40iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.7dy\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/birthday", putData, appleHomeUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.shengri, fullBirthDate);
action?.Invoke(noticeKey, DisplyType.xinxi, "生日修改完成");
return true;
}
_ = httpResult.StatusCode;
action?.Invoke(noticeKey, DisplyType.xinxi, "生日修改失败,未知异常");
return false;
}
private bool changePwd(string oldPwd, string newPwd)
{
string putData = "{\"currentPassword\":\"" + oldPwd + "\",\"newPassword\":\"" + newPwd + "\"}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfbAAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuL5raZmTiRgjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJkHW2AA93rMhUfSHolk2dUf.j7J1gBZEMgzH_y3Cmx_B4WukY6UhU.6elV2pNJFub49R2ukAm58L5H6e_yN2wcQe2RjOI0NFgBFY5BNlrJNNlY5QB4bVNjMk.._O\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/password", putData, appleHomeUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.mima, newPwd);
action?.Invoke(noticeKey, DisplyType.xinxi, "密码修改成功");
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, httpResult.Header[text]);
}
else
{
handelDic[text] = httpResult.Header[text];
}
}
return true;
}
_ = httpResult.StatusCode;
action?.Invoke(noticeKey, DisplyType.xinxi, "密码修改失败,未知异常");
return false;
}
private bool intoHome()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-Request-Context", "ca");
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"NOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfO_Wxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnA2vLG9mhORoVijvw2WwjftckvIhIDLTK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9NkONFeA9OJhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSnMk0ugN.xL43DlkIijpVMZ90L5H6edyJ2wohp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.0SX\"}");
HttpResult webContent = getWebContent(appleHomeUrl, "https://appleid.apple.com/", webHeaderCollection, "application/json, text/plain", "application/json");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string[] allKeys = webContent.Header.AllKeys;
foreach (string text in allKeys)
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, webContent.Header[text]);
}
else
{
handelDic[text] = webContent.Header[text];
}
}
string text2 = new Regex(AppSysConfig.getConfig("Regex_intoHome_jsonData")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
if (!string.IsNullOrEmpty(text2))
{
loginAppleInfo = JsonConvert.DeserializeObject<LoginAppleInfo>(text2 + "}");
action?.Invoke(noticeKey, DisplyType.shengri, loginAppleInfo.security.birthday);
action?.Invoke(noticeKey, DisplyType.guojia, loginAppleInfo.person.primaryAddress.countryName);
accountFirstName = loginAppleInfo.person.name.firstName;
accountLastName = loginAppleInfo.person.name.lastName;
action?.Invoke(noticeKey, DisplyType.xinxi, "账号获取完成");
}
string value = new Regex(AppSysConfig.getConfig("Regex_intoHome_jsonDataQuestions")).Match(webContent.Html).Groups[0].Value;
if (!string.IsNullOrEmpty(value))
{
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
}
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "获取账号信息网络异常");
return false;
}
private bool verifyAuthQuestions(AothQuestions questions, string[] question)
{
AothQuestions.Question[] questions2 = questions.questions;
int num = 0;
while (true)
{
if (num < questions2.Length)
{
AothQuestions.Question question2 = questions2[num];
int anwerId_Index = Tools.getAnwerId_Index(question2.id);
if (anwerId_Index == 0)
{
break;
}
question2.answer = question[anwerId_Index - 1];
num++;
continue;
}
string postData = JsonConvert.SerializeObject(questions);
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Auth-Attributes", X_Apple_Auth_Attributes);
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["X-Apple-ID-Session-Id"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"NOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfO_Wxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnA2vLG9mhORoVijvw2WwjftckvIhIDLTK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9NkONFeA9OJhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSnMk0ugN.xL43DlkIijpVMZ90L5H6edyJ2wohp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.0SX\"}");
webHeaderCollection.Add("X-Apple-OAuth-Redirect-URI", redirectURI);
webHeaderCollection.Add("X-Apple-OAuth-Client-Id", Apple_Widget_Key);
webHeaderCollection.Add("X-Apple-OAuth-Client-Type", "firstPartyAuth");
webHeaderCollection.Add("X-Apple-OAuth-Response-Mode", "web_message");
webHeaderCollection.Add("X-Apple-OAuth-Response-Type", "code");
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-State", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-Require-Grant-Code", "true");
HttpResult httpResult = postWebContent(verifyquestionsUrl, postData, authUrl, webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.NoContent)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "X-Apple-OAuth-Grant-Code")
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, httpResult.Header[text]);
}
else
{
handelDic[text] = httpResult.Header[text];
}
}
}
if (httpResult.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
XAppleIDAccountCountry = AppleUtlis.GetAreaByCode(httpResult.Header["X-Apple-ID-Account-Country"].ToString());
action?.Invoke(noticeKey, DisplyType.area, XAppleIDAccountCountry);
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保验证成功");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text2 in allKeys)
{
if (text2 == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
if (text2 == "scnt")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpResult.Header[text2]);
}
else
{
handelDic[text2] = httpResult.Header[text2];
}
}
}
if (httpResult.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
XAppleIDAccountCountry = AppleUtlis.GetAreaByCode(httpResult.Header["X-Apple-ID-Account-Country"].ToString());
action?.Invoke(noticeKey, DisplyType.area, XAppleIDAccountCountry);
}
return repair();
}
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "非正常密保问题,无法识别");
return false;
}
private bool repair()
{
action?.Invoke(noticeKey, DisplyType.xinxi, "获取阅读协议");
string text = "zh_CN_CHN";
if (handelDic.ContainsKey("X-Apple-Locale"))
{
text = handelDic["X-Apple-Locale"];
}
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
HttpItem httpItem = new HttpItem
{
URL = "https://appleid.apple.com/widget/account/repair?widgetKey=" + apple_Widget_Key + "&rv=1&language=" + text,
Method = "get",
Timeout = 120000,
ReadWriteTimeout = 30000,
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
ContentType = "text/html;charset=UTF-8",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
Referer = "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=" + apple_Widget_Key + "&language=zh_CN&rv=1",
ResultType = ResultType.String,
ProtocolVersion = HttpVersion.Version11,
WebProxy = WebRequest.DefaultWebProxy
};
httpItem.Header = webHeaderCollection;
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
if (httpReuslt.StatusCode == HttpStatusCode.OK)
{
try
{
string text2 = "";
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
if (!string.IsNullOrEmpty(value))
{
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
}
string value2 = new Regex(AppSysConfig.getConfig("Regex_repair_sessionId")).Match(httpReuslt.Html).Groups[1].Value.Trim().Replace("\n", "").Replace("\r", "")
.Replace("\"", "")
.TrimStart(':')
.Trim();
string key = "repairSessionId";
if (!handelDic.ContainsKey(key))
{
handelDic.TryAddDic(key, value2);
}
else
{
handelDic[key] = value2;
}
string[] allKeys = httpReuslt.Header.AllKeys;
foreach (string text3 in allKeys)
{
if (text3 == "scnt")
{
if (!handelDic.ContainsKey(text3))
{
handelDic.TryAddDic(text3, httpReuslt.Header[text3]);
}
else
{
handelDic[text3] = httpReuslt.Header[text3];
}
}
if (text3 == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text3))
{
handelDic.TryAddDic(text3, httpReuslt.Header[text3]);
}
else
{
handelDic[text3] = httpReuslt.Header[text3];
}
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "协议获取成功");
return options();
}
action?.Invoke(noticeKey, DisplyType.xinxi, "协议获取失败");
return false;
}
private bool options()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("scnt", handelDic["scnt"]);
if (openHsa2)
{
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
}
else
{
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[\"hsa2_enrollment\"]");
}
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Repair-Session-Token"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\".Ga44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZrVglE4YcA.0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6.KQnu7KOmaxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8j0OXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD.erboFen_CvLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4BKPQeOMNkDpyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BStQs.xLB.Tf1X3dlHbHzL0TFc4NO7TjKy4Iy6hSFQ_v9NA14WX3NlY5DuV25BNnOVgw24uy.Bp1\"}");
string text = "https://appleid.apple.com/account/manage/repair/options";
if (acount?.appleQt3 == "changAccount" && !string.IsNullOrEmpty(_changeItem.newPwd))
{
text += "?passwordRepairType=w";
}
HttpItem httpItem = new HttpItem
{
URL = text,
Method = "get",
Timeout = 120000,
ReadWriteTimeout = 30000,
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
ContentType = "application/json; charset=utf-8",
Accept = "application/json, text/javascript, */*; q=0.01",
Referer = "https://appleid.apple.com/widget/account/repair?widgetKey=" + apple_Widget_Key + "&rv=1&language=zh_CN_CHN",
ResultType = ResultType.String,
ProtocolVersion = HttpVersion.Version11,
WebProxy = WebRequest.DefaultWebProxy
};
httpItem.Header = webHeaderCollection;
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
if (httpReuslt.StatusCode == HttpStatusCode.OK)
{
string[] allKeys = httpReuslt.Header.AllKeys;
foreach (string text2 in allKeys)
{
if (text2 == "X-Apple-Session-Token")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpReuslt.Header[text2]);
}
else
{
handelDic[text2] = httpReuslt.Header[text2];
}
}
if (openHsa2 && text2 == "scnt")
{
if (!handelDic.ContainsKey(text2))
{
handelDic.TryAddDic(text2, httpReuslt.Header[text2]);
}
else
{
handelDic[text2] = httpReuslt.Header[text2];
}
}
}
Dictionary<string, object> dictionary = Tools.Todejosn<Dictionary<string, object>>(httpReuslt.Html);
if (openHsa2 && !httpReuslt.Html.Contains("hsa2_enrollment"))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "该账号无法开启双重验证#2");
return false;
}
if (httpReuslt.Html.Contains("requiredSteps"))
{
foreach (object item in (dynamic)dictionary["requiredSteps"])
{
string text3 = (string)(dynamic)item;
if (!(text3 == "hsa2_enrollment") || !openHsa2)
{
if (text3 == "account_name")
{
if (_changeItem == null)
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置账号#2");
return false;
}
if (string.IsNullOrEmpty(acount.newAppleId) || string.IsNullOrEmpty(acount.newApplePopPwd))
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置账号#2");
return false;
}
if (!setAccnount(acount.newAppleId, acount.newApplePopPwd, Apple_Widget_Key))
{
return false;
}
}
if (text3 == "weak_password")
{
if (_changeItem == null)
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置新密码#2");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newPwd))
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置新密码#1");
return false;
}
if (!setWeakPassword(_changeItem.newPwd))
{
return false;
}
}
if (text3 == "missing_data")
{
if (_changeItem == null)
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置生日#2");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newshengri))
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置生日#2");
return false;
}
if (!setBirthday(_changeItem.newshengri))
{
return false;
}
isVieyBirthday = true;
}
if (text3 == "challenge_response")
{
if (_changeItem == null)
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置密保#1");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newQt1))
{
if (AppSysConfig.getConfig("oldAccountApply") == "1")
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(noticeKey, DisplyType.xinxi, "需要设置密保#2");
return false;
}
if (!setQuestions(_changeItem.newQt1, _changeItem.newQt2, _changeItem.newQt3))
{
return false;
}
isViey = true;
}
if (!(text3 == "phoneNumber") || SkipPhoneNumber())
{
if (text3 == "privacy_consent" && !accept())
{
action?.Invoke(noticeKey, DisplyType.xinxi, "协议阅读失败#2");
return false;
}
continue;
}
return false;
}
if (string.IsNullOrEmpty(acount.moblie))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "请先导入手机号码");
return false;
}
return OpenHsa2Act(_changeItem.mode, _changeItem.countryCode);
}
}
return complete();
}
action?.Invoke(noticeKey, DisplyType.xinxi, "协议获取失败#2");
return false;
}
public bool OpenHsa2Act(string mode, string countryCode)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "发送验证码中");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
}
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
string text = string.Empty;
int msmId = 0;
lock (lockSendMsmObj)
{
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/security/upgrade/verify/phone", "{\"phoneNumberVerification\":{\"phoneNumber\":{\"number\":\"" + acount.moblie + "\",\"countryCode\":\"" + countryCode + "\"},\"mode\":\"" + mode + "\"}}", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode == (HttpStatusCode)423)
{
dynamic val = JsonConvert.DeserializeObject<object>(httpResult.Html);
string text2 = val["phoneNumberVerification"]?["serviceErrors"]?[0]["message"];
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + text2);
return false;
}
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
if (httpResult.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "发送验证码失败,未知异常");
return false;
}
dynamic val2 = JsonConvert.DeserializeObject<object>(httpResult.Html);
msmId = val2["phoneNumberVerification"]?["phoneNumber"]?["id"];
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码发送成功");
text = getCodeAct_?.Invoke("请输入账号 " + acount.appleId + "\n发送至 " + acount.moblie + " 的验证码", 1);
if (text == null || string.IsNullOrEmpty(text))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码未输入");
return false;
}
if (text.Trim().Length != 6)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码输入不正确");
return false;
}
}
return verifyCode(msmId, text, acount.moblie, countryCode, mode);
}
public bool verifyCode(int msmId, string code, string moblie, string countryCode, string mode)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
}
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
string postData = "{\"phoneNumberVerification\":{\"phoneNumber\":{\"id\":" + msmId + ",\"number\":\"" + moblie + "\",\"countryCode\":\"" + countryCode + "\",\"nonFTEU\":true},\"securityCode\":{\"code\":\"" + code + "\"},\"mode\":\"" + mode + "\"}}";
HttpResult httpResult = postWebContent("https://appleid.apple.com/account/security/upgrade", postData, "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "双重开启成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "验证失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
public bool SkipPhoneNumber()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[\"phoneNumber\"]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
if (getWebJsonContent("https://appleid.apple.com/account/manage/repair/options", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection).StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "跳过手机号码成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "跳过手机号码失败");
return false;
}
public bool setAccnount(string newAccount, string popPwd, string newwidgKey)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
newwidgKey = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", newwidgKey);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
HttpResult httpResult = postWebContent("https://appleid.apple.com/account/manage/appleid/verification", "\"" + newAccount + "\"", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
string text = "";
Verification verification = JsonConvert.DeserializeObject<Verification>(httpResult.Html);
action?.Invoke(noticeKey, DisplyType.xinxi, "邮件验证码发送成功");
Thread.Sleep(new Random().Next(AppSysConfig.CheckCodeDelay * 1000, AppSysConfig.CheckCodeDelay * 1000 + 1000));
int num = 0;
do
{
num++;
HttpItem item = new HttpItem
{
URL = "http://localhost:47513/?email=" + acount.newAppleId + "&popPwd=" + acount.newApplePopPwd,
Method = "GET",
Timeout = 100000,
ReadWriteTimeout = 30000,
ResultType = ResultType.String
};
HttpResult html = new HttpHelper().GetHtml(item);
if (html.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
else
{
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(html.Html);
if (dictionary["code"] == "1")
{
text = dictionary["vieyCode"];
if (!string.IsNullOrEmpty(text))
{
break;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
}
Thread.Sleep(5000);
}
while (num < 5);
if (!string.IsNullOrEmpty(text))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码获取成功");
return setAccountName(newAccount, verification?.verificationId, text);
}
action?.Invoke(noticeKey, DisplyType.xinxi, "获取验证码失败超过最大次数");
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "发送邮件验证码失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
public bool setAccountName(string accountName, string verificationId, string answer)
{
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/appleid/verification", putData, "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.newAccount, accountName);
appleId = accountName;
acount.appleId = accountName;
action?.Invoke(noticeKey, DisplyType.xinxi, "新账号设置成功");
isChangAppleId = true;
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "新账号设置失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
public bool setWeakPassword(string newPwd)
{
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/password", putData, "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
acount.applePwd = newPwd;
isPwdViey = true;
applyAtion?.Invoke(appleId, DisplyType.mima, newPwd);
action?.Invoke(noticeKey, DisplyType.xinxi, "新密码设置成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "新密码设置失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "新密码失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "新密码失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
public bool setBirthday(string newBirthday)
{
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOdAvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJCjCBeipaZjhO3f9p_nH1uzjkD6myjaY2_GGEQIgwe98vDdYejftckuyPBDjaY2ftckZZLQ084akJk231kaJK8QxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3Nvxfs.xLB.Tf1X6NveRQukAm4.f282pvEmmjyXuVrAqJkL3A237lY5BSp55BNlan0Os5Apw.C4E\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/repair", putData, "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.shengri, newBirthday);
action?.Invoke(noticeKey, DisplyType.xinxi, "生日设置成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "生日修改设置失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "生日修改设置失败");
return false;
}
private bool setQuestions(string newqt1, string newqt2, string newqt3)
{
AothQuestions aothQuestions = new AothQuestions();
aothQuestions.questions = new AothQuestions.Question[3];
aothQuestions.questions[0] = new AothQuestions.Question
{
id = 130,
answer = newqt1,
number = 1,
question = securityQuestions.availableSecurityQuestions[0][0].question
};
aothQuestions.questions[1] = new AothQuestions.Question
{
id = 136,
answer = newqt2,
number = 2,
question = securityQuestions.availableSecurityQuestions[1][0].question
};
aothQuestions.questions[2] = new AothQuestions.Question
{
id = 142,
answer = newqt3,
number = 3,
question = securityQuestions.availableSecurityQuestions[2][0].question
};
Dictionary<string, AothQuestions> obj = new Dictionary<string, AothQuestions> { { "security", aothQuestions } };
string putData = JsonConvert.SerializeObject(obj);
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfO_Wxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnA2vLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4BN.45_.Jc3rurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lrurk0ugN.xL43DlkIZkzL0TFc4NO7TjKz1dy3hp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.7Nd\"}");
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/repair/questions", putData, "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(appleId, DisplyType.qt1, newqt1);
applyAtion?.Invoke(appleId, DisplyType.qt2, newqt2);
applyAtion?.Invoke(appleId, DisplyType.qt3, newqt3);
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败");
return false;
}
private bool accept()
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在同意协议");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Skip-Repair-Attributes", "[]");
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\".Ga44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZrVglE4YcA.0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6.KQnu7KOmaxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8j0OXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD.erboFen_CvLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4BKPQeOMNkDpyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BStQs.xLB.Tf1X3dlHbHzL0TFc4NO7TjKy4Iy6hSFQ_v9NA14WX3NlY5DuV25BNnOVgw24uy.Bp1\"}");
HttpItem httpItem = new HttpItem
{
URL = "https://appleid.apple.com/account/manage/privacy/accept",
Method = "put",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
ContentType = "application/json; charset=utf-8",
Accept = "application/json, text/javascript, */*; q=0.01",
Referer = "https://appleid.apple.com/widget/account/repair?widgetKey=" + apple_Widget_Key + "&rv=1&language=zh_CN_CHN",
ProtocolVersion = HttpVersion.Version11,
WebProxy = WebRequest.DefaultWebProxy
};
httpItem.Header = webHeaderCollection;
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
if (httpReuslt.StatusCode != HttpStatusCode.OK && httpReuslt.StatusCode != HttpStatusCode.MethodNotAllowed)
{
return false;
}
return true;
}
private bool complete()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
string value = checkDisableScnt;
if (handelDic.ContainsKey("scnt2"))
{
value = handelDic["scnt2"];
}
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
if (string.IsNullOrEmpty(value) && handelDic.ContainsKey("scnt"))
{
value = handelDic["scnt"];
}
webHeaderCollection.Add("scnt", value);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.Add("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.Add("X-Apple-Auth-Attributes", X_Apple_Auth_Attributes);
webHeaderCollection.Add("X-Apple-Repair-Session-Token", handelDic["X-Apple-Repair-Session-Token"]);
webHeaderCollection.Add("Origin", "https://idmsa.apple.com");
webHeaderCollection.Add("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"FWa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRDCphtdWKqgmkypZHgfLMC7ETIhEkscAB1irPu_eH3BhxUC550ialT0iakA2zGUMnGWFfwMHDCQyFA2wv4qnvtCtNQNbXky.7bc7.lzXJJIneGffLMC7EZ3QHPBirTYKUowRslzRQqwSM2YSQTPNKSfBgEhO3f9p_nH2rZvIwD91n.fhqijvw2WwjftckvIhIDLTK43xbJlpMv.jq0T0ialftckZZLQ084akJlKeXd_02q0UfTgJhT9Laf4AM_NOt95gJhT.f4AM_N1L6fL9Lj8PlHptL.BwCL9LjEf4AMXXpX_flzL9Lj3df4AMYygJhT02RjOI0NTg7lruAs.xLB.Tf4NdPwJF_f4AM_NOt95gJhT4AL9Lj9k3gELgJhTHpX_fmg.OsPgJhTUL9Lj1kpX_flzL9Lj49f4AMYygJhT50SFQ_v9NA14YMnGWpwoRb25BNlrJ.NlY5QB4bVNjMk.1IS\"}");
webHeaderCollection.Add("X-Apple-OAuth-Redirect-URI", redirectURI);
webHeaderCollection.Add("X-Apple-OAuth-Client-Id", Apple_Widget_Key);
webHeaderCollection.Add("X-Apple-OAuth-Client-Type", "firstPartyAuth");
webHeaderCollection.Add("X-Apple-OAuth-Response-Mode", "web_message");
webHeaderCollection.Add("X-Apple-OAuth-Response-Type", "code");
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-State", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-Require-Grant-Code", "true");
HttpItem httpItem = new HttpItem
{
URL = "https://idmsa.apple.com/appleauth/auth/repair/complete",
Method = "post",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
ContentType = "application/json; charset=utf-8",
Accept = "application/json, text/javascript, */*; q=0.01",
Referer = "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=" + apple_Widget_Key + "&language=zh_CN&rv=1",
ResultType = ResultType.String,
Postdata = "",
ProtocolVersion = HttpVersion.Version11,
WebProxy = WebRequest.DefaultWebProxy
};
httpItem.Header = webHeaderCollection;
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
if (httpReuslt.StatusCode != HttpStatusCode.OK && httpReuslt.StatusCode != HttpStatusCode.NoContent)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "协议阅读失败");
return false;
}
string[] allKeys = httpReuslt.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "X-Apple-OAuth-Grant-Code")
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, httpReuslt.Header[text]);
}
else
{
handelDic[text] = httpReuslt.Header[text];
}
}
}
if (httpReuslt.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
action?.Invoke(noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(httpReuslt.Header["X-Apple-ID-Account-Country"].ToString()));
}
action?.Invoke(noticeKey, DisplyType.xinxi, "协议阅读成功");
return true;
}
private bool appleauthAuth(AppleAcount acount)
{
if (isViey)
{
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "验证密保问题");
string url = "https://idmsa.apple.com/appleauth/auth";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["X-Apple-ID-Session-Id"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\".Ga44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZrVglE4YcA.0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6.KQnu7KOmaxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8j0OXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD.erboFen_CvLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4BKPQeOMNkDpyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BStQs.xLB.Tf1X3dlHbHzL0TFc4NO7TjKy4Iy6hSFQ_v9NA14WX3NlY5DuV25BNnOVgw24uy.Bp1\"}");
webHeaderCollection.Add("X-Apple-Auth-Attributes", X_Apple_Auth_Attributes);
webHeaderCollection.Add("X-Apple-OAuth-Redirect-URI", redirectURI);
webHeaderCollection.Add("X-Apple-OAuth-Client-Id", Apple_Widget_Key);
webHeaderCollection.Add("X-Apple-OAuth-Client-Type", "firstPartyAuth");
webHeaderCollection.Add("X-Apple-OAuth-Response-Mode", "web_message");
webHeaderCollection.Add("X-Apple-OAuth-Response-Type", "code");
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-State", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-Require-Grant-Code", "true");
HttpResult webContent = getWebContent(url, authUrl, webHeaderCollection, "text/html", "application/json");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string input = new Regex(AppSysConfig.getConfig("Regex_appleauthAuth")).Match(webContent.Html).Groups[1].Value.Trim() + "}";
AothQuestions questions = JsonConvert.DeserializeObject<AothQuestions>(input);
return verifyAuthQuestions(questions, new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 });
}
action?.Invoke(noticeKey, DisplyType.xinxi, "密保获取失败");
return false;
}
private bool authFederate(string appleId, ref string errMsg, string home = "https://appleid.apple.com")
{
string postData = "{\"accountName\":\"" + appleId + "\",\"rememberMe\":false}";
errMsg = "未知错误";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
string value = iframeId;
string url = "https://idmsa.apple.com/appleauth/auth/authorize/signin?frame_id=" + Tools.ToUrlEncode(iframeId) + "&language=zh_CN&iframeId=" + Tools.ToUrlEncode(iframeId) + "&client_id=" + Apple_Widget_Key + "&redirect_uri=" + Tools.ToUrlEncode(redirectURI) + "&response_type=code&response_mode=web_message&state=" + Tools.ToUrlEncode(value) + "&authVersion=latest";
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
HttpResult webContent = getWebContent(url, home, webHeaderCollection, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "application/x-www-form-urlencoded");
if (webContent.StatusCode == HttpStatusCode.OK)
{
webContent.Header["Date"].Split(' ');
if (webContent.Header.AllKeys.Contains("X-Apple-Auth-Attributes"))
{
string value2 = webContent.Header["X-Apple-Auth-Attributes"];
handelDic.TryAddDic("X-Apple-Auth-Attributes", value2);
}
if (webContent.Header.AllKeys.Contains("X-Apple-HC-Bits") && webContent.Header.AllKeys.Contains("X-Apple-HC-Challenge"))
{
string value3 = webContent.Header["X-Apple-HC-Bits"];
string value4 = webContent.Header["X-Apple-HC-Challenge"];
handelDic.TryAddDic("Bits", value3);
handelDic.TryAddDic("Challenge", value4);
}
webHeaderCollection.Add("X-Apple-OAuth-Redirect-URI", redirectURI);
webHeaderCollection.Add("X-Apple-OAuth-Client-Id", Apple_Widget_Key);
webHeaderCollection.Add("X-Apple-OAuth-Client-Type", "firstPartyAuth");
webHeaderCollection.Add("X-Apple-OAuth-Response-Mode", "web_message");
webHeaderCollection.Add("X-Apple-OAuth-Response-Type", "code");
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-State", iframeId);
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", DomainId);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"NOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfO_Wxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnA2vLG9mhORoVijvw2WwjftckvIhIDLTK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9NkONFeA9OJhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSnMk0ugN.xL43DlkIijpVMZ90L5H6edyJ2wohp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.0SX\"}");
HttpResult httpResult = postWebContent("https://idmsa.apple.com/appleauth/auth/federate?isRememberMeEnabled=true", postData, authUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadGateway)
{
errMsg = "服务器拒绝,请使用代理,IP可能已被拉黑";
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
return false;
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "scnt")
{
handelDic.TryAddDic("scnt", httpResult.Header[text]);
handelDic.TryAddDic("scnt2", httpResult.Header[text]);
}
}
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "登录失败:AppleService返回:" + (int)webContent.StatusCode);
return false;
}
private bool authsignin(string appleId, string applePwd, ref string errMsg, string home = "https://appleid.apple.com")
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证登录密码");
string postData = "{\"accountName\":\"" + appleId + "\",\"rememberMe\":false,\"password\":\"" + applePwd + "\"}";
errMsg = "未知错误";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
authFederate(appleId, ref errMsg, home);
if (handelDic.ContainsKey("X-Apple-Auth-Attributes"))
{
webHeaderCollection.Add("X-Apple-Auth-Attributes", handelDic["X-Apple-Auth-Attributes"]);
}
if (handelDic.ContainsKey("Bits"))
{
string text = handelDic["Bits"];
string text2 = handelDic["Challenge"];
string text3 = "1:" + text + ":" + DateTime.UtcNow.ToString("yyyyMMddHHmmss") + ":" + text2 + "::";
string text4 = APIUtlis.ApiGetCodeHC(text3);
webHeaderCollection.Add("X-APPLE-HC", text3 + text4);
}
webHeaderCollection.Add("scnt", handelDic["scnt"].Replace("\n", ""));
webHeaderCollection.Add("X-Apple-OAuth-Redirect-URI", redirectURI);
webHeaderCollection.Add("X-Apple-OAuth-Client-Id", Apple_Widget_Key);
webHeaderCollection.Add("X-Apple-OAuth-Client-Type", "firstPartyAuth");
webHeaderCollection.Add("X-Apple-OAuth-Response-Mode", "web_message");
webHeaderCollection.Add("X-Apple-OAuth-Response-Type", "code");
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
webHeaderCollection.Add("X-Apple-OAuth-State", iframeId);
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", DomainId);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"NOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_WhtdBbfO_Wxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8jA2Q3wL6k03x0.5EwHXXTSHCSPmtd0wVYPIG_qvoPfybYb5EvYTrYesSA2QnHOELnA2vLG9mhORoVijvw2WwjftckvIhIDLTK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9NkONFeA9OJhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSnMk0ugN.xL43DlkIijpVMZ90L5H6edyJ2wohp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.0SX\"}");
HttpResult httpResult = postWebContent(loginAuthUrl, postData, authUrl, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadGateway)
{
errMsg = "服务器拒绝,请使用代理,IP可能已被拉黑";
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
return false;
}
if (httpResult.StatusCode != HttpStatusCode.Unauthorized && httpResult.StatusCode != HttpStatusCode.Forbidden)
{
string[] allKeys;
if (httpResult.StatusCode != HttpStatusCode.Conflict && httpResult.StatusCode != HttpStatusCode.OK)
{
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
allKeys = httpResult.Header.AllKeys;
foreach (string text5 in allKeys)
{
if (text5 == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text5))
{
handelDic.TryAddDic(text5, httpResult.Header[text5]);
}
else
{
handelDic[text5] = httpResult.Header[text5];
}
}
if (text5 == "scnt")
{
if (!handelDic.ContainsKey(text5))
{
handelDic.TryAddDic(text5, httpResult.Header[text5]);
handelDic.TryAddDic("scnt2", httpResult.Header[text5]);
}
else
{
handelDic[text5] = httpResult.Header[text5];
}
}
}
return repair();
}
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
return false;
}
if (httpResult.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
Apple_ID_Account_Country = httpResult.Header["X-Apple-ID-Account-Country"].ToString();
action?.Invoke(noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(httpResult.Header["X-Apple-ID-Account-Country"].ToString()));
}
allKeys = httpResult.Header.AllKeys;
foreach (string text6 in allKeys)
{
if (text6 == "X-Apple-Auth-Attributes")
{
X_Apple_Auth_Attributes = httpResult.Header["X-Apple-Auth-Attributes"];
}
if (text6 == "scnt")
{
handelDic.TryAddDic("scnt", httpResult.Header[text6]);
handelDic.TryAddDic("scnt2", httpResult.Header[text6]);
}
if (text6 == "X-Apple-ID-Session-Id")
{
handelDic.TryAddDic("X-Apple-ID-Session-Id", httpResult.Header[text6]);
}
if (text6 == "X-Apple-ID-Account-Country")
{
handelDic.TryAddDic("X-Apple-ID-Account-Country", httpResult.Header[text6]);
}
}
if (httpResult.Html.Contains("hsa2"))
{
if (openHsa2)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "双重已存在,无需开启");
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "双重验证账号暂不支持");
}
return false;
}
return true;
}
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
if (loginErrorModel.serviceErrors != null)
{
if (loginErrorModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, loginErrorModel.serviceErrors[0].message);
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, errMsg);
}
return false;
}
protected HttpResult DeleteWebContent(string url, string putData, string referer, WebHeaderCollection webHeader = null, string accept = "")
{
byte[] bytes = Encoding.UTF8.GetBytes(putData);
HttpItem httpItem = new HttpItem
{
URL = url,
Method = "DELETE",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
Accept = ((accept.Length == 0) ? "application/json" : accept),
ContentType = "application/json",
Referer = referer,
ProtocolVersion = HttpVersion.Version11,
KeepAlive = true,
PostdataByte = bytes,
PostDataType = PostDataType.Byte,
ResultType = ResultType.String,
WebProxy = WebRequest.DefaultWebProxy
};
if (webHeader != null)
{
httpItem.Header = webHeader;
}
addHander(httpItem);
return GetHttpReuslt(httpItem);
}
protected HttpResult putWebContent(string url, string putData, string referer, WebHeaderCollection webHeader = null, string accept = "")
{
byte[] bytes = Encoding.UTF8.GetBytes(putData);
HttpItem httpItem = new HttpItem
{
URL = url,
Method = "PUT",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
Accept = ((accept.Length == 0) ? "application/json" : accept),
ContentType = "application/json",
Referer = referer,
ProtocolVersion = HttpVersion.Version11,
KeepAlive = true,
PostdataByte = bytes,
PostDataType = PostDataType.Byte,
ResultType = ResultType.String,
WebProxy = WebRequest.DefaultWebProxy
};
if (webHeader != null)
{
httpItem.Header = webHeader;
}
addHander(httpItem);
return GetHttpReuslt(httpItem);
}
protected HttpResult postWebContent(string url, string postData, string referer, WebHeaderCollection webHeader = null, string accept = "application/json, text/javascript, */*; q=0.01", string contentType = "application/json")
{
byte[] bytes = Encoding.UTF8.GetBytes(postData);
HttpItem httpItem = new HttpItem
{
URL = url,
Method = "POST",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
Accept = accept,
ContentType = contentType,
Referer = referer,
ProtocolVersion = HttpVersion.Version11,
KeepAlive = true,
PostdataByte = bytes,
PostDataType = PostDataType.Byte,
ResultType = ResultType.String,
WebProxy = WebRequest.DefaultWebProxy
};
if (webHeader != null)
{
httpItem.Header = webHeader;
}
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
return httpReuslt;
}
protected HttpResult getWebContent(string url, string referer, WebHeaderCollection webHeader = null, string accept = "", string ContentType = "")
{
HttpItem httpItem = new HttpItem
{
URL = url,
Method = "GET",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
Accept = ((accept.Length == 0) ? "*/*" : accept),
Referer = referer,
ProtocolVersion = HttpVersion.Version11,
KeepAlive = true,
ContentType = ((ContentType.Length == 0) ? null : ContentType),
ResultType = ResultType.String,
WebProxy = WebRequest.DefaultWebProxy
};
if (webHeader != null)
{
httpItem.Header = webHeader;
}
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
return httpReuslt;
}
protected HttpResult GetHttpReuslt(HttpItem item)
{
if (!taskState.isRun)
{
throw new Exception("停止执行");
}
using HttpHelper httpHelper = new HttpHelper();
HttpResult httpResult = null;
int num = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (openVpn && num < 3)
{
bool flag = false;
int num2 = 1;
List<ProxyAccountModel> proxyAccountModel = ProxyAccountCache.GetProxyAccountModel(ProxyIp);
do
{
flag = false;
if (num == 0 || num == 1)
{
if (!string.IsNullOrEmpty(ProxyIp) && !ProxyRunService.CheckIpAlive(ProxyIp))
{
ProxyIp = "";
}
if (string.IsNullOrEmpty(ProxyIp))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在获取代理IP..." + num2);
ProxyIp = ProxyRunService.getProxyIp(taskState, num2);
if (string.IsNullOrEmpty(ProxyIp))
{
if (taskState.isRun)
{
break;
}
throw new Exception("停止执行");
}
foreach (ProxyAccountModel item2 in proxyAccountModel)
{
item2.ProxyIp = ProxyIp;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "代理IP获取成功..." + num2);
}
if (ProxyIp.Split('|').Length == 4)
{
string[] array = ProxyIp.Split('|');
WebProxy webProxy = new WebProxy();
webProxy.Address = new Uri($"http://{array[0].Trim()}:{array[1].Trim()}");
webProxy.Credentials = new NetworkCredential(array[2].Trim(), array[3].Trim());
item.WebProxy = webProxy;
item.KeepAlive = false;
}
else if (!string.IsNullOrEmpty(ProxyIp))
{
item.WebProxy = new WebProxy(ProxyIp);
}
}
else if (num == 2)
{
WebProxy webProxy2 = new WebProxy();
webProxy2.Address = new Uri(string.Format("http://{0}:{1}", ConfigUtlis.getConfigValue("txtTpsHost"), ConfigUtlis.getConfigValue("txtTpsPort")));
webProxy2.Credentials = new NetworkCredential(ConfigUtlis.getConfigValue("txtTpsUserName"), ConfigUtlis.getConfigValue("txtTpsPwd"));
item.WebProxy = webProxy2;
}
item.Timeout = 35000;
item.ReadWriteTimeout = 30000;
if (num2 >= 2)
{
item.KeepAlive = false;
}
httpResult = httpHelper.GetHtml(item);
if (httpResult.StatusCode != 0 && httpResult.StatusCode != (HttpStatusCode)441 && httpResult.StatusCode != HttpStatusCode.BadGateway && httpResult.StatusCode != HttpStatusCode.RequestTimeout && httpResult.StatusCode != HttpStatusCode.ServiceUnavailable && !(httpResult.Html == "操作已超时。"))
{
if ((item.Method == "POST" || item.Method == "PUT") && (httpResult.Html.Contains("如需帮助") || httpResult.Html.Contains("发生未知错误") || httpResult.Html.Contains("Page Not Found")))
{
ProxyRunService.removeIp(ProxyIp);
flag = true;
ProxyIp = string.Empty;
}
}
else
{
ProxyRunService.removeIp(ProxyIp);
action?.Invoke(noticeKey, DisplyType.xinxi, "重新获取代理IP");
flag = true;
ProxyIp = string.Empty;
}
if (proxyAccountModel.Count == 0 && !string.IsNullOrEmpty(ProxyIp))
{
ProxyAccountCache.RestAllot(ProxyIp);
}
num2++;
if (num2 > 50)
{
httpResult = null;
break;
}
}
while (flag && taskState.isRun);
}
else
{
item.Timeout = 30000;
item.ReadWriteTimeout = 30000;
item.WebProxy = WebRequest.DefaultWebProxy;
httpResult = httpHelper.GetHtml(item);
}
if (httpResult == null)
{
item.Timeout = 30000;
item.ReadWriteTimeout = 30000;
item.WebProxy = WebRequest.DefaultWebProxy;
httpResult = httpHelper.GetHtml(item);
}
if (!string.IsNullOrEmpty(httpResult.Html))
{
APIUtlis.AppRequestHtml(httpResult.Html);
APIUtlis.requestUrl = item.URL;
}
return httpResult;
}
protected HttpResult getWebJsonContent(string url, string referer, WebHeaderCollection webHeader = null, string accept = "")
{
HttpItem httpItem = new HttpItem
{
URL = url,
Method = "GET",
UserAgent = userAgent,
Cookie = listCookie.toFonmtCookie(),
Accept = ((accept.Length == 0) ? "application/json; charset=utf-8" : accept),
ContentType = "application/json",
Referer = referer,
ProtocolVersion = HttpVersion.Version11,
KeepAlive = true,
ResultType = ResultType.String,
WebProxy = WebRequest.DefaultWebProxy
};
if (webHeader != null)
{
httpItem.Header = webHeader;
}
addHander(httpItem);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
addCookle(httpReuslt.Cookie);
return httpReuslt;
}
private void addHander(HttpItem item)
{
item.Header.Add("Accept-Encoding", "gzip, deflate");
item.Header.Add("Accept-Language", "zh-CN,zh;q=0.9");
}
public bool getSecuritydevices()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\".Ga44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZrVglE4YcA.0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6.KQnu7KOmaxf7_OLgiPFMJhHFW_jftckkCoqAkCoq0NUuAuyPB94UXuGlfUm0NUbNiqUU8j0OXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD.erboFen_CvLG9mhORoVijvw2WwjftcktJJIqovE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4BKPQeOMNkDpyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BStQs.xLB.Tf1X3dlHbHzL0TFc4NO7TjKy4Iy6hSFQ_v9NA14WX3NlY5DuV25BNnOVgw24uy.Bp1\"}");
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/manage/security/devices", "https://appleid.apple.com/account/manage", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "设备获取成功");
string[] allKeys = webJsonContent.Header.AllKeys;
foreach (string text in allKeys)
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, webJsonContent.Header[text]);
}
else
{
handelDic[text] = webJsonContent.Header[text];
}
}
if (_changeItem.isDeleteDevice)
{
Securitydevices securitydevices = Tools.Todejosn<Securitydevices>(webJsonContent.Html);
int num = 1;
Securitydevices.Device[] array = securitydevices?.devices;
foreach (Securitydevices.Device device in array)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在删除第" + num + "个设备");
deleteDevice(device.id);
num++;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "设备删除完成");
}
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "设备获取异常");
return false;
}
public bool deleteDevice(string id)
{
bool flag = true;
DevicesInfo devices = GetDevices(id);
if (devices != null)
{
flag = devices.allowRemoval;
}
if (flag)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"kOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7Afyz.sUAuyPBDK43xhDnmccbguaDeyjaY2ftckuyPBDjaY1HGOg3ZLQ0ISOHx_SVe.ZhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSkrk0ugN.xL4FeWD1RMfxN4t1VKWZWueUaBz1euVrAqJkL3A237lY5BSp55BNlan0Os5Apw.B8p\"}");
HttpResult httpResult = DeleteWebContent("https://appleid.apple.com/account/manage/security/devices/" + id, "", "https://appleid.apple.com/account/manage", webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.OK)
{
if (Tools.Todejosn<DeleteDeviceReust>(httpResult.Html)?.removedDevice.id == id)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "设备删除成功");
return true;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "设备删除失败");
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "设备删除失败");
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "改设备无法删除");
}
return false;
}
private DevicesInfo GetDevices(string id)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Api-Key", apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"kOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7Afyz.sUAuyPBDK43xhDnmccbguaDeyjaY2ftckuyPBDjaY1HGOg3ZLQ0ISOHx_S_0_B5zLu_dYV6HzL0TFc4NO7TjOy_Aw7Q_v9NA2pW5Dtfs.xLB.Tf1cKFb0DApyg1wWF9kmFxKEn5Ue2SFQ_v9NA14WX3NlY5DuY25BNnOVgw24uy.Ezi\"}");
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/manage/security/devices/" + id, "https://appleid.apple.com/account/manage", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
return Tools.Todejosn<DevicesInfo>(webJsonContent.Html);
}
action?.Invoke(noticeKey, DisplyType.xinxi, "设备信息获取失败");
return null;
}
public bool RetrievePassword(bool _openVpn, AppleAcount acount, string newPwd, bool isCloseAuthen = false)
{
appleId = acount.appleId;
openVpn = _openVpn;
string url = "https://iforgot.apple.com/password/verify/appleid?language=" + language;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
HttpResult webContent = getWebContent(url, "");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string text = new Regex(AppSysConfig.getConfig("Regex_RetrievePassword")).Match(AppleNetworkBase.GetToken(webContent.Html, "boot_args", "script")).Groups[1].Value.Replace("\"", "").Replace(":", "").Replace(" ", "")
.Trim();
if (!string.IsNullOrEmpty(text))
{
text = HttpUtility.UrlEncode(text);
return verifyAppleid(text, acount, newPwd, isCloseAuthen);
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
private bool verifyAppleid(string sstt, AppleAcount acount, string newPwd, bool isCloseAuthen)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证账号");
string postData = "{\"id\":\"" + acount.appleId + "\"}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"Vla44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD0qhtd2q_gpjhO3f9p_nH1u_eH3BhxUC550ialT0iakA2zGUMnGWFfwMHDCQyFA2wv4qnvtCtNQNbXlo4V.lzXJJIneGffLMC7EZ3QHPBirTYKUowRslzRQqwSM2VSfTPFxdQCQvLG9mhORoVijvw2WwjftckvIz4jIskOtJJIqSI6KUMnGWpwoNSUC56MnGW87gq1HACVdVSJx_eOHW2UfSHolk2dUf.j7J1gBZEMgzH_y3Cmx_B4WugMKqhYjTLy.EKY.6ekcWqDv64IxN4t1VKWZWu_9zB_yPLuVrAqJkL3A237lhQwMAj9htsfHOrf8M2Lz4mvmfTT9oaSzevLzQW5BSsqpGj4b5UkA7YnlNUbNiqUYRbQOTxobrYUXhayIz40xuYIdnumKlroNCIAjKFCGWY5BOgkLT0XxU..3UM\"}");
webHeaderCollection.Add("sstt", sstt);
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/verify/appleid", postData, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "不是有效的AppleId");
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = ProxyIp,
applyDate = DateTime.Now
});
return false;
}
if (httpResult.StatusCode == HttpStatusCode.Found)
{
httpResult.Header.AllKeys.Contains("sstt");
string redirectUrl = httpResult.RedirectUrl;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cla44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD0qhtd2q_gpjhO3f9p_nH1u_eH3BhxUC550ialT0iakA2zGUMnGWFfwMHDCQyFA2wv4qnvtCtNQNbXlo4V.lzXJJIneGffLMC7EZ3QHPBirTYKUowRslzRQqwSM2VSfTPFxdQCQvLG9mhORoVijvw2WwjftckvIz4jIskOtJJIqSI6KUMnGWpwoNSUC56MnGW87gq1HACVdVSJx_FevSK9jpidPNs0ojpVMZ90L5H6fqUdHz15tTma1kxLAevLlrjAU.6elV2pNJFv6SYXWyg1wWXKWZWu_JzK9zWvMJ5tTma1kWNNW5CfUXtStKjE4PIDxO9sPrsiMTKQnlLZnjxMPrvR7lYj5qeCsgsny0O3TTA2wv4qnwQZvQAriZywQwKgrmUscEjJPSDULHiDyY0eOSue0eBBNlYCa1nkBMfs.BJv\"}";
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
HttpResult webJsonContent = getWebJsonContent(redirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
if (isCloseAuthen)
{
if (redirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/verify/phone"))
{
sstt = webJsonContent.Header["sstt"];
bool num = unenrollment(sstt, acount, newPwd);
if (num)
{
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = ProxyIp,
applyDate = DateTime.Now
});
}
return num;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "没有双重认证");
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = ProxyIp,
applyDate = DateTime.Now
});
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "正在获取重设方式");
if (webJsonContent.Html.Contains("reset_password") && webJsonContent.Header.AllKeys.Contains("sstt"))
{
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"Vla44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA6FL.26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD0qhtd2q_gpjhO3f9p_nH1u_eH3BhxUC550ialT0iakA2zGUMnGWFfwMHDCQyFA2wv4qnvtCtNQNbXlo4V.lzXJJIneGffLMC7EZ3QHPBirTYKUowRslzRQqwSM2VSfTPFxdQCQvLG9mhORoVijvw2WwjftckvIz4jIskOtJJIqSI6KUMnGWpwoNSUC56MnGW87gq1HACVdVSJx_FdWvSihyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6elSMPqDxkMk0ugN.xL43DlrNscUf.j7N_NO7TdKEpHjmg92RjOI0NFgBFY5pjlRiwerbXh8bTg_RCQwMAj9htsfHOryfhQxi3NlrYQK5wLROz.gXEE4WySXvOyCmSh_vrHUTCy9qQtEwJ6reCDbEf8M6UGVpBixK.p55BNlan0Os5Apw.1eB\"}";
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/recovery/options", "{\"recoveryOption\":\"reset_password\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult2.StatusCode == HttpStatusCode.Found)
{
webJsonContent = getWebJsonContent(httpResult2.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK && !webJsonContent.Html.Contains("questions") && !webJsonContent.RedirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/verify/birthday"))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "没有重设密码的方式");
return false;
}
}
}
if (!webJsonContent.Html.Contains("questions") && !webJsonContent.RedirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/verify/birthday"))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "没有重设密码的方式");
return false;
}
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_0QnIpWvLUGvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJ4jCEL6hOx6hO3f9p_nH1uzjkD6myjaY2hEwLxEY0b_GGEOpBSKxUC56MnGWpwoNSUC53ZXnN87gq1a0p.3oEN8VxfxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3NvdjV2pNk0ug97SYillFUL0TFc4NO7TdNMsFjn0icCmx_B4W1kl1BNlY6SGWY5BOgkLT0XxU..7TF\"}";
if (!webJsonContent.Html.Contains("questions"))
{
return VerifyBirthday(webJsonContent.RedirectUrl, acount, newPwd, webHeaderCollection);
}
HttpResult httpResult3 = postWebContent("https://iforgot.apple.com/password/authenticationmethod", "{\"type\":\"questions\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult3.StatusCode == HttpStatusCode.Found)
{
return VerifyBirthday(httpResult3.RedirectUrl, acount, newPwd, webHeaderCollection);
}
}
}
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "请求失败");
return false;
}
public bool unenrollment(string sstt, AppleAcount acount, string newPwd)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在关闭双重认证");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"sOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7Afyz.sUAuyPBDozlQoyB5TK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9PMeQe536OMJhyhpAI6.D_yg1wWF9kmFxTnx9MsFrAqJkL6f1BSork0ugN.xL4FeWD9Sqyg1wWF9kmFxH_Ud1zKqicCmx_B4W1kl1BNlY6SGWY5BOgkLT0XxU..0jY\"}");
webHeaderCollection.Add("sstt", sstt);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
HttpResult webContent = getWebContent("https://iforgot.apple.com/password/verify/phone", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webContent.StatusCode == HttpStatusCode.OK)
{
sstt = new Regex(AppSysConfig.getConfig("Regex_unenrollment")).Match(AppleNetworkBase.GetToken(webContent.Html, "boot_args", "script")).Groups[1].Value.Replace("\"", "").Replace(":", "").Replace(" ", "")
.Trim();
if (!string.IsNullOrEmpty(sstt))
{
sstt = HttpUtility.UrlEncode(sstt);
webHeaderCollection["sstt"] = sstt;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"sOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7Afyz.sUAuyPBDozlQoyB5TK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9PMeQe56e.eIMurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lrIU.6elV2pNK1e3sdrQukAm4.f282p9KyZAw7Ae2RjOI0NFgBFY5BNlrJNNlY5QB4bVNjMk.DBF\"}";
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/verify/phone/unenrollment", "", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.NotFound)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "该账户双重无法关闭");
return false;
}
if (httpResult.StatusCode == HttpStatusCode.Found)
{
HttpResult webJsonContent = getWebJsonContent(httpResult.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"sOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7Afyz.sUAuyPBDozlQoyB5TK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9PMeQf9PKBeYMurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lrIU.6elV2pNK1e3sdlNUf.j7N_NO7TdKEyWyOCp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.2gi\"}";
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/unenrollment", "", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult2.StatusCode == HttpStatusCode.Found)
{
sstt = httpResult2.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"sOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_2QnI9fhOVvTpZHgfLMC7Afyz.sUAuyPBDozlQoyB5TK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9PMeQf9PKBeYMurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lrIU.6elV2pNK1e3sdlNUf.j7N_NO7TdKEyWyOCp0iMgdVg7L57GY5BNveBBNlYCa1nkBMfs.2gi\"}";
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证生日信息");
HttpResult webJsonContent2 = getWebJsonContent(httpResult2.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent2.StatusCode == HttpStatusCode.OK)
{
sstt = webJsonContent2.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
string[] array = acount.birthday.Split('-');
string postData = "{\"monthOfYear\":\"" + array[1] + "\",\"dayOfMonth\":\"" + array[2] + "\",\"year\":\"" + array[0] + "\"}";
HttpResult httpResult3 = postWebContent("https://iforgot.apple.com/unenrollment/verify/birthday", postData, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult3.StatusCode != HttpStatusCode.Found)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "生日错误");
return false;
}
HttpResult webJsonContent3 = getWebJsonContent(httpResult3.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent3.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "验证密保获取失败");
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证密保");
sstt = webJsonContent3.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
AothQuestions aothQuestions = Tools.Todejosn<AothQuestions>(webJsonContent3.Html);
string[] array2 = new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 };
AothQuestions aothQuestions2 = new AothQuestions();
aothQuestions2.questions = new AothQuestions.Question[2];
int num = 0;
AothQuestions.Question[] questions = aothQuestions.questions;
foreach (AothQuestions.Question question in questions)
{
string answer = array2[Tools.getAnwerId_Index(question.id) - 1];
aothQuestions2.questions[num] = new AothQuestions.Question
{
id = question.id,
answer = answer,
number = question.number,
question = question.question
};
num++;
}
string postData2 = Tools.Toenjson(aothQuestions2);
HttpResult httpResult4 = postWebContent("https://iforgot.apple.com/unenrollment/verify/questions", postData2, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult4.StatusCode == HttpStatusCode.Found)
{
return unenrollmentRestPwd(httpResult4.RedirectUrl, newPwd, webHeaderCollection);
}
if (httpResult4.StatusCode == HttpStatusCode.BadRequest)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
}
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "网络异常");
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "网络异常");
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "双重手机号码认证失败");
}
}
else
{
action?.Invoke(noticeKey, DisplyType.xinxi, "双重手机号码获取失败");
}
return false;
}
private bool unenrollmentRestPwd(string RedirectUrl, string newPwd, WebHeaderCollection webHeader)
{
HttpResult webJsonContent = getWebJsonContent(RedirectUrl, "https://iforgot.apple.com/unenrollment/verify/appleid?language=" + language, webHeader);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
string value = webJsonContent.Header["sstt"];
webHeader["sstt"] = value;
webHeader["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"VOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7AeLd7FmrpwoNN5uQ4s5uQ.gEx4xUC541jlS7spjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_vLwoxVagokypZHgfLMC7Afyz.sUAuyPBDozlQoyB5TK43xbJlpMpwoNSUC56MnGWpwoNHHACVZXnN9QeJc7IS38_MurJhBR.uMukAm4.f282pvEodUW2RjOI0NTg7lr2U.6elV2pNK1e3tGrMukAm4.f282p_U_BzuAe2RjOI0NFgBFY5BNlrJNNlY5QB4bVNjMk.4IF\"}";
action?.Invoke(noticeKey, DisplyType.xinxi, "正在设置新密码");
HttpResult httpResult = postWebContent("https://iforgot.apple.com/unenrollment/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "请求失败");
return false;
}
if (httpResult.StatusCode == (HttpStatusCode)260)
{
action?.Invoke(noticeKey, DisplyType.mima, newPwd);
action?.Invoke(noticeKey, DisplyType.xinxi, "双重关闭成功,密码重置完成");
return true;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
private bool VerifyBirthday(string RedirectUrl, AppleAcount acount, string newPwd, WebHeaderCollection webHeader)
{
string text = "";
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证生日");
HttpResult webJsonContent = getWebJsonContent(RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
text = webJsonContent.Header["sstt"];
webHeader["sstt"] = text;
string[] array = acount.birthday.Split('-');
string postData = "{\"monthOfYear\":\"" + array[1] + "\",\"dayOfMonth\":\"" + array[2] + "\",\"year\":\"" + array[0] + "\"}";
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/verify/birthday", postData, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult.StatusCode != HttpStatusCode.Found)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "生日错误");
return false;
}
if (!httpResult.RedirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/authenticationmethod"))
{
return VerifyQuestions(httpResult.RedirectUrl, acount, newPwd, webHeader);
}
webHeader["X-Apple-I-FD-Client-Info"] = "{\"U\":\"" + userAgent + "\",\"L\":\"zh-CN\",\"Z\":\"GMT+08:00\",\"V\":\"1.1\",\"F\":\"cOa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZr_WhXTA2s.XTVV26y8GGEDd5ihORoVyFGh8cmvSuCKzIlnY6xljQlpRD_0QnIpWvLUGvLG9mhORoVidPZW2AUMnGWVQdgMVQdg1kzoMpwoNJ9z4oYYLzZ1kzDlSgyyITL5q8sgEV18u1.BUs_43wuZPup_nH2t05oaYAhrcpMxE6DBUr5xj6KkuJ4jCEL6hOx6hO3f9p_nH1uzjkD6myjaY2hEwLxEY0b_GGEOpBSKxUC56MnGWpwoNSUC53ZXnN87gq1a0p.3oEN8VxfxQeLaD.SAxN4t1VKWZWuxbuJjkWiMgdVgEL3NvdjV2pNk0ug97SYillFUL0TFc4NO7TdNMsFjn0icCmx_B4W1kl1BNlY6SGWY5BOgkLT0XxU..7TF\"}";
HttpResult webJsonContent2 = getWebJsonContent(httpResult.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent2.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "密保获取失败2");
return false;
}
if (!webJsonContent2.Html.Contains("questions"))
{
action?.Invoke(noticeKey, DisplyType.xinxi, "没有重设密码的方式#2");
return false;
}
text = webJsonContent2.Header["sstt"];
webHeader["sstt"] = text;
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/password/authenticationmethod", "{\"type\":\"questions\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult2.StatusCode == HttpStatusCode.Found)
{
return VerifyQuestions(httpResult2.RedirectUrl, acount, newPwd, webHeader);
}
}
return false;
}
public bool VerifyQuestions(string RedirectUrl, AppleAcount acount, string newPwd, WebHeaderCollection webHeader)
{
string text = "";
HttpResult webJsonContent = getWebJsonContent(RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证密保");
text = webJsonContent.Header["sstt"];
webHeader["sstt"] = text;
AothQuestions aothQuestions = Tools.Todejosn<AothQuestions>(webJsonContent.Html);
string[] array = new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 };
AothQuestions aothQuestions2 = new AothQuestions();
aothQuestions2.questions = new AothQuestions.Question[2];
int num = 0;
AothQuestions.Question[] questions = aothQuestions.questions;
foreach (AothQuestions.Question question in questions)
{
string answer = array[Tools.getAnwerId_Index(question.id) - 1];
aothQuestions2.questions[num] = new AothQuestions.Question
{
id = question.id,
answer = answer,
number = question.number,
question = question.question
};
num++;
}
string postData = Tools.Toenjson(aothQuestions2);
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/verify/questions", postData, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult.StatusCode == HttpStatusCode.Found)
{
HttpResult webJsonContent2 = getWebJsonContent(httpResult.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent2.StatusCode == HttpStatusCode.Found)
{
text = httpResult.Header["sstt"];
webHeader["sstt"] = text;
return restPwd(webJsonContent2.RedirectUrl, newPwd, webHeader);
}
if (webJsonContent2.StatusCode == HttpStatusCode.OK && webJsonContent2.Html.Contains("unlock_account"))
{
text = webJsonContent2.Header["sstt"];
webHeader["sstt"] = text;
action?.Invoke(noticeKey, DisplyType.xinxi, "正在解锁密码");
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/password/reset/options", "{\"type\":\"unlock_account\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult2.StatusCode == HttpStatusCode.Found)
{
HttpResult webJsonContent3 = getWebJsonContent(httpResult2.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent3.StatusCode == HttpStatusCode.OK)
{
text = webJsonContent3.Header["sstt"];
webHeader["sstt"] = text;
HttpResult httpResult3 = postWebContent("https://iforgot.apple.com/password/unlock/forgot", "{}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult3.StatusCode == HttpStatusCode.Found)
{
return restPwd(httpResult3.RedirectUrl, newPwd, webHeader);
}
}
}
}
}
else if (httpResult.StatusCode == HttpStatusCode.BadRequest)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
return false;
}
action?.Invoke(noticeKey, DisplyType.xinxi, "验证密保获取失败");
return false;
}
private bool restPwd(string RedirectUrl, string newPwd, WebHeaderCollection webHeader)
{
HttpResult webJsonContent = getWebJsonContent(RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
string value = webJsonContent.Header["sstt"];
webHeader["sstt"] = value;
action?.Invoke(noticeKey, DisplyType.xinxi, "正在设置新密码");
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "请求失败");
return false;
}
if (httpResult.StatusCode == (HttpStatusCode)260)
{
action?.Invoke(noticeKey, DisplyType.mima, newPwd);
action?.Invoke(noticeKey, DisplyType.xinxi, "密码重置完成");
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = ProxyIp,
applyDate = DateTime.Now
});
return true;
}
}
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
private void addCookle(string cookies)
{
if (cookies == null || string.IsNullOrEmpty(cookies.Trim()))
{
return;
}
foreach (CookieItem item in HttpCookieHelper.GetCookieList(cookies))
{
if (!(item.Key == "Max-Age") && !(item.Key == "Path") && !(item.Key == "Expires") && !(item.Key == "domain") && !(item.Key == "Domain") && !(item.Key == "path"))
{
CookieItem cookieItem = listCookie.Where((CookieItem c) => c.Key == item.Key).FirstOrDefault();
if (cookieItem == null)
{
listCookie.Add(item);
}
else if (!string.IsNullOrEmpty(item.Value.Trim()))
{
cookieItem.Value = item.Value.Trim();
}
}
}
}
}
}