mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
Added security protocol selection to Request and CFBypass blocks
This commit is contained in:
@@ -281,6 +281,7 @@ REQUEST METHOD "URL" [AcceptEncoding?] [AutoRedirect?] [ReadResponseSource?] [Pa
|
||||
[BOUNDARY "abcd"]
|
||||
[COOKIE "abc: def"]*
|
||||
[HEADER "abc: def"]*
|
||||
[SECPROTO security-protocol]
|
||||
[-> STRING / -> FILE "path"]
|
||||
|
||||
Examples:
|
||||
@@ -335,7 +336,7 @@ PARSE "<SOURCE>" CSS "[name=csrf]" "value" -> VAR "CSRF"
|
||||
This will spawn and execute a BypassCF Block.
|
||||
|
||||
Syntax:
|
||||
BYPASSCF "URL" ["UA"]
|
||||
BYPASSCF "URL" SECPROTO security-protocol ["UA"]
|
||||
|
||||
Example:
|
||||
BYPASSCF "http://example.com"
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
<Label Content="User Agent:" />
|
||||
<TextBox Text="{Binding UserAgent, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Security Protocol:"/>
|
||||
<ComboBox x:Name="securityProtocolCombobox" SelectionChanged="securityProtocolCombobox_SelectionChanged"/>
|
||||
</DockPanel>
|
||||
<CheckBox IsChecked="{Binding PrintResponseInfo}" Content="Print Response Info" VerticalContentAlignment="Center" />
|
||||
<CheckBox IsChecked="{Binding ErrorOn302}" Content="Set Error Status on 302" VerticalContentAlignment="Center" />
|
||||
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using RuriLib;
|
||||
using RuriLib.Functions.Requests;
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OpenBullet.Views.StackerBlocks
|
||||
@@ -15,6 +17,16 @@ namespace OpenBullet.Views.StackerBlocks
|
||||
InitializeComponent();
|
||||
vm = block;
|
||||
DataContext = vm;
|
||||
|
||||
foreach (var s in Enum.GetNames(typeof(SecurityProtocol)))
|
||||
securityProtocolCombobox.Items.Add(s);
|
||||
|
||||
securityProtocolCombobox.SelectedIndex = (int)vm.SecurityProtocol;
|
||||
}
|
||||
|
||||
private void securityProtocolCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
vm.SecurityProtocol = (SecurityProtocol)((ComboBox)e.OriginalSource).SelectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Row 1 -->
|
||||
@@ -40,11 +39,13 @@
|
||||
<CheckBox Grid.Column="0" Grid.Row="1" Content="Read Resp. Source" IsChecked="{Binding ReadResponseSource}" VerticalContentAlignment="Center" />
|
||||
<CheckBox Grid.Column="1" Grid.Row="1" Content="Accept-Encoding" IsChecked="{Binding AcceptEncoding}" VerticalContentAlignment="Center"/>
|
||||
<CheckBox Grid.Column="2" Grid.Row="1" Content="Encode Content" IsChecked="{Binding EncodeContent}" VerticalContentAlignment="Center"/>
|
||||
|
||||
<!-- Row 3 -->
|
||||
|
||||
</Grid>
|
||||
|
||||
<DockPanel>
|
||||
<Label Content="Security Protocol:"/>
|
||||
<ComboBox x:Name="securityProtocolCombobox" SelectionChanged="securityProtocolCombobox_SelectionChanged"/>
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel Margin="0 5 0 0">
|
||||
<Label Content="Request Type:" Foreground="{DynamicResource ForegroundCustom}" />
|
||||
<ComboBox x:Name="requestTypeCombobox" SelectionChanged="requestTypeCombobox_SelectionChanged" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using OpenBullet.Views.Main.Runner;
|
||||
using RuriLib;
|
||||
using RuriLib.Functions.Requests;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
@@ -47,6 +48,11 @@ namespace OpenBullet.Views.StackerBlocks
|
||||
|
||||
foreach (var c in commonContentTypes)
|
||||
contentTypeCombobox.Items.Add(c);
|
||||
|
||||
foreach (var s in Enum.GetNames(typeof(SecurityProtocol)))
|
||||
securityProtocolCombobox.Items.Add(s);
|
||||
|
||||
securityProtocolCombobox.SelectedIndex = (int)vm.SecurityProtocol;
|
||||
}
|
||||
|
||||
private void methodCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -104,5 +110,10 @@ namespace OpenBullet.Views.StackerBlocks
|
||||
{
|
||||
vm.SetMultipartContents(multipartContentsRTB.Lines());
|
||||
}
|
||||
|
||||
private void securityProtocolCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
vm.SecurityProtocol = (SecurityProtocol)((ComboBox)e.OriginalSource).SelectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using CloudflareSolverRe.CaptchaProviders;
|
||||
using System.Net.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RuriLib.Functions.Requests;
|
||||
|
||||
namespace RuriLib
|
||||
{
|
||||
@@ -28,9 +29,9 @@ namespace RuriLib
|
||||
/// <summary>Whether to print the full response info to the log.</summary>
|
||||
public bool PrintResponseInfo { get { return printResponseInfo; } set { printResponseInfo = value; OnPropertyChanged(); } }
|
||||
|
||||
private bool errorOn302 = true;
|
||||
/// <summary>Whether to set ERROR Status on 302.</summary>
|
||||
public bool ErrorOn302 { get { return errorOn302; } set { errorOn302 = value; OnPropertyChanged(); } }
|
||||
private SecurityProtocol securityProtocol = SecurityProtocol.SystemDefault;
|
||||
/// <summary>The security protocol(s) to use for the HTTPS request.</summary>
|
||||
public SecurityProtocol SecurityProtocol { get { return securityProtocol; } set { securityProtocol = value; OnPropertyChanged(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Cloudflare bypass block.
|
||||
@@ -52,7 +53,7 @@ namespace RuriLib
|
||||
|
||||
/*
|
||||
* Syntax
|
||||
* BYPASSCF "URL" ["UA"]
|
||||
* BYPASSCF "URL" SECPROTO PROTOCOL ["UA"]
|
||||
* */
|
||||
|
||||
Url = LineParser.ParseLiteral(ref input, "URL");
|
||||
@@ -62,6 +63,11 @@ namespace RuriLib
|
||||
UserAgent = LineParser.ParseLiteral(ref input, "UA");
|
||||
}
|
||||
|
||||
if (input != "" && LineParser.ParseToken(ref input, TokenType.Parameter, false, true) == "SECPROTO")
|
||||
{
|
||||
SecurityProtocol = LineParser.ParseEnum(ref input, "Security Protocol", typeof(SecurityProtocol));
|
||||
}
|
||||
|
||||
while (input != "")
|
||||
{
|
||||
LineParser.SetBool(ref input, this);
|
||||
@@ -78,9 +84,10 @@ namespace RuriLib
|
||||
.Label(Label)
|
||||
.Token("BYPASSCF")
|
||||
.Literal(Url)
|
||||
.Token("SECPROTO")
|
||||
.Token(SecurityProtocol)
|
||||
.Literal(UserAgent, "UserAgent")
|
||||
.Boolean(PrintResponseInfo, "PrintResponseInfo")
|
||||
.Boolean(ErrorOn302, "ErrorOn302");
|
||||
.Boolean(PrintResponseInfo, "PrintResponseInfo");
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
@@ -143,7 +150,8 @@ namespace RuriLib
|
||||
{
|
||||
AllowAutoRedirect = true,
|
||||
CookieContainer = cookies,
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
|
||||
SslProtocols = SecurityProtocol.ToSslProtocols()
|
||||
};
|
||||
|
||||
// Assign the proxy to the inner handler if necessary
|
||||
@@ -316,12 +324,6 @@ namespace RuriLib
|
||||
data.Log(new LogEntry("Response Source:", Colors.Green));
|
||||
data.Log(new LogEntry(data.ResponseSource, Colors.GreenYellow));
|
||||
}
|
||||
|
||||
// Error on 302 status
|
||||
if (ErrorOn302 && response.StatusCode == HttpStatusCode.Redirect)
|
||||
{
|
||||
data.Status = BotStatus.ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ namespace RuriLib
|
||||
/// <summary>The method of the HTTP request.</summary>
|
||||
public HttpMethod Method { get { return method; } set { method = value; OnPropertyChanged(); } }
|
||||
|
||||
private SecurityProtocol securityProtocol = SecurityProtocol.SystemDefault;
|
||||
/// <summary>The security protocol(s) to use for the HTTPS request.</summary>
|
||||
public SecurityProtocol SecurityProtocol { get { return securityProtocol; } set { securityProtocol = value; OnPropertyChanged(); } }
|
||||
|
||||
/// <summary>The custom headers that are sent in the HTTP request.</summary>
|
||||
public Dictionary<string, string> CustomHeaders { get; set; } = new Dictionary<string, string>() {
|
||||
{ "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" },
|
||||
@@ -221,6 +225,10 @@ namespace RuriLib
|
||||
MultipartBoundary = LineParser.ParseLiteral(ref input, "BOUNDARY");
|
||||
break;
|
||||
|
||||
case "SECPROTO":
|
||||
SecurityProtocol = LineParser.ParseEnum(ref input, "Security Protocol", typeof(SecurityProtocol));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -338,6 +346,14 @@ namespace RuriLib
|
||||
.Literal($"{h.Key}: {h.Value}");
|
||||
}
|
||||
|
||||
if (SecurityProtocol != SecurityProtocol.SystemDefault)
|
||||
{
|
||||
writer
|
||||
.Indent()
|
||||
.Token("SECPROTO")
|
||||
.Token(SecurityProtocol, "SecurityProtocol");
|
||||
}
|
||||
|
||||
if (ResponseType == ResponseType.File)
|
||||
{
|
||||
writer
|
||||
@@ -358,7 +374,7 @@ namespace RuriLib
|
||||
|
||||
// Setup
|
||||
var request = new Request();
|
||||
request.Setup(data.GlobalSettings, AutoRedirect, data.ConfigSettings.MaxRedirects, AcceptEncoding);
|
||||
request.Setup(data.GlobalSettings, securityProtocol, AutoRedirect, data.ConfigSettings.MaxRedirects, AcceptEncoding);
|
||||
|
||||
var localUrl = ReplaceValues(Url, data);
|
||||
data.Log(new LogEntry($"Calling URL: {localUrl}", Colors.MediumTurquoise));
|
||||
|
||||
+41
-1
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using RuriLib.Functions.Requests;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@@ -117,4 +119,42 @@ namespace RuriLib
|
||||
return (length < value.Length) ? value.Substring(value.Length - length) : value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for SecurityProtocol enum.
|
||||
/// </summary>
|
||||
public static class SecurityProtocolExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the SecurityProtocol to an SslProtocols enum. Multiple protocols are not supported and SystemDefault is None.
|
||||
/// </summary>
|
||||
/// <param name="protocol">The SecurityProtocol</param>
|
||||
/// <returns>The converted SslProtocols.</returns>
|
||||
public static SslProtocols ToSslProtocols(this SecurityProtocol protocol)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
case SecurityProtocol.SystemDefault:
|
||||
return SslProtocols.None;
|
||||
|
||||
case SecurityProtocol.SSL2:
|
||||
return SslProtocols.Ssl2;
|
||||
|
||||
case SecurityProtocol.SSL3:
|
||||
return SslProtocols.Ssl3;
|
||||
|
||||
case SecurityProtocol.TLS10:
|
||||
return SslProtocols.Tls;
|
||||
|
||||
case SecurityProtocol.TLS11:
|
||||
return SslProtocols.Tls11;
|
||||
|
||||
case SecurityProtocol.TLS12:
|
||||
return SslProtocols.Tls12;
|
||||
|
||||
default:
|
||||
throw new Exception("Protocol not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,30 @@ using System.Windows.Media;
|
||||
|
||||
namespace RuriLib.Functions.Requests
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerates the supported security protocols.
|
||||
/// </summary>
|
||||
public enum SecurityProtocol
|
||||
{
|
||||
/// <summary>Let the operative system decide and block the unsecure protocols.</summary>
|
||||
SystemDefault,
|
||||
|
||||
/// <summary>The SSL2 protocol (obsolete).</summary>
|
||||
SSL2,
|
||||
|
||||
/// <summary>The SSL3 protocol (obsolete).</summary>
|
||||
SSL3,
|
||||
|
||||
/// <summary>The TLS 1.0 protocol (obsolete).</summary>
|
||||
TLS10,
|
||||
|
||||
/// <summary>The TLS 1.1 protocol.</summary>
|
||||
TLS11,
|
||||
|
||||
/// <summary>The TLS 1.2 protocol.</summary>
|
||||
TLS12
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides methods to easily perform Extreme.NET requests.
|
||||
/// </summary>
|
||||
@@ -42,11 +66,13 @@ namespace RuriLib.Functions.Requests
|
||||
/// Sets up the request options.
|
||||
/// </summary>
|
||||
/// <param name="settings">The RuriLib settings</param>
|
||||
/// <param name="securityProtocol">The security protocol to use</param>
|
||||
/// <param name="autoRedirect">Whether to perform automatic redirection</param>
|
||||
/// <param name="acceptEncoding"></param>
|
||||
/// <param name="maxRedirects"></param>
|
||||
/// <returns></returns>
|
||||
public Request Setup(RLSettingsViewModel settings, bool autoRedirect = true, int maxRedirects = 8, bool acceptEncoding = true)
|
||||
public Request Setup(RLSettingsViewModel settings, SecurityProtocol securityProtocol = SecurityProtocol.SystemDefault,
|
||||
bool autoRedirect = true, int maxRedirects = 8, bool acceptEncoding = true)
|
||||
{
|
||||
// Setup options
|
||||
timeout = settings.General.RequestTimeout * 1000;
|
||||
@@ -57,6 +83,7 @@ namespace RuriLib.Functions.Requests
|
||||
request.ConnectTimeout = timeout;
|
||||
request.KeepAlive = true;
|
||||
request.MaximumAutomaticRedirections = maxRedirects;
|
||||
request.SslProtocols = securityProtocol.ToSslProtocols();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user