-
Notifications
You must be signed in to change notification settings - Fork 579
process_spoofing plugin #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
process_spoofing plugin #1826
Conversation
|
68b51e8
to
5e654b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your submission and sorry it took so long to find time to review, this plugin looks fun! It's mostly fine, but it smushes the results together into a string, which is longwinded for humans to read and difficult for programs/plugins to parse. Hopefully this should be pretty straight forward to refactor into returning boolean values. It also feels like as number of the methods here may be useful for other plugins, so first check that other plugins don't already implement them and otherwise consider converting them into classmethods so that they can be called externally...
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
return None | ||
|
||
try: | ||
argv = proc_layer.read(start, size_to_read) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd check to see if existing argument handling isn't done somewhere else (either in another plugin or a task structure). It seems like it might be more useful exposed that way, just to avoid people rewriting it themselves each time and possibly making slight parsing differences each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ikelos want me to use psaux.PsAux._get_command_line_args
? its not directly exposed as an external function but maybe I can refactor it. also in general I think its better that useful methods are exposed through a dedicated utilities class instead of other plugins?
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
1 for name in [exe_basename, cmdline_basename, comm] if name | ||
) | ||
|
||
is_deleted = exe_basename.endswith(self.deleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a good way of identifying this, it should be a separate boolean flag handed around. Stuffing it on the end of a string and then parsing it back out again feels very brittle. I'd make each of your three methods return a tuple (basename, deleted)
and then process those, the other two methods can return None but you really should be loading up the basename, and certainly not at the end, because then you can't tell the difference between random file
that's been deleted and random file (deleted)
, within your code the two are indistinguishable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, also I'd rather it depend on my other PR for the linuxutilities function instead of reusing the code here... I'm not sure about a boolean flag and also many gnu-utils already do that (appending (deleted) to a path).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored it now, tell me what you think and if we should also implement it in my lsof PR?
notes.append(f"'Potential Process image deletion: exe_file={exe_basename}'") | ||
exe_basename = exe_basename[: len(self.deleted) * -1] | ||
|
||
if available_sources < 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely you'd want to highlight that the file was only present in one source? Seems like a sure fire sign that something unusual happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernel threads dont have mm_struct
, that means no cmdline and exe_file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose kernel threads can be "flagged" in the output as such?
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
volatility3/framework/plugins/linux/malware/process_spoofing.py
Outdated
Show resolved
Hide resolved
9b8f701
to
b7a1bec
Compare
|
Hello, just playing with memory & OS internals.
apparently some legitimate processes do these techniques to have enriched information in their cmdline or so. here are some such processes: