- Accept proxycheck api key as parameter

- Add Pc Name to tag
This commit is contained in:
Stone_Red
2022-01-08 16:13:52 +01:00
parent 05e20edca3
commit 20390d30db
4 changed files with 36 additions and 15 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ internal class DomainHelper
}; };
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("User-Agent", $"{Program.AppName} - https://github.com/Stone-Red-Code/FraudCapturer"); httpClient.DefaultRequestHeaders.Add("User-Agent", $"({Program.AppName}/{Environment.MachineName}) - ({Program.AppUrl})");
AntiFishReqestBody reqestBody = new AntiFishReqestBody() AntiFishReqestBody reqestBody = new AntiFishReqestBody()
{ {
+3 -1
View File
@@ -5,11 +5,13 @@ namespace FraudCapturer;
internal class IpHelper internal class IpHelper
{ {
public static string? ProxycheckApiKey { get; set; }
public static IpInfo? GetIpReputation(IPAddress ipAddress) public static IpInfo? GetIpReputation(IPAddress ipAddress)
{ {
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
string rawResponseData = httpClient.GetStringAsync($"http://proxycheck.io/v2/{ipAddress}?key=65019k-719i38-2k0r91-36q7o7&risk=2&vpn=1&asn=1&tag={Program.AppName}").GetAwaiter().GetResult(); string rawResponseData = httpClient.GetStringAsync($"http://proxycheck.io/v2/{ipAddress}?key={ProxycheckApiKey}&risk=2&vpn=1&asn=1&tag={Program.AppName}({Environment.MachineName})").GetAwaiter().GetResult();
JsonDocument responseData = JsonDocument.Parse(rawResponseData); JsonDocument responseData = JsonDocument.Parse(rawResponseData);
+24 -13
View File
@@ -13,6 +13,7 @@ namespace FraudCapturer;
public class Program public class Program
{ {
public const string AppName = "FraudCapturer"; public const string AppName = "FraudCapturer";
public const string AppUrl = "https://github.com/Stone-Red-Code/FraudCapturer";
public const string IpStorePath = "ipAdresses.txt"; public const string IpStorePath = "ipAdresses.txt";
private static DateTime lastCacheClear; private static DateTime lastCacheClear;
@@ -24,16 +25,28 @@ public class Program
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
private static void Main() private static void Main(string[] args)
{ {
Console.OutputEncoding = System.Text.Encoding.UTF8; Console.OutputEncoding = System.Text.Encoding.UTF8;
// Print SharpPcap version // Print SharpPcap version
Console.WriteLine(AppName); Console.WriteLine($"{AppName} - {AppUrl}");
Console.WriteLine(); Console.WriteLine();
// Retrieve the device list // Retrieve the device list
CaptureDeviceList devices = CaptureDeviceList.Instance; CaptureDeviceList devices = CaptureDeviceList.Instance;
if (string.IsNullOrWhiteSpace(args.FirstOrDefault()))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("No proxycheck api key provided! You are limited to 100 IP checks per day. Get one for free at proxycheck.io.");
Console.WriteLine();
Console.ResetColor();
}
else
{
IpHelper.ProxycheckApiKey = args.FirstOrDefault();
}
// If no devices were found print an error // If no devices were found print an error
if (devices.Count < 1) if (devices.Count < 1)
{ {
@@ -45,12 +58,12 @@ public class Program
Console.WriteLine("----------------------------------------------------"); Console.WriteLine("----------------------------------------------------");
Console.WriteLine(); Console.WriteLine();
//Print all available devices
int i = 0; int i = 0;
// Print out the available devices
foreach (ILiveDevice dev in devices) foreach (ILiveDevice dev in devices)
{ {
Console.WriteLine("{0}) {1}", i, dev.Description); Console.WriteLine($"{i}) {dev.Description}");
i++; i++;
} }
@@ -72,9 +85,8 @@ public class Program
device = devices[choice]; device = devices[choice];
//Register our handler function to the 'packet arrival' event //Register handler function to the 'packet arrival' event
device.OnPacketArrival += device.OnPacketArrival += new PacketArrivalEventHandler(Device_OnPacketArrival);
new PacketArrivalEventHandler(Device_OnPacketArrival);
// Open the device for capturing // Open the device for capturing
device.Open(); device.Open();
@@ -82,13 +94,8 @@ public class Program
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("-- Listening on {0}, hit 'Ctrl-C' to exit...", device.Description); Console.WriteLine("-- Listening on {0}, hit 'Ctrl-C' to exit...", device.Description);
// Start capture 'INFINTE' number of packets // Start capture of packets
device.Capture(); device.Capture();
// Close the pcap device
// (Note: this line will never be called since
// we're capturing infinite number of packets
device.Close();
} }
private static void Device_OnPacketArrival(object sender, PacketCapture e) private static void Device_OnPacketArrival(object sender, PacketCapture e)
@@ -103,6 +110,7 @@ public class Program
IPAddress remoteIpAddress; IPAddress remoteIpAddress;
string direction; string direction;
//Check if the package is destined for the PC and determine if it goes in or out.
if (IpHelper.IsLocalIpAddress(ip.SourceAddress.ToString())) if (IpHelper.IsLocalIpAddress(ip.SourceAddress.ToString()))
{ {
remoteIpAddress = ip.DestinationAddress; remoteIpAddress = ip.DestinationAddress;
@@ -118,6 +126,7 @@ public class Program
return; return;
} }
//Clear cache every 10 minutes.
if (DateTime.Now - lastCacheClear >= new TimeSpan(0, 10, 0)) if (DateTime.Now - lastCacheClear >= new TimeSpan(0, 10, 0))
{ {
lastCacheClear = DateTime.Now; lastCacheClear = DateTime.Now;
@@ -127,6 +136,7 @@ public class Program
Console.WriteLine("Cleared cache"); Console.WriteLine("Cleared cache");
} }
//Check if a DNS packet contains a "dangerous" domain.
CheckDns(packet, remoteIpAddress, direction); CheckDns(packet, remoteIpAddress, direction);
if (capturedIpsCache.Contains(remoteIpAddress.ToString())) if (capturedIpsCache.Contains(remoteIpAddress.ToString()))
@@ -139,6 +149,7 @@ public class Program
capturedIpsCache.Add(remoteIpAddress.ToString()); capturedIpsCache.Add(remoteIpAddress.ToString());
//Check if ip address is "dangerous" or blocked
CheckIpAddress(remoteIpAddress, direction); CheckIpAddress(remoteIpAddress, direction);
} }
} }
@@ -0,0 +1,8 @@
{
"profiles": {
"FraudCapturer": {
"commandName": "Project",
"commandLineArgs": "65019k-719i38-2k0r91-36q7o7"
}
}
}