Skip to content

Commit f7f834f

Browse files
authored
Merge pull request kevoreilly#2898 from kevoreilly/DroppedPidFix
Fix issue with missing pids in dropped, moved & deleted files (kevoreilly#2823)
2 parents efa74ac + ef34dd5 commit f7f834f

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

analyzer/windows/analyzer.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,10 +1408,11 @@ def _handle_process2(self, data):
14081408

14091409
return self._inject_process(int(pid), int(tid), int(mode))
14101410

1411-
def _handle_file_new(self, file_path):
1411+
def _handle_file_new(self, data):
14121412
"""Notification of a new dropped file."""
1413-
if os.path.exists(file_path):
1414-
self.analyzer.files.add_file(file_path.decode(), self.pid)
1413+
pid, file_path = data.split(b",", 1)
1414+
if os.path.exists(file_path.decode()):
1415+
self.analyzer.files.add_file(file_path.decode(), pid.decode())
14151416

14161417
def _handle_file_cape(self, data):
14171418
"""Notification of a new dropped file."""
@@ -1432,9 +1433,9 @@ def _handle_file_cape(self, data):
14321433
def _handle_file_del(self, data):
14331434
"""Notification of a file being removed (if it exists) - we have to
14341435
dump it before it's being removed."""
1435-
file_path = data.decode()
1436-
if os.path.exists(file_path):
1437-
self.analyzer.files.delete_file(file_path, self.pid)
1436+
pid, file_path = data.split(b",", 1)
1437+
if os.path.exists(file_path.decode()):
1438+
self.analyzer.files.delete_file(file_path.decode(), pid.decode())
14381439

14391440
def _handle_file_dump(self, file_path):
14401441
# We extract the file path.
@@ -1492,19 +1493,15 @@ def _handle_file_move(self, data):
14921493
if b"::" not in data:
14931494
log.warning("Received FILE_MOVE command from monitor with an incorrect argument")
14941495
return
1495-
1496-
old_filepath, new_filepath = data.split(b"::", 1)
1497-
new_filepath = new_filepath.decode()
1498-
self.analyzer.files.move_file(old_filepath.decode(), new_filepath, self.pid)
1496+
pid, paths = data.split(b",", 1)
1497+
old_filepath, new_filepath = paths.split(b"::", 1)
1498+
self.analyzer.files.move_file(old_filepath.decode(), new_filepath.decode(), pid.decode())
14991499

15001500
def dispatch(self, data):
15011501
response = "NOPE"
15021502
if not data or b":" not in data:
15031503
log.critical("Unknown command received from the monitor: %s", data.strip())
15041504
else:
1505-
# Backwards compatibility (old syntax is, e.g., "FILE_NEW:" vs the
1506-
# new syntax, e.g., "1234:FILE_NEW:").
1507-
# if data[0].isupper():
15081505
command, arguments = data.strip().split(b":", 1)
15091506
# Uncomment to debug monitor commands
15101507
# if command not in (b"DEBUG", b"INFO"):

analyzer/windows/dll/capemon.dll

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)