dissect.target.tools.shell
#
Module Contents#
Classes#
Subclassed cmd.Cmd to provide some additional features. |
|
Hub Cli for interacting with multiple targets. |
|
Cli for interacting with a target. |
|
Cli for browsing the registry. |
Functions#
Parse the LS_COLORS environment variable so we can use it later. |
|
Helper method to colorize strings according to LS_COLORS. |
|
Generator context manager that chains piped subprocessess and |
|
Generator context manager that chains piped subprocessess, with a chain's |
|
Helper method for generating a mode string from a numerical mode value. |
|
Helper method for starting a TargetCli or TargetHubCli for one or multiple targets. |
|
Helper method for starting a (I)Python shell with multiple targets. |
|
Helper method for running a cmd.Cmd cli. |
|
Attributes#
- dissect.target.tools.shell.log#
- dissect.target.tools.shell.STAT_TEMPLATE = Multiline-String#
Show Value
""" File: {path} Size: {size} {filetype} Inode: {inode} Links: {nlink} Access: ({modeord}/{modestr}) Uid: ( {uid} ) Gid: ( {gid} ) Access: {atime} Modify: {mtime} Change: {ctime}"""
- dissect.target.tools.shell.prepare_ls_colors()#
Parse the LS_COLORS environment variable so we can use it later.
- dissect.target.tools.shell.LS_COLORS#
- class dissect.target.tools.shell.TargetCmd(target)#
Bases:
cmd.Cmd
Subclassed cmd.Cmd to provide some additional features.
- Add new simple commands by implementing:
do_<cmd>(self, line)
- Add new complex commands by implementing:
cmd_<cmd>(self, args, stdout)
Simple commands are plain cmd.Cmd commands. Output is generally presented using print().
Complex command allow @arg decorators for argparse argument parsing. Additionally, complex commands allow their output to be piped to external commands. Complex commands should therefor always write to the stdout handle that is passed as argument.
- CMD_PREFIX = 'cmd_'#
- static check_compatible(target)#
- do_exit(line)#
exit shell
- get_names()#
- default(line)#
Called on an input line when the command prefix is not recognized.
If this method is not overridden, it prints an error message and returns.
- __getattr__(attr)#
- class dissect.target.tools.shell.TargetHubCli(targets, cli)#
Bases:
cmd.Cmd
Hub Cli for interacting with multiple targets.
- prompt = 'dissect> '#
- doc_header = Multiline-String#
Show Value
"""Target Hub ========== List and enter targets by using 'list' and 'enter'. Documented commands (type help <topic>):"""
- default(line)#
Called on an input line when the command prefix is not recognized.
If this method is not overridden, it prints an error message and returns.
- do_exit(line)#
exit shell
- do_list(line)#
list the loaded targets
- do_enter(line)#
enter a target by number or name
- complete_enter(text, line, begidx, endidx)#
- do_python(line)#
drop into a Python shell
- class dissect.target.tools.shell.TargetCli(target)#
Bases:
TargetCmd
Cli for interacting with a target.
- property prompt#
- completedefault(text, line, begidx, endidx)#
Method called to complete an input line when no command-specific complete_*() method is available.
By default, it returns an empty list.
- resolvepath(path)#
- resolveglobpath(path)#
- checkfile(path)#
- checkdir(path)#
- chdir(path)#
Change directory to the given path
- scandir(path, color=False)#
List a directory for the given path
- do_cd(line)#
change directory
- do_pwd(line)#
print current directory
- do_disks(line)#
print target disks
- do_volumes(line)#
print target volumes
- do_filesystems(line)#
print target filesystems
- do_info(line)#
print target information
- cmd_ls(args, stdout)#
list directory contents
- print_extensive_file_stat(stdout, target_path: dissect.target.helpers.fsutil.TargetPath, name: str) None #
Print the file status.
- cmd_find(args, stdout)#
search for files in a directory hierarchy
- cmd_stat(args, stdout)#
display file status
- cmd_file(args, stdout)#
determine file type
- cmd_save(args, stdout)#
save a common file or directory to the host filesystem
- cmd_cat(args, stdout)#
print file content
- cmd_hexdump(args, stdout)#
print a hexdump of the first X bytes
- cmd_hash(args, stdout)#
print the MD5, SHA1 and SHA256 hashes of a file
- cmd_less(args, stdout)#
open the first 10 MB of a file with less
- cmd_readlink(args, stdout)#
print resolved symbolic links or canonical file names
- cmd_registry(args, stdout)#
drop into a registry shell
- do_python(line)#
drop into a Python shell
- do_clear(line)#
clears the terminal screen
- class dissect.target.tools.shell.RegistryCli(target, registry=None)#
Bases:
TargetCmd
Cli for browsing the registry.
- property prompt#
- static check_compatible(target)#
- completedefault(text, line, begidx, endidx)#
Method called to complete an input line when no command-specific complete_*() method is available.
By default, it returns an empty list.
- resolvekey(path)#
- checkkey(path)#
- checkvalue(path)#
- chdir(path)#
- scandir(path, color=False)#
- do_cd(line)#
change subkey
- do_up(line)#
go up a subkey
- do_pwd(line)#
print current path
- do_recommend(line)#
recommend a key
- cmd_ls(args, stdout)#
- cmd_cat(args, stdout)#
- do_clear(line)#
Clears the terminal screen
- dissect.target.tools.shell.fmt_ls_colors(ft, name)#
Helper method to colorize strings according to LS_COLORS.
- dissect.target.tools.shell.build_pipe(pipe_parts, pipe_stdout=subprocess.PIPE)#
Generator context manager that chains piped subprocessess and returns a tuple (chain input stream, chain output stream).
On context exit the generator will close the input stream and wait for the subprocessess to finish.
- dissect.target.tools.shell.build_pipe_stdout(pipe_parts)#
Generator context manager that chains piped subprocessess, with a chain’s outgoing stream configured to be parent’s stdout.
Generator returns a chain’s input stream from build_pipe generator.
- dissect.target.tools.shell.stat_modestr(st)#
Helper method for generating a mode string from a numerical mode value.
- dissect.target.tools.shell.target_shell(targets, cli)#
Helper method for starting a TargetCli or TargetHubCli for one or multiple targets.
- dissect.target.tools.shell.python_shell(targets)#
Helper method for starting a (I)Python shell with multiple targets.
- dissect.target.tools.shell.run_cli(cli)#
Helper method for running a cmd.Cmd cli.
Loops cli.cmdloop(), skipping KeyboardInterrupts. This is done so that ctrl+c doesn’t exit the shell but only resets the current line.
- dissect.target.tools.shell.main()#