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

Add FortiOS rootfs.gz decrypt functionality #510

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

JSCU-CNI
Copy link
Contributor

This PR adds rudimentary support for decrypting rootfs.gz files on FortiOS 7.4.1 and up.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: 89 lines in your changes are missing coverage. Please review.

Comparison is base (72774a2) 73.64% compared to head (9c64916) 73.45%.

Files Patch % Lines
...issect/target/plugins/os/unix/linux/fortios/_os.py 11.90% 74 Missing ⚠️
...ect/target/plugins/os/unix/linux/fortios/locale.py 23.07% 10 Missing ⚠️
...ct/target/plugins/os/unix/linux/fortios/generic.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #510      +/-   ##
==========================================
- Coverage   73.64%   73.45%   -0.20%     
==========================================
  Files         275      275              
  Lines       22872    22943      +71     
==========================================
+ Hits        16845    16853       +8     
- Misses       6027     6090      +63     
Flag Coverage Δ
unittests 73.45% <12.74%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Schamper
Copy link
Member

Schamper commented Jan 24, 2024

I've fixed the decryption to work with the existing pycryptodome dependency. It seems to all work alright on my end, but if you could give it a quick test-spin, this should be good to go!

Would be cool if we could dynamically extract the encryption key. I was working on some Ivanti appliances with the loop-AES encryption, which also have hardcoded keys in the kernel. I haven't looked at the FortiOS kernel yet, but the Ivanti's have a symbol pointing to the key, making recovery of it fairly trivial. Perhaps it's similar for FortiOS, or a pattern match could suffice.

Way too much work for relatively little gain, though. But perhaps fun to explore some day 😄

@pyrco
Copy link
Contributor

pyrco commented Jan 24, 2024

Would it be an idea to split this PR in 3 not-to-be-squashed commits, 1 for the robustness improvements in locale.py, 1 for the additional file locations in generic.py and 1 with the actual decrypt functionality in _os.py?

Schamper added a commit to JSCU-CNI/dissect.target that referenced this pull request Jan 24, 2024
Schamper added a commit to JSCU-CNI/dissect.target that referenced this pull request Jan 24, 2024
Schamper added a commit to JSCU-CNI/dissect.target that referenced this pull request Jan 24, 2024
Schamper added a commit to JSCU-CNI/dissect.target that referenced this pull request Jan 24, 2024
@Schamper Schamper force-pushed the feature/add-fortios-rootfs-decrypt branch from 449dc99 to 243244b Compare January 24, 2024 14:00
@Schamper Schamper force-pushed the feature/add-fortios-rootfs-decrypt branch from 243244b to 9c64916 Compare January 24, 2024 14:01
@Schamper
Copy link
Member

Would it be an idea to split this PR in 3 not-to-be-squashed commits, 1 for the robustness improvements in locale.py, 1 for the additional file locations in generic.py and 1 with the actual decrypt functionality in _os.py?

Split it over 4 to also separate the FortiManager out.

@Schamper Schamper merged commit 75739c6 into fox-it:main Jan 25, 2024
Schamper added a commit that referenced this pull request Jan 25, 2024
@JSCU-CNI JSCU-CNI deleted the feature/add-fortios-rootfs-decrypt branch February 15, 2024 12:38
Poeloe pushed a commit that referenced this pull request Feb 29, 2024
Poeloe pushed a commit that referenced this pull request Feb 29, 2024
Poeloe pushed a commit that referenced this pull request Feb 29, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
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.

3 participants