Skip to content

Commit fcc1404

Browse files
committed
Fix rules for "\xXX" string
1 parent 4a6e343 commit fcc1404

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fenjing/payload_gen.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,7 @@ def gen_string_dictfirstreverse(context: dict, value: str):
30313031
def gen_string_x1(context: dict, value: str):
30323032
if any(ord(c) >= 128 for c in value):
30333033
return [(UNSATISFIED,)]
3034-
target = "".join("\\x" + hex(ord(c))[2:] for c in value)
3034+
target = "".join("\\x" + hex(ord(c))[2:].zfill(2) for c in value)
30353035
target_list = [(LITERAL, '"{}"'.format(target))]
30363036
return [(EXPRESSION, precedence["literal"], target_list)]
30373037

@@ -3040,7 +3040,7 @@ def gen_string_x1(context: dict, value: str):
30403040
def gen_string_x2(context: dict, value: str):
30413041
if any(ord(c) >= 128 for c in value):
30423042
return [(UNSATISFIED,)]
3043-
target = "".join("\\x" + hex(ord(c))[2:] for c in value)
3043+
target = "".join("\\x" + hex(ord(c))[2:].zfill(2) for c in value)
30443044
target_list = [(LITERAL, "'{}'".format(target))]
30453045
return [(EXPRESSION, precedence["literal"], target_list)]
30463046

@@ -3049,7 +3049,7 @@ def gen_string_x2(context: dict, value: str):
30493049
def gen_string_u1(context: dict, value: str):
30503050
if any(ord(c) >= 128 for c in value):
30513051
return [(UNSATISFIED,)]
3052-
target = "".join("\\u00" + hex(ord(c))[2:] for c in value)
3052+
target = "".join("\\u00" + hex(ord(c))[2:].zfill(2) for c in value)
30533053
target_list = [(LITERAL, "'{}'".format(target))]
30543054
return [(EXPRESSION, precedence["literal"], target_list)]
30553055

@@ -3058,7 +3058,7 @@ def gen_string_u1(context: dict, value: str):
30583058
def gen_string_u2(context: dict, value: str):
30593059
if any(ord(c) >= 128 for c in value):
30603060
return [(UNSATISFIED,)]
3061-
target = "".join("\\u00" + hex(ord(c))[2:] for c in value)
3061+
target = "".join("\\u00" + hex(ord(c))[2:].zfill(2) for c in value)
30623062
target_list = [(LITERAL, "'{}'".format(target))]
30633063
return [(EXPRESSION, precedence["literal"], target_list)]
30643064

@@ -3067,7 +3067,7 @@ def gen_string_u2(context: dict, value: str):
30673067
def gen_string_o1(context: dict, value: str):
30683068
if any(ord(c) >= 128 for c in value):
30693069
return [(UNSATISFIED,)]
3070-
target = "".join("\\" + oct(ord(c))[2:] for c in value)
3070+
target = "".join("\\" + oct(ord(c))[2:].zfill(2) for c in value)
30713071
target_list = [(LITERAL, "'{}'".format(target))]
30723072
return [(EXPRESSION, precedence["literal"], target_list)]
30733073

@@ -3076,7 +3076,7 @@ def gen_string_o1(context: dict, value: str):
30763076
def gen_string_o2(context: dict, value: str):
30773077
if any(ord(c) >= 128 for c in value):
30783078
return [(UNSATISFIED,)]
3079-
target = "".join("\\" + oct(ord(c))[2:] for c in value)
3079+
target = "".join("\\" + oct(ord(c))[2:].zfill(2) for c in value)
30803080
target_list = [(LITERAL, "'{}'".format(target))]
30813081
return [(EXPRESSION, precedence["literal"], target_list)]
30823082

0 commit comments

Comments
 (0)