mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 21:21:34 +00:00
- 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.
546 lines
22 KiB
C#
546 lines
22 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Web;
|
||
using AppleBatch_June.ExecuteTasks;
|
||
using AppleBatch_June.Model;
|
||
using DotNet.Utilities;
|
||
|
||
namespace AppleBatch_June.Utils
|
||
{
|
||
public class GetGameUtils : ItunesUtlis
|
||
{
|
||
public GetGameUtils(ITaskRunState _taskState, string _notyKey, Action<string, DisplyType, string> _action = null, bool _OpenVpn = false)
|
||
: base(_taskState, _notyKey, _action, _OpenVpn)
|
||
{
|
||
}
|
||
|
||
public int getNewGameByUrl3(string url, AppleItunesLogin itunesLogin)
|
||
{
|
||
string html = "";
|
||
string[] gameDataInfo = getGameDataInfo(url, itunesLogin, ref html);
|
||
if (gameDataInfo != null)
|
||
{
|
||
string buyParams = gameDataInfo[0];
|
||
Dictionary<string, object> dictionary = null;
|
||
bool flag = false;
|
||
try
|
||
{
|
||
dictionary = Tools.Todejosn<Dictionary<string, object>>(gameDataInfo[1]);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
flag = true;
|
||
}
|
||
if (flag)
|
||
{
|
||
return getGameByUrl(url, itunesLogin);
|
||
}
|
||
string text = (dynamic)dictionary["pageId"];
|
||
_ = (string)(dynamic)dictionary["page"];
|
||
string text2 = (dynamic)dictionary["pageType"];
|
||
Dictionary<string, string> dataSource = ConveDicTobuyParams(buyParams);
|
||
dataSource.getDicVal("productType", "");
|
||
string dicVal = dataSource.getDicVal("appExtVrsId", "");
|
||
string dicVal2 = dataSource.getDicVal("salableAdamId", "");
|
||
string dicVal3 = dataSource.getDicVal("productType", "");
|
||
string dicVal4 = dataSource.getDicVal("pg", "");
|
||
string dicVal5 = dataSource.getDicVal("pricingParameters", "");
|
||
string dicVal6 = dataSource.getDicVal("price", "0");
|
||
string text3 = "appExtVrsId=" + dicVal + "&";
|
||
if (string.IsNullOrEmpty(dicVal))
|
||
{
|
||
text3 = "";
|
||
}
|
||
string postData = text3 + "clientBuyId=1&guid=[guid]&kbsync=[kbsync]&mtApp=com.apple.AppStore&mtClientId=[xp_ci]&mtEventTime=" + Tools.GetTimestamp2() + "&mtPageContext=App Store&mtPageId=" + text + "&mtPageType=" + text2 + "&mtPrevPage=page_" + dicVal + "&mtRequestId=[mtRequestId]&mtTopic=xp_its_main&needDiv=1&pg=" + dicVal4 + "&price=" + dicVal6 + "&pricingParameters=" + dicVal5 + "&productType=" + dicVal3 + "&salableAdamId=" + dicVal2;
|
||
string getWkUrl = "";
|
||
string yzmUrl = "";
|
||
string gamaInfoConvert = GetGamaInfoConvert(itunesLogin, postData, url, "1", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl);
|
||
if (gamaInfoConvert == "0000")
|
||
{
|
||
return 1;
|
||
}
|
||
if (gamaInfoConvert.StartsWith("sign"))
|
||
{
|
||
return 99;
|
||
}
|
||
if (gamaInfoConvert.StartsWith("1122") && VerificationGame(yzmUrl, getWkUrl, itunesLogin, dicVal2))
|
||
{
|
||
gamaInfoConvert = GetGamaInfoConvert(itunesLogin, postData, url, "1", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl);
|
||
if (gamaInfoConvert == "0000")
|
||
{
|
||
return 1;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n " + gamaInfoConvert + "[" + itunesLogin.serverIndex + "]");
|
||
return 0;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n " + gamaInfoConvert + "[" + itunesLogin.serverIndex + "]");
|
||
return 0;
|
||
}
|
||
string keyValue = GetKeyValue("<key>explanation</key>", "<string>", "</string>", html);
|
||
if (!string.IsNullOrEmpty(keyValue))
|
||
{
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:" + keyValue);
|
||
}
|
||
else if (!html.Contains("product-dv") && !html.Contains("product-dv-product"))
|
||
{
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:没有购买参数,请检查ID和应用国家是否一致");
|
||
}
|
||
else
|
||
{
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:请检查ID和应用国家是否一致[-]");
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
public string GameVerification(string appleId, string pic_str, string wkInt, string salableAdamId, string count, int serverIndex, ref string yzmUrl, ref string getWkUrl, bool isAgent = false)
|
||
{
|
||
if (pic_str == "99999")
|
||
{
|
||
new Dictionary<string, string>();
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public int getGameByUrl(string url, AppleItunesLogin itunesLogin)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split(',')[0] + ",28");
|
||
string userAgent = itunesLogin.Headers["User-Agent"].ToString();
|
||
itunesLogin.Headers["User-Agent"] = "iTunes/12.0.1 (Macintosh; OS X 10.10) AppleWebKit/600.1.3.41";
|
||
HttpResult itunesWebContext = getItunesWebContext(url, "", itunesLogin, dictionary, addToken: false);
|
||
itunesLogin.Headers["User-Agent"] = userAgent;
|
||
if (itunesWebContext.StatusCode == (HttpStatusCode)0)
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Thread.Sleep(1000);
|
||
num++;
|
||
itunesWebContext = getItunesWebContext(url, "", itunesLogin, dictionary, addToken: false);
|
||
}
|
||
while (itunesWebContext.StatusCode == (HttpStatusCode)0 && num < 5);
|
||
}
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
_ = itunesLogin.cookis.Where((KeyValuePair<string, string> c) => c.Key == "xp_ci").FirstOrDefault().Value;
|
||
GameDataInfo gameDataInfo = ParsingGameData(itunesWebContext.Html, url);
|
||
if (gameDataInfo != null)
|
||
{
|
||
try
|
||
{
|
||
Dictionary<string, string> dataSource = ConveDicTobuyParams(gameDataInfo.buyParams2);
|
||
string dicVal = dataSource.getDicVal("appExtVrsId", "");
|
||
string dicVal2 = dataSource.getDicVal("salableAdamId", "");
|
||
string dicVal3 = dataSource.getDicVal("productType", "");
|
||
string dicVal4 = dataSource.getDicVal("pg", "");
|
||
string dicVal5 = dataSource.getDicVal("pricingParameters", "");
|
||
string dicVal6 = dataSource.getDicVal("price", "0");
|
||
string pageId = gameDataInfo.pageId;
|
||
_ = gameDataInfo.page;
|
||
string pageType = gameDataInfo.pageType;
|
||
string text = "appExtVrsId=" + dicVal + "&";
|
||
if (string.IsNullOrEmpty(dicVal))
|
||
{
|
||
text = "";
|
||
}
|
||
string postData = text + "clientBuyId=1&guid=[guid]&kbsync=[kbsync]&mtApp=com.apple.AppStore&mtClientId=[xp_ci]&mtEventTime=" + Tools.GetTimestamp2() + "&mtPageContext=App Store&mtPageId=" + pageId + "&mtPageType=" + pageType + "&mtPrevPage=page_" + dicVal + "&mtRequestId=[mtRequestId]&mtTopic=xp_its_main&needDiv=1&pg=" + dicVal4 + "&price=" + dicVal6 + "&pricingParameters=" + dicVal5 + "&productType=" + dicVal3 + "&salableAdamId=" + dicVal2;
|
||
string yzmUrl = "";
|
||
string getWkUrl = "";
|
||
string gamaInfoConvert = GetGamaInfoConvert(itunesLogin, postData, url, "1", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl);
|
||
if (gamaInfoConvert == "0000")
|
||
{
|
||
return 1;
|
||
}
|
||
if (gamaInfoConvert.StartsWith("sign"))
|
||
{
|
||
return 99;
|
||
}
|
||
if (gamaInfoConvert.StartsWith("1122") && VerificationGame(yzmUrl, getWkUrl, itunesLogin, dicVal2))
|
||
{
|
||
gamaInfoConvert = GetGamaInfoConvert(itunesLogin, postData, url, "1", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl);
|
||
if (gamaInfoConvert == "0000")
|
||
{
|
||
return 1;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n " + gamaInfoConvert);
|
||
return 0;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n " + gamaInfoConvert);
|
||
return 0;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:" + ex.Message);
|
||
return 0;
|
||
}
|
||
}
|
||
string keyValue = GetKeyValue("<key>explanation</key>", "<string>", "</string>", itunesWebContext.Html);
|
||
if (!string.IsNullOrEmpty(keyValue))
|
||
{
|
||
if (keyValue.ToLower().StartsWith("sign"))
|
||
{
|
||
return 99;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:" + keyValue);
|
||
}
|
||
else if (!itunesWebContext.Html.Contains("product-dv") && !itunesWebContext.Html.Contains("product-dv-product"))
|
||
{
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:没有购买参数,请检查ID和应用国家是否一致");
|
||
}
|
||
else
|
||
{
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:请检查ID和应用国家是否一致[" + itunesWebContext.StatusCode.ToString() + "]");
|
||
}
|
||
return 0;
|
||
}
|
||
appGameUrlLog(itunesLogin.account, "链接:" + HttpUtility.UrlDecode(url) + "\n 失败:网络请求失败");
|
||
return 0;
|
||
}
|
||
|
||
public string GetGamaInfoConvert(AppleItunesLogin itunesLogin, string postData, string gameUrl, string gameType, int serverIndex, ref string yzmUrl, ref string getWkUrl)
|
||
{
|
||
postData += "&wasWarnedAboutFirstTimeBuy=true";
|
||
string gamaInfo = GetGamaInfo(itunesLogin, postData, gameUrl, serverIndex);
|
||
if (!string.IsNullOrEmpty(gamaInfo))
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(gamaInfo);
|
||
if (gamaInfo.Contains("captchaModel"))
|
||
{
|
||
dynamic val2 = val["captchaModel"];
|
||
if (val2 != null)
|
||
{
|
||
yzmUrl = val2["yzmUrl"];
|
||
getWkUrl = val2["getWkUrl"];
|
||
}
|
||
}
|
||
return val["msg"];
|
||
}
|
||
return "获取失败";
|
||
}
|
||
|
||
public string GetGamaInfo(AppleItunesLogin itunesLogin, string postData, string gameUrl, int serverIndex, bool isxieyi = false, bool paySwit = false)
|
||
{
|
||
Dictionary<string, object> dictionary = new Dictionary<string, object>();
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZBuy.woa/wa/buyProduct?guid=" + itunesLogin.Guid;
|
||
Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
|
||
dictionary2.Add("X-Apple-Store-Front", itunesLogin.software.Split(',')[0] + ",13");
|
||
string text = (from c in postData.Split('&')
|
||
where c.Split('=')[0] == "price"
|
||
select c.Split('=')[1]).FirstOrDefault();
|
||
bool flag = false;
|
||
if (text != null)
|
||
{
|
||
if (text.Trim() == "0")
|
||
{
|
||
itunesLogin.Headers["User-Agent"] = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||
}
|
||
else
|
||
{
|
||
flag = true;
|
||
if (paySwit)
|
||
{
|
||
itunesLogin.Headers["User-Agent"] = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||
}
|
||
else
|
||
{
|
||
itunesLogin.Headers["User-Agent"] = "MacAppStore/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||
}
|
||
}
|
||
}
|
||
string value = itunesLogin.cookis.Where((KeyValuePair<string, string> c) => c.Key == "xp_ci").FirstOrDefault().Value;
|
||
string reqIda = "";
|
||
string guidNow = "";
|
||
string appleKbsync = getAppleKbsync(itunesLogin, ref reqIda, ref guidNow);
|
||
postData = postData.Replace("[kbsync]", appleKbsync);
|
||
string newValue = value + reqIda;
|
||
postData = postData.Replace("[guid]", guidNow);
|
||
postData = postData.Replace("[xp_ci]", value);
|
||
postData = postData.Replace("[mtRequestId]", newValue);
|
||
(from c in postData.Split('&')
|
||
where c.Split('=')[0] == "salableAdamId"
|
||
select c.Split('=')[1]).FirstOrDefault();
|
||
HttpResult httpResult = postItunesWebContext(url, postData, gameUrl, itunesLogin, dictionary2);
|
||
if (httpResult.StatusCode == (HttpStatusCode)0)
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Thread.Sleep(1000);
|
||
num++;
|
||
httpResult = postItunesWebContext(url, postData, gameUrl, itunesLogin, dictionary2);
|
||
}
|
||
while (httpResult.StatusCode == (HttpStatusCode)0 && num < 3);
|
||
}
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (httpResult.Html.Contains("purchaseSuccess"))
|
||
{
|
||
dictionary.AddOrUpdateObj("msg", "0000");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
if (!httpResult.Html.Contains("Downloading Item") && !httpResult.Html.Contains("MZCommerceSoftware.OwnsAllUnfulfilledFailureSoftwareApplication") && !httpResult.Html.Contains("MZCommerceSoftware.OwnsCurrentMinorSoftwareApplicationForUpdate") && !httpResult.Html.Contains("MZCommerceSoftware.OwnsSupersededMinorSoftwareApplicationForUpdate") && !httpResult.Html.Contains("MZCommerceSong.OwnsSongForRedownload"))
|
||
{
|
||
if (httpResult.Html.Contains("termsPage?") && !isxieyi)
|
||
{
|
||
string text2 = "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/getTermsByCountryAndTypeSrv?cc=" + itunesLogin.AreaCode + "&termsType=MZStore.NewTermsAndConditionsStatement";
|
||
HttpResult itunesWebContext = getItunesWebContext(text2, "", itunesLogin, null, addToken: true);
|
||
if (itunesWebContext.StatusCode != HttpStatusCode.OK)
|
||
{
|
||
dictionary.AddOrUpdateObj("msg", "失败:协议处理失败");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
string token = AppleNetworkBase.GetToken(itunesWebContext.Html, "termsVersionId\":", ",");
|
||
string postData2 = "{\"id\":\"" + itunesLogin.dsis + "\",\"accepted\":" + token + "}";
|
||
string url2 = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/termsCheckSrv";
|
||
httpResult = postUrlencodedItunesWebContext(url2, postData2, text2, itunesLogin, null);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK && httpResult.Html.Contains("status"))
|
||
{
|
||
return GetGamaInfo(itunesLogin, postData, gameUrl, serverIndex, isxieyi: true);
|
||
}
|
||
}
|
||
string keyValue = GetKeyValue("<key>url</key>", "<string>", "</string>", httpResult.Html);
|
||
if (keyValue.Contains("finance-app.itunes.apple.com/challenge"))
|
||
{
|
||
string text3 = (from c in postData.Split('&')
|
||
where c.Split('=')[0] == "salableAdamId"
|
||
select c.Split('=')[1]).FirstOrDefault();
|
||
if (!string.IsNullOrEmpty(text3))
|
||
{
|
||
CaptchaModel captchaModel = LoadCaptcha(keyValue, text3, itunesLogin, 0);
|
||
if (captchaModel != null)
|
||
{
|
||
dictionary.AddOrUpdateObj("msg", "1122,需要进行验证码识别");
|
||
dictionary.AddOrUpdateObj("captchaModel", captchaModel);
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
}
|
||
}
|
||
string keyValue2 = GetKeyValue("<key>customerMessage</key>", "<string>", "</string>", httpResult.Html);
|
||
string keyValue3 = GetKeyValue("<key>explanation</key>", "<string>", "</string>", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue2))
|
||
{
|
||
if (httpResult.Html.Contains("MZCommerce.OsIncompatible") && flag && !paySwit)
|
||
{
|
||
return GetGamaInfo(itunesLogin, postData, gameUrl, serverIndex, isxieyi: true, paySwit: true);
|
||
}
|
||
if ((httpResult.Html.Contains("LoginRequired") || httpResult.Html.Contains("<string>authorization</string>")) && !isxieyi)
|
||
{
|
||
dictionary.AddOrUpdateObj("msg", "sign");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
dictionary.AddOrUpdateObj("msg", "失败:" + keyValue2 + "【" + keyValue3 + "】[" + isxieyi + "]");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
string keyValue4 = GetKeyValue("<key>message</key>", "<string>", "</string>", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue4))
|
||
{
|
||
if ((httpResult.Html.Contains("LoginRequired") || httpResult.Html.Contains("<string>authorization</string>")) && !isxieyi)
|
||
{
|
||
dictionary.AddOrUpdateObj("msg", "sign");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
dictionary.AddOrUpdateObj("msg", "失败:" + keyValue4 + "【" + keyValue3 + "】[" + isxieyi + "]");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
dictionary.AddOrUpdateObj("msg", "失败:未知异常");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
dictionary.AddOrUpdateObj("msg", "0000");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
dictionary.AddOrUpdateObj("msg", "失败:网络请求失败,无法请求完成");
|
||
return Tools.Toenjson(dictionary);
|
||
}
|
||
|
||
public bool VerificationGame(string yzmUrl, string getWkUrl, AppleItunesLogin itunesLogin, string salableAdamId)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
bool flag = false;
|
||
bool flag2 = false;
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
try
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在识别验证码" + (i + 1) + "...");
|
||
HttpResult itunesWebContext = getItunesWebContext(yzmUrl, "", itunesLogin, dictionary, addToken: false, ResultType.Byte);
|
||
HttpResult itunesWebContext2 = getItunesWebContext(getWkUrl, "", itunesLogin, dictionary, addToken: true);
|
||
string value = new Regex("wk\":([\\s\\S]*?)}").Match(itunesWebContext2.Html).Groups[1].Value;
|
||
if (itunesWebContext.StatusCode != HttpStatusCode.OK)
|
||
{
|
||
continue;
|
||
}
|
||
if (itunesWebContext.ResultByte == null)
|
||
{
|
||
if (!GameVerification(itunesLogin.account, "99999", value, salableAdamId, "0", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl).StartsWith("1122"))
|
||
{
|
||
break;
|
||
}
|
||
continue;
|
||
}
|
||
string imageContent = Convert.ToBase64String(itunesWebContext.ResultByte);
|
||
HttpResult captcha = APIUtlis.getCaptcha(1, imageContent, flag2);
|
||
if (captcha.StatusCode != HttpStatusCode.OK)
|
||
{
|
||
continue;
|
||
}
|
||
dynamic val = Tools.Todejosn<object>(captcha.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
string pic_str = val["Data"];
|
||
string text = GameVerification(itunesLogin.account, pic_str, value, salableAdamId, "0", itunesLogin.serverIndex, ref yzmUrl, ref getWkUrl);
|
||
if (text == "0000")
|
||
{
|
||
APIUtlis.getCaptcha(3, imageContent);
|
||
flag = true;
|
||
break;
|
||
}
|
||
if (text.StartsWith("1122"))
|
||
{
|
||
APIUtlis.getCaptcha(2, imageContent);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
flag2 = !flag2;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在识别验证码" + (i + 1) + "...");
|
||
}
|
||
}
|
||
if (flag)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "验证成功");
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "验证失败");
|
||
}
|
||
return flag;
|
||
}
|
||
|
||
public CaptchaModel LoadCaptcha(string yanzhegnUrl, string salableAdamId, AppleItunesLogin itunesLogin, int count)
|
||
{
|
||
try
|
||
{
|
||
if (count > 2)
|
||
{
|
||
return null;
|
||
}
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
string url = "https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/nuDataShowCaptchaSrv?X-Token=" + itunesLogin.xtoken + "&guid=" + itunesLogin.Guid + "&salableAdamId=" + salableAdamId;
|
||
HttpResult itunesWebContext = getItunesWebContext(url, "", itunesLogin, dictionary, addToken: true);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(itunesWebContext.Html);
|
||
string text = val["nuDetectInfo"]["html"];
|
||
dynamic val2 = Tools.Todejosn<object>(new Regex("try{ndwti\\(([\\s\\S]*?)\\)").Match(text).Groups[1].Value);
|
||
if (val2 != null)
|
||
{
|
||
return VerificationCodeIdentification(yanzhegnUrl, text, salableAdamId, itunesLogin, 0);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
return LoadCaptcha(yanzhegnUrl, salableAdamId, itunesLogin, count + 1);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public CaptchaModel VerificationCodeIdentification(string yanzhegnUrl, string nuDetectInfo, string salableAdamId, AppleItunesLogin itunesLogin, int count)
|
||
{
|
||
Dictionary<string, string> suosou = new Dictionary<string, string>();
|
||
suosou.AddOrUpdate("yanzhegnUrl", yanzhegnUrl);
|
||
dynamic val = Tools.Todejosn<object>(new Regex("try{ndwti\\(([\\s\\S]*?)\\)").Match(nuDetectInfo).Groups[1].Value);
|
||
string value = val["fd"]["s"];
|
||
suosou.AddOrUpdate("ndpd-s", value);
|
||
string value2 = val["fd"]["f"];
|
||
suosou.AddOrUpdate("ndpd-f", value2);
|
||
string value3 = val["fd"]["fm"];
|
||
suosou.AddOrUpdate("ndpd-fm", value3);
|
||
string value4 = val["fd"]["w"];
|
||
suosou.AddOrUpdate("ndpd-w", value4);
|
||
string text = new Random().Next(107742, 740782).ToString();
|
||
string value5 = CreatMdpdipr();
|
||
suosou.AddOrUpdate("ndpd-ipr", value5);
|
||
string value6 = "d1-ac04327a26f1ac9";
|
||
suosou.AddOrUpdate("ndpd-di", value6);
|
||
string value7 = "b2|1920x1080 1920x1052 24 24|-480|zh-CN|bp1-9fa0b15534448358|true||Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36|Not Supported";
|
||
suosou.AddOrUpdate("ndpd-bi", value7);
|
||
string value8 = Regex.Match(nuDetectInfo, "(?<=\\<input.*id=\\\"ndpd-probe\\\".*value=\\\").*?(?=\\\")").Value;
|
||
suosou.AddOrUpdate("ndpd-probe", value8);
|
||
string value9 = "";
|
||
suosou.AddOrUpdate("ndpd-af", value9);
|
||
string value10 = "fv,ogg,mp4,webm";
|
||
suosou.AddOrUpdate("ndpd-fv", value10);
|
||
string value11 = "fa,mpeg,ogg,wav";
|
||
suosou.AddOrUpdate("ndpd-fa", value11);
|
||
string value12 = "p,Chrome PDF Viewer,Chrome PDF Viewer,Native Client,Shockwave Flash";
|
||
suosou.AddOrUpdate("ndpd-bp", value12);
|
||
suosou.AddOrUpdate("ndpd-wk", "");
|
||
string value13 = Regex.Match(nuDetectInfo, "(?<=\\<input.*id=\\\"ndpd-vk\\\".*value=\\\").*?(?=\\\")").Value;
|
||
suosou.AddOrUpdate("ndpd-vk", value13);
|
||
suosou.AddOrUpdate("ndpd-wkr", text);
|
||
string value14 = Regex.Match(nuDetectInfo, "(?<=\\<input.*id=\\\"nucaptcha-token\\\".*value=\\\").*?(?=\\\")").Value;
|
||
string dsis = itunesLogin.dsis;
|
||
string guid = itunesLogin.Guid;
|
||
suosou.AddOrUpdate("nucaptcha-answer", "");
|
||
string value15 = Tools.GenerateTimeStamp().ToString();
|
||
if (count == 0)
|
||
{
|
||
suosou.AddOrUpdate("nucaptcha-answer-enter", value15);
|
||
}
|
||
int num = new Random().Next(5, 10);
|
||
string value16 = Tools.GenerateTimeStamp(DateTime.Now.AddSeconds(num)).ToString();
|
||
suosou.AddOrUpdate("nucaptcha-answer-exit", value16);
|
||
new Random().Next(5, 20).ToString();
|
||
suosou.AddOrUpdate("nucaptcha-token", value14);
|
||
suosou.AddOrUpdate("id", dsis);
|
||
suosou.AddOrUpdate("guid", guid);
|
||
suosou.AddOrUpdate("salableAdamId", salableAdamId);
|
||
string text2 = val["wmd"]["wk"]["r"];
|
||
string text3 = val["wmd"]["wk"]["w"];
|
||
string getWkUrl = text2 + "?r=" + text + "&wt=" + text3;
|
||
string value17 = Regex.Match(nuDetectInfo, "(?<=\\<img.*id=\\\"nucaptcha-media\\\".*src=\\\").*?(?=\\\")").Value;
|
||
return new CaptchaModel
|
||
{
|
||
getWkUrl = getWkUrl,
|
||
yzmUrl = value17
|
||
};
|
||
}
|
||
|
||
public string getAppleKbsync(AppleItunesLogin itunesLogin, ref string reqIda2, ref string guidNow)
|
||
{
|
||
int serverIndex = itunesLogin.serverIndex;
|
||
string kbsync = getKbsync(itunesLogin.dsis, ref serverIndex, ref reqIda2, ref guidNow);
|
||
if (string.IsNullOrEmpty(kbsync.Trim()))
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Thread.Sleep(1000);
|
||
kbsync = getKbsync(itunesLogin.dsis, ref serverIndex, ref reqIda2, ref guidNow);
|
||
num++;
|
||
}
|
||
while (string.IsNullOrEmpty(kbsync.Trim()) && num < 50);
|
||
}
|
||
if (itunesLogin.serverIndex == -1)
|
||
{
|
||
itunesLogin.serverIndex = serverIndex;
|
||
}
|
||
return kbsync;
|
||
}
|
||
}
|
||
}
|