Skip to content

Commit c51d4d4

Browse files
committed
Only generate string variable in accurate mode
1 parent d90a967 commit c51d4d4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fenjing/full_payload_gen.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ContextVariableUtil,
1313
)
1414
from .const import (
15+
DETECT_MODE_FAST,
1516
CALLBACK_PREPARE_FULLPAYLOADGEN,
1617
CALLBACK_GENERATE_FULLPAYLOAD,
1718
STRING,
@@ -299,7 +300,6 @@ def prepare_extra_context_vars(self, append_targets: Union[List, None] = None):
299300
continue
300301
self.added_extra_context_vars.add(target)
301302

302-
303303
def add_context_variable(
304304
self,
305305
payload: str,
@@ -352,13 +352,15 @@ def generate_with_tree(
352352
assert self.payload_gen is not None, "when prepared, we should have payload_gen"
353353
assert isinstance(self.outer_pattern, str)
354354

355-
# 添加一系列值为字符串的变量,需要从生成目标中取出需要生成的字符串
356-
extra_strings = []
357-
if gen_type == OS_POPEN_READ:
358-
extra_strings = [args[0]]
359-
elif gen_type == EVAL and args[0][0] == STRING:
360-
extra_strings = [args[0][1]]
361-
self.prepare_extra_context_vars(extra_strings)
355+
# 在生成模式不是快速时生成一系列的字符串变量以减少嵌套括号
356+
if self.options != DETECT_MODE_FAST:
357+
# 添加一系列值为字符串的变量,需要从生成目标中取出需要生成的字符串
358+
extra_strings = []
359+
if gen_type == OS_POPEN_READ:
360+
extra_strings = [args[0]]
361+
elif gen_type == EVAL and args[0][0] == STRING:
362+
extra_strings = [args[0][1]]
363+
self.prepare_extra_context_vars(extra_strings)
362364

363365
logger.info("Start generating final expression...")
364366

0 commit comments

Comments
 (0)