Skip to content

Commit 0b253cc

Browse files
committed
调整base64正则避免匹配太多无用结果
1 parent 8eb207c commit 0b253cc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xanalyzer/file.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def get_special_strs(self):
225225
the_file = open(self.file_path, "rb")
226226
file_content = the_file.read()
227227
the_file.close()
228-
tmp_base64_strs = re.findall(rb"[A-Za-z0-9+/]{2,}={0,2}", file_content)
228+
tmp_base64_strs = re.findall(rb"[A-Za-z0-9+/]{6,}={1,2}", file_content)
229229
possible_base64_strs = []
230230
for tmp_base64_str in tmp_base64_strs:
231231
# 过滤hex字符串
@@ -240,7 +240,10 @@ def get_special_wide_strs(self):
240240
the_file = open(self.file_path, "rb")
241241
file_content = the_file.read()
242242
the_file.close()
243-
tmp_base64_strs = re.findall(rb"(?:[A-Za-z0-9+/]\x00){2,}(?:=\x00){0,2}", file_content)
243+
tmp_base64_strs = re.findall(
244+
rb"(?:[A-Za-z0-9+/]\x00){6,}(?:=\x00){1,2}",
245+
file_content,
246+
)
244247
possible_base64_strs = []
245248
for tmp_base64_str in tmp_base64_strs:
246249
# 过滤hex字符串

0 commit comments

Comments
 (0)