-
Notifications
You must be signed in to change notification settings - Fork 51
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
Refactor target-shell #812
Merged
Schamper
merged 24 commits into
fox-it:main
from
JSCU-CNI:improvement/target-shell-fs-refactor
Aug 14, 2024
Merged
Refactor target-shell #812
Schamper
merged 24 commits into
fox-it:main
from
JSCU-CNI:improvement/target-shell-fs-refactor
Aug 14, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Functional changes: * Target-shell ls supports -h flag * Target-fs ls now outputs with color when printing to terminal
This allows CLI tools to re-use cmd extensions that TargetCli had, without needing to have a target. Should introduce no functional changes.
Schamper
requested changes
Aug 8, 2024
Schamper
requested changes
Aug 8, 2024
Co-authored-by: Erik Schamper <[email protected]>
* adds `@alias` decorator for Plugin functions and cmd.Cmd functions * makes .targetcfg.py read from $HOME * adds fs block and blocksize to stat output * adds .dissect_history to CommandHistoryPlugin (meta) * fixes UTC and microseconds output inconsistencies in stat, ls and info output * fixes spacing output differences in cmd_ls * fixes autocomplete for files starting with { * adds command usage help to help output * adds PS1 config support to TargetCli * adds ANSI colors to default PS1 prompt * adds autocomplete for aliased cmd's * adds `man` cmd as alias to `help` * adds `cls` cmd as alias to `clear` * adds `l` and `ll` as alias to `ls` * adds `tree` as alias to `ls -R` * adds macb flags to `find` * make `attr` cmd more robust * adds `type` as alias to `cat` * adds `xxd` as alias to `hexdump` * adds length, skip and hex args to `hexdump` * adds `digest` and `shasum` aliases to `hash` * adds `head` and `more` as aliases to `less` * adds `cd ..` as alias to `up` * adds simple `hexdump` and `xxd` to RegistryCli * fix writing to history file when command failed * add version flag to target-shell
Schamper
requested changes
Aug 12, 2024
JSCU-CNI
changed the title
Move re-usable functions out of TargetCli
Refactor target-shell
Aug 12, 2024
Schamper
requested changes
Aug 12, 2024
Removes the need for a tuple return with a 'handled' variable.
Schamper
requested changes
Aug 12, 2024
Schamper
requested changes
Aug 12, 2024
Co-authored-by: Erik Schamper <[email protected]>
Co-authored-by: Erik Schamper <[email protected]>
Is this PR good to go? :) |
Schamper
approved these changes
Aug 14, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #812 +/- ##
==========================================
- Coverage 75.56% 75.39% -0.17%
==========================================
Files 299 300 +1
Lines 25783 26023 +240
==========================================
+ Hits 19482 19620 +138
- Misses 6301 6403 +102
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This was referenced Aug 14, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains a
target-shell
refactor as discussed in #664.We've tried to break the refactor into separate commits:
4d7e0c7 Moves some functions outside of the
TargetCli
class so they can be used elsewhere.Such as in target-fs and hopefully target-diff at a later point in time. Functionally it changes two things:
target-fs ls
now prints with colors when outputting to a tty, andtarget-shell ls
now supports human-readable file sizes. This closes Add human readable format to target-shell ls #624.7a45275 Introduces the
ExtendedCmd
class.Moves some shell-interactivity functionality outside of the
TargetCli
class so it can be re-used (as we intend to do in Add target-diff #664).4cacdc7 Add trailing slash to directories when auto completing.
A small quality of life improvement where autocomplete in target-shell now adds a trailing slash to directories. This way, when pressing tab again, you'll get suggestions for that folder.
8153fee Add stat function to target-fs
Is a quick win, implementing the stat command from target-shell. There is potential to transfer even more functionality from target-shell to a shared utils file so it can be reused in target-fs (The
walk
command comes to mind).2ed01b9 Fix opening tar and zip files inside target-shell using
enter
Previously this worked but has been broken since the velociraptor plugin tries to load zip files using
os
.b7f6765 UI/UX improvements to target-shell
We added
@alias
decorators forcmd.Cmd
functions and generally improved most of the target-shell functions. We also addedPS1
support as can be seen in the screenshots below.Overview of all commands and aliases:
Default PS1 prompt colors:
Or if you want you could customize it in a
.targetcfg.py
file:for those interested in the uwu config:
PS1="\x1b[1;35m{base}\x1b[1;36m{cwd}\x1b[0m (ノ^ヮ^)ノ✨ "