Files
kami_itunes_june/AppleBatch_June/AppleManageWebUtlis.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

3595 lines
147 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using Newtonsoft.Json;
using AppleBatch_June.AppleWebServace;
using AppleBatch_June.ExecuteTasks;
using AppleBatch_June.Model;
using AppleBatch_June.Utils;
using DotNet.Utilities;
namespace AppleBatch_June
{
public class AppleManageWebUtlis : AppleWebBase
{
private class CaptchaModel
{
public class Payload
{
public string contentType { get; set; }
public string content { get; set; }
}
public Payload payload { get; set; }
public string token { get; set; }
public string type { get; set; }
public int id { get; set; }
public string reust { get; set; } = "";
}
private static string homeLanguage = "zh_CN";
public string Apple_Widget_Key = "af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3";
private string loginAuthUrl = "https://idmsa.apple.com/appleauth/auth/signin";
private string verifyquestionsUrl = "https://idmsa.apple.com/appleauth/auth/verify/questions";
private string appleHomeUrl = "https://appleid.apple.com/account/manage";
private AvailableSecurityQuestions securityQuestions;
private LoginAppleInfo loginAppleInfo;
public string _appleId = "";
public AppleChangeItem _changeItem;
private bool isPwdViey;
private bool isViey;
private bool isVieyBirthday;
private AppleAcount acount = new AppleAcount();
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();
public bool AuthenDoubleOpenState;
private string redirectURI = "https://appleid.apple.com";
private string language = "zh_CN";
private string authUrl => "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=" + Apple_Widget_Key + "&language=" + homeLanguage;
private string iframeId { get; set; } = "auth-w78m90aa-d7ll-rirf-04xy-rsvumkpw";
public bool CheckAppleId { get; set; }
public string appleId
{
get
{
return _appleId;
}
set
{
_appleId = value;
}
}
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 scnt { get; set; }
public AppleManageWebUtlis(Action<string, DisplyType, string> _action, Action<string, DisplyType, string> _applyAtion, ITaskRunState _taskState)
: base(_action, _applyAtion, _taskState)
{
taskState = _taskState ?? throw new Exception("任务运行状态不能是空的");
action = _action;
applyAtion = _applyAtion;
base.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36";
base.userAgent = Tools.GetRandomUserAgent();
iframeId = APPLEHCHelp.getIframeId();
}
public bool applyChangeAcount(AppleAcount acount, AppleChangeItem changeItem, bool errorGoint, bool _openVpn, string _noticeKey, ref string accountName)
{
if (string.IsNullOrEmpty(base.ProxyIp))
{
ProxyAccountModel proxyAccountInfo = ProxyAccountCache.getProxyAccountInfo(acount.appleId);
if (proxyAccountInfo != null)
{
base.ProxyIp = proxyAccountInfo.ProxyIp;
if (string.IsNullOrEmpty(proxyAccountInfo.accountWebUserAgent))
{
proxyAccountInfo.accountWebUserAgent = base.userAgent;
}
else
{
base.userAgent = proxyAccountInfo.accountWebUserAgent;
}
}
}
base.noticeKey = _noticeKey;
base.openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
this.acount = acount;
appleId = acount.appleId;
try
{
_changeItem = changeItem;
string errMsg = "";
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg))
{
if (!handelDic.ContainsKey("scnt"))
{
base.ProxyIp = "";
authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg);
if (!handelDic.ContainsKey("scnt"))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录初始化失败,请重试");
return false;
}
}
if (isPwdViey)
{
changeItem.newPwd = "";
}
if (isViey)
{
acount.appleQt1 = changeItem.newQt1;
acount.appleQt2 = changeItem.newQt2;
acount.appleQt3 = changeItem.newQt3;
changeItem.newQt1 = "";
if (isPwdViey && isChangAppleId && isVieyBirthday)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "账号修改完成");
return true;
}
isViey = false;
handelDic.Clear();
return applyChangeAcount(this.acount, _changeItem, errorGoint, base.openVpn, base.noticeKey, ref accountName);
}
if (appleauthAuth(acount))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录成功");
ProxyAccountCache.addProxyIp(acount.appleId, base.ProxyIp);
if (intoHome())
{
manageFamily();
bool flag = true;
getSecuritydevices();
if (changeItem.CreatePin)
{
flag = CreateSupportpin(appleHomeUrl);
}
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 (loginAppleInfo != null && !string.IsNullOrEmpty(loginAppleInfo?.security?.rescueEmail) && changeItem.isRemoveRescueEmail)
{
flag = RemoveRescueEmail();
}
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(base.ProxyIp))
{
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = base.ProxyIp,
applyDate = DateTime.Now
});
}
return flag;
}
}
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(base.noticeKey, DisplyType.xinxi, ex.Message);
}
finally
{
accountName = appleId;
try
{
signout();
}
catch (Exception)
{
}
}
return false;
}
public bool CreateSupportpin(string appleHomeUrl)
{
string postData = "{}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-I-TimeZone", "Asia/Shanghai");
webHeaderCollection.Add("X-Apple-I-Request-Context", "ca");
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Apple-Api-Key", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = postWebContent("https://appleid.apple.com/account/manage/supportpin", postData, "https://appleid.apple.com/account/manage", webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = Tools.Todejosn<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
Dictionary<string, string> dataSource = Tools.Todejosn<Dictionary<string, string>>(httpResult.Html);
string dicVal = dataSource.getDicVal("pin", "");
string dicVal2 = dataSource.getDicVal("localizedDate", "");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "支持 PIN" + dicVal + ",有效期:" + dicVal2);
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;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "获取PIN码失败,未知异常");
return false;
}
public bool applyQueryAuthBalance(AppleAcount acount, bool _openVpn)
{
Apple_Widget_Key = "04659e25236376d440c224638c1cdd6a001abdd7f186cdcfa120abf35417efab";
base.openVpn = _openVpn;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
this.acount = acount;
appleId = acount.appleId;
try
{
HttpResult webContent = getWebContent("https://privacy.apple.com/account", "");
if (webContent.StatusCode == HttpStatusCode.OK)
{
string value = new Regex(AppSysConfig.getConfig("Regex_apply_CsrfToken")).Match(webContent.Html).Groups[1].Value.Trim();
string errMsg = "";
if (authsignin(this.acount.appleId, this.acount.applePwd, ref errMsg) && appleauthAuth(acount))
{
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);
getWebJsonContent("https://privacy.apple.com/session/create", "https://privacy.apple.com/account", webHeaderCollection, "application/json, text/plain, */*");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在获取余额");
HttpResult webJsonContent = getWebJsonContent("https://privacy.apple.com/section/delete-account", "https://privacy.apple.com/account", webHeaderCollection, "application/json, text/plain, */*");
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
if (webJsonContent.Html.Contains("store_balance"))
{
string text = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
if (string.IsNullOrEmpty(text))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额解析失败");
return false;
}
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text + "}");
decimal num = (dynamic)dictionary["balance"];
string text2 = (dynamic)dictionary["currency"];
action?.Invoke(base.noticeKey, DisplyType.balance, num + " " + text2);
}
else
{
action?.Invoke(base.noticeKey, DisplyType.balance, "0");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在重新获取余额");
webJsonContent = getWebJsonContent("https://privacy.apple.com/section/deactivate-account", "https://privacy.apple.com/account");
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
if (webJsonContent.Html.Contains("store_balance"))
{
string text3 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
if (string.IsNullOrEmpty(text3))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额解析失败");
return false;
}
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text3 + "}");
decimal num2 = (dynamic)dictionary2["balance"];
string text4 = (dynamic)dictionary2["currency"];
action?.Invoke(base.noticeKey, DisplyType.balance, num2 + " " + text4);
}
else
{
action?.Invoke(base.noticeKey, DisplyType.balance, "0");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额获取失败");
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "页面加载失败#1");
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(base.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, string _noticeKey)
{
if (string.IsNullOrEmpty(base.ProxyIp))
{
base.ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
}
base.noticeKey = _noticeKey;
base.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))
{
if (appleauthAuth(acount) && !AuthenDoubleOpenState)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录成功");
ProxyAccountCache.addProxyIp(acount.appleId, base.ProxyIp);
if (intoHome())
{
if (string.IsNullOrEmpty(acount.moblie))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "请先导入手机号码");
return false;
}
getSecuritydevices();
AuthenDoubleOpenState = OpenHsa2Act(_changeItem.mode, _changeItem.countryCode, base.apiKey);
}
}
return AuthenDoubleOpenState;
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
action?.Invoke(base.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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "名称修改失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "名称修改失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "名称修改完成");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "名称修改失败,请求错误");
}
action?.Invoke(base.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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/manage/payment", "https://appleid.apple.com/account/manage", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在修改内容");
string text = "ownerName";
ManagePayment managePayment = JsonConvert.DeserializeObject<ManagePayment>(webJsonContent.Html);
string text2 = "";
if (pairs.ContainsKey("税号"))
{
text2 = "\"taxId\":\"" + getDicValue(pairs, "税号", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.taxId != null)
{
text2 = "\"taxId\":\"" + managePayment.primaryPaymentMethod.taxId + "\",";
}
string text3 = "";
if (pairs.ContainsKey("卡号"))
{
text3 = text3 + "\"number\":\"" + getDicValue(pairs, "卡号", "") + "\",";
text = "nameOnCard";
}
else if (managePayment.primaryPaymentMethod.number != null)
{
text3 = text3 + "\"number\":\"" + managePayment.primaryPaymentMethod.number + "\",";
}
if (pairs.ContainsKey("有效期限年"))
{
text3 = text3 + "\"expirationYear\":\"" + getDicValue(pairs, "有效期限年", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.expirationYear.HasValue)
{
text3 = text3 + "\"expirationYear\":\"" + managePayment.primaryPaymentMethod.expirationYear + "\",";
}
if (pairs.ContainsKey("有效期限月"))
{
text3 = text3 + "\"expirationMonth\":\"" + getDicValue(pairs, "有效期限月", "") + "\",";
}
else if (managePayment.primaryPaymentMethod.expirationMonth.HasValue)
{
text3 = text3 + "\"expirationMonth\":\"" + managePayment.primaryPaymentMethod.expirationMonth + "\",";
}
if (pairs.ContainsKey("安全码"))
{
text3 = text3 + "\"cvv\":\"" + getDicValue(pairs, "安全码", "") + "\",";
}
if (managePayment.primaryPaymentMethod.nameOnCard != null)
{
text = "nameOnCard";
}
string putData = string.Concat("{\"" + text + "\":{\"firstName\":\"" + getDicValue(pairs, "账单名字", managePayment.primaryPaymentMethod.ownerName.firstName) + "\",\"lastName\":\"" + getDicValue(pairs, "账单姓氏", managePayment.primaryPaymentMethod.ownerName.lastName) + "\"},\"phoneNumber\":{\"areaCode\":\"" + (getDicValue(pairs, "电话", managePayment.primaryPaymentMethod.phoneNumber.number).Contains(getDicValue(pairs, "区号", managePayment.primaryPaymentMethod.phoneNumber.areaCode)) ? "" : getDicValue(pairs, "区号", managePayment.primaryPaymentMethod.phoneNumber.areaCode)) + "\",\"number\":\"" + getDicValue(pairs, "电话", managePayment.primaryPaymentMethod.phoneNumber.number).Replace("(", "").Replace(")", "").Replace("-", "")
.Replace(" ", "") + "\",\"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), "\"},", text2, text3, "\"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", base.apiKey.Trim());
webHeaderCollection2.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/" + ((text == "nameOnCard") ? "card" : "none") + "/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(base.noticeKey, DisplyType.xinxi, "账单信息修改失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "账单信息修改失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "信息修改完成");
action?.Invoke(base.noticeKey, DisplyType.lostBillNo, "");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "账单信息修改失败,请求错误");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "信息修改失败,未知异常:" + httpResult.StatusCode);
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "网络异常,修改失败");
return false;
}
public bool checkDisable(bool _openVpn, string appleId, string pwd, string _notityKey)
{
this.appleId = appleId;
base.openVpn = _openVpn;
base.noticeKey = _notityKey;
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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "ID 或密码不正确");
string.IsNullOrEmpty(base.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(base.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(base.noticeKey, DisplyType.xinxi, "密码验证成功");
if (httpResult.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
{
action?.Invoke(base.noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(httpResult.Header["X-Apple-ID-Account-Country"].ToString()));
}
return reportaproblem(appleId);
}
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, ex.Message);
return false;
}
isError = true;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
public bool priveSignout()
{
return true;
}
public bool signout()
{
return true;
}
public bool reportSingOut()
{
return true;
}
public bool sponsorRefund(string appleId, string amountSpik)
{
action?.Invoke(base.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(base.noticeKey, DisplyType.lostBillNo, text5);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
}
action?.Invoke(base.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)
{
HttpResult webJsonContent = getWebJsonContent("https://reportaproblem.apple.com/api/login", webContent.ResponseUri);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(base.noticeKey, DisplyType.normal, "正常");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
string.IsNullOrEmpty(base.ProxyIp);
idIsNormal = true;
dataR = new Regex(AppSysConfig.getConfig("Regex_reportaproblem")).Match(webContent.Html).Groups[1].Value;
return true;
}
string token = AppleNetworkBase.GetToken(webJsonContent.Html, "messageBodyLocKey\":\"", "\"");
if (!string.IsNullOrEmpty(token))
{
if (AppSysConfig.getConfig("MessageBodyLocKey").Split(',').Contains(token))
{
applyAtion?.Invoke(base.noticeKey, DisplyType.forbidden, "禁用");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,错误码:" + token);
return false;
}
applyAtion?.Invoke(base.noticeKey, DisplyType.normal, "正常");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
if (webContent.StatusCode != HttpStatusCode.Found && webContent.StatusCode != HttpStatusCode.MovedPermanently)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知异常,请重新检测");
return false;
}
string.IsNullOrEmpty(base.ProxyIp);
if (webContent.RedirectUrl.ToLower().Contains("accountdisabled"))
{
applyAtion?.Invoke(base.noticeKey, DisplyType.forbidden, "禁用");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
if (webContent.RedirectUrl.ToLower().Contains("https://reportaproblem.apple.com"))
{
applyAtion?.Invoke(base.noticeKey, DisplyType.normal, "正常");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
return true;
}
action?.Invoke(base.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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
getWebJsonContent("https://appleid.apple.com/account/manage/family", "https://appleid.apple.com/account/manage", webHeaderCollection);
}
private bool authenticatePassword(string pwd)
{
string url = "https://appleid.apple.com/authenticate/password";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-Api-Key", base.apiKey);
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Domain-Id", "1");
webHeaderCollection.Add("scnt", handelDic["scnt"]);
webHeaderCollection.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = postWebContent(url, "{\"password\":\"" + pwd + "\"}", appleHomeUrl, webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.NoContent)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密码验证成功");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, httpResult.Header[text]);
}
else
{
handelDic[text] = httpResult.Header[text];
}
}
if (text == "scnt")
{
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(base.noticeKey, DisplyType.area, XAppleIDAccountCountry);
}
}
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密码错误");
return false;
}
private bool changQuestions(string newqt1, string newqt2, string newqt3)
{
string text = "";
try
{
if (securityQuestions != null)
{
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);
}
else
{
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 + "\"}]}"));
}
}
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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.qt1, newqt1);
applyAtion?.Invoke(base.noticeKey, DisplyType.qt2, newqt2);
applyAtion?.Invoke(base.noticeKey, DisplyType.qt3, newqt3);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保修改成功");
return true;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(base.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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(base.noticeKey, DisplyType.guojia, pay.billingAddress.countryCode);
AppleItunesLogin loginIdUserInfo = iTunesAccountLoginCache.getLoginIdUserInfo(acount.appleId, acount.applePwd);
if (loginIdUserInfo != null)
{
loginIdUserInfo.Area = AppleUtlis.GetAreaCodeByCode(pay.billingAddress.countryCode);
loginIdUserInfo.software = AppleUtlis.GetStoreIdByCode(pay.billingAddress.countryCode);
iTunesAccountLoginCache.removeReddemUserInfo(loginIdUserInfo.account, loginIdUserInfo.StdndbyKeyGuid);
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "国家修改完成");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "国家修改失败,请求错误");
}
action?.Invoke(base.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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
applyAtion?.Invoke(base.noticeKey, DisplyType.shengri, fullBirthDate);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日修改完成");
return true;
}
_ = httpResult.StatusCode;
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日修改失败,未知异常");
return false;
}
private bool RemoveRescueEmail()
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在移除救援邮箱");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.AddWebHander("scnt", handelDic["scnt"]);
}
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.AddWebHander("X-Apple-Api-Key", base.apiKey);
webHeaderCollection.AddWebHander("Origin", "https://appleid.apple.com");
string appleIFDClientInfo = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
webHeaderCollection.AddWebHander("X-Apple-I-FD-Client-Info", appleIFDClientInfo);
HttpResult httpResult = DeleteWebContent("https://appleid.apple.com/account/manage/security/email/rescue", "", "https://appleid.apple.com/", webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.OK && httpResult.StatusCode != HttpStatusCode.NoContent)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "除救援邮箱移除失败");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.balance, "已移除");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "除救援邮箱移除成功");
return true;
}
protected new 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 = base.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);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
Array.Clear(bytes, 0, bytes.Length);
if (httpReuslt.StatusCode == (HttpStatusCode)451 && authenticatePassword(acount.applePwd))
{
return DeleteWebContent(url, putData, referer, webHeader, accept);
}
Array.Clear(bytes, 0, bytes.Length);
return httpReuslt;
}
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", base.apiKey.Trim());
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
}
if (httpResult.StatusCode == HttpStatusCode.OK)
{
acount.applePwd = newPwd;
applyAtion?.Invoke(base.noticeKey, DisplyType.mima, newPwd);
action?.Invoke(base.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(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.shengri, loginAppleInfo.security.birthday);
if (loginAppleInfo.person.primaryAddress != null && loginAppleInfo.person.primaryAddress.countryName != null)
{
action?.Invoke(base.noticeKey, DisplyType.guojia, loginAppleInfo.person.primaryAddress.countryName);
}
accountFirstName = loginAppleInfo.person.name.firstName;
accountLastName = loginAppleInfo.person.name.lastName;
if (loginAppleInfo.person.name.middleName != null)
{
accountLastName = accountLastName + " " + loginAppleInfo.person.name.middleName;
}
decimal? num = loginAppleInfo.person.reachableAtOptions.primaryEmailAddress.createdDate as decimal?;
if (num.HasValue)
{
string arg = Tools.GetTimeByTimeStamp((long)num.Value).ToString("yyyy-MM-dd HH:mm:ss");
action?.Invoke(base.noticeKey, DisplyType.lostBillNo, arg);
}
action?.Invoke(base.noticeKey, DisplyType.xiaofeiriqiNow, accountLastName + " " + accountFirstName);
if (!string.IsNullOrEmpty(loginAppleInfo.security.rescueEmail))
{
action?.Invoke(base.noticeKey, DisplyType.balance, loginAppleInfo.security.rescueEmail);
}
else
{
action?.Invoke(base.noticeKey, DisplyType.balance, "无");
}
action?.Invoke(base.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(base.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-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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = postWebContent(verifyquestionsUrl, postData, authUrl, webHeaderCollection);
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
{
if (httpResult.StatusCode == HttpStatusCode.NoContent)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保验证成功");
return true;
}
if (httpResult.StatusCode == HttpStatusCode.PreconditionFailed)
{
string[] allKeys = httpResult.Header.AllKeys;
foreach (string text in allKeys)
{
if (text == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text))
{
handelDic.TryAddDic(text, httpResult.Header[text]);
}
else
{
handelDic[text] = httpResult.Header[text];
}
}
if (text == "scnt")
{
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(base.noticeKey, DisplyType.area, XAppleIDAccountCountry);
}
return repair();
}
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "非正常密保问题,无法识别");
return false;
}
private bool repair()
{
action?.Invoke(base.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 = base.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);
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(base.noticeKey, DisplyType.xinxi, "协议获取成功");
return options();
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "协议获取失败");
return false;
}
private bool options(bool skieprderPrivacy = false)
{
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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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 = base.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);
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 (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)
{
int num = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置账号#1");
return false;
}
if (string.IsNullOrEmpty(acount.newAppleId) || string.IsNullOrEmpty(acount.newApplePopPwd))
{
int num2 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num2 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置账号#2");
return false;
}
if (!setAccnount(acount.newAppleId, acount.newApplePopPwd, Apple_Widget_Key))
{
return false;
}
}
if (text3 == "weak_password")
{
if (_changeItem == null)
{
int num3 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num3 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置新密码#2");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newPwd))
{
int num4 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num4 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置新密码#2");
return false;
}
if (!setWeakPassword(_changeItem.newPwd))
{
return false;
}
}
if (text3 == "missing_data")
{
if (_changeItem == null)
{
int num5 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num5 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置生日#1");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newshengri))
{
int num6 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num6 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置生日#2");
return false;
}
if (!setBirthday(_changeItem.newshengri))
{
return false;
}
isVieyBirthday = true;
}
if (text3 == "challenge_response")
{
if (_changeItem == null)
{
int num7 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num7 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置密保#1");
return false;
}
if (string.IsNullOrEmpty(_changeItem.newQt1))
{
int num8 = Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0);
if (AppSysConfig.getConfig("oldAccountApply") == "1" && base.openVpn && num8 == 0)
{
APIUtlis.ApiApplyAct(38, "查询老帐号");
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "需要设置密保#2");
return false;
}
if (!setQuestions(_changeItem.newQt1, _changeItem.newQt2, _changeItem.newQt3))
{
return false;
}
isViey = true;
}
if (!(text3 == "phoneNumber") || SkipPhoneNumber())
{
if (!(text3 == "crossBorderPrivacyConsent") || skieprderPrivacy)
{
if (text3 == "privacy_consent" && !accept())
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "协议阅读失败#2");
return false;
}
continue;
}
bool gcbdCrossBorderPrivacyConsentRequired = false;
bool appleCrossBorderPrivacyConsentRequired = false;
try
{
dynamic val = dictionary["repairContext"];
gcbdCrossBorderPrivacyConsentRequired = val["privacyConsentRequirement"]["gcbdCrossBorderPrivacyConsentRequired"];
appleCrossBorderPrivacyConsentRequired = val["privacyConsentRequirement"]["appleCrossBorderPrivacyConsentRequired"];
}
catch (Exception)
{
}
if (!CrossBorderPrivacyConsent(gcbdCrossBorderPrivacyConsentRequired, appleCrossBorderPrivacyConsentRequired))
{
return false;
}
return options(skieprderPrivacy: true);
}
return false;
}
if (string.IsNullOrEmpty(acount.moblie))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "请先导入手机号码");
return false;
}
getSecurityUpgrade();
return OpenHsa2Act(_changeItem.mode, _changeItem.countryCode, Apple_Widget_Key);
}
}
return complete();
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "协议获取失败#2");
return false;
}
public bool CrossBorderPrivacyConsent(bool gcbdCrossBorderPrivacyConsentRequired, bool appleCrossBorderPrivacyConsentRequired)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
string apple_Widget_Key = Apple_Widget_Key;
if (widgKey != string.Empty)
{
webHeaderCollection.AddWebHander("X-Apple-Repair-App-Id", "1879");
apple_Widget_Key = widgKey;
}
webHeaderCollection.AddWebHander("X-Apple-Widget-Key", apple_Widget_Key);
webHeaderCollection.AddWebHander("scnt", handelDic["scnt"]);
webHeaderCollection.AddWebHander("X-Apple-Skip-Repair-Attributes", "[]");
if (handelDic.ContainsKey("X-Apple-Session-Token"))
{
webHeaderCollection.AddWebHander("X-Apple-Session-Token", handelDic["X-Apple-Session-Token"]);
}
webHeaderCollection.AddWebHander("X-Apple-Locale", homeLanguage);
if (handelDic.ContainsKey("repairSessionId"))
{
webHeaderCollection.AddWebHander("X-Apple-ID-Session-Id", handelDic["repairSessionId"]);
}
webHeaderCollection.AddWebHander("X-Apple-OAuth-Context", handelDic.getDicVal("X-Apple-OAuth-Context", ""));
string appleIFDClientInfo = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
webHeaderCollection.AddWebHander("X-Apple-I-FD-Client-Info", appleIFDClientInfo);
string postData = "{\"account\":{\"preferences\":{\"privacyPreferences\":{\"appleCrossBorderPrivacyNoticeAccepted\":true}}},\"completedSteps\":[],\"requiredSteps\":[\"crossBorderPrivacyConsent\"],\"repairContext\":{\"repairType\":\"crossBorderPrivacyConsent\",\"repairItems\":[\"crossBorderPrivacyConsent\"]}}";
if (gcbdCrossBorderPrivacyConsentRequired)
{
postData = "{\"account\":{\"preferences\":{\"privacyPreferences\":{\"gcbdCrossBorderPrivacyNoticeAccepted\":true}}},\"completedSteps\":[],\"requiredSteps\":[\"crossBorderPrivacyConsent\"],\"repairContext\":{\"repairType\":\"crossBorderPrivacyConsent\",\"repairItems\":[\"crossBorderPrivacyConsent\"]}}";
}
if (gcbdCrossBorderPrivacyConsentRequired && appleCrossBorderPrivacyConsentRequired)
{
postData = "{\"account\":{\"preferences\":{\"privacyPreferences\":{\"appleCrossBorderPrivacyNoticeAccepted\":true,\"gcbdCrossBorderPrivacyNoticeAccepted\":true}}},\"completedSteps\":[],\"requiredSteps\":[\"crossBorderPrivacyConsent\"],\"repairContext\":{\"repairType\":\"crossBorderPrivacyConsent\",\"repairItems\":[\"crossBorderPrivacyConsent\"]}}";
}
if (postWebContent("https://appleid.apple.com/account/manage/repair/privacy/consent", postData, "https://appleid.apple.com/", webHeaderCollection).StatusCode == HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "同意数据隐私协议");
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "跳过隐私协议失败");
return false;
}
public bool OpenHsa2Act(string mode, string countryCode, string widgetWey)
{
action?.Invoke(base.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", widgetWey);
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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
return false;
}
if (httpResult.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "发送验证码失败,未知异常");
return false;
}
dynamic val2 = JsonConvert.DeserializeObject<object>(httpResult.Html);
msmId = val2["phoneNumberVerification"]?["phoneNumber"]?["id"];
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码发送成功");
text = getCodeAct_?.Invoke("请输入账号 " + acount.appleId + "\n发送至 " + acount.moblie + " 的验证码", 1);
if (text == null || string.IsNullOrEmpty(text))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码未输入");
return false;
}
if (text.Trim().Length != 6)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码输入不正确");
return false;
}
}
return verifyCode(msmId, text, acount.moblie, countryCode, mode, widgetWey);
}
public bool verifyCode(int msmId, string code, string moblie, string countryCode, string mode, string widgetWey)
{
action?.Invoke(base.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", widgetWey);
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-Request-Context", "ca");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "双重开启成功");
AuthenDoubleOpenState = true;
return true;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "开启失败,未知异常");
}
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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "跳过手机号码成功");
return true;
}
action?.Invoke(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "邮件验证码发送成功");
Thread.Sleep(new Random().Next(AppSysConfig.CheckCodeDelay * 1000, AppSysConfig.CheckCodeDelay * 1000 + 1000));
int num = 0;
do
{
if (taskState.isRun)
{
num++;
HttpItem item = new HttpItem
{
URL = "http://localhost:47513/?email=" + HttpUtility.UrlEncode(acount.newAppleId) + "&popPwd=" + HttpUtility.UrlEncode(acount.newApplePopPwd),
Method = "GET",
Timeout = 100000,
ReadWriteTimeout = 30000,
ResultType = ResultType.String
};
HttpResult html = new HttpHelper().GetHtml(item);
if (html.StatusCode == HttpStatusCode.OK)
{
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(base.noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取第" + num + "次,失败");
}
Thread.Sleep(5000);
continue;
}
throw new Exception("停止执行");
}
while (num < 5);
if (!string.IsNullOrEmpty(text))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取成功");
return setAccountName(newAccount, verification?.verificationId, text);
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "获取验证码失败超过最大次数");
return false;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.newAccount, accountName);
appleId = accountName;
acount.appleId = accountName;
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新账号设置成功");
isChangAppleId = true;
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新账号设置失败,未知异常:" + (int)httpResult.StatusCode);
return false;
}
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.mima, newPwd);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新密码设置成功");
return true;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "新密码失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新密码失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.shengri, newBirthday);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日设置成功");
return true;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日修改设置失败");
return false;
}
private bool setQuestions(string newqt1, string newqt2, string newqt3)
{
string text = "";
if (securityQuestions != null)
{
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 } };
text = JsonConvert.SerializeObject(obj);
}
else
{
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-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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/repair/questions", text, "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(base.noticeKey, DisplyType.qt1, newqt1);
applyAtion?.Invoke(base.noticeKey, DisplyType.qt2, newqt2);
applyAtion?.Invoke(base.noticeKey, DisplyType.qt3, newqt3);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保修改成功");
return true;
}
action?.Invoke(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保修改失败");
return false;
}
public void getSecurityUpgrade()
{
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-Skip-Repair-Attributes", "[]");
webHeaderCollection.Add("X-Apple-Session-Token", handelDic["X-Apple-Repair-Session-Token"]);
webHeaderCollection.Add("X-Apple-ID-Session-Id", handelDic["X-Apple-ID-Session-Id"]);
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/security/upgrade", "https://appleid.apple.com/", webHeaderCollection);
if (webJsonContent.StatusCode != HttpStatusCode.OK)
{
return;
}
try
{
string html = webJsonContent.Html;
if (!string.IsNullOrEmpty(html))
{
SecurityUpgradeModel securityUpgradeModel = JsonConvert.DeserializeObject<SecurityUpgradeModel>(html);
action?.Invoke(base.noticeKey, DisplyType.shengri, securityUpgradeModel.account.security.birthday);
action?.Invoke(base.noticeKey, DisplyType.guojia, securityUpgradeModel.account.person.primaryAddress.countryName);
}
}
catch (Exception ex)
{
APIUtlis.ApiSeriveError(ex);
}
}
private bool accept()
{
action?.Invoke(base.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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpItem httpItem = new HttpItem
{
URL = "https://appleid.apple.com/account/manage/privacy/accept",
Method = "put",
UserAgent = base.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);
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-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", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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 = base.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);
if (httpReuslt.StatusCode != HttpStatusCode.OK && httpReuslt.StatusCode != HttpStatusCode.NoContent)
{
action?.Invoke(base.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(base.noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(httpReuslt.Header["X-Apple-ID-Account-Country"].ToString()));
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "协议阅读成功");
return true;
}
private bool appleauthAuth(AppleAcount acount)
{
if (isViey)
{
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证密保问题");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
string url = "https://idmsa.apple.com/appleauth/auth";
WebHeaderCollection webHeader = new WebHeaderCollection
{
{ "X-Apple-Widget-Key", Apple_Widget_Key },
{ "X-Requested-With", "XMLHttpRequest" },
{ "X-Apple-Domain-Id", "1" },
{ "X-Apple-Locale", homeLanguage },
{
"scnt",
handelDic["scnt"]
},
{
"X-Apple-ID-Session-Id",
handelDic["X-Apple-ID-Session-Id"]
}
};
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult webContent = getWebContent(url, authUrl, webHeader, "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(base.noticeKey, DisplyType.xinxi, "密保获取失败");
return false;
}
public bool authsignin(string appleId, string applePwd, ref string errMsg)
{
handelDic.Clear();
string url = "https://idmsa.apple.com/appleauth/auth/authorize/signin?frame_id=" + Tools.ToUrlEncode(iframeId) + "&language=zh_CN&skVersion=7&iframeId=" + Tools.ToUrlEncode(iframeId) + "&client_id=" + Apple_Widget_Key + "&redirect_uri=" + Tools.ToUrlEncode(redirectURI) + "&response_type=code&response_mode=web_message&state=" + Tools.ToUrlEncode(iframeId) + "&authVersion=latest";
string referer = "https://appleid.apple.com";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
HttpResult webContent = getWebContent(url, referer, 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)
{
string value = "";
if (webContent.Header.AllKeys.Contains("X-Apple-Auth-Attributes"))
{
string text = "X-Apple-Auth-Attributes";
handelDic.TryAddDic(text, webContent.Header[text]);
}
if (webContent.Header.AllKeys.Contains("X-Apple-HC-Bits") && webContent.Header.AllKeys.Contains("X-Apple-HC-Challenge"))
{
string text2 = webContent.Header["X-Apple-HC-Bits"];
string text3 = webContent.Header["X-Apple-HC-Challenge"];
string text4 = "1:" + text2 + ":" + DateTime.UtcNow.ToString("yyyyMMddHHmmss") + ":" + text3 + "::";
string text5 = APIUtlis.ApiGetCodeHC(text4);
if (!string.IsNullOrEmpty(text5))
{
value = text4 + text5;
}
else
{
text5 = APIUtlis.ApiGetCodeHC(text4);
if (!string.IsNullOrEmpty(text5))
{
value = text4 + text5;
}
}
}
if (!string.IsNullOrEmpty(value))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证登录密码");
string postData = "{\"accountName\":\"" + appleId + "\",\"rememberMe\":false,\"password\":\"" + applePwd + "\"}";
errMsg = "未知错误";
WebHeaderCollection webHeaderCollection2 = new WebHeaderCollection();
webHeaderCollection2.Add("X-Apple-Widget-Key", Apple_Widget_Key);
webHeaderCollection2.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection2.Add("X-APPLE-HC", value);
webHeaderCollection2.Add("X-Apple-Domain-Id", "1");
webHeaderCollection2.Add("X-Apple-Locale", homeLanguage);
webHeaderCollection2.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = postWebContent(loginAuthUrl, postData, authUrl, webHeaderCollection2);
if (httpResult.StatusCode == HttpStatusCode.BadGateway)
{
errMsg = "服务器拒绝,请使用代理,IP可能已被拉黑";
action?.Invoke(base.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 text6 in allKeys)
{
if (text6 == "X-Apple-Repair-Session-Token")
{
if (!handelDic.ContainsKey(text6))
{
handelDic.TryAddDic(text6, httpResult.Header[text6]);
}
else
{
handelDic[text6] = httpResult.Header[text6];
}
}
if (text6 == "scnt")
{
if (!handelDic.ContainsKey(text6))
{
handelDic.TryAddDic(text6, httpResult.Header[text6]);
handelDic.TryAddDic("scnt2", httpResult.Header[text6]);
}
else
{
handelDic[text6] = httpResult.Header[text6];
}
}
}
return repair();
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, errMsg + "(" + (int)httpResult.StatusCode + ")");
return false;
}
allKeys = httpResult.Header.AllKeys;
foreach (string text7 in allKeys)
{
if (text7 == "scnt")
{
handelDic.TryAddDic("scnt", httpResult.Header[text7]);
handelDic.TryAddDic("scnt2", httpResult.Header[text7]);
}
if (text7 == "X-Apple-ID-Session-Id")
{
handelDic.TryAddDic("X-Apple-ID-Session-Id", httpResult.Header[text7]);
}
if (text7 == "X-Apple-ID-Account-Country")
{
handelDic.TryAddDic("X-Apple-ID-Account-Country", httpResult.Header[text7]);
}
}
if (httpResult.Html.Contains("hsa2"))
{
if (openHsa2)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "双重已存在,无需开启");
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "双重验证账号暂不支持更改");
}
return false;
}
return true;
}
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
if (loginErrorModel.serviceErrors != null)
{
if (loginErrorModel.serviceErrors.Length != 0)
{
errMsg = loginErrorModel.serviceErrors[0].message;
action?.Invoke(base.noticeKey, DisplyType.xinxi, loginErrorModel.serviceErrors[0].message);
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, errMsg);
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, errMsg);
}
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录失败#2:AppleService返回:" + (int)webContent.StatusCode);
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录失败:AppleService返回:" + (int)webContent.StatusCode);
return false;
}
protected new virtual 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 = base.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);
HttpResult httpReuslt = GetHttpReuslt(httpItem);
if (httpReuslt.StatusCode == (HttpStatusCode)451 && authenticatePassword(acount.applePwd))
{
return putWebContent(url, putData, referer, webHeader, accept);
}
addCookle(httpReuslt.Cookie);
Array.Clear(bytes, 0, bytes.Length);
return httpReuslt;
}
public 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 = base.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);
if (httpReuslt.StatusCode == (HttpStatusCode)451 && authenticatePassword(acount.applePwd))
{
return postWebContent(url, postData, referer, webHeader, accept);
}
Array.Clear(bytes, 0, bytes.Length);
return httpReuslt;
}
public bool getSecuritydevices()
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Api-Key", base.apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.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(base.noticeKey, DisplyType.xinxi, "正在删除第" + num + "个设备");
deleteDevice(device.id);
num++;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "设备删除完成");
}
return true;
}
action?.Invoke(base.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();
if (handelDic.ContainsKey("scnt"))
{
webHeaderCollection.Add("scnt", handelDic["scnt"]);
}
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
webHeaderCollection.Add("X-Apple-Api-Key", base.apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = DeleteWebContent("https://appleid.apple.com/account/manage/security/devices/" + id, "", "https://appleid.apple.com/account/manage", webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.OK)
{
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];
}
}
if (Tools.Todejosn<DeleteDeviceReust>(httpResult.Html)?.removedDevice.id == id)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "设备删除成功");
return true;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "设备删除失败");
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "设备删除失败");
}
}
else
{
action?.Invoke(base.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", base.apiKey);
webHeaderCollection.Add("Origin", "https://appleid.apple.com");
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult webJsonContent = getWebJsonContent("https://appleid.apple.com/account/manage/security/devices/" + id, "https://appleid.apple.com/account/manage", webHeaderCollection);
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
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];
}
}
return Tools.Todejosn<DevicesInfo>(webJsonContent.Html);
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "设备信息获取失败");
return null;
}
public bool RetrievePassword(bool _openVpn, AppleAcount acount, string newPwd, string _notityKey, bool isCloseAuthen = false, bool ckTailNumber = false)
{
if (string.IsNullOrEmpty(base.ProxyIp))
{
base.ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
}
appleId = acount.appleId;
base.noticeKey = _notityKey;
base.openVpn = _openVpn;
string url = "https://iforgot.apple.com/password/verify/appleid?language=" + language;
listCookie.Add(new CookieItem
{
Key = "idclient",
Value = "web"
});
if (acount.birthday.Split('-').Length == 3)
{
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);
bool num = verifyAppleid(text, acount, newPwd, isCloseAuthen, 0, ckTailNumber);
if (num)
{
ProxyAccountCache.addProxyIp(appleId, base.ProxyIp);
}
return num;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知错误");
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日未导入或者格式错误");
}
return false;
}
private CaptchaModel getCaptcha(string sstt)
{
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
webHeaderCollection.Add("sstt", sstt);
HttpResult httpResult = postWebContent("https://iforgot.apple.com/captcha", "{\"type\":\"IMAGE\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult.StatusCode == HttpStatusCode.OK)
{
return Tools.Todejosn<CaptchaModel>(httpResult.Html);
}
return null;
}
private bool verifyAppleid(string sstt, AppleAcount acount, string newPwd, bool isCloseAuthen, int RetryCount = 0, bool ckTailNumber = false)
{
if (RetryCount >= 3)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取失败,#3");
return false;
}
int num = 0;
CaptchaModel captchaModel = null;
bool flag = false;
do
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "获取验证码.." + (num + 1));
captchaModel = getCaptcha(sstt);
if (captchaModel == null)
{
Thread.Sleep(500);
}
else if (!string.IsNullOrEmpty(captchaModel.payload.content))
{
HttpResult captcha = APIUtlis.getCaptcha(1, captchaModel.payload.content, flag);
if (captcha.StatusCode == HttpStatusCode.OK)
{
dynamic val = Tools.Todejosn<object>(captcha.Html);
if (val["Code"] == "0000")
{
string reust = val["Data"];
captchaModel.reust = reust;
break;
}
flag = !flag;
}
Thread.Sleep(500);
}
num++;
}
while (num <= 5);
if (captchaModel != null)
{
if (!string.IsNullOrEmpty(captchaModel.reust))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在验证账号");
string postData = "{\"id\":\"" + acount.appleId + "\",\"captcha\":{\"id\":" + captchaModel.id + ",\"answer\":\"" + captchaModel.reust + "\",\"token\":\"" + captchaModel.token + "\"}}";
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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)
{
APIUtlis.getCaptcha(3, captchaModel.payload.content);
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "不是有效的AppleId");
}
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = base.ProxyIp,
applyDate = DateTime.Now
});
return false;
}
if (httpResult.StatusCode == HttpStatusCode.Found)
{
httpResult.Header.AllKeys.Contains("sstt");
APIUtlis.getCaptcha(3, captchaModel.payload.content);
string redirectUrl = httpResult.RedirectUrl;
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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"))
{
if (ckTailNumber)
{
if (webJsonContent.Html.Contains("trustedPhones"))
{
IforgotVerifyPhoneModel iforgotVerifyPhoneModel = Tools.Todejosn<IforgotVerifyPhoneModel>(webJsonContent.Html);
if (iforgotVerifyPhoneModel != null)
{
string text = "";
IforgotVerifyPhoneModel.Trustedphone[] array = iforgotVerifyPhoneModel?.trustedPhones;
foreach (IforgotVerifyPhoneModel.Trustedphone trustedphone in array)
{
if (trustedphone != null)
{
text = text + "," + trustedphone.number;
}
}
text = ((!iforgotVerifyPhoneModel.recoverable) ? (text.TrimStart(',') + ", 无法关闭") : (text.TrimStart(',') + ", 可以关闭"));
APIUtlis.ApiApplyAct(44, "尾号查询");
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询到号码:" + text);
return false;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "手机号码获取失败");
return false;
}
sstt = webJsonContent.Header["sstt"];
bool num2 = unenrollment(sstt, acount, newPwd);
if (num2)
{
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = base.ProxyIp,
applyDate = DateTime.Now
});
}
return num2;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "没有双重认证");
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = base.ProxyIp,
applyDate = DateTime.Now
});
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在获取重设方式");
if (webJsonContent.Html.Contains("reset_password") && webJsonContent.Header.AllKeys.Contains("sstt"))
{
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "没有重设密码的方式");
return false;
}
}
}
if (!webJsonContent.Html.Contains("questions") && !webJsonContent.RedirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/verify/birthday"))
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "没有重设密码的方式");
return false;
}
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.noticeKey, DisplyType.xinxi, "未知错误#2");
return false;
}
if (httpResult.Html.Contains("captchaAnswer.Invalid"))
{
APIUtlis.getCaptcha(2, captchaModel.payload.content);
return verifyAppleid(sstt, acount, newPwd, isCloseAuthen, RetryCount + 1, ckTailNumber);
}
ServiceErrorsModel serviceErrorsModel2 = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
if (serviceErrorsModel2 != null)
{
if (serviceErrorsModel2.validationErrors != null && serviceErrorsModel2.validationErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel2.validationErrors[0].message);
return false;
}
if (serviceErrorsModel2.service_errors != null && serviceErrorsModel2.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel2.service_errors[0].message);
return false;
}
if (serviceErrorsModel2.serviceErrors != null && serviceErrorsModel2.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel2.serviceErrors[0].message);
return false;
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "请求失败");
}
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取失败#2");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码获取失败");
return false;
}
public bool unenrollment(string sstt, AppleAcount acount, string newPwd)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在关闭双重认证");
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
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(base.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.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在验证生日信息");
if (webJsonContent.StatusCode == HttpStatusCode.OK)
{
sstt = webJsonContent.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
string[] array = acount.birthday.Split('-');
string postData = "{\"monthOfYear\":\"" + array[1].PadLeft(2, '0') + "\",\"dayOfMonth\":\"" + array[2].PadLeft(2, '0') + "\",\"year\":\"" + array[0] + "\"}";
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/unenrollment/verify/birthday", postData, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult2.StatusCode != HttpStatusCode.Found)
{
if (httpResult2.StatusCode == HttpStatusCode.BadRequest)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日错误");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "网络异常...2#Birthday," + (int)httpResult2.StatusCode);
return false;
}
HttpResult webJsonContent2 = getWebJsonContent(httpResult2.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (webJsonContent2.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证密保获取失败");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在验证密保");
sstt = webJsonContent2.Header["sstt"];
webHeaderCollection["sstt"] = sstt;
AothQuestions aothQuestions = Tools.Todejosn<AothQuestions>(webJsonContent2.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 httpResult3 = postWebContent("https://iforgot.apple.com/unenrollment/verify/questions", postData2, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeaderCollection);
if (httpResult3.StatusCode == HttpStatusCode.Found)
{
return unenrollmentRestPwd(httpResult3.RedirectUrl, newPwd, webHeaderCollection);
}
if (httpResult3.StatusCode == HttpStatusCode.BadRequest)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "网络异常");
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "网络异常");
}
}
else
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "双重手机号码认证失败");
}
}
else
{
action?.Invoke(base.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.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult httpResult = postWebContent("https://iforgot.apple.com/unenrollment", "", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (httpResult.StatusCode == HttpStatusCode.Found)
{
value = httpResult.Header["sstt"];
webHeader["sstt"] = value;
webHeader.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在设置新密码");
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/unenrollment/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader, "application/json, text/javascript, *; q=0.01");
if (httpResult2.StatusCode == HttpStatusCode.BadRequest || httpResult2.StatusCode == HttpStatusCode.Unauthorized)
{
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult2.Html);
if (serviceErrorsModel != null)
{
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "请求失败");
return false;
}
if (httpResult2.StatusCode == (HttpStatusCode)260)
{
acount.applePwd = newPwd;
action?.Invoke(base.noticeKey, DisplyType.mima, newPwd);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "双重关闭成功,密码重置完成");
return true;
}
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
private bool VerifyBirthday(string RedirectUrl, AppleAcount acount, string newPwd, WebHeaderCollection webHeader)
{
string text = "";
action?.Invoke(base.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)
{
if (httpResult.StatusCode == HttpStatusCode.BadRequest)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日错误");
return false;
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "网络异常...#Birthday," + (int)httpResult.StatusCode);
return false;
}
if (!httpResult.RedirectUrl.ToLower().StartsWith("https://iforgot.apple.com/password/authenticationmethod"))
{
return VerifyQuestions(httpResult.RedirectUrl, acount, newPwd, webHeader);
}
webHeader.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
HttpResult webJsonContent2 = getWebJsonContent(httpResult.RedirectUrl, "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
if (webJsonContent2.StatusCode != HttpStatusCode.OK)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保获取失败2");
return false;
}
if (!webJsonContent2.Html.Contains("questions"))
{
action?.Invoke(base.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(base.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(base.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(base.noticeKey, DisplyType.xinxi, "密保错误");
return false;
}
return false;
}
action?.Invoke(base.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(base.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(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.validationErrors[0].message);
return false;
}
if (serviceErrorsModel.service_errors != null && serviceErrorsModel.service_errors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.service_errors[0].message);
return false;
}
if (serviceErrorsModel.serviceErrors != null && serviceErrorsModel.serviceErrors.Length != 0)
{
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + serviceErrorsModel.serviceErrors[0].message);
return false;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "请求失败");
return false;
}
if (httpResult.StatusCode == (HttpStatusCode)260)
{
action?.Invoke(base.noticeKey, DisplyType.mima, newPwd);
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密码重置完成");
AppSysConfig.proxyModels.Push(new ProxyModel2
{
prixyIp = base.ProxyIp,
applyDate = DateTime.Now
});
return true;
}
}
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知错误");
return false;
}
}
}