ó
"b<]c           @@  sÇ   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z d d l	 Z
 d d l Z
 i  Z e
 j j j ƒ  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d d d „  ƒ  YZ d S(   s¸  openid.py: an openid library for web.py

Notes:

 - This will create a file called .openid_secret_key in the
   current directory with your secret key in it. If someone
   has access to this file they can log in as any user. And
   if the app can't find this file for any reason (e.g. you
   moved the app somewhere else) then each currently logged
   in user will get logged out.

 - State must be maintained through the entire auth process
   -- this means that if you have multiple web.py processes
   serving one set of URLs or if you restart your app often
   then log ins will fail. You have to replace sessions and
   store for things to work.

 - We set cookies starting with "openid_".

i    (   t   absolute_importNi   (   t   webapic          C@  sS   y t  d ƒ j ƒ  }  Wn6 t k
 rN t j d ƒ }  t  d d ƒ j |  ƒ n X|  S(   Ns   .openid_secret_keyi   t   w(   t   filet   readt   IOErrort   ost   urandomt   write(   t   secret(    (    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/webopenid.pyt   _secret    s    c         C@  s   t  j t ƒ  |  ƒ j ƒ  S(   N(   t   hmact   newR
   t	   hexdigest(   t   identity_url(    (    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/webopenid.pyt   _hmac*   s    c          C@  s;   t  j  ƒ  }  x |  t k r* t  j  ƒ  }  q Wt |  ƒ }  |  S(   N(   t   randomt   sessionst   str(   t   n(    (    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/webopenid.pyt   _random_session.   s
    c          C@  s_   t  j ƒ  j d d ƒ j d d ƒ }  t |  ƒ d k r[ |  \ }  } |  t | ƒ k r[ | Sn  d  S(   Nt   openid_identity_hasht    t   ,i   (   t   webt   cookiest   gett   splitt   lenR   t   None(   t   oid_hashR   (    (    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/webopenid.pyt   status7   s    $c         C@  s>   t  ƒ  } | r& d |  | t j j f Sd |  t j j f Sd  S(   NsI  
        <form method="post" action="%s">
          <img src="http://openid.net/login-bg.gif" alt="OpenID" />
          <strong>%s</strong>
          <input type="hidden" name="action" value="logout" />
          <input type="hidden" name="return_to" value="%s" />
          <button type="submit">log out</button>
        </form>s^  
        <form method="post" action="%s">
          <input type="text" name="openid" value=""
            style="background: url(http://openid.net/login-bg.gif) no-repeat; padding-left: 18px; background-position: 0 50%%;" />
          <input type="hidden" name="return_to" value="%s" />
          <button type="submit">log in</button>
        </form>(   R   R   t   ctxt   fullpath(   t
   openid_loct   oid(    (    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/webopenid.pyt   form@   s    	c           C@  s   t  j d d d d ƒd  S(   NR   R   t   expiresiÿÿÿÿ(   R   t	   setcookie(    (    (    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/webopenid.pyt   logoutH   s    t   hostc           B@  s   e  Z d  „  Z d „  Z RS(   c         C@  sã   t  j d d ƒ } | j d ƒ d k r> t ƒ  t  j | j ƒ St  j d d d ƒ} t ƒ  } i | j d 6t | <t j	 j	 j
 t | t ƒ } | j | j ƒ } | j t  j j t  j j t  j j ƒ } t  j d | ƒ t  j | ƒ S(   Nt	   return_tot   /t   actionR'   t   openidt   webpy_return_tot   openid_session_id(   R   t   inputR   R'   t   redirectR)   R   R   R,   t   consumert   Consumert   storet   begint   redirectURLR    t   homeR!   R&   (   t   selft   iR   t   ct   at   f(    (    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/webopenid.pyt   POSTN   s    	(c         C@  sÊ   t  j d ƒ j } t  j d d d d ƒt | d } t j j j t | t ƒ } | j	 t  j
 ƒ  t  j j t  j j ƒ } | j j ƒ  d k r¶ t  j d t | j ƒ d | j ƒ n  t | =t  j | ƒ S(	   NR.   R   R%   iÿÿÿÿR-   t   successR   R   (   R   R   R.   R&   R   R,   R1   R2   R3   t   completeR/   R    R6   R!   R   t   lowerR   R   R0   (   R7   R   R)   R9   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/webopenid.pyt   GET\   s    ('(   t   __name__t
   __module__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/webopenid.pyR(   L   s   	(    (   t   __doc__t
   __future__R    R   R   R   R   R   R   t   openid.consumer.consumerR,   t   openid.store.memstoreR   R3   t   memstoret   MemoryStoreR
   R   R   R   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/webopenid.pyt   <module>   s    	
							