ó
"b<]c           @   s  d  Z  d d l m Z d d l m Z d d l m Z m Z d d l Z d d l	 m
 Z
 e
 r… d „  Z d	 „  Z d
 „  Z d „  Z n$ d „  Z d „  Z d „  Z d „  Z y| d d l m Z d d l m Z m Z 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 Wnƒ e k
 rªd d l m Z d d l  m Z d d l! m Z m Z m Z m Z d d l! m Z d d l" m Z d d l# m Z n Xe$ Z% d d d d g Z& d e' f d „  ƒ  YZ( d e) f d „  ƒ  YZ* d e* f d „  ƒ  YZ+ d e f d „  ƒ  YZ, d S(   s0   Browser to test web applications.
(from web.py)
i   (   t
   re_compile(   t   htmlunquoteiÿÿÿÿ(   t   BytesIOt   StringION(   t   PY2c         C   s
   |  j  ƒ  S(   N(   t   get_selector(   t   x(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   <lambda>   t    c         C   s
   |  j  ƒ  S(   N(   t   get_host(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s
   |  j  ƒ  S(   N(   t   get_data(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s
   |  j  ƒ  S(   N(   t   get_type(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s   |  j  S(   N(   t   selector(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s   |  j  S(   N(   t   host(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s   |  j  S(   N(   t   data(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   c         C   s   |  j  S(   N(   t   type(   R   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR      R   (   t   HTTPMessage(   t   HTTPHandlert   HTTPCookieProcessort   build_openert   Requestt	   HTTPError(   R   (   t   urljoin(   t	   CookieJar(   t
   addinfourl(   R   R   R   R   t   BrowserErrort   Browsert
   AppBrowsert
   AppHandlerc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   )   s   c           B   s  e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d i  d „ Z	 d „  Z
 d „  Z d „  Z d d	 „ Z d
 „  Z d d d d d d „ Z d d d d d d d „ Z d d d d d d „ Z d d d d d d „ Z d „  Z d d d d „ Z d „  Z d „  Z d „  Z RS(   c         C   sa   t  ƒ  |  _ t |  j ƒ |  _ d  |  _ d |  _ d |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  S(   Ns   http://0.0.0.0:8080/t   /(   R   t	   cookiejarR   t   _cookie_processort   Nonet   formt   urlt   patht   statusR   t	   _responset   _forms(   t   self(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   __init__/   s    							c         C   s   |  j  j d ƒ S(   Ns   utf-8(   R   t   decode(   R)   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   text;   s    c         C   s   |  j  j ƒ  d S(   s   Clears all cookies and history.N(   R    t   clear(   R)   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   reset?   s    c         C   s   t  ƒ  S(   s‘   Builds the opener using (urllib2/urllib.request).build_opener. 
        Subclasses can override this function to prodive custom openers.
        (   t   urllib_build_opener(   R)   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   C   s    c         C   sÛ   t  r# d | j ƒ  | j ƒ  f GHn  |  j ƒ  } | j |  j ƒ y | j | ƒ |  _ Wn t k
 rs } | |  _ n X|  j j	 ƒ  |  _
 t t |  j
 ƒ ƒ |  _ |  j j ƒ  |  _ |  j j |  _ d  |  _ d  |  _ |  j ƒ  S(   Nt
   requesting(   t   DEBUGt
   get_methodt   get_full_urlR   t   add_handlerR!   t   openR'   R   t   geturlR$   R   R   R%   t   readR   t   codeR&   R"   R(   R#   t   get_response(   R)   t   reqt   openert   e(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt
   do_requestI   s    		c         C   s1   t  |  j | ƒ } t | | | ƒ } |  j | ƒ S(   s   Opens the specified url.(   R   R$   R   R=   (   R)   R$   R   t   headersR:   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR5   [   s    c         C   sh   t  d d ƒ } | j |  j ƒ | j ƒ  d d l } d d l } d | j j d ƒ } | j  | ƒ d S(   s+   Opens the current page in real web browser.s	   page.htmlt   wiÿÿÿÿNs   file://(   R5   t   writeR   t   closet
   webbrowsert   osR%   t   abspath(   R)   t   fRB   RC   R$   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   showa   s    
c         C   s+   t  t |  j ƒ |  j j ƒ  |  j j ƒ  ƒ S(   s'   Returns a copy of the current response.(   R   R   R   R'   t   infoR6   (   R)   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR9   j   s    c         C   s   d d l  } | j  |  j ƒ S(   s/   Returns beautiful soup of the current document.iÿÿÿÿN(   t   BeautifulSoupR   (   R)   RH   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   get_soupn   s    c         C   sM   | p |  j  ƒ  } d j g  | j ƒ  D]! } t | t ƒ r% t | ƒ ^ q% ƒ S(   s;   Returns content of e or the current document as plain text.R   (   RI   t   joint   recursiveChildGeneratort
   isinstancet   unicodeR   (   R)   R<   t   c(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   get_texts   s    c         C   s/   |  j  ƒ  } g  | j d d ƒ D] } | ^ q S(   Nt   namet   a(   RI   t   findAll(   R)   t   soupRQ   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt
   _get_linksx   s    c         C   s1   |  j  |  j ƒ  d | d | d | d | d | ƒS(   s"   Returns all links in the document.R,   t
   text_regexR$   t	   url_regext	   predicate(   t   _filter_linksRT   (   R)   R,   RU   R$   RV   RW   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt	   get_links|   s    c         C   s}   | d  k rR |  j |  j ƒ  d | d | d | d | d | ƒ} | oL | d } n  | ri |  j | d ƒ St d ƒ ‚ d  Sd  S(	   NR,   RU   R$   RV   RW   i    t   hrefs   No link found(   R"   RX   RY   R5   R   (   R)   t   linkR,   RU   R$   RV   RW   t   links(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   follow_link€   s    3c         C   sG   |  j  |  j ƒ  d | d | d | d | d | ƒ} | rC | d pF d  S(   NR,   RU   R$   RV   RW   i    (   RX   RY   R"   (   R)   R,   RU   R$   RV   RW   R\   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt	   find_linkŠ   s    3c   	         sâ   g  ‰  ˆ d  k	 r+ ˆ  j ‡ f d †  ƒ n  ˆ d  k	 rP ˆ  j ‡ f d †  ƒ n  ˆ d  k	 ru ˆ  j ‡ f d †  ƒ n  ˆ d  k	 rš ˆ  j ‡ f d †  ƒ n  | r° | j | ƒ n  ‡  f d †  } g  | D] } | | ƒ rÆ | ^ qÆ S(   Nc            s   |  j  ˆ  k S(   N(   t   string(   R[   (   R,   (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   ‘   R   c            s   t  ˆ  ƒ j |  j p d ƒ S(   NR   (   R    t   searchR_   (   R[   (   RU   (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   “   R   c            s   |  j  d ƒ ˆ  k S(   NRZ   (   t   get(   R[   (   R$   (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   •   R   c            s   t  ˆ  ƒ j |  j d d ƒ ƒ S(   NRZ   R   (   R    R`   Ra   (   R[   (   RV   (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   —   R   c            s%   x ˆ  D] } | |  ƒ s t  Sq Wt S(   N(   t   Falset   True(   R[   t   p(   t
   predicates(    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyRE   ›   s    (   R"   t   append(	   R)   R\   R,   RU   R$   RV   RW   RE   R[   (    (   Re   R,   RU   R$   RV   s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyRX   Ž   s    c         C   sC   |  j  d k r< d d l } | j |  j ƒ  d t ƒ|  _  n  |  j  S(   s‚   Returns all forms in the current document.
        The returned form objects implement the ClientForm.HTMLForm interface.
        iÿÿÿÿNt   backwards_compat(   R(   R"   t
   ClientFormt   ParseResponseR9   Rb   (   R)   Rh   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt	   get_forms¤   s    !i    c         C   sŸ   |  j  ƒ  } | d k	 rC g  | D] } | j | k r | ^ q } n  | rq g  | D] } | | ƒ rP | ^ qP } n  | r‹ | | |  _ |  j St d ƒ ‚ d Sd S(   s   Selects the specified form.s   No form selected.N(   Rj   R"   RP   R#   R   (   R)   RP   RW   t   indext   formsRE   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   select_form­   s    +(c         K   s=   |  j  d k r t d ƒ ‚ n  |  j  j |   } |  j | ƒ S(   s$   submits the currently selected form.s   No form selected.N(   R#   R"   R   t   clickR=   (   R)   t   kwR:   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   submit»   s    c         C   s   |  j  | S(   N(   R#   (   R)   t   key(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   __getitem__Â   s    c         C   s   | |  j  | <d  S(   N(   R#   (   R)   Rq   t   value(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   __setitem__Å   s    N(   R   R   R*   t   propertyR,   R.   R   R=   R"   R5   RF   R9   RI   RO   RT   RY   R]   R^   RX   Rj   Rm   Rp   Rr   Rt   (    (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   -   s(   									
				c           B   s    e  Z d  Z d „  Z d „  Z RS(   sR  Browser interface to test web.py apps.
    
        b = AppBrowser(app)
        b.open('/')
        b.follow_link(text='Login')
        
        b.select_form(name='login')
        b['username'] = 'joe'
        b['password'] = 'secret'
        b.submit()
    
        assert b.path == '/'
        assert 'Welcome joe' in b.get_text()
    c         C   s   t  j |  ƒ | |  _ d  S(   N(   R   R*   t   app(   R)   Rv   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR*   Ù   s    c         C   s   t  t |  j ƒ ƒ S(   N(   R/   R   Rv   (   R)   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   Ý   s    (   R   R   t   __doc__R*   R   (    (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   É   s   	c           B   sY   e  Z d  Z d Z d „  Z d „  Z d „  Z y e j Z	 Wn e
 k
 rM n Xd „  Z RS(   s<   urllib2 handler to handle requests using web.py application.id   c         C   s   | |  _  d  S(   N(   Rv   (   R)   Rv   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR*   å   s    c         C   sy   |  j  j d t | ƒ d | j ƒ  d t | ƒ d t | ƒ d t | j ƒ  ƒ d t | ƒ d k ƒ } |  j	 | | j
 ƒ  ƒ S(   Nt	   localpartt   methodR   R   R>   t   https(   Rv   t   requestR   R2   R	   R
   t   dictt   header_itemsR   t   _make_responseR3   (   R)   R:   t   result(    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt	   http_openè   s    cc         C   s   |  j  | ƒ S(   N(   R€   (   R)   R:   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt
   https_openì   s    c         C   s¾   d j  g  | j D] \ } } d | | f ^ q ƒ } t rP t t | ƒ ƒ } n d d  l } | j | ƒ } t t | j ƒ | | ƒ } | j	 j
 d  d ƒ \ }	 }
 t |	 ƒ |
 | _ | _ | S(   Ns   
s   %s: %siÿÿÿÿi   (   RJ   R}   R   R   R   t   emailt   message_from_stringR   R   R&   t   splitR"   t   intR8   t   msg(   R)   R   R$   t   kt   vR   R>   R‚   t   responseR8   R†   (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR~   ô   s    5(   R   R   Rw   t   handler_orderR*   R€   R   R   t   do_request_t   https_requestt   AttributeErrorR~   (    (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyR   á   s   			(-   Rw   t   utilsR    t   netR   t   ioR   R   t   copyt
   py3helpersR   R   R	   R
   R   t   http.clientR   t   urllib.requestR   R   R   R   R   R/   t   urllib.parseR   t   http.cookiejarR   t   urllib.responseR   t   ImportErrort   httplibt   urllibt   urllib2t	   cookielibt   urlparseRb   R1   t   __all__t	   ExceptionR   t   objectR   R   R   (    (    (    s¤   /mnt/my-files/home/darkz3ro/Desktop/my files/malware analysing and devlopment/viruses codes and analysis/APT34-leat/MuddyC3v1.0.1-/muddyc3_v1.0.1/lib/web/browser.pyt   <module>   sJ   							("	œ