Skip to content

Commit ce0bb00

Browse files
author
patched.codes[bot]
committed
Patched: "/tmp/tmpqik896dk/modules/leak_detector/leak_detector.py"
1 parent a1911f4 commit ce0bb00

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/leak_detector/leak_detector.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from slips_files.common.imports import *
2+
import shlex
23
import sys
34
import base64
45
import time
@@ -247,23 +248,22 @@ def delete_compiled_rules(self):
247248
"""
248249
shutil.rmtree(self.compiled_yara_rules_path)
249250
os.mkdir(self.compiled_yara_rules_path)
250-
251+
251252
def find_matches(self):
252253
"""Run yara rules on the given pcap and find matches"""
253254
for compiled_rule in os.listdir(self.compiled_yara_rules_path):
254255
compiled_rule_path = os.path.join(self.compiled_yara_rules_path, compiled_rule)
255256
# -p 7 means use 7 threads for faster analysis
256257
# -f to stop searching for strings when they were already found
257258
# -s prints the found string
258-
cmd = f'yara -C {compiled_rule_path} "{self.pcap}" -p 7 -f -s '
259+
cmd = ['yara', '-C', compiled_rule_path, self.pcap, '-p', '7', '-f', '-s']
259260
yara_proc = subprocess.Popen(
260261
cmd,
261262
stdout=subprocess.PIPE,
262263
stderr=subprocess.PIPE,
263-
stdin=subprocess.PIPE,
264-
shell=True
264+
stdin=subprocess.PIPE
265265
)
266-
266+
267267
lines, error = yara_proc.communicate()
268268
lines = lines.decode()
269269
if error:
@@ -272,13 +272,13 @@ def find_matches(self):
272272
# will re-compile and save rules again and try to find matches
273273
self.run()
274274
else:
275-
self.print (f"YARA error {yara_proc.returncode}: {error.strip()}")
275+
self.print(f"YARA error {yara_proc.returncode}: {error.strip()}")
276276
return
277-
277+
278278
if not lines:
279279
# no match
280280
return
281-
281+
282282
lines = lines.splitlines()
283283
matching_rule = lines[0].split()[0]
284284
# each match (line) should be a separate detection(yara match)

0 commit comments

Comments
 (0)