2015-07-12 17:52:32 +00:00
|
|
|
|
using System;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2015-07-12 17:52:32 +00:00
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
|
namespace Jackett.Common.Utils
|
2015-07-12 17:52:32 +00:00
|
|
|
|
{
|
|
|
|
|
public static class BrowserUtil
|
|
|
|
|
{
|
|
|
|
|
public static string ChromeUserAgent
|
|
|
|
|
{
|
2015-08-23 21:11:18 +00:00
|
|
|
|
get {
|
2018-01-22 15:55:54 +00:00
|
|
|
|
// When updating these make sure they are not detected by the incapsula bot detection engine (e.g. kickasstorrent indexer)
|
2015-08-23 21:11:18 +00:00
|
|
|
|
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
|
|
|
|
{
|
2018-10-20 09:47:18 +00:00
|
|
|
|
return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36";
|
2015-08-23 21:11:18 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-20 09:47:18 +00:00
|
|
|
|
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36";
|
2015-08-23 21:11:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-12 17:52:32 +00:00
|
|
|
|
}
|
2016-12-06 08:40:38 +00:00
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
// This can be used to decode e-mail addresses protected by cloudflare
|
|
|
|
|
public static string DecodeCloudFlareProtectedEmail(string input)
|
|
|
|
|
{
|
|
|
|
|
var key = Convert.ToInt32(input.Substring(0, 2), 16);
|
|
|
|
|
string result = "";
|
|
|
|
|
for (var i = 2; i < input.Length - 1; i += 2)
|
|
|
|
|
{
|
|
|
|
|
var hexChar = input.Substring(i, 2);
|
|
|
|
|
var intChar = Convert.ToInt32(hexChar, 16) ^ key;
|
|
|
|
|
var strChar = Convert.ToChar(intChar);
|
|
|
|
|
result += strChar;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// decode cloudflare protected emails in a HTML document
|
|
|
|
|
public static string DecodeCloudFlareProtectedEmailFromHTML(string html)
|
|
|
|
|
{
|
|
|
|
|
Regex CFEMailRegex = new Regex("<span class=\"__cf_email__\" data-cfemail=\"(\\w+)\">\\[email protected\\]<\\/span><script data-cfhash='[\\w]+' type=\"text\\/javascript\">.*?<\\/script>", RegexOptions.Compiled);
|
|
|
|
|
var CFEMailRegexMatches = CFEMailRegex.Match(html);
|
|
|
|
|
|
|
|
|
|
while (CFEMailRegexMatches.Success)
|
|
|
|
|
{
|
|
|
|
|
string all = CFEMailRegexMatches.Groups[0].Value;
|
|
|
|
|
string cfemail = CFEMailRegexMatches.Groups[1].Value;
|
|
|
|
|
var decoded = DecodeCloudFlareProtectedEmail(cfemail);
|
|
|
|
|
html = html.Replace(all, decoded);
|
|
|
|
|
CFEMailRegexMatches = CFEMailRegexMatches.NextMatch();
|
|
|
|
|
}
|
|
|
|
|
return html;
|
2016-12-06 08:40:38 +00:00
|
|
|
|
}
|
2015-07-12 17:52:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|