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 a decryption function to use on a local esxi target #542

Merged
merged 7 commits into from
Feb 21, 2024

Conversation

Miauwkeru
Copy link
Contributor

(DIS-2995)

@Miauwkeru Miauwkeru requested a review from Schamper February 19, 2024 10:28
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

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

Comparison is base (acdbb2b) 73.95% compared to head (282ab97) 73.98%.

Files Patch % Lines
dissect/target/plugins/os/unix/esxi/_os.py 73.33% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #542      +/-   ##
==========================================
+ Coverage   73.95%   73.98%   +0.02%     
==========================================
  Files         284      284              
  Lines       23499    23521      +22     
==========================================
+ Hits        17379    17401      +22     
  Misses       6120     6120              
Flag Coverage Δ
unittests 73.98% <73.33%> (+0.02%) ⬆️

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.

Comment on lines 245 to 252
local_tgz = BytesIO(
subprocess.run(
["crypto-util", "envelope", "extract", "--aad", "ESXConfiguration", f"/{local_tgz_ve.as_posix()}", "-"],
capture_output=True,
).stdout
)

return local_tgz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local_tgz = BytesIO(
subprocess.run(
["crypto-util", "envelope", "extract", "--aad", "ESXConfiguration", f"/{local_tgz_ve.as_posix()}", "-"],
capture_output=True,
).stdout
)
return local_tgz
result = subprocess.run(
["crypto-util", "envelope", "extract", "--aad", "ESXConfiguration", f"/{local_tgz_ve.as_posix()}", "-"],
capture_output=True,
)
return BytesIO(result.stdout)

This maybe looks a bit nicer.

target.log.warning(
"local.tgz is encrypted but static decryption failed, attempting dynamic decryption using crypto-util"
)
local_tgz = _decrypt_crypto_util(local_tgz_ve)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this fails, btw? Maybe add a case and log message for that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some checks for this specific case

@Miauwkeru Miauwkeru requested a review from Schamper February 20, 2024 10:14
Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the lint error

@Miauwkeru Miauwkeru force-pushed the DIS-2995_implement-tpm-mode-dissect branch from 2047aea to 282ab97 Compare February 20, 2024 13:47
@Miauwkeru Miauwkeru merged commit fde5578 into main Feb 21, 2024
17 of 18 checks passed
@Miauwkeru Miauwkeru deleted the DIS-2995_implement-tpm-mode-dissect branch February 21, 2024 11:42
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
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.

2 participants