diff --git a/src/Milky/Checker.cs b/src/Milky/Checker.cs index 3320d95..040815b 100644 --- a/src/Milky/Checker.cs +++ b/src/Milky/Checker.cs @@ -203,7 +203,7 @@ private async Task StartCpmCounterAsync() private void OutputCombo(Combo combo, CheckResult checkResult) { - if (checkResult.ComboResult == ComboResult.Invalid && !_outputSettings.OutputInvalids) + if ((checkResult.ComboResult == ComboResult.Invalid && !_outputSettings.OutputInvalids) || checkResult.ComboResult == ComboResult.Banned) { return; } @@ -239,31 +239,57 @@ private void OutputCombo(Combo combo, CheckResult checkResult) File.AppendAllText(globalOutputPath, outputString + Environment.NewLine); } + } - Console.ForegroundColor = checkResult.ComboResult switch - { - ComboResult.Hit => _outputSettings.HitColor, - ComboResult.Free => _outputSettings.FreeColor, - ComboResult.Invalid => _outputSettings.InvalidColor - }; - - if (_outputSettings.CustomColors.Count > 0 && checkResult.Captures != null) + Console.ForegroundColor = checkResult.ComboResult switch + { + ComboResult.Hit => _outputSettings.HitColor, + ComboResult.Free => _outputSettings.FreeColor, + ComboResult.Invalid => _outputSettings.InvalidColor, + ComboResult.Banned => _outputSettings.BannedColor, + ComboResult.Unknown => _outputSettings.UnknownColor + }; + + if (_outputSettings.CustomColors.Count > 0 && checkResult.Captures != null) + { + foreach (var customColor in _outputSettings.CustomColors) { - foreach (var customColor in _outputSettings.CustomColors) + if (checkResult.Captures.TryGetValue(customColor.Value.Key, out var capturedObject)) { - if (checkResult.Captures.TryGetValue(customColor.Value.Key, out var capturedObject)) + if (customColor.Value.Value(capturedObject)) { - if (customColor.Value.Value(capturedObject)) - { - Console.ForegroundColor = customColor.Key; - break; - } + Console.ForegroundColor = customColor.Key; + break; } } } } - Console.WriteLine(outputString); + switch (checkResult.ComboResult) + { + case ComboResult.Free: + if (_outputSettings.DisplayFrees) + Console.WriteLine(outputString); + break; + case ComboResult.Unknown: + if (_outputSettings.DisplayUnknowns) + Console.WriteLine(outputString); + break; + case ComboResult.Banned: + if (_outputSettings.DisplayBanneds) + Console.WriteLine(outputString); + break; + case ComboResult.Invalid: + if (_outputSettings.OutputInvalids) + Console.WriteLine(outputString); + break; + case ComboResult.Hit: + default: + Console.WriteLine(outputString); + break; + } + + Info.LastHit = DateTime.Now; } } diff --git a/src/Milky/CheckerBuilder.cs b/src/Milky/CheckerBuilder.cs index e711684..12dd07e 100644 --- a/src/Milky/CheckerBuilder.cs +++ b/src/Milky/CheckerBuilder.cs @@ -55,7 +55,7 @@ public CheckerBuilder WithProxies(IEnumerable proxies) { foreach (var proxy in proxies.Where(p => p.Valid)) { - _httpClientLibrary.Add(proxy.GetHttpClient()); + _httpClientLibrary.Add(proxy.GetHttpClient(_checkerSettings)); } return this; @@ -112,7 +112,9 @@ private void SetUpHttpClientLibrary() _httpClientLibrary.Add(new HttpClient(new HttpClientHandler() { - UseCookies = false // Using cookies would suck with shared HttpClients, especially for credential stuffing + AllowAutoRedirect = _checkerSettings.AllowAutoRedirect, + MaxAutomaticRedirections = _checkerSettings.MaxAutomaticRedirections, + UseCookies = _checkerSettings.UseCookies // Using cookies would suck with shared HttpClients, especially for credential stuffing })); } else if (_httpClientLibrary.Items.Count == 0) @@ -140,4 +142,4 @@ private void SetUpMiscellaneous(int extraThreads = 10) Directory.CreateDirectory(_outputSettings.OutputDirectory); } } -} +} \ No newline at end of file diff --git a/src/Milky/Enums/ComboResult.cs b/src/Milky/Enums/ComboResult.cs index a341edf..de2cc83 100644 --- a/src/Milky/Enums/ComboResult.cs +++ b/src/Milky/Enums/ComboResult.cs @@ -5,6 +5,8 @@ public enum ComboResult Retry, Invalid, Free, - Hit + Hit, + Banned, + Unknown } } diff --git a/src/Milky/Models/CheckerSettings.cs b/src/Milky/Models/CheckerSettings.cs index 7bf892c..89873ca 100644 --- a/src/Milky/Models/CheckerSettings.cs +++ b/src/Milky/Models/CheckerSettings.cs @@ -4,14 +4,22 @@ public class CheckerSettings { /// Maximum combos to check concurrently /// Whether proxies should be used or not - public CheckerSettings(int maxThreads, bool useProxies) + /// Whether or not to use/save/keep cookies, usually not recommended for credential stuffing but who knows + /// Whether or not to follow redirections + /// Max automatic request redirections + public CheckerSettings(int maxThreads, bool useProxies, bool useCookies = false, bool allowAutoRedirect = true, int maxAutomaticRedirections = 50) { MaxThreads = maxThreads; UseProxies = useProxies; + UseCookies = useCookies; + AllowAutoRedirect = allowAutoRedirect; + MaxAutomaticRedirections = maxAutomaticRedirections; } public int MaxThreads { get; } - public bool UseProxies { get; } + public bool UseCookies { get; } + public bool AllowAutoRedirect { get; set; } + public int MaxAutomaticRedirections { get; set; } } -} +} \ No newline at end of file diff --git a/src/Milky/Models/OutputSettings.cs b/src/Milky/Models/OutputSettings.cs index 037be43..d05cb86 100644 --- a/src/Milky/Models/OutputSettings.cs +++ b/src/Milky/Models/OutputSettings.cs @@ -19,6 +19,21 @@ public class OutputSettings /// public bool OutputInvalids { get; set; } = false; + /// + /// Whether to display free's in console + /// + public bool DisplayFrees { get; set; } = true; + + /// + /// Whether to display unknown's in console + /// + public bool DisplayUnknowns { get; set; } = false; + + /// + /// Whether to display banned's in console + /// + public bool DisplayBanneds { get; set; } = false; + /// /// Separator that's going to be used to separate the combo and the capture, as well as each capture /// @@ -34,6 +49,16 @@ public class OutputSettings /// public ConsoleColor FreeColor { get; set; } = ConsoleColor.Cyan; + /// + /// Console output color for + /// + public ConsoleColor UnknownColor { get; set; } = ConsoleColor.DarkRed; + + /// + /// Console output color for + /// + public ConsoleColor BannedColor { get; set; } = ConsoleColor.Yellow; + /// /// Console output color for /// diff --git a/src/Milky/Models/Proxy.cs b/src/Milky/Models/Proxy.cs index 01ca661..fc2dc2d 100644 --- a/src/Milky/Models/Proxy.cs +++ b/src/Milky/Models/Proxy.cs @@ -46,9 +46,9 @@ public Proxy(string proxy, ProxySettings settings) internal NetworkCredential Credentials { get; } - public HttpClient GetHttpClient(CookieContainer cookieContainer = null) + public HttpClient GetHttpClient(CheckerSettings checkerSettings, CookieContainer cookieContainer = null) { - var httpMessageHandler = GetHttpMessageHandler(cookieContainer); + var httpMessageHandler = GetHttpMessageHandler(checkerSettings, cookieContainer); var httpClient = new HttpClient(httpMessageHandler) { @@ -63,16 +63,17 @@ public HttpClient GetHttpClient(CookieContainer cookieContainer = null) return httpClient; } - public HttpMessageHandler GetHttpMessageHandler(CookieContainer cookieContainer = null) + public HttpMessageHandler GetHttpMessageHandler(CheckerSettings checkerSettings, CookieContainer cookieContainer = null) { if (Settings.Protocol == ProxyProtocol.HTTP) { return new HttpClientHandler() { Proxy = new WebProxy(Host, Port) { Credentials = Credentials }, - AllowAutoRedirect = Settings.AllowAutoRedirect, - UseCookies = Settings.UseCookies, - CookieContainer = cookieContainer ?? new CookieContainer() + AllowAutoRedirect = checkerSettings.AllowAutoRedirect, + UseCookies = checkerSettings.UseCookies, + CookieContainer = cookieContainer ?? new CookieContainer(), + MaxAutomaticRedirections = checkerSettings.MaxAutomaticRedirections }; } @@ -80,33 +81,35 @@ public HttpMessageHandler GetHttpMessageHandler(CookieContainer cookieContainer var proxySettings = new SocksSharp.Proxy.ProxySettings() { - Host = Host, Port = Port, + Host = Host, + Port = Port, Credentials = Credentials, ConnectTimeout = timeoutMilliseconds, ReadWriteTimeOut = timeoutMilliseconds }; + // Note: MaxAutomaticRedirections not supported by SocksSharp return Settings.Protocol switch { ProxyProtocol.SOCKS4 => new ProxyClientHandler(proxySettings) { - AllowAutoRedirect = Settings.AllowAutoRedirect, - UseCookies = Settings.UseCookies, - CookieContainer = cookieContainer + AllowAutoRedirect = checkerSettings.AllowAutoRedirect, + UseCookies = checkerSettings.UseCookies, + CookieContainer = cookieContainer ?? new CookieContainer(), }, ProxyProtocol.SOCKS4A => new ProxyClientHandler(proxySettings) { - AllowAutoRedirect = Settings.AllowAutoRedirect, - UseCookies = Settings.UseCookies, - CookieContainer = cookieContainer + AllowAutoRedirect = checkerSettings.AllowAutoRedirect, + UseCookies = checkerSettings.UseCookies, + CookieContainer = cookieContainer ?? new CookieContainer(), }, ProxyProtocol.SOCKS5 => new ProxyClientHandler(proxySettings) { - AllowAutoRedirect = Settings.AllowAutoRedirect, - UseCookies = Settings.UseCookies, - CookieContainer = cookieContainer + AllowAutoRedirect = checkerSettings.AllowAutoRedirect, + UseCookies = checkerSettings.UseCookies, + CookieContainer = cookieContainer ?? new CookieContainer(), } }; } } -} +} \ No newline at end of file diff --git a/src/Milky/Models/ProxySettings.cs b/src/Milky/Models/ProxySettings.cs index 1cbfa66..522cda9 100644 --- a/src/Milky/Models/ProxySettings.cs +++ b/src/Milky/Models/ProxySettings.cs @@ -1,6 +1,5 @@ using Milky.Enums; using System; -using System.Net; namespace Milky.Models { @@ -19,15 +18,5 @@ public ProxySettings(ProxyProtocol protocol) public bool Rotating { get; set; } = false; public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(10); - - /// - /// Whether or not to follow redirections - /// - public bool AllowAutoRedirect { get; set; } = true; - - /// - /// Whether or not to use/save/keep cookies, usually not recommended for credential stuffing but who knows - /// - public bool UseCookies { get; set; } = false; } -} +} \ No newline at end of file