
    *1fm                     (   d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZmZmZmZmZ ddlmZmZ ddlmZ ddlZddlZddlmZ ddlmZmZ ddlmZmZmZm Z m!Z!m"Z"m#Z# dd	l$m%Z% dd
l&m'Z'  ej(                    Z) ej(        e*          Z+ ej,                    Z-e-.                    ej/                    ej0        d          Z1e-2                    e1            G d de3          Z4 G d de4          Z5 G d d          Z6d Z7dS )aX  A CommandLine User Interface for the volatility framework.

User interfaces make use of the framework to:
 * determine available plugins
 * request necessary information for those plugins from the user
 * determine what "automagic" modules will be used to populate information the user does not provide
 * run the plugin
 * display the results
    N)AnyDictListTupleTypeUnion)parserequest)text_filter)	framework)text_renderervolargparse)	automagicconfiguration	constantscontexts
exceptions
interfacesplugins)stacker)requirementsz(%(levelname)-8s %(name)-12s: %(message)sc                   :    e Zd ZdZd Zddeeef         defdZ	dS )PrintedProgressz`A progress handler that prints the progress value and the description
    onto the command line.c                     d| _         d S Nr   )_max_message_lenselfs    J/home/panchajanya/Development/work/volatility3/volatility3/cli/__init__.py__init__zPrintedProgress.__init__9   s     !    Nprogressdescriptionc                     dt          |d          dd|pd }t          |          }t          | j        |g          | _        t          j                            |d| j        |z
  z  z   dz              dS )	zA simple function for providing text-based feedback.

        .. warning:: Only for development use.

        Args:
            progress: Percentage of progress of the current procedure
        zProgress:    z 7.2fz		  N)roundlenmaxr   sysstderrwrite)r   r"   r#   messagemessage_lens        r   __call__zPrintedProgress.__call__<   s     Sx!3!3RRR{?PbRR'll #T%:K$H I I
C4+@;+N$OPSWWXXXXXr!   N)
__name__
__module____qualname____doc__r    r   intfloatstrr1    r!   r   r   r   5   sf         " " "Y YsEz!2 Y Y Y Y Y Y Yr!   r   c                   4    e Zd ZdZddeeef         defdZdS )MuteProgressz=A dummy progress handler that produces no output when called.Nr"   r#   c                     d S r2   r:   )r   r"   r#   s      r   r1   zMuteProgress.__call__M   s    r!   r2   )	r3   r4   r5   r6   r   r7   r8   r9   r1   r:   r!   r   r<   r<   J   sJ        GG sEz!2       r!   r<   c            
       |   e Zd ZdZdZd Zed             Zd Zede	de	fd            Z
de	deeeee	f                  ee	ef         f         fd	Zd
 Zd Zdej        j        dee	eej        j                 f         dej        de	ddf
dZd ZddZdeej        ej         f         deej        j                 fdZ!dS )CommandLinezDConstructs a command-line interface object for users to run plugins.
volatilityc                 <    |                                   d | _        d S r2   )setup_logging
output_dirr   s    r   r    zCommandLine.__init__V   s    r!   c                 x    t                               d           t                               t                     d S )N   )rootlogsetLevel
addHandlerconsole)clss    r   rB   zCommandLine.setup_loggingZ   s2     	7#####r!   c                    t           j                            ddd           t          d t          j        t
          j                  D                       }|                     d          \  }}t          j	        d| j
        d          }|                    dd	d
t          j        d                    |j                             |                    ddddt                      |                    dddg dddt                      |                    ddddd           |                    dddd t                      |                    d!d"d#d t                      |                    d$d%d&dd'           |                    d(d)d*dt                      |                    d+d,d-t#          j                    t                      |                    d.d/d0dd1           |                    d2d3d4d5d6                    t)          |                     d7d8t)          |          9           |                    d:d;d<dt           d=>           |                    d?d@dd1           |                    dAdBdt                      |                    dCdDdd1           |                    dEdFt*          j         dGt*          j        t                      |                    dHdIdd1           |                    dJdKg d            |j        dui | dL t0          j        D             }|                    |          \  }}t0          j        }||j                 j        rt0          j        }|                    dMt*          j          dN           |j!        rtE          j#        |j!                  }	|	$                    dO           tE          j%        dPdQR          }
|	&                    |
           tN          (                    |	           tR          *                    dS           | +                                 |j,        dTk     rG|j,        dOk     rdt0          _-        t\          $                    tD          j/        |j,        dUz  z
             n/t\          $                    tD          j0        |j,        dz
  z
             |D ] \  }}tR          !                    ||           !|j1        r@dV |j1        2                    dW          D             t*          j3        z   t           j4        _5        |j6        r@dX |j6        2                    dW          D             t*          j7        z   t           j8        _5        |j9        r|j9        t*          _        tR          *                    dYt           j4        j5                    tR          *                    dZt           j8        j5                    |j:        dk    rt*          j;        j<        t*          _=        nB|j:        d[k    rt*          j;        j>        t*          _=        nt*          j;        j?        t*          _=        |j@        rt          j@                     |jA        r|jA        t*          _B        t          jD                    }t          jE        t           j4        d\          }|rId]d6                    t          |                    z   |_G        tR          *                    |jG                   t          jI        |          }t          jJ                    }t                      }i }|D ]V}||v r|L                    |           t          |t          jO        jP                  r| Q                    ||jR                   W|S                    d^d_d`                    | j
                  t          jT        a          }t          |          D ]@}|U                    |||         jV        b          }| Q                    |||                    A|W                                }|jX        |Y                    dc           tR          !                    t*          jZ        ddt*          j                    ||jX                 }|||jX        <   de}t          jO        [                    ||j\                  }|j]        ri	 t          j_        `                    |j]                  }||ja        df<   n9# t          $ r,}|Y                    t!          |                     Y d}~nd}~ww xY w|ja        ryt          |ja        dg          5 }t          je        |          }|ja        f                    |t          jO        g                    |                     ddd           n# 1 swxY w Y   t          jh        ||          }|D ]}|||jR        j\        <   |ja        i                    dhd          t          jk        |          |ja        dh<   |jl        | _l        t"          jm        n                    | jl                  s|Y                    di| jl                    | o                    ||||           |jp        rv|jp        D ]n}dj|vrt          dk          |d|q                    dj                   t          jr        ||q                    dj          dOz   d                   } }| |ja        |<   od}!	 t                      }"|jt        rt                      }"ti          jv        |||||"| w                                          }!|jx        r!tR          y                    dl           dm|_z        |jz        rtR          {                    dn           t"          jm        n                    t"          jm        |                    |jz                            r|Y                    do|jz         dp           t          |jz        dq          5 }t          j}        t          |!~                                          |d\dr           |                    dN           ddd           n# 1 swxY w Y   nZ# t          j        $ rH}|                     |           |                    dOdsdt |j        D              dN           Y d}~nd}~ww xY w	 |!r`|!                                }# ||j                             }$t          j        |#|j                  |$_        |$                    |#           dS dS # t          j        $ r }|                     |           Y d}~dS d}~ww xY w)vzyExecutes the command line module, taking the system arguments,
        determining the plugin to run and then running it.r%   r   c                 D    g | ]}|j                                         |fS r:   )namelower.0xs     r   
