
    [
#g3"              
          d Z ddlZddlZddlZdZej
                  j                  ed   k7  sTej
                  j                  ed   k  s8ej
                  j                  ed   k(  r1ej
                  j                  ed   k  r e	 dj                  e       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mZ ddlmZmZ d	eeeef   fd
Z ej:                  e      ZddZ  G d de!      Z"ded	efdZ# ed      Z$dee$   d	eee$   ddf   fdZ%dde&d	ee'   fdZ(de'fdZ)dde'de'de&d	ee'   fdZ*de'fdZ+d	ee'eejX                  jZ                     f   fdZ.ddZ/y)zVolatility 3 framework.    N)      r         z@Volatility framework requires python version {}.{}.{} or greater)AnyDict	GeneratorListTupleTypeTypeVar)	constants
interfacesreturnc                  `    t         j                  t         j                  t         j                  fS )z.Provides the so version number of the library.)r   VERSION_MAJORVERSION_MINORVERSION_PATCH     P/home/panchajanya/Development/work/volatility3/volatility3/framework/__init__.pyinterface_versionr   .   s!    ""I$;$;Y=T=TTTr   c                     t        |       r| d   t               d   k7  r)t        dj                  t               d   | d               t        |       dkD  r| d   t               d   kD  rut        dj                  dj	                  t               dd D cg c]  }t        |       c}      dj	                  | dd D cg c]  }t        |       c}                  yyyc c}w c c}w )z(Checks the required version of a plugin.r   zGFramework interface version {} is incompatible with required version {}r   zPFramework interface version {} is an older revision than the required version {}.r   N)lenr   RuntimeErrorformatjoinstr)argsxs     r   require_interface_versionr"   6   s    
4y7')!,,Y``%'*DG 
 t9q=Aw*,Q//"fmm2C2Ea2J!KQ#a&!KL$q)!<Q#a&!<=  0   "L!<s   C!=C&c                   6    e Zd ZdededdfdZd	dededefdZy)
NonInheritablevalueclsr   Nc                      || _         || _        y N)default_valuer&   )selfr%   r&   s      r   __init__zNonInheritable.__init__J   s    "r   objget_typec                     t         | j                  k(  r>t        | j                  d      r| j                  j	                  ||      S | j                  S t
        )N__get__)typer&   hasattrr)   r/   AttributeError)r*   r,   r-   s      r   r/   zNonInheritable.__get__N   sI    488t))95))11#x@@%%%r   r(   )__name__
__module____qualname__r   r   r+   r/   r   r   r   r$   r$   I   s6    c   3 $ # r   r$   r&   c                 (    t        d|       | _        | S )NT)r$   hidden)r&   s    r   hide_from_subclassesr8   V   s    c*CJJr   Tc              #      K   t        j                  |       st        d|        | j                         D ]2  }t	        |d      r|j
                  s| t        |      D ]  }|  4 yw)z8Returns all the (recursive) subclasses of a given class.z.class_subclasses parameter not a valid class: r7   N)inspectisclass	TypeError__subclasses__r1   r7   class_subclasses)r&   clazzreturn_values      r   r?   r?   ^   sb     ??3HNOO##%uh'u||K,U3L 4	 &s   A*A,ignore_errorsc                    g }t        | j                  t              st        d      t        j                  t        j                  ddj                  | j                                | j                  D ]  }t        j                  |d      D ]  \  }}}|j                  d      r|D ]  }t        j                  t        j                  j                  ||            ru| }|t        |      t        t        j                  j                         z   d j#                  t        j                  j                   d      }	|	j%                  d      D ]  }
|
s	 t'        ||
      } t        j                  j                  ||      g|j                  z   |_        t+        t        j                  j                  ||            D ]  \  }}|D ]  }t-        |      s|d|j/                  d       j#                  t        j                  j                   d      }|t1        |j2                  dz   |z   t        j                  j                  |||            z  }  t-        |      st        j                  j                  |t        |      t        t        j                  j                         z   d |d|j/                  d             }|j#                  t        j                  j                   d      }|t1        | j2                  dz   |z   t        j                  j                  ||      |      z  }   |S # t(        $ r ||dz   |
z   gz  }Y w xY w)	z;Imports all plugins present under plugins module namespace.z.[base_module].__path__ must be a list of pathsz$Importing from the following paths: z, T)followlinks__pycache__Nr   )
isinstance__path__listr=   volloglogr   LOGLEVEL_VVVVr   oswalkendswithzipfile
is_zipfilepathr   sepreplacesplitgetattrr2   _zipwalk_filter_filesrfindimport_filer3   )base_modulerB   failuresrQ   root_filesfilename
new_module
premodules	componentziprootzipfileszfile	submodulemodpaths                   r   import_filesrh   j   s   Hk**D1HII
JJ
.tyy9M9M/N.OP $$ ggd==ND!U}}]+!%%bggll4&BC!,J!%c$i#bggkk2B&B&D!E!M!MS"J &0%5%5c%:	$K-4Z-K
 &; T84+"+++,J' .6bggll46R-S)%-E,U3,12DEKK4D,E,M,M$&GGKK-"	 !)K$.$7$7#$=	$I$&GGLLw$F-" !" &. .T %X."$'',, TS-=!=!?@$%:x~~c':;# %,OOBGGKK$E	 K'0036BGGLLx8)% C "	 > %X O9 $2 K (Z#-=	-I,J JKs   L::MMr_   c                     | j                  d      xs$ | j                  d      xs | j                  d      xr | j                  d       S )z>Ensures that a filename traversed is an importable python filez.pyz.pycz.pyo__)rN   
startswith)r_   s    r   rW   rW      sU     	%  	%V$	%V$( !!$'
'	(r   modulerQ   c                    g }| t         j                  vr	 t        j                  |        |S |S # t        $ r}t
        j                  dj                  t        j                  j                  |      j                  d                   t
        j                  dj                  | |             |j                  |        |s Y d}~|S d}~ww xY w)a   Imports a python file based on an existing module, a submodule and a filepath for error messages

    Args
        module: Module name to be imported
        path: File to be imported from (used for error messages)

    Returns
        List of modules that may have failed to import

     T)chainz,Failed to import module {} based on file: {}N)sysmodules	importlibimport_moduleImportErrorrI   debugr   	tracebackTracebackExceptionfrom_exceptionr   append)rl   rQ   rB   r[   es        r   rY   rY      s     HS[[ 	##F+ O8O  	LL00??BIIPTIU
 LL>EEfdS OOF#  !O	s   / 	CB
CCc           
   #   @  K   i }t        j                  |       5 }|j                  D ]  }|j                         r|j	                  t
        j                  j                  |j                        g       }|j                  t
        j                  j                  |j                               ||t
        j                  j                  | t
        j                  j                  |j                              <    	 ddd       |D ]  }|||   f  y# 1 sw Y   xY ww)z1Walks the contents of a zipfile just like os.walkN)rO   ZipFilefilelistis_dirgetrL   rQ   dirnamer_   ry   basenamer   )rQ   zip_resultsarchivefiledirlistr%   s         r   rV   rV      s     K		 '$$D;;=%//"''//$--*H"Mrww//>? BGGLLrwwt}}/MNO	 % ['''  s"   D DB=D9DDDc                      i } t        t        j                  j                        D ]B  }|j                  dz   |j
                  z   }|j                  d      r|t        d      d  }|| |<   D | S )Nr   zvolatility3.plugins.)r?   r   pluginsPluginInterfacer4   r3   rk   r   )plugin_listpluginplugin_names      r   list_pluginsr      sp    K":#5#5#E#EF''#-?!!"89%c*@&A&CDK#)K 	 G
 r   c                    	 | r]d}t        j                   t        j                  j                  t        j
                  |            D ]  }t        j                  |        t        j                  t        j                  j                  t        j
                  t        j                               y # t        $ r' t        j                  t        j                  d       Y y w xY w)Nz*.cachez(Attempting to clear a non-existant cache)globrL   rQ   r   r   
CACHE_PATHunlinkIDENTIFIERS_FILENAMEFileNotFoundErrorrI   rJ   rK   )completeglob_patterncache_filenames      r   clear_cacher      s    	X$L"&))Y11<@# 		.)# 			"'',,y33Y5S5STU X

9**,VWXs   B.B1 1-C! C!)r   N)F)T)0__doc__r   rp   rO   required_python_versionversion_infomajorminormicror   r   rr   r;   loggingrL   rv   typingr   r   r	   r
   r   r   r   volatility3.frameworkr   r   intr   	getLoggerr3   rI   r"   objectr$   r8   r9   r?   boolr   rh   rW   rY   rV   r   r   r   r   r   r   r   <module>r      s     
 # 5a88
 7 ::"9!"<<""%<Q%?? QJQQ$	
     	  C C C 7U5c3/ U
 
		8	$&
V 
d t 
 CL	$q' 	iQt0C&D 	5T 5d3i 5p(C ( 3 t S	 <(3 (d3Z%7%7%G%G HHI 
Xr   