
    Xf                         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 d dlm	Z	m
Z
 d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ  ej        e          Z G d	 d
ej                  ZdS )    N)	GeneratorList)schemassymbols)	constants
interfaces	renderers)symbol_cache)requirements)plugins)	resourcesc                       e Zd ZdZdZdZedeej	        j
                 fd            Zedeeddf         fd            Zd Zd ZdS )	IsfInfozQDetermines information about the currently available ISF files, or a specific one)   r   r   returnc           
          t          j        dddg           t          j        ddd d          t          j        dd	d
d          t          j        dt
          j        d          t          j        ddd
d          gS )Nfilterz>String that must be present in the file URI to display the ISFT)namedescriptionoptionaldefaultisfzSpecific ISF file to process)r   r   r   r   validatez#Validate against schema if possibleFSQLiteCache)   r   r   )r   	componentversionlivez-Traverse all files, rather than use the cache)r   ListRequirementURIRequirementBooleanRequirementVersionRequirementr
   SqliteCache)clss    W/home/panchajanya/Development/work/volatility3/volatility3/framework/plugins/isfinfo.pyget_requirementszIsfInfo.get_requirements   s     (\	   ':	   +A	   +"&2!  
 +K	  1
 	
    Nc              #     K   t           j        D ]@}t          j        |d          D ]%\  }}}|D ]}t          j                            ||          }|                    d          rt          j        |d          5 }|	                                D ]R}t          j        D ]C}	|                    |	          r,dt          t          j        |                    z   dz   |z   V  DS	 ddd           n# 1 swxY w Y   t          j        D ]?}	|                    |	          r(t          j        |                                          V  @'BdS )z)Lists all the ISF files that can be foundT)followlinksziprz	jar:file:!N)r   __path__oswalkpathjoinendswithzipfileZipFilenamelistr   ISF_EXTENSIONSstrpathlibPathas_uri)
r$   symbol_pathrootdirsfilesfilename	base_namezfiler   	extensions
             r%   list_all_isf_fileszIsfInfo.list_all_isf_files=   s      #+ 	G 	GK%'W[d%K%K%K G G!dE % G GH "T8 < <I((// G$_Y<< 7(-(8(8 7 71:1I !7 !7I'+}}Y'?'? %7.9C,3L,C,C=* =* /*,//026/7 )7 )7 )7!777 7 7 7 7 7 7 7 7 7 7 7 7 7 7 *3)A G GI'00;; G&-l9&=&=&D&D&F&F F F FGGG	G 	Gs   >A(C3	3C7:C7c              #   `  K   | j                             dd           | j         d         g}n!t          |                                           }g }t	          | j         d                   s|}n.|D ]+}| j         d         D ]}||v r|                    |           ,	 dd l}| j         d         st          d }n# t          $ r d }Y nw xY w| j         d         r|D ]}dx}x}	x}
}d}t          j	                    
                    |	          5 }	 t          j        |          }t	          |                    d
g                     }t	          |                    dg                     }t	          |                    dg                     }	t	          |                    dg                     }
t          j                            t           j        t           j                  }t'          j        |          }|                    |          }|r|                    dd          }nt/          j                    } ||          }n># t2          t          j        j        f$ r  t8                              d|            Y nw xY wd d d            n# 1 swxY w Y   d|||
|||	|ffV  d S t          j                            t           j        t           j                  }t'          j        |          }d}|                                                                D ]\  }}|                     |          \  }
}}	}|r|!                    |          }|r|tD          j#        v rd}| j         d         rt          j	                    
                    |	          5 }	 t          j        |          } ||          }n># t2          t          j        j        f$ r  t8                              d|            Y nw xY wd d d            n# 1 swxY w Y   d|||
|||	tI          |          ffV  d S )Nr   r   r   r   c                 4    t          j        | d          rdndS )NTTrueFalse)r   r   datas    r%   check_validz'IsfInfo._generator.<locals>.check_validi   s    !(!1$!=!=Jvv7Jr'   c                     dS )NUnknown rH   s    r%   rJ   z'IsfInfo._generator.<locals>.check_validn   s     yr'   r   rL   )urlr   
user_typesenums
base_types)locationzutf-8replace)errorszInvalid ISF: zTrue (cached))%configgetlistrC   lenappend
jsonschemaImportErrorr   ResourceAccessoropenjsonloadr.   r0   r1   r   
CACHE_PATHIDENTIFIERS_FILENAMEr
   r#   get_identifierdecoder	   NotAvailableValueUnicodeDecodeErrordecoderJSONDecodeErrorvollogwarningget_identifier_dictionaryitemsget_location_statisticsget_hashr   cached_validationsr7   )self	file_listfiltered_listisf_filefilter_itemrZ   rJ   entry	num_types	num_enums	num_basesnum_symbolsvalidfprI   identifiers_pathidentifier_cache
identifiercacherR   	json_hashs                        r%   
_generatorzIsfInfo._generatorS   s     ;??5$''3U+,IIT446677I 4;x()) 	7%MM% 7 7#';x#8 7 7K"h..%,,X6667	!;z* "!!K K K K  	! 	! 	!! ! ! ! !	!
 ;v J	& " "BCC	CIC	K!/116656AA @R@#y}}&)$((9b*A*A&B&B$'r(B(B$C$C	$'"(=(=$>$>	$'r(B(B$C$C	+-7<<%0)2P, ,( ,8+CDT+U+U(%5%D%De%D%T%T
% G)3):):79):)U)UJJ)2)D)F)FJ +D 1 1.0LM @ @ @'>u'>'>?????@%@ @ @ @ @ @ @ @ @ @ @ @ @ @ @* !!#!"    /" "H  "w||$i&D    !,-=>>EE(-(G(G(I(I(O(O(Q(Q  $
H 11(;;  %x 8 8I  0Y'2L%L%L /{:. K&799>>8>LL KPRK'+y}}(3D(9(9$68T#U K K K &/Ix/I/I J J J J JK	K K K K K K K K K K K K K K K $!%%'%
OO   ) s   B8 8CCJD6IJ8J JJJJ	J	PN=<P=8O85P7O88PP	P	c           
          t          j        dt          fdt          fdt          fdt          fdt          fdt          fdt          fg|                                           S )NURIValidzNumber of base_typeszNumber of typeszNumber of symbolszNumber of enumszIdentifying information)r	   TreeGridr7   intr   )ro   s    r%   runzIsfInfo.run   sa    !#'-"C($c*"C(*C0 OO
 
 	
r'   )__name__
__module____qualname____doc___required_framework_version_versionclassmethodr   r   configurationRequirementInterfacer&   r   r7   rC   r   r   rM   r'   r%   r   r      s        [["+H
j&>&S!T 
 
 
 [
B G9S$_#= G G G [G*h h hX
 
 
 
 
r'   r   )r^   loggingr.   r8   r3   typingr   r   volatility3r   r   volatility3.frameworkr   r   r	   volatility3.framework.automagicr
   #volatility3.framework.configurationr    volatility3.framework.interfacesr   volatility3.framework.layersr   	getLoggerr   rh   PluginInterfacer   rM   r'   r%   <module>r      s     				   " " " " " " " " ( ( ( ( ( ( ( ( B B B B B B B B B B 8 8 8 8 8 8 < < < < < < 4 4 4 4 4 4 2 2 2 2 2 2		8	$	$v
 v
 v
 v
 v
g% v
 v
 v
 v
 v
r'   