Skip to content

Commit

Permalink
调整base64正则避免匹配太多无用结果
Browse files Browse the repository at this point in the history
  • Loading branch information
qux-bbb committed Apr 8, 2024
1 parent 8eb207c commit 0b253cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xanalyzer/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def get_special_strs(self):
the_file = open(self.file_path, "rb")
file_content = the_file.read()
the_file.close()
tmp_base64_strs = re.findall(rb"[A-Za-z0-9+/]{2,}={0,2}", file_content)
tmp_base64_strs = re.findall(rb"[A-Za-z0-9+/]{6,}={1,2}", file_content)
possible_base64_strs = []
for tmp_base64_str in tmp_base64_strs:
# 过滤hex字符串
Expand All @@ -240,7 +240,10 @@ def get_special_wide_strs(self):
the_file = open(self.file_path, "rb")
file_content = the_file.read()
the_file.close()
tmp_base64_strs = re.findall(rb"(?:[A-Za-z0-9+/]\x00){2,}(?:=\x00){0,2}", file_content)
tmp_base64_strs = re.findall(
rb"(?:[A-Za-z0-9+/]\x00){6,}(?:=\x00){1,2}",
file_content,
)
possible_base64_strs = []
for tmp_base64_str in tmp_base64_strs:
# 过滤hex字符串
Expand Down

0 comments on commit 0b253cc

Please sign in to comment.