
    Zi                     r    S r SrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKrS r\S	:X  a  \" 5         gg)
a  
pyxswf.py

pyxswf is a script to detect, extract and analyze Flash objects (SWF) that may
be embedded in files such as MS Office documents (e.g. Word, Excel),
which is especially useful for malware analysis.

pyxswf is an extension to xxxswf.py published by Alexander Hanel on
http://hooked-on-mnemonics.blogspot.nl/2011/12/xxxswfpy.html
Compared to xxxswf, it can extract streams from MS Office documents by parsing
their OLE structure properly (-o option), which is necessary when streams are
fragmented.
Stream fragmentation is a known obfuscation technique, as explained on
http://www.breakingpointsystems.com/resources/blog/evasion-with-ole2-fragmentation/

It can also extract Flash objects from RTF documents, by parsing embedded
objects encoded in hexadecimal format (-f option).

pyxswf project website: http://www.decalage.info/python/pyxswf

pyxswf is part of the python-oletools package:
http://www.decalage.info/python/oletools
z0.54    N   )rtfobj)BytesIO)xxxswfc                     [        S[        -  5        [        S5        [        S5        Sn [        R                  " [        S-   U -   S9nUR                  SSS	S
SS9  UR                  SSS	SSS9  UR                  SSS	SSS9  UR                  SSS	SSS9  UR                  SSS	SSS9  UR                  SSSS S!S"9  UR                  S#S$S	S%S&S9  UR                  S'S(S	S)S*S9  UR                  S+S,S	S-S.S9  UR                  5       u  p#[        U5      S/:X  a  UR                  5         g UR                  (       a  U H  n[        R                  " U5      nUR                   H  nUc  M  UR                  [        R                  :X  d  M(  UR                  UR                   UR"                  5      nUR%                  5       nS0U;   d  S1U;   aB  [        S2['        UR(                  5      -  5        [*        R,                  " XvR(                  U5        UR/                  5         M     UR/                  5         M     g UR0                  (       ax  U Hq  n[2        R4                  " U5       HT  u  pnS0U;   d  S1U;   d  M  [        S3[        U5      U	4-  5        [7        U5      nS4U	-  n[*        R,                  " X{U5        MV     Ms     g [*        R8                  " 5         g )5Nz0pyxswf %s - http://decalage.info/python/oletoolszGPlease report any issue at https://github.com/decalage2/oletools/issues z!usage: %prog [options] <file.bad>
)usagez-xz	--extract
store_trueextractziExtracts the embedded SWF(s), names it MD5HASH.swf & saves it in the working dir. No addition args needed)actiondesthelpz-yz--yarayarazdScans the SWF(s) with yara. If the SWF(s) is compressed it will be deflated. No addition args neededz-sz	--md5scanmd5scanzgScans the SWF(s) for MD5 signatures. Please see func checkMD5 to define hashes. No addition args neededz-Hz--headerheaderz6Displays the SWFs file header. No addition args neededz-dz--decompress
decompresszDeflates compressed SWFS(s)z-rz--recdirPATHstringzZWill recursively scan a directory for files that contain SWFs. Must provide path in quotes)r   typer   z-cz
--compresscompresszCompresses the SWF using Zlibz-oz--oleolezCParse an OLE file (e.g. Word, Excel) to look for SWF in each streamz-fz--rtfrtfz9Parse an RTF file to look for SWF in each embedded objectr   s   FWSs   CWSzOLE stream: %sz)RTF embedded object size %d at index %08XzRTF_embedded_object_%08X)print__version__optparseOptionParser__doc__
add_option
parse_argslen
print_helpr   olefile	OleFileIO
direntries
entry_typeSTGTY_STREAM_open
isectStartsizegetvaluereprnamer   
disneylandcloser   r   rtf_iter_objectsr   main)r
   parseroptionsargsfilenamer   direntryfdataindexorig_lenr-   s               i/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/oletools/pyxswf.pyr1   r1   W   s   	=KL	TU	2J 0E""4%)?@F
dK9  T  @
dH\  Nt  u
dK9  T}  ~
dJ|(  RJ  K
dN<lYvw
dJV(  Jf  g
dLJUtu
dGLu  LQ  R
dGLu  LG  H '')OW 4yA~ {{H##H-CNN'H,?,?7CWCW,W		("5"5x}}EA::<D~4.hmm1DDE))!]]GDGGI + IIK  
H)/)@)@)J%T>Vt^ETTYHZZ[A5=D%%aw7 *K  	    __main__)r   r   r   sysosr   r   ior   thirdparty.xxxswfr   r#   r1   __name__ r<   r;   <module>rD      s@   x       % 
>@ zF r<   