
    Zi2                     \   S r SrSSKrSSKrSSKrSSKr\R                  R                  \R                  R                  \R                  R                  \
5      5      5      r\R                  R                  \R                  R                  \S5      5      r\\R                  ;  a  \R                  R                  S\5        SSKrSSKJr  SSKJr  SSKJr  S\-  r\R.                  S	\R0                  S
\R2                  S\R4                  S\R6                  S\R8                  S0r\R<                  S\R>                  S\R@                  S\RB                  S0r"\R<                  S\R>                  S\R@                  S\RB                  SSS0r#S r$SS jr%S r&S r'S r(\)S:X  a  \(" 5         gg)a  
olemap

olemap parses OLE files to display technical information about its structure.

Author: Philippe Lagadec - http://www.decalage.info
License: BSD, see source code or documentation

olemap is part of the python-oletools package:
http://www.decalage.info/python/oletools
z0.55    Nz..)tablestream)xglob)hexdump3z0olemap %s - http://decalage.info/python/oletoolsEmptyStorageStream
ILockBytesIPropertyStorageRootFreezEnd of Chainz
FAT SectorzDIFAT Sectorgreenyellowcyanbluedefaultc                 0    U [         R                  :X  a  g U $ )N)olefileNOSTREAM)sids    i/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/oletools/olemap.pysid_displayr   r   s    
g
    c                    [        S5        [        R                  " / SQ/ SQS9nUR                  S[        R
                  " U R                  5      R                  5       S/5        UR                  SU R                  S/5        UR                  S	S
U R                  -  S/5        UR                  SS
U R                  -  S/5        UR                  SS
U R                  -  S/5        UR                  SS
U R                  -  S/5        UR                  SU R                  S/5        UR                  SU R                  S/5        UR                  SSU R                  -  S/5        UR                  SU R                   S/5        UR                  SU R"                  S/5        UR                  SSU R$                  -  S/5        UR                  SU R&                  S/5        UR                  SSU R(                  -  S/5        UR                  S U R*                  S/5        UR-                  5         [        S5        [        S!5        [        R                  " / SQ/ SQS9nUR                  S"U R.                  S#/5        UR                  S$U R0                  S%/5        U R.                  S&-  nX0R                  -  nUS'-   U R.                  -  nUR                  S(US)/5        U R0                  U:  a  U R0                  U-
  nS*nOS+nS nUR                  S,US-/XwU/S.9  [3        U R4                  5      S'-
  n[7        [3        U R4                  5      S'-
  S+S/5       H(  n	U	nU R4                  U	   [8        R:                  :w  d  M(    O   U R<                  US0-   -  n
UR                  S1SU
-  S2/5        U R0                  U
-
  nUS+:  a  S*OS nUR                  S3US4/XwU/S.9  UR-                  5         [        S5        U(       a  [        S55        US+::  a  [        S65        OZU R>                  RA                  U
5        U R>                  RC                  5       n[3        U5      U:X  d   e[        [E        US7U
S895        [        S5        g g )9NzOLE HEADER:)      #   )	AttributeValueDescription
header_rowzOLE Signature (hex)zShould be D0CF11E0A1B11AE1zHeader CLSIDzShould be empty (0)zMinor Versionz%04XzShould be 003EzMajor VersionzShould be 3 or 4z
Byte OrderzShould be FFFE (little endian)zSector ShiftzShould be 0009 or 000Cz# of Dir Sectorsz!Should be 0 if major version is 3z# of FAT Sectors zFirst Dir Sector%08Xz(hex)zTransaction Sig NumberzShould be 0zMiniStream cutoffzShould be 4096 byteszFirst MiniFAT Sectorz# of MiniFAT SectorszFirst DIFAT Sectorz# of DIFAT SectorszCALCULATED ATTRIBUTES:zSector Size (bytes)zShould be 512 or 4096 byteszActual File Size (bytes)zReal file size on disk      zMax File Size in FATzMax file size covered by FATredr   zExtra data beyond FATz(Only if file is larger than FAT coveragecolors   zExtra data offset in FATz+Offset of the 1st free sector at end of FATzExtra data sizez:Size of data starting at the 1st free sector at end of FATzHEX DUMP OF EXTRA DATA:
z#No extra data found at end of file.r   )length
startindex)#printr   TableStream	write_rowbinasciib2a_hexheader_signatureupperheader_clsidminor_versiondll_version
byte_ordersector_shiftnum_dir_sectorsnum_fat_sectorsfirst_dir_sectortransaction_signature_numbermini_stream_cutoff_sizefirst_mini_fat_sectornum_mini_fat_sectorsfirst_difat_sectornum_difat_sectorsclosesector_size	_filesizelenfatranger   FREESECT
sectorsizefpseekreadr   )ole
extra_datatnum_sectors_per_fat_sectornum_sectors_in_fatmax_filesize_fatextra_size_beyond_fatcolorlast_used_sectorioffset_extra_dataextra_data_sizeexdatas                r   show_headerrZ   y   s   	- 6ChiAKK&(8(89M9M(N(T(T(VXtuvKK!1!13HIJKK&3+<+<"<>NOPKK&3??":<NOPKKv68XYZKK#*:*:!:<TUVKK#S%8%8:]^_KK#S%8%8"=>KK#Vc.B.B%BGLMKK)3+K+K][\KK$c&A&ACYZ[KK'#2K2K)KWUVKK')A)A2FGKK%v0F0F'FPQKK%s'<'<bABGGI	"I	
"# 6ChiAKK&9VWXKK+S]]<TUV!$!236I6II*Q.#//AKK')9;YZ[
}}'' #0@ @ !KK(*?Akle,  . 377|A~3sww<>1b)771:))) *
 *:Q*>?KK+V6G-GIvwxmm&77O$q(EdEKK"O5qre,  .GGI	"I)*a78FFKK)*VV[[]Fv;/111(6"9JKLb	 r   c                    [        S5        [        R                  " / SQ/ SQS9n[        [	        U R
                  5      5       Hx  nU R
                  U   n[        R                  US5      n[        R                  U[        S   5      nU R                  US-   -  nUR                  SU-  US	U-  SU-  /S US S /S
9  Mz     UR                  5         [        S5        g )NzFAT:      r]   r]   zSector #TypeOffsetzNext #r    z<Data>r   r%   %8Xr#   r'   r"   )r-   r   r.   rG   rE   rF   	FAT_TYPESget
FAT_COLORSrI   r/   rB   )rM   rO   rV   	fat_valuefat_type
color_typeoffsets          r   show_fatrj      s    	&M:bcA3sww< GGAJ	==H5^^Iz)/DE
1q5)	UQY&6/59;LM *dD9 	 	; ! GGI	"Ir   c                    [        S5        U R                  5         [        R                  " / SQ/ SQS9n[	        [        U R                  5      5       Hc  nU R                  U   n[        R                  US5      n[        R                  U[        S   5      nUR                  SU-  USSU-  /S US S /S	9  Me     UR                  5         [        S
5        g )NzMiniFAT:r\   r_   r    Datar   rb   zN/Ar'   r"   )r-   loadminifatr   r.   rG   rE   minifatrc   rd   re   r/   rB   )rM   rO   rV   rf   rg   rh   s         r   show_minifatro      s    	*OO:bcA3s{{#$KKN	==F3^^Iz)/DE
 	
UQY%1BC *dD9 	 	; % GGI	"Ir   c            	         Sn [         R                  " U S9nUR                  SSSSS9  UR                  SS	S
SS SS9  UR                  SSSSSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSSSS9  UR                  5       u  p#[	        U5      S :X  aC  [        [        5        [        [        5        UR                  5         [        R                  " 5         S!nUR                  (       d+  UR                  (       d  UR                  (       d	  S"Ul        S"n[        [        5        [        R                  " X2R                   UR"                  UR$                  S#9 H  u  pVnU(       a  UR'                  S$5      (       a  M%  U(       a	  U< S%U< 3OUn[        S&5        [        S'U-  5        Ub  [(        R*                  " U5      n	O[(        R*                  " U5      n	UR                  (       a  [-        XR.                  S(9  UR                  (       a  [1        U	5        UR                  (       a  [3        U	5        U	R5                  5         M     U(       a  [        S)5        g g )*Nz2usage: olemap [options] <filename> [filename2 ...])usagez-r
store_true	recursivez)find files recursively in subdirectories.)actiondesthelpz-zz--zipzip_passwordstrzhif the file is a zip archive, open all files from it, using the provided password (requires Python 2.6+))ru   typer   rv   z-fz
--zipfname	zip_fname*zoif the file is a zip archive, file(s) to be opened within the zip. Wildcards * and ? are supported. (default:*)z--headerheaderz%Display the OLE header (default: yes)z--fatrF   zDisplay the FAT (default: no)z	--minifatrn   z!Display the MiniFAT (default: no)z-xz--exdatarN   z/Display a hex dump of extra data at end of filer   FT)rs   rw   rz   /z in zO-------------------------------------------------------------------------------z	FILE: %s
)rN   zZTo display the FAT or MiniFAT structures, use options --fat or --minifat, and -h for help.)optparseOptionParser
add_option
parse_argsrE   r-   BANNER__doc__
print_helpsysexitr|   rF   rn   r   
iter_filesrs   rw   rz   endswithr   	OleFileIOrZ   rN   rj   ro   rB   )
rq   parseroptionsargsdefault_options	containerfilenamedata	full_namerM   s
             r   mainr      sM   @E""/F
d<kF  H
dG.ud F  G
dL{PS M  N jHB  D
gl:  <
k,Y>  @
dJ|,L  N
 '')OW 4yA~fg
 ONNgkkW__  
&M%*%5%5dFWFWCJCWCWcjctct&v!	T **3//:C(I6	hlY&'##D)C ##H-C>>(:(:;;;SM??		/&v4 jk r   __main__)F)*r   __version__r   osr~   r0   pathnormpathabspathdirname__file___thismodule_dirjoin_parent_dirinsertr   oletools.thirdparty.tablestreamr   oletools.thirdparty.xglobr   oletools.ezhexviewerr   r   STGTY_EMPTYSTGTY_STORAGESTGTY_STREAMSTGTY_LOCKBYTESSTGTY_PROPERTY
STGTY_ROOTSTORAGE_NAMESrH   
ENDOFCHAINFATSECTDIFSECTrc   re   r   rZ   rj   ro   r   __name__ r   r   <module>r      s  
n  # " ''""277??277??83L#MNggrww||OTBCchhHHOOA{#  7 + ) 
<k	I WYX\/V OOOO		 OOOO
AH $ElP zF r   