add beginnings to safe browsing integration
This commit is contained in:
parent
4506a0d460
commit
b74eca3d38
67 changed files with 100000 additions and 2 deletions
|
@ -33,6 +33,10 @@
|
|||
<assemblyIdentity name="ExCSS" publicKeyToken="bdbe16be9b936b9a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
|
|
@ -4,11 +4,49 @@ using System.Windows.Forms;
|
|||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using EasyTabs;
|
||||
using Google.Apis.Safebrowsing.v4;
|
||||
using Google.Apis.Safebrowsing.v4.Data;
|
||||
using Google.Apis.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace XeroBrowser
|
||||
{
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static async Task<bool> IsUrlUnsafe(string url, string apiKey)
|
||||
{
|
||||
var safeBrowsingService = new SafebrowsingService(new BaseClientService.Initializer
|
||||
{
|
||||
ApiKey = "AIzaSyCQV - s52iNah - il6T5iFuqo6M_JzcLyaxs",
|
||||
ApplicationName = "XeroBrowser"
|
||||
});
|
||||
|
||||
var request = new GoogleSecuritySafebrowsingV4FindThreatMatchesRequest
|
||||
{
|
||||
Client = new GoogleSecuritySafebrowsingV4ClientInfo { ClientId = "XeroBrowser", ClientVersion = "1.0" },
|
||||
ThreatInfo = new GoogleSecuritySafebrowsingV4ThreatInfo
|
||||
{
|
||||
ThreatTypes = new List<string>
|
||||
{
|
||||
"MALWARE",
|
||||
"SOCIAL_ENGINEERING",
|
||||
"UNWANTED_SOFTWARE",
|
||||
"POTENTIALLY_HARMFUL_APPLICATION"
|
||||
},
|
||||
PlatformTypes = new List<string> { "ANY_PLATFORM" },
|
||||
ThreatEntryTypes = new List<string> { "URL" },
|
||||
ThreatEntries = new List<GoogleSecuritySafebrowsingV4ThreatEntry> { new GoogleSecuritySafebrowsingV4ThreatEntry { Url = url } }
|
||||
}
|
||||
};
|
||||
|
||||
var response = await safeBrowsingService.ThreatMatches.Find(request).ExecuteAsync();
|
||||
|
||||
return response != null && response.Matches != null && response.Matches.Count > 0;
|
||||
}
|
||||
|
||||
public static AppContainer Container;
|
||||
|
||||
private static TitleBarTabsApplicationContext _applicationContext;
|
||||
|
@ -26,6 +64,9 @@ namespace XeroBrowser
|
|||
settings.UserAgent = "Mozilla/5.0 (Windows NT 11.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 XeroBrowser/1.0.0";
|
||||
settings.CefCommandLineArgs.Add("enable-media-stream", "1");
|
||||
settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF";
|
||||
settings.CefCommandLineArgs.Add("safebrowsing-disable-download-protection", "0");
|
||||
settings.CefCommandLineArgs.Add("safebrowsing-disable-extension-blacklist", "0");
|
||||
settings.CefCommandLineArgs.Add("safebrowsing-disable-auto-update", "0");
|
||||
|
||||
Cef.Initialize(settings);
|
||||
|
||||
|
|
|
@ -204,12 +204,27 @@
|
|||
<Reference Include="Fizzler, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4ebff4844e382110, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Fizzler.1.3.0\lib\netstandard2.0\Fizzler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Apis, Version=1.60.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Apis.1.60.0\lib\net45\Google.Apis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Apis.Core, Version=1.60.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Apis.Core.1.60.0\lib\net45\Google.Apis.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Apis.PlatformServices, Version=1.60.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Apis.1.60.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Apis.Safebrowsing.v4, Version=1.60.0.2968, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Apis.Safebrowsing.v4.1.60.0.2968\lib\net45\Google.Apis.Safebrowsing.v4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EasyTabs.2.0.0\lib\net40\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EasyTabs.2.0.0\lib\net40\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Svg, Version=3.4.0.0, Culture=neutral, PublicKeyToken=12a0bac221edeae2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Svg.3.4.4\lib\net462\Svg.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
@ -6,6 +6,11 @@ using Bunifu.Utils;
|
|||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using EasyTabs;
|
||||
using Google.Apis.Safebrowsing.v4;
|
||||
using Google.Apis.Safebrowsing.v4.Data;
|
||||
using Google.Apis.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using XeroBrowser.Properties;
|
||||
using static System.Net.WebRequestMethods;
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
|
@ -66,6 +71,21 @@ namespace XeroBrowser
|
|||
private bool _isBlocked;
|
||||
private void chromiumWebBrowser1_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
|
||||
{
|
||||
// chromiumWebBrowser1.LoadingStateChanged += async (s, args) =>
|
||||
// {
|
||||
// if (args.IsLoading)
|
||||
// {
|
||||
// var isUnsafe = await Program.IsUrlUnsafe(args.Browser.MainFrame.Url, "AIzaSyCQV-s52iNah-il6T5iFuqo6M_JzcLyaxs");
|
||||
// if (isUnsafe)
|
||||
// {
|
||||
// chromiumWebBrowser1.Stop(); // cancel the navigation
|
||||
// _isBlocked = true;
|
||||
// chromiumWebBrowser1.LoadHtml("");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
if (e.IsLoading)
|
||||
{
|
||||
loadingIndicator.Visible = true;
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<package id="EasyTabs" version="2.0.0" targetFramework="net48" />
|
||||
<package id="ExCSS" version="4.2.0" targetFramework="net48" />
|
||||
<package id="Fizzler" version="1.3.0" targetFramework="net48" />
|
||||
<package id="Google.Apis" version="1.60.0" targetFramework="net48" />
|
||||
<package id="Google.Apis.Core" version="1.60.0" targetFramework="net48" />
|
||||
<package id="Google.Apis.Safebrowsing.v4" version="1.60.0.2968" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net48" />
|
||||
<package id="Svg" version="3.4.4" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||
|
|
Reference in a new issue