Skip to content
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

Linux support #2001

Merged
merged 32 commits into from
Mar 13, 2024
Merged

Linux support #2001

merged 32 commits into from
Mar 13, 2024

Conversation

winson0123
Copy link
Contributor

Long awaited Linux support.

Description of how behavioral information is captured by Linux Machines:

  • strace is used to detonate the malware sample, and the logs are captured and uploaded to the host.
  • Strace logs are processed and outputted similarly to how the current implementation of windows behaviors are.
  • Strace information is stored onto the "behaviors" key in the CAPE report json (like how Windows would)
  • Information is fetched and retrieved from the database and is displayed on the behavioral tab
  • Behavioral tab showcases all the syscalls that are called by each process that is spawned by the sample
  • Syscalls are filtered by the root of the kernel source code (mm, fs, crypto, etc)
  • Small hiccup we've encountered running ransomware samples, it encrypts the strace log and prevents us from processing the logs for behavioral analysis

Database changes:

  • Adds the column platform to the guests table in PostgreSQL
  • Required to run alembic migrations

Future work:

  • More signaturization for Linux samples is possible

kenleejl and others added 26 commits March 7, 2024 10:41
Description:
- Sample executed via `strace` to capture api execution sequence
- Strace logs output to linux guest machine
- Filecollector to ignore strace log
- Strace logs uploaded to host
- Strace logs processed and output to CAPE report json
- removal of strace-process-tree dependencies
- removal of strace folder in analysis output folder
- changed output location of strace log files to match like behavior ("logs" folder)
- extra clean up of previous systemtap implementations
Description:
Some malware may not close file descriptors, relies on lazy cleanup.
Fix is to assume that the file descriptor is closed after running,
If encounter fd that is unclosed during processing, match the
respective filename anyway, since most likely reach near end of file
descriptor list
Previous implementation was referencing the `strace` syscall indexes in order to match the relevant syscalls and argument inputs. Turns out, this is not very reliable and causes a bug on the `open` syscall which is output by strace to be the index of 5. Upon matching with the linux syscall json, it incorrectly matches with `newfstat`. The fix to this was to just match via the same syscall name instead.
@doomedraven
Copy link
Collaborator

hello amazing job on this, i got first quick look, i will check properly a bit later. but so far looks good, i have a question, to prevent ransom encrypt logs, maybe we should stream the strace log to the server side? it sound to me that we had something for that i will have to double check

@nbargnesi
Copy link
Contributor

And well-timed with the ability to run tests against the analyzer and agent! (CC @rkoumis )

@winson0123
Copy link
Contributor Author

hello amazing job on this, i got first quick look, i will check properly a bit later. but so far looks good, i have a question, to prevent ransom encrypt logs, maybe we should stream the strace log to the server side? it sound to me that we had something for that i will have to double check

I'll probably take a look into this next week, that suggestion does sound better to circumvent the encryption issue. Probably something along the lines of piping the output on the agent and streaming to the server side.

@kevoreilly
Copy link
Owner

Thank you ❤️

@nbargnesi
Copy link
Contributor

hello amazing job on this, i got first quick look, i will check properly a bit later. but so far looks good, i have a question, to prevent ransom encrypt logs, maybe we should stream the strace log to the server side? it sound to me that we had something for that i will have to double check

I'll probably take a look into this next week, that suggestion does sound better to circumvent the encryption issue. Probably something along the lines of piping the output on the agent and streaming to the server side.

This is a great PR as-is. It'd be great to have it merge even without addressing this.

@doomedraven
Copy link
Collaborator

i have one question, is not related to fully related to this PR, but as we nuke stap, we need to remove it from the .conf maybe we should already nuke all not .conf.default as we touch already one we can delete directly it maybe as it will be overwritten anyway on install, any thoughts to help me decide the proper way?

@doomedraven doomedraven merged commit d46b28e into kevoreilly:master Mar 13, 2024
5 checks passed
@winson0123 winson0123 deleted the linux-support branch April 3, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants