예제 #1
0
        /// <inheritdoc />
        public override string ToLS(bool indent = true)
        {
            var writer = new BlockWriter(GetType(), indent, Disabled);

            writer
            .Label(Label)
            .Token("KEYCHECK")
            .Boolean(BanOn4XX, "BanOn4XX")
            .Boolean(BanOnToCheck, "BanOnToCheck");

            foreach (var kc in KeyChains)
            {
                writer
                .Indent(1)
                .Token("KEYCHAIN")
                .Token(kc.Type);

                if (kc.Type == KeyChain.KeychainType.Custom)
                {
                    writer.Literal(kc.CustomType);
                }

                writer.Token(kc.Mode);

                foreach (var k in kc.Keys)
                {
                    if (k.LeftTerm == "<SOURCE>" && k.Condition == Condition.Contains)
                    {
                        writer
                        .Indent(2)
                        .Token("KEY")
                        .Literal(k.RightTerm);
                    }
                    else
                    {
                        writer
                        .Indent(2)
                        .Token("KEY")
                        .Literal(k.LeftTerm)
                        .Token(k.Condition);

                        if (k.Condition != Condition.Exists)
                        {
                            writer.Literal(k.RightTerm);
                        }
                    }
                }
            }

            return(writer.ToString());
        }
예제 #2
0
        /// <inheritdoc />
        public override string ToLS(bool indent = true)
        {
            var writer = new BlockWriter(GetType(), indent, Disabled);

            writer
            .Label(Label)
            .Token("BYPASSCF")
            .Literal(Url)
            .Literal(UserAgent, nameof(UserAgent));

            if (SecurityProtocol != SecurityProtocol.SystemDefault)
            {
                writer
                .Token("SECPROTO")
                .Token(SecurityProtocol);
            }

            writer
            .Boolean(PrintResponseInfo, nameof(PrintResponseInfo))
            .Boolean(AutoRedirect, nameof(AutoRedirect));
            return(writer.ToString());
        }
예제 #3
0
        /// <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());
        }
예제 #4
0
        /// <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;
            }

            if (!writer.CheckDefault(VariableName, "VariableName"))
            {
                writer
                .Arrow()
                .Token(IsCapture ? "CAP" : "VAR")
                .Literal(VariableName);
            }

            return(writer.ToString());
        }
예제 #5
0
        /// <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());
        }
예제 #6
0
        /// <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")
                .Boolean(KeyBase64, "KeyBase64");
                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.UnixTimeToDate:
            case Function.DateToUnixTime:
                writer
                .Literal(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.RSAPKCS1PAD2:
                writer
                .Literal(RsaN)
                .Literal(RsaE);
                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());
        }
예제 #7
0
        /// <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;

            case RequestType.Raw:
                if (HttpRequest.CanContainRequestBody(method))
                {
                    writer
                    .Token("RAWDATA")
                    .Literal(RawData)
                    .Indent()
                    .Token("CONTENTTYPE")
                    .Literal(ContentType);
                }
                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());
        }