<listcomp>z#CommandLine.run.<locals>.<listcomp>g   s7        #  r!   zvol.jsonFz)An open-source memory forensics framework)add_helpprogr#   -h--helphelpzYShow this help message and exit, for specific plugin options use '{} <pluginname> --help')actiondefaultrW   z-cz--configz'Load the configuration from a json fileN)rW   rY   typez--parallelismz:Enables parallelism (defaults to off if no argument given)?)	processesthreadsoffr\   )rW   nargschoicesconstrY   rZ   z-ez--extendz8Extend the configuration with a new (or changed) settingappend)rW   rY   rX   z-pz--plugin-dirsz2Semi-colon separated list of paths to find pluginsr&   z-sz--symbol-dirsz2Semi-colon separated list of paths to find symbolsz-vz--verbosityzIncrease output verbositycountz-lz--logz+Log output to a file as well as the consolez-oz--output-dirz0Directory in which to output any generated filesz-qz--quietzRemove progress feedback
store_truez-rz
--rendererRENDERERz%Determines how to render the output (z, )quick)metavarrW   rY   r`   z-fz--fileFILEzIShorthand for --single-location=file:// if single-location is not defined)rh   rY   rZ   rW   z--write-configz0Write configuration JSON file out to config.jsonz--save-configz&Save configuration JSON file to a filez--clear-cachez&Clears out all short-term cached itemsz--cache-pathzChange the default path (z) used to store the cachez	--offlinez.Do not search online for additional JSON filesz	--filterszPList of filters to apply to the output (in the form of [+-]columname,pattern[!])c                 *    g | ]}|d k    |dk    |S )rV   rU   r:   )rP   args     r   rR   z#CommandLine.run.<locals>.<listcomp>   s%    QQQcSD[[c[[[r!   zVolatility 3 Framework 
rE   z%y-%m-%d %H:%M:%Sz3%(asctime)s %(name)-12s %(levelname)-8s %(message)s)datefmtfmtzLogging started   
   c                 L    g | ]!}t           j                            |          "S r:   ospathabspathrP   ps     r   rR   z#CommandLine.run.<locals>.<listcomp>  3     , , ,'("", , ,r!   ;c                 L    g | ]!}t           j                            |          "S r:   rr   rv   s     r   rR   z#CommandLine.run.<locals>.<listcomp>  rx   r!   zVolatility plugins path: zVolatility symbols path: r]   Tz@The following plugins could not be loaded (use -vv to see why): Pluginspluginz5For plugin specific options, run '{} <plugin> --help')titledestr#   rX   )rW   zPlease select a plugin to runzCache directory used: r   z&automagic.LayerStacker.single_locationrzautomagic.LayerStacker.stackersz/The output directory specified does not exist: =zNInvalid extension (extensions must be of the format "conf.path.value='value'")zOUse of --write-config has been deprecated, replaced by --save-config <filename>zconfig.jsonz4Writing out configuration data to {args.save_config}z!Cannot write configuration: file z already existsw)	sort_keysindentz,Unable to validate the plugin requirements: c                     g | ]}|S r:   r:   rO   s     r   rR   z#CommandLine.run.<locals>.<listcomp>  s    ?\?\?\a?\?\?\r!   r:   )volatility3r   require_interface_versiondictclass_subclassesr   CLIRendererload_system_defaultsr   HelpfulArgParserCLI_NAMEadd_argumentargparseSUPPRESSformatrT   r9   rs   getcwdjoinlistr   
CACHE_PATHset_defaultsr,   argvparse_known_argsstdoutrendererstructured_outputr-   r.   PACKAGE_VERSIONlogloggingFileHandlerrG   	FormattersetFormatterrF   rH   volloginfoorder_extra_verbose_levels	verbositytracebacklimitrI   WARNINGDEBUGplugin_dirssplitPLUGINS_PATHr   __path__symbol_dirsSYMBOL_BASEPATHSsymbols
cache_pathparallelismParallelismMultiprocessingPARALLELISM	ThreadingOffclear_cacheofflineOFFLINEr   Contextimport_filessortedepilogr   	availablelist_pluginssetadd
isinstancer   r   ConfigurableInterfacepopulate_requirements_argparse	__class__add_subparsersHelpfulSubparserAction
add_parserr6   
parse_argsr|   errorLOGLEVEL_VVV	path_joinr3   filer   URIRequirementlocation_from_fileconfig
ValueErroropenjsonloadspliceHierarchicalDictchoose_automagicgetr   choose_os_stackersrC   rt   existspopulate_configextendfindloadsr   quietr<   construct_pluginfile_handler_class_factorywrite_configwarningsave_configdebugru   dumpbuild_configurationr   UnsatisfiedExceptionprocess_unsatisfied_exceptionsexitunsatisfiedrunr   	CLIFilterfiltersfilterrenderVolatilityExceptionprocess_exceptions)%r   	renderersdelayed_logsdefault_configparser
known_argspartial_args_banner_outputfile_loggerfile_formatterlevelmsgctxfailures
automagicsplugin_listseen_automagicschosen_configurables_listamagic	subparserr|   plugin_parserargsbase_config_pathplugin_config_pathsingle_locationexcpfjson_val	extensionaddressvalueconstructedprogress_callbackgridr   s%                                        r   r   zCommandLine.run`   s    	771a@@@ "3M4MNN  
 
	 (,'@'@'L'L$n-C
 
 

 	%lss  	 	
 	
 	
 	: 	 	
 	
 	
 	M333 	 	
 	
 	
 	K 	 	
 	
 	
 	E 	 	
 	
 	
 	E 	 	
 	
 	
 	, 	 	
 	
 	
 	> 	 	
 	
 	
 	CIKK 	 	
 	
 	
 	+ 	 	
 	
 	
 	V4	??9S9SVVVOO 	 	
 	
 	
 	\ 	 	
 	
 	
 	C	 	 	
 	
 	
 	9	 	 	
 	
 	
 	9	 	 	
 	
 	
 	\Y-A\\\(	 	 	
 	
 	
 	A	 	 	
 	
 	
 	c	 	 	
 	
 	
 	--n--- RQSXQQQ
 11*==a
\*+= 	'JMSi6OSSSTTT  		+!-l.>??K  ###$.+I  N $$^444{+++KK)***'')))!A%%%))%)"W_0F0KLMMMMW]l.Dq.HIJJJ& 	# 	#JE3JJuc"""" # 	', ,,8,D,J,J3,O,O, , ,&,'K( # 	+, ,,8,D,J,J3,O,O, , ,*,+K( " 	;#/#:I N0C0LNNOOON0C0LNNOOO #{22$-$9$II!!%22$-$9$CI!!$-$9$=I!# 	$!### 	5 , 4I   )
 
  	'R))F8,,--. M KK&&&(--
,..%%$&!  	N 	NF(('''&*":"PQQ N33FF<LMMM))OVV  5 * 
 
	 [)) 	T 	TF%00[08 1  M //{6?RSSSS   "";LL8999

"$SY=Q$S$S	
 	
 	
 T[)17!$+.$'5??fo
 
 9 	(("."="P"PI# # HW
CDD ( ( (SYY''''''''( ; 	dk3'' 19Q<<
!!&,==hGG                 /
FCC
  	J 	JFCI%f&6&?@@:>>;TBBJ<C<V= =CJ89 /w~~do.. 	LLS$/SS   	S";TCUVVV; 		,![ , ,	i''$j   "++@Y^^C-@-@+@!A4:innS11A5778D D ',
7##
 &	 / 1 1z 3$0NN!!2 !//11 K   1e   $1  "STTT7>>"'//$2B"C"CDD LL]D<L]]]   $*C00 "AI[<<>>??"& 	    GGDMMM" " " " " " " " " " " " " " " . 	 	 	//555KK`?\?\4K[?\?\?\```       		* &"((39T]355"-"7dl"K"K%%%%%	& &
 - 	* 	* 	*##D)))))))))	*s   5.c$ $
d."dd9Afff"Dq -Aq:q q

q q
q r)!>r$$r)-A t u  t;;u filenamereturnc                     t                               t           d           t          j                            |          S )zReturns the URL location from a file parameter (which may be a URL)

        Args:
            filename: The path to the file (either an absolute, relative, or URL path)

        Returns:
            The URL for the location of the file
        zc.location_from_file has been deprecated and moved to requirements.URIRequirement.location_from_file)r   r   r3   r   r   r   )rJ   r  s     r   r   zCommandLine.location_from_file  s?     	|||	
 	
 	
 *==hGGGr!   c           	      R   t           j                            t           j                            d          dd|          }t          j        dk    r\t           j                            t           j                            dt           j                            d                    d|          }g }t           j                            |          rt          |d          5 }t          j        |          }ddd           n# 1 swxY w Y   t          |t                    s&|                    t          j        d| d	f           na|                    t          j        d
| f           |                    t          j        dt          j        |dd           f           ||fS |i fS )zIModify the main configuration based on the default configuration override~z.configr   win32APPDATArbNzDefault configuration file z does not contain a dictionaryz+Loading default configuration options from zLoaded configuration: r%   T)r   r   )rs   rt   r   
expanduserr,   platformenvironr   r   r   r   r   r   r   rb   r   INFOr   dumps)r   r  default_config_pathr   config_jsonresults         r   r   z CommandLine.load_system_defaults  s   
 !gllGs##Yx
 
 <7"""$',,
y"'*<*<S*A*ABB# #  7>>-.. 	,)400 0K;//0 0 0 0 0 0 0 0 0 0 0 0 0 0 0fd++ ,##i6Iiii    ##[FY[[   ##cFQ\`1a1a1acc   $V++Rs   C>>DDc                    t           j                            d           t           j                                         t           j                                         t
          j                            |                              d          }t          
                    d                    |                     t          |t          j                  rd}t          |t          j                  r)dt!          |j                   d|j         d| d	}d
dg}n8t          |t          j                  r(dt!          |j                   d|j         d| d	}g d}nt!          |j                   d|j         d| d	}g d}nt          |t          j                  r&d}|j         t,          j         |j         d| }g d}nt          |t          j                  r
d}| }g d}nkt          |t          j                  rd|j         }| }dg}n@t          |t          j                  rd|j         }| }dg}nd}d}ddt,          j         g}t           j        }|                    | d           |                    | d           |D ]}|                    d| d           |                    d           t          j        d           dS )zHProvide useful feedback if an exception occurs during a run of a plugin.z

T)chainr&   z/Volatility was unable to read a requested page:zSwap error z
 in layer z (rf   zUNo suitable swap file having been provided (locate and provide the correct swap file)z;An intentionally invalid page (operating system protection)zPage error )>Memory smear during acquisition (try re-acquiring if possible)BAn intentionally invalid page lookup (operating system protection)AA bug in the plugin/volatility3 (re-run with -vvv and file a bug))zDThe base memory file being incomplete (try re-acquiring if possible)r&  r'  r(  z.Volatility experienced a symbol-related issue:: )zAn invalid symbol tablez A plugin requesting a bad symbolz1A plugin requesting a symbol from the wrong tablez:Volatility experienced an issue related to a symbol table:z.Volatility experienced a layer-related issue: z?A faulty layer implementation (re-run with -vvv and file a bug)z0Volatility could not import a necessary module: zIA required python module is not installed (install the module and re-run)z/Volatility encountered an unexpected situation.z<Please re-run using with -vvv and file a bug with the outputzat rl   z	* z%
No further results will be produced
rE   N)r,   r   r.   flushr-   	tracebackTracebackExceptionfrom_exceptionr   r   r   r   r   r   InvalidAddressExceptionSwappedInvalidAddressExceptionhexinvalid_address
layer_namePagedInvalidAddressExceptionSymbolError
table_namer   BANGsymbol_nameSymbolSpaceErrorLayerExceptionMissingModuleExceptionmoduleBUG_URLr   )r   r  	fulltracegeneraldetail	caused_byoutputcauses           r   r   zCommandLine.process_exceptions  s:    	
   

 0??EELLSWLXX	RWWY''(((dJ>?? ;	GG$
 IJJ fs4+?'@'@ffDOff_cfffkQ		 D*"IJJ fs4+?'@'@ffDOff_cfff  		 4/00VVDOVVtVVV   		 j455 "	FGSS9ISSTSSF  II
 j9:: 	RGYF  II
 j788 	XtXXGYFQII j?@@ 	VVVGYF[II HGFN)i'))I ^^^$$$___%%% 	* 	*ELLu))))>???r!   c                    t          d           d}d}|j        D ]}|p)t          |j        |         t          j        j                  }|p)t          |j        |         t          j        j                  }t          d| d|j        |         j                    |rt          d           |rt          d           dS dS )zNProvide useful feedback if an exception occurs during requirement fulfillment.r&   FzUnsatisfied requirement r)  z
A translation layer requirement was not fulfilled.  Please verify that:
	A file was provided to create this layer (by -f, --single-location or by config)
	The file exists and is readable
	The file is a valid memory image and was acquired cleanlya9  
A symbol table requirement was not fulfilled.  Please verify that:
	The associated translation layer requirement was fulfilled
	You have the correct symbol file for the requirement
	The symbol file is under the correct directory or zip file
	The symbol file is named appropriately or contains the correct banner
N)printr   r   r   r   TranslationLayerRequirementSymbolTableRequirementr#   )r   r  translation_failedsymbols_failedconfig_paths        r   r   z*CommandLine.process_unsatisfied_exceptionse  s    	b			"+ 	 	K!3 "z -*F8 8 , z -*A0 0N
 e;ee$:J;:W:cee     	N    	\    	 	r!   contextconfigurables_listr  r	  Nc                    t          |          }|D ]}||                                         D ]|                    j        d          }|t	          t
          j                  rt	          |t                    rt          j	        |          j
        }|rt          |          dk    rft          j                            |          st          d| d          dt!          j        t          j                            |                     }t	          t
          j                  rJt	          |t(                    s't+          d                    j                            fd|D             }t/          j        ||                   s||         j        }	n|}	t4          j                            |	j                  }
||j        |
<   dS )a  Populate the context config based on the returned args.

        We have already determined these elements must be descended from ConfigurableInterface

        Args:
            context: The volatility3 context to operate on
            configurables_list: A dictionary of configurable items that can be configured on the plugin
            args: An object containing the arguments necessary
            plugin_config_path: The path within the context's config containing the plugin's configuration
        NrE   zNon-existent file z passed to URIRequirementzfile://z4Configuration for ListRequirement was not a list: {}c                 :    g | ]}                     |          S r:   )element_type)rP   rQ   requirements     r   rR   z/CommandLine.populate_config.<locals>.<listcomp>  s'     L L L!9!9!!<!< L L Lr!   )varsget_requirementsr   rM   r   r   r   r9   r	   urlparseschemer*   rs   rt   r   FileNotFoundErrorr
   pathname2urlru   ListRequirementr   	TypeErrorr   inspectisclassrI  r   r   r   r   )r   rJ  rK  r  r	  vargsconfigurabler  rS  rI  extended_pathrO  s              @r   r   zCommandLine.populate_config  s   & T

. 	: 	:L1,?PPRR : :		+"2D99$!+|/JKK a%eS11 a%*^E%:%:%AF#) aS[[A-=-=')w~~e'<'< !&*;(]U(](](]+& +& %& )a'2FrwW\G]G]2^2^(`(`!+|/KLL M)%66 "+ V ] ]$/$4!" !"# # 
 !M L L Le L L L"?+=l+KLL 9&8&F&R '9$.$<$F$F#[%5% %M 5:GN=19:	: 	:r!   c                     t          t          j        t          j        t          j        t          j        g          D ] \  }}t          j        |d|dz               !d S )NzDETAIL rE   )	enumerater   
LOGLEVEL_VLOGLEVEL_VVr   LOGLEVEL_VVVVr   addLevelName)r   r   level_values      r   r   z&CommandLine.order_extra_verbose_levels  sp    "+$%&'	#
 #
 	C 	CE;  .Aa.A.ABBBB	C 	Cr!   Tc                     | j          G fddt          j        j                   G fddt          j                  } G fdd          }|r|S |S )Nc                       e Zd Z fdZdS )>CommandLine.file_handler_class_factory.<locals>.CLIFileHandlerc                    t          d          t          j        d           | j                            d          }t          j                            d                    |dd                             |d         }}| d| }d}t          j                            |          r.| d| d| }|dz  }t          j                            |          .|S )	zGets the final filenameNz Output directory is not a stringT)exist_ok.rE   -)rW  rs   makedirspreferred_filenamer   rt   r   r   )r   pref_name_arrayr  r  output_filenamecounterrC   s         r   _get_final_filenamezRCommandLine.file_handler_class_factory.<locals>.CLIFileHandler._get_final_filename  s    %#$FGGGJ6666"&"9"?"?"D"DGLLSXXocrc6J-K-KLL#B' $ &.";";	";";gnn_55 !)1&I&IG&I&Ii&I&IOqLG gnn_55 ! '&r!   N)r3   r4   r5   rq  )rC   s   r   CLIFileHandlerrf    s.        ' ' ' ' ' ' 'r!   rr  c                   0     e Zd ZdeffdZ fdZ xZS )ACommandLine.file_handler_class_factory.<locals>.CLIMemFileHandlerr  c                 r    t           j                            |                                | |           d S r2   )ioBytesIOr    )r   r  rr  s     r   r    zJCommandLine.file_handler_class_factory.<locals>.CLIMemFileHandler.__init__  s5    
##D)))''h77777r!   c                    | j         rd S |                     d           |                                 }t          |d          5 }|                    |                                            d| _        t                              t          j
        d|            d d d            n# 1 swxY w Y   t                                                       d S )Nr   wbTzSaved stored plugin file: )closedseekrq  r   r.   read
_committedr   r   r   r  superclose)r   ro  current_filer   s      r   r  zGCommandLine.file_handler_class_factory.<locals>.CLIMemFileHandler.close  s    ;  4		!"&":":"<"</400 L &&tyy{{333&*DOJJ&T?&T&T                 s   AB''B+.B+)r3   r4   r5   r9   r    r  __classcell__)r   rr  s   @r   CLIMemFileHandlerrt    s^        8 8 8 8 8 8 8                 r!   r  c                   p    e Zd Zdef fdZd Zed             Zed             Zed             Z	d Z
dS )	DCommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandlerr  c           	      P   t          j        dd          \  }| _        t          j        |d          | _                            | |           t          | j                  D ]?}|                    d          s(|dvr$t          | |t          | j        |                     @d S )Nz.vol3tmp_)suffixprefixdirzw+b)moder   )rz  r  r  rM   )tempfilemkstemp_namerv  r   _filer    r  
startswithsetattrgetattr)r   r  fditemrr  rC   s       r   r    zMCommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.__init__  s    !)!1"6z" " "DJ  WRe444
''h777
OO G GD??3// GD A 5 5  dGDJ,E,EFFFG Gr!   c                 ,    t          | j        |          S r2   )r  r  )r   r  s     r   __getattr__zPCommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.__getattr__  s    tz4000r!   c                     | j         j        S r2   )r  rz  r   s    r   rz  zKCommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.closed  s    z((r!   c                     | j         j        S r2   )r  r  r   s    r   r  zICommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.mode      z&r!   c                     | j         j        S r2   )r  rM   r   s    r   rM   zICommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.name  r  r!   c                     | j         j        rdS | j                                          |                                 }t	          j        | j        |           dS )zMCloses and commits the file (by moving the temporary file to the correct nameN)r  rz  r  rq  rs   renamer  )r   ro  s     r   r  zJCommandLine.file_handler_class_factory.<locals>.CLIDirectFileHandler.close  sU     :$  4
  """"&":":"<"<	$*o66666r!   N)r3   r4   r5   r9   r    r  propertyrz  r  rM   r  )rr  rC   s   r   CLIDirectFileHandlerr    s        G G G G G G G G1 1 1 ) ) X) ' ' X' ' ' X'7 7 7 7 7r!   r  )rC   r   r   FileHandlerInterfacerv  rw  )r   directr  r  rr  rC   s       @@r   r   z&CommandLine.file_handler_class_factory  s    _
	' 	' 	' 	' 	' 	' 	'Z/D 	' 	' 	'(	  	  	  	  	  	  	 
N 	  	  	 .'	7 '	7 '	7 '	7 '	7 '	7 '	7 '	7> '	7 '	7 '	7R  	%''$$r!   r   r[  c           	         t          |t          j        j                  st	          dt          |                     |                                D ]}i }t          |t          j        j                  s't	          d	                    |j
                            t          |t          j        j                  rQ|j        |d<   t          |t          j                  rd |d<   t          |t          j                  rd|d<   d|v r|d= nt          |t           j        j        j        j                  r2|j        t(          k    rd |d<   n
|j        |d<   |j        rdnd	}||d
<   n@t          |t           j        j        j        j                  rt.          |d<   |j        |d<   nV |j        d|j                            dd          z   f|j        |j        |j        |j         d| dS )zAdds the plugin's simple requirements to the provided parser.

        Args:
            parser: The parser to add the plugin's (simple) requirements to
            configurable: The plugin object to pull the requirements from
        z*Expected ConfigurableInterface type, not: zCPlugin contains requirements that are not RequirementInterfaces: {}rZ   c                 "    t          | d          S r   r7   rQ   s    r   <lambda>z<CommandLine.populate_requirements_argparse.<locals>.<lambda>B      3q!99 r!   rd   rX   c                 "    t          | d          S r   r  r  s    r   r  z<CommandLine.populate_requirements_argparse.<locals>.<lambda>M  r  r!   *+r_   r`   z--r   rk  )rW   rY   r~   requiredN)
issubclassr   r   r   rW  rZ   rQ  r   RequirementInterfacer   r3   SimpleTypeRequirementinstance_typer   IntRequirementBooleanRequirementr   r   rV  rN  r7   optionalChoiceRequirementr9   r`   r   rM   replacer#   rY   )r   r   r[  rO  
additionalr_   s         r   r   z*CommandLine.populate_requirements_argparse#  sL    ,
(@(VWW 	QT,=O=OQQ   (88:: ,	 ,	K)+JZ5J    Y``$-   
 +z'?'UVV %0%>
6"k<+FGG =)<)<Jv&k<+JKK /+7Jx(++&v.%3@P  
 +s22)<)<Jv&&)4)AJv&*3<&+
7##%3@R   &)
6"(3(;
9%%F{'//S999 ,#+ %(11     K,	 ,	r!   )T)"r3   r4   r5   r6   r   r    classmethodrB   r   r9   r   r   r   r7   r   r   r   r   r   r   rJ  ContextInterfacer   r   r   r   	Namespacer   r   r   r   ArgumentParser_ArgumentGroupr   r:   r!   r   r?   r?   Q   s       NNH   $ $ [$
w* w* w*r H# H# H H H [H* * 	tE#s(O$d38n4	5*  *  *  * XO O Ob" " "H1:#41: !j.DEE
1:  1:  1: 
1: 1: 1: 1:f	C 	C 	CZ% Z% Z% Z%x>h-x/FFG> :3IJ> > > > > >r!   r?   c                  F    t                                                       dS )z^A convenience function for constructing and running the
    :class:`CommandLine`'s run method.N)r?   r   r:   r!   r   mainr  d  s      MMr!   )8r6   r   rX  rv  r   r   rs   r,   r  r+  typingr   r   r   r   r   r   urllibr	   r
   volatility3.clir   volatility3.pluginsr   volatility3.symbolsr   r   r   volatility3.frameworkr   r   r   r   r   r   r   volatility3.framework.automagicr   #volatility3.framework.configurationr   	getLoggerrF   r3   r   StreamHandlerrI   rG   r   r   	formatterr   objectr   r<   r?   r  r:   r!   r   <module>r     s      				   				 



      6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ! ! ! ! ! ! ! ! ' ' ' ' ' '         ! ! ! ! ! ! 6 6 6 6 6 6 6 6                  4 3 3 3 3 3 < < < < < < '


		8	$	$
'

!
!    ! ! !GHII	   Y   Y Y Y Y Yf Y Y Y*    ?   P P P P P P P Pf    r!   