/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("REQUEST") .Token(Method) .Literal(Url) .Boolean(AutoRedirect, "AutoRedirect") .Boolean(ReadResponseSource, "ReadResponseSource") .Boolean(ParseQuery, "ParseQuery") .Boolean(EncodeContent, "EncodeContent") .Token(RequestType, "RequestType") .Indent(); switch (RequestType) { case RequestType.BasicAuth: writer .Token("USERNAME") .Literal(AuthUser) .Token("PASSWORD") .Literal(AuthPass) .Indent(); break; case RequestType.Standard: if (!writer.CheckDefault(PostData, "PostData")) { writer .Token("CONTENT") .Literal(PostData) .Indent() .Token("CONTENTTYPE") .Literal(ContentType); } break; case RequestType.Multipart: foreach (var c in MultipartContents) { writer .Indent() .Token($"{c.Type.ToString().ToUpper()}CONTENT") .Literal($"{c.Name}: {c.Value}"); } if (!writer.CheckDefault(MultipartBoundary, "MultipartBoundary")) { writer .Indent() .Token("BOUNDARY") .Literal(MultipartBoundary); } break; } foreach (var c in CustomCookies) { writer .Indent() .Token("COOKIE") .Literal($"{c.Key}: {c.Value}"); } foreach (var h in CustomHeaders) { writer .Indent() .Token("HEADER") .Literal($"{h.Key}: {h.Value}"); } if (ResponseType == ResponseType.File) { writer .Indent() .Arrow() .Token("FILE") .Literal(DownloadPath); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("FUNCTION") .Token(FunctionType); switch (FunctionType) { case Function.Hash: writer .Token(HashType); break; case Function.HMAC: writer .Token(HashType) .Literal(HmacKey) .Boolean(HmacBase64, "HmacBase64"); break; case Function.Translate: writer .Boolean(StopAfterFirstMatch, "StopAfterFirstMatch"); foreach (var t in TranslationDictionary) { writer .Indent() .Token("KEY") .Literal(t.Key) .Token("VALUE") .Literal(t.Value); } writer .Indent(); break; case Function.DateToUnixTime: writer .Literal(DateFormat, "DateFormat"); break; case Function.Replace: writer .Literal(ReplaceWhat) .Literal(ReplaceWith) .Boolean(UseRegex, "UseRegex"); break; case Function.RegexMatch: writer .Literal(RegexMatch, "RegexMatch"); break; case Function.RandomNum: writer .Literal(RandomMin) .Literal(RandomMax) .Boolean(RandomZeroPad, "RandomZeroPad"); break; case Function.CountOccurrences: writer .Literal(StringToFind); break; case Function.CharAt: writer .Literal(CharIndex); break; case Function.Substring: writer .Literal(SubstringIndex) .Literal(SubstringLength); break; case Function.RSAEncrypt: writer .Literal(RsaN) .Literal(RsaE) .Boolean(RsaOAEP, "RsaOAEP"); break; /* * case Function.RSADecrypt: * writer * .Literal(RsaN) * .Literal(RsaD) * .Boolean(RsaOAEP, "RsaOAEP"); * break; */ case Function.GetRandomUA: if (UserAgentSpecifyBrowser) { writer .Token("BROWSER") .Token(UserAgentBrowser); } break; case Function.AESDecrypt: case Function.AESEncrypt: writer .Literal(AesKey) .Literal(AesIV) .Token(AesMode) .Token(AesPadding); break; case Function.PBKDF2PKCS5: if (KdfSalt != string.Empty) { writer.Literal(KdfSalt); } else { writer.Integer(KdfSaltSize); } writer .Integer(KdfIterations) .Integer(KdfKeySize) .Token(KdfAlgorithm); break; } writer .Literal(InputString, "InputString"); if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("FUNCTION") .Token(FunctionType); switch (FunctionType) { case Function.Hash: writer .Token(HashType); break; case Function.HMAC: writer .Token(HashType) .Literal(HmacKey) .Boolean(HmacBase64, "HmacBase64"); break; case Function.Translate: writer .Boolean(StopAfterFirstMatch, "StopAfterFirstMatch"); foreach (var t in TranslationDictionary) { writer .Indent() .Token("KEY") .Literal(t.Key) .Token("VALUE") .Literal(t.Value); } writer .Indent(); break; case Function.DateToUnixTime: writer .Literal(DateFormat, "DateFormat"); break; case Function.Replace: writer .Literal(ReplaceWhat) .Literal(ReplaceWith) .Boolean(UseRegex, "UseRegex"); break; case Function.RegexMatch: writer .Literal(RegexMatch, "RegexMatch"); break; case Function.RandomNum: writer .Integer(RandomMin) .Integer(RandomMax); break; case Function.CountOccurrences: writer .Literal(StringToFind); break; case Function.CharAt: writer .Literal(CharIndex); break; case Function.Substring: writer .Literal(SubstringIndex) .Literal(SubstringLength); break; case Function.RSA: writer .Literal(RSAMod) .Literal(RSAExp); break; } writer .Literal(InputString, "InputString"); if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
/// <inheritdoc/> public override string ToLS(bool indent = true) { BlockWriter writer = new BlockWriter(GetType(), indent, Disabled); writer.Label(Label) .Token("WS") .Token(Command); switch (Command) { case WSCommand.Connect: { writer.Literal(Url); if (Redirection) { writer.Boolean(Redirection, nameof(Redirection)); } if (EmitOnPing) { writer.Boolean(EmitOnPing, nameof(EmitOnPing)); } if (Credentials) { writer.Boolean(Credentials, nameof(Credentials)); } WriteVarOrCap(writer); if (Credentials) { writer.Indent() .Token("USERNAME") .Token(Username, nameof(Username)); writer.Indent() .Token("PASSWORD") .Token(Password, nameof(Password)); if (PreAuth) { writer.Indent() .Token("PREAUTH") .Token(PreAuth, nameof(PreAuth)); } } if (SslProtocols != SslProtocols.Default) { writer.Indent() .Token("SSLPROTO") .Token(SslProtocols, nameof(SslProtocols)); } if (Compression != CompressionMethod.None) { writer.Indent() .Token("COMPRESSION") .Token(Compression, nameof(Compression)); } foreach (var c in CustomCookies) { writer.Indent() .Token("COOKIE") .Literal($"{c.Key}: {c.Value}"); } } break; case WSCommand.Send: { writer.Literal(Message); WriteVarOrCap(writer); } break; default: WriteVarOrCap(writer); break; } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("REQUEST") .Token(Method) .Literal(Url) .Boolean(AcceptEncoding, "AcceptEncoding") .Boolean(AutoRedirect, "AutoRedirect") .Boolean(ReadResponseSource, "ReadResponseSource") .Boolean(EncodeContent, "EncodeContent") .Token(RequestType, "RequestType") .Indent(); switch (RequestType) { case RequestType.BasicAuth: writer .Token("USERNAME") .Literal(AuthUser) .Token("PASSWORD") .Literal(AuthPass) .Indent(); break; case RequestType.Standard: if (HttpRequest.CanContainRequestBody(method)) { writer .Token("CONTENT") .Literal(PostData) .Indent() .Token("CONTENTTYPE") .Literal(ContentType); } break; case RequestType.Multipart: foreach (var c in MultipartContents) { writer .Indent() .Token($"{c.Type.ToString().ToUpper()}CONTENT"); if (c.Type == MultipartContentType.String) { writer.Literal($"{c.Name}: {c.Value}"); } else if (c.Type == MultipartContentType.File) { writer.Literal($"{c.Name}: {c.Value}: {c.ContentType}"); } } if (!writer.CheckDefault(MultipartBoundary, "MultipartBoundary")) { writer .Indent() .Token("BOUNDARY") .Literal(MultipartBoundary); } break; } if (SecurityProtocol != SecurityProtocol.SystemDefault) { writer .Indent() .Token("SECPROTO") .Token(SecurityProtocol, "SecurityProtocol"); } foreach (var c in CustomCookies) { writer .Indent() .Token("COOKIE") .Literal($"{c.Key}: {c.Value}"); } foreach (var h in CustomHeaders) { writer .Indent() .Token("HEADER") .Literal($"{h.Key}: {h.Value}"); } if (ResponseType == ResponseType.File) { writer .Indent() .Arrow() .Token("FILE") .Literal(DownloadPath) .Boolean(SaveAsScreenshot, "SaveAsScreenshot"); } else if (ResponseType == ResponseType.Base64String) { writer .Indent() .Arrow() .Token("BASE64") .Literal(OutputVariable); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("UTILITY") .Token(Group); switch (Group) { case UtilityGroup.List: writer .Literal(ListName) .Token(ListAction); switch (ListAction) { case ListAction.Join: writer .Literal(Separator); break; case ListAction.Sort: writer .Boolean(Ascending, "Ascending") .Boolean(Numeric, "Numeric"); break; case ListAction.Concat: case ListAction.Zip: case ListAction.Map: writer .Literal(SecondListName); break; case ListAction.Add: writer .Literal(ListItem) .Literal(ListIndex); break; case ListAction.Remove: writer .Literal(ListIndex); break; case ListAction.RemoveValues: writer .Token(ListElementComparer) .Literal(ListComparisonTerm); break; } break; case UtilityGroup.Variable: writer .Literal(VarName) .Token(VarAction); switch (VarAction) { case VarAction.Split: writer .Literal(SplitSeparator); break; } break; case UtilityGroup.Conversion: writer .Token(ConversionFrom) .Token(ConversionTo) .Literal(InputString); break; case UtilityGroup.File: writer .Literal(FilePath) .Token(FileAction); switch (FileAction) { case FileAction.Write: case FileAction.WriteLines: case FileAction.Append: case FileAction.AppendLines: case FileAction.Copy: case FileAction.Move: writer .Literal(InputString); break; } break; case UtilityGroup.Folder: writer .Literal(FolderPath) .Token(FolderAction); break; case UtilityGroup.Telegram: writer.Token(TelegramAction) .Literal(BotToken) .Literal(ChatId); if (ParseMode != ParseMode.Default) { writer.Token(ParseMode); } foreach (var message in Messages) { writer.Indent() .Token("MESSAGE") .Literal(message); } break; } if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }