mirror of
https://github.com/Stone-Red-Code/FraudCapturer.git
synced 2026-09-08 23:40:35 +02:00
- Add Block config class
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
namespace FraudCapturer.Configuration;
|
||||||
|
|
||||||
|
internal class BlockConfig
|
||||||
|
{
|
||||||
|
public BlockConfigSet LowRiskSet { get; set; } = new BlockConfigSet(false, true, false);
|
||||||
|
public BlockConfigSet MeduimRiskSet { get; set; } = new BlockConfigSet(false, true, true);
|
||||||
|
public BlockConfigSet HighRiskSet { get; set; } = new BlockConfigSet(true, true, true);
|
||||||
|
|
||||||
|
public bool CheckIfBlock(IpInfo ipInfo)
|
||||||
|
{
|
||||||
|
if (ipInfo.Risk <= 33)
|
||||||
|
{
|
||||||
|
return CheckIfBlockSet(ipInfo, LowRiskSet);
|
||||||
|
}
|
||||||
|
else if (ipInfo.Risk >= 67)
|
||||||
|
{
|
||||||
|
return CheckIfBlockSet(ipInfo, HighRiskSet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CheckIfBlockSet(ipInfo, MeduimRiskSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckIfBlockSet(IpInfo ipInfo, BlockConfigSet blockConfigSet)
|
||||||
|
{
|
||||||
|
if (ipInfo.Type == "VPN" && blockConfigSet.BlockIfVpn)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (ipInfo.IsProxy && blockConfigSet.BlockIfProxy)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!ipInfo.IsProxy && blockConfigSet.BlockIfNotProxy)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace FraudCapturer.Configuration;
|
||||||
|
|
||||||
|
internal class BlockConfigSet
|
||||||
|
{
|
||||||
|
public BlockConfigSet(bool blockIfNotProxy, bool blockIfProxy, bool blockIfVpn)
|
||||||
|
{
|
||||||
|
BlockIfNotProxy = blockIfNotProxy;
|
||||||
|
BlockIfProxy = blockIfProxy;
|
||||||
|
BlockIfVpn = blockIfVpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BlockIfNotProxy { get; }
|
||||||
|
public bool BlockIfProxy { get; }
|
||||||
|
public bool BlockIfVpn { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FraudCapturer.Configuration;
|
||||||
|
|
||||||
|
internal class Configurator
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ using System.Text.Json;
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace FraudCapturer;
|
namespace FraudCapturer.Helpers;
|
||||||
|
|
||||||
internal class DomainHelper
|
internal class DomainHelper
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace FraudCapturer;
|
namespace FraudCapturer.Helpers;
|
||||||
|
|
||||||
internal class FirewallHelper
|
internal class FirewallHelper
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace FraudCapturer;
|
namespace FraudCapturer.Helpers;
|
||||||
|
|
||||||
internal class IpHelper
|
internal class IpHelper
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace FraudCapturer;
|
namespace FraudCapturer.Helpers;
|
||||||
|
|
||||||
internal static class PackageHelper
|
internal static class PackageHelper
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using FraudCapturer.Configuration;
|
||||||
|
using FraudCapturer.Helpers;
|
||||||
|
|
||||||
using PacketDotNet;
|
using PacketDotNet;
|
||||||
|
|
||||||
using SharpPcap;
|
using SharpPcap;
|
||||||
@@ -10,9 +12,6 @@ using System.Net;
|
|||||||
|
|
||||||
namespace FraudCapturer;
|
namespace FraudCapturer;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Example showing packet manipulation
|
|
||||||
/// </summary>
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public const string AppName = "FraudCapturer";
|
public const string AppName = "FraudCapturer";
|
||||||
@@ -25,6 +24,8 @@ public class Program
|
|||||||
private static readonly ConcurrentBag<string> capturedIpsCache = new();
|
private static readonly ConcurrentBag<string> capturedIpsCache = new();
|
||||||
private static readonly ConcurrentDictionary<string, DomainInfo?> capturedDomainsCache = new();
|
private static readonly ConcurrentDictionary<string, DomainInfo?> capturedDomainsCache = new();
|
||||||
|
|
||||||
|
private static BlockConfig blockConfig = new BlockConfig();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -174,19 +175,19 @@ public class Program
|
|||||||
bool block = false;
|
bool block = false;
|
||||||
ConsoleColor consoleColor;
|
ConsoleColor consoleColor;
|
||||||
|
|
||||||
if (ipInfo.Risk >= 67)
|
if (ipInfo.Risk >= 67 && blockConfig.CheckIfBlockSet(ipInfo, blockConfig.HighRiskSet))
|
||||||
{
|
{
|
||||||
FirewallHelper.BlockIp(remoteIpAddress);
|
FirewallHelper.BlockIp(remoteIpAddress);
|
||||||
consoleColor = ConsoleColor.Red;
|
consoleColor = ConsoleColor.Red;
|
||||||
block = true;
|
block = true;
|
||||||
}
|
}
|
||||||
else if (ipInfo.Risk >= 34 && ipInfo.IsProxy)
|
else if (ipInfo.Risk <= 33 && blockConfig.CheckIfBlockSet(ipInfo, blockConfig.LowRiskSet))
|
||||||
{
|
{
|
||||||
FirewallHelper.BlockIp(remoteIpAddress);
|
FirewallHelper.BlockIp(remoteIpAddress);
|
||||||
consoleColor = ConsoleColor.DarkYellow;
|
consoleColor = ConsoleColor.Yellow;
|
||||||
block = true;
|
block = true;
|
||||||
}
|
}
|
||||||
else if (ipInfo.IsProxy && ipInfo.Type != "VPN")
|
else if (blockConfig.CheckIfBlockSet(ipInfo, blockConfig.MeduimRiskSet))
|
||||||
{
|
{
|
||||||
FirewallHelper.BlockIp(remoteIpAddress);
|
FirewallHelper.BlockIp(remoteIpAddress);
|
||||||
consoleColor = ConsoleColor.DarkYellow;
|
consoleColor = ConsoleColor.DarkYellow;
|
||||||
|
|||||||
Reference in New Issue
Block a user