
"b<]c        2   @  s  d  Z  d d l m Z d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 g2 Z d d5 l Z d d5 l Z d d5 l Z d d5 l Z d d5 l Z d d5 l	 Z	 d d5 l
 Z
 d d5 l Z d d5 l Z d d6 l m Z d7 d8 l m Z m Z m Z m Z m Z m Z m Z y d d9 l m Z Wn! e k
 rd d9 l m Z n Xd e f d:     YZ e Z d;   Z d e f d<     YZ e Z e  e! e" e# g Z$ d= e! f d>     YZ% e% e$  Z$ d? e$ _  d@   Z& dA   Z' dB   Z( dC   Z) dD dE  Z* dD dF  Z+ e sce+ Z* n  dG   Z, d dr dH     YZ- e- Z. e. e j/  Z0 dI e0 _  dJ ds dK     YZ1 dL   Z2 dM   Z3 d5 dN  Z5 dO   Z6 d dt dP     YZ7 e7 Z8 d5 e9 dQ  Z: dR   Z; dS   Z< dT   Z= dU   Z> dV   Z? dW   Z@ d dX  ZA dY dZ  ZB d5 d[  ZC d5 d\  ZD d5 d]  ZE d^   ZF d_   ZG d`   ZH da   ZI db   ZJ d5 dc  ZK d* du dd     YZL eL ZM d, dv de     YZN eN ZO d d5 l	 Z	 eP e	 df  sd d9 lQ m Z d5 dg  ZR eR e	 _R n  d5 dh  ZS d/ e f di     YZT eT ZU dj   ZV dk   ZW e0 dl  ZX dm   ZY d5 dn  ZZ do dw dp     YZ[ e\ dq k rd d5 l] Z] e] j^   n  d5 S(x   s$   
General Utilities
(part of web.py)
i(   t   print_functiont   Storaget   storaget   storifyt   Countert   countert   iterst   rstripst   lstripst   stripst   safeunicodet   safestrt	   timelimitt   Memoizet   memoizet
   re_compilet   re_submt   groupt   uniqt   iterviewt
   IterBettert
   iterbettert   safeitert	   safewritet   dictreverset   dictfindt   dictfindallt   dictincrt   dictaddt   requeuet   restackt   listgett   intgett   datestrt   numifyt   denumifyt   commifyt   dateifyt   nthstrt   condt   CaptureStdoutt   capturestdoutt   Profilet   profilet   tryallt   ThreadedDictt   threadeddictt
   autoassignt   to36t   safemarkdownt   sendmailN(   t   locali   (   t   PY2t
   itervaluest	   iteritemst	   text_typet   string_typest   imapt   is_iter(   t   StringIOc           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sw  
    A Storage object is like a dictionary except `obj.foo` can be used
    in addition to `obj['foo']`.
    
        >>> o = storage(a=1)
        >>> o.a
        1
        >>> o['a']
        1
        >>> o.a = 2
        >>> o['a']
        2
        >>> del o.a
        >>> o.a
        Traceback (most recent call last):
            ...
        AttributeError: 'a'
    
    c         C  s2   y |  | SWn t  k
 r- } t |   n Xd  S(   N(   t   KeyErrort   AttributeError(   t   selft   keyt   k(    (    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/utils.pyt   __getattr__H   s    c         C  s   | |  | <d  S(   N(    (   R>   R?   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/utils.pyt   __setattr__N   s    c         C  s1   y |  | =Wn t  k
 r, } t |   n Xd  S(   N(   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/utils.pyt   __delattr__Q   s    c         C  s   d t  j |   d S(   Ns	   <Storage t   >(   t   dictt   __repr__(   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/utils.pyRG   W   s    (   t   __name__t
   __module__t   __doc__RA   RC   RD   RG   (    (    (    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/utils.pyR   3   s
   			c   	        s  | j  d t    t    t k	 r< t   d  r<    n     f d     f d   } t   } x | t |  j    D] } |  | } t | t  r t | j	 |  t  r g  | D] } | |  ^ q } q | d } n  t | j	 |  t
  s
| |  } n  t | j	 |  t  r>t | t  r>| g } n  t | | |  q} Wxt t |  D]f \ } } | } t | |  r| | } n  | d k rt | t  r| f } n  t | | |  q_W| S(   s,  
    Creates a `storage` object from dictionary `mapping`, raising `KeyError` if
    d doesn't have all of the keys in `requireds` and using the default 
    values for keys found in `defaults`.
    
    For example, `storify({'a':1, 'c':3}, b=2, c=0)` will return the equivalent of
    `storage({'a':1, 'b':2, 'c':3})`.
    
    If a `storify` value is a list (e.g. multiple values in a form submission), 
    `storify` returns the last element of the list, unless the key appears in 
    `defaults` as a list. Thus:
    
        >>> storify({'a':[1, 2]}).a
        2
        >>> storify({'a':[1, 2]}, a=[]).a
        [1, 2]
        >>> storify({'a':1}, a=[]).a
        [1]
        >>> storify({}, a=[]).a
        []
    
    Similarly, if the value has a `value` attribute, `storify will return _its_
    value, unless the key appears in `defaults` as a dictionary.
    
        >>> storify({'a':storage(value=1)}).a
        1
        >>> storify({'a':storage(value=1)}, a={}).a
        <Storage {'value': 1}>
        >>> storify({}, a={}).a
        {}
        
    t   _unicodet   __call__c           s'     r t  |  t  r  |   S|  Sd  S(   N(   t
   isinstancet   str(   t   s(   RK   t
   to_unicode(    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/utils.pyt	   unicodify   s    
c           sO   t  |  d  r% t  |  d  r% |  j St  |  d  rA   |  j  S  |   Sd  S(   Nt   fileRB   (   t   hasattrRB   (   t   x(   RQ   (    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/utils.pyt   getvalue   s
    i(    (   t   popt   FalseR
   RS   R   t   tuplet   keysRM   t   listt   getRF   t   setattrR6   (	   t   mappingt	   requiredst   defaultsRU   t   storR?   RB   RT   t   result(    (   RK   RP   RQ   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/utils.pyR   ]   s4    !		
"(c           B  sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s@  Keeps count of how many times something is added.
        
        >>> c = counter()
        >>> c.add('x')
        >>> c.add('x')
        >>> c.add('x')
        >>> c.add('x')
        >>> c.add('x')
        >>> c.add('y')
        >>> c['y']
        1
        >>> c['x']
        5
        >>> c.most()
        ['x']
    c         C  s$   |  j  | d  |  | c d 7<d  S(   Ni    i   (   t
   setdefault(   R>   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/utils.pyt   add   s    c         C  sA   t  t |    } g  t |   D] \ } } | | k r | ^ q S(   s$   Returns the keys with maximum count.(   t   maxR5   R6   (   R>   t   mR@   t   v(    (    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/utils.pyt   most   s    c         C  sA   t  |  j    } g  t |   D] \ } } | | k r | ^ q S(   s$   Returns the keys with mininum count.(   t   minR5   R6   (   R>   Rf   R@   Rg   (    (    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/utils.pyt   least   s    c         C  s   t  |  |  t |  j    S(   s4  Returns what percentage a certain key is of all entries.
        
            >>> c = counter()
            >>> c.add('x')
            >>> c.add('x')
            >>> c.add('x')
            >>> c.add('y')
            >>> c.percent('x')
            0.75
            >>> c.percent('y')
            0.25
        (   t   floatt   sumt   values(   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/utils.pyt   percent   s    c           s%   t    j   d   f d   d t S(   s   Returns keys sorted by value.
             
             >>> c = counter()
             >>> c.add('x')
             >>> c.add('x')
             >>> c.add('y')
             >>> c.sorted_keys()
             ['x', 'y']
        R?   c           s     |  S(   N(    (   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/utils.pyt   <lambda>   t    t   reverse(   t   sortedRY   t   True(   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/utils.pyt   sorted_keys   s    
c         C  s!   g  |  j    D] } |  | ^ q S(   s   Returns values sorted by value.
            
            >>> c = counter()
            >>> c.add('x')
            >>> c.add('x')
            >>> c.add('y')
            >>> c.sorted_values()
            [2, 1]
        (   Rt   (   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/utils.pyt   sorted_values   s    
c         C  s'   g  |  j    D] } | |  | f ^ q S(   s   Returns items sorted by value.
            
            >>> c = counter()
            >>> c.add('x')
            >>> c.add('x')
            >>> c.add('y')
            >>> c.sorted_items()
            [('x', 2), ('y', 1)]
        (   Rt   (   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/utils.pyt   sorted_items   s    
c         C  s   d t  j |   d S(   Ns	   <Counter RE   (   RF   RG   (   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/utils.pyRG      s    (   RH   RI   RJ   Rd   Rh   Rj   Rn   Rt   Ru   Rv   RG   (    (    (    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/utils.pyR      s   							t   _hackc           B  s   e  Z RS(    (   RH   RI   (    (    (    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/utils.pyRw     s   s   
A list of iterable items (like lists, but not strings). Includes whichever
of lists, tuples, sets, and Sets are available in this version of Python.
c         C  s   t  | t  r6 x  | D] } t |  | |  } q W| S|  d k rb | j |  r | t |  Sn9 |  d k r | j |  r | t |   Sn t d   | S(   Nt   lt   rs   Direction needs to be r or l.(   RM   R   t   _stripst
   startswitht   lent   endswitht
   ValueError(   t	   directiont   textt   removet   subr(    (    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/utils.pyRz     s    c         C  s   t  d |  |  S(   s{   
    removes the string `remove` from the right of `text`
    
        >>> rstrips("foobar", "bar")
        'foo'
    
    Ry   (   Rz   (   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/utils.pyR     s    c         C  s   t  d |  |  S(   sN  
    removes the string `remove` from the left of `text`
    
        >>> lstrips("foobar", "foo")
        'bar'
        >>> lstrips('http://foo.org/', ['http://', 'https://'])
        'foo.org/'
        >>> lstrips('FOOBARBAZ', ['FOO', 'BAR'])
        'BAZ'
        >>> lstrips('FOOBARBAZ', ['BAR', 'FOO'])
        'BARBAZ'
    
    Rx   (   Rz   (   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/utils.pyR   *  s    c         C  s   t  t |  |  |  S(   s   
    removes the string `remove` from the both sides of `text`
    
        >>> strips("foobarfoo", "foo")
        'bar'
    
    (   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/utils.pyR	   ;  s    s   utf-8c         C  sb   t  |   } | t k r |  S| t k r5 |  j |  S| t t t g k rT t |   St |   Sd S(   s   
    Converts any given object to unicode string.
    
        >>> safeunicode('hello')
        u'hello'
        >>> safeunicode(2)
        u'2'
        >>> safeunicode('\xe1\x88\xb4')
        u'\u1234'
    N(   t   typeR7   t   bytest   decodet   intRk   t   boolt   unicode(   t   objt   encodingt   t(    (    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/utils.pyR
   F  s    
c         C  sI   t  r" t |  t  r" |  j |  St |   r; t t |   St |   Sd S(   s   
    Converts any given object to utf-8 encoded string. 
    
        >>> safestr('hello')
        'hello'
        >>> safestr(2)
        '2'
    N(   R4   RM   R   t   encodeR:   R9   R   RN   (   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/utils.pyR   \  s
    	c           s     f d   } | S(   s  
    A decorator to limit a function to `timeout` seconds, raising `TimeoutError`
    if it takes longer.
    
        >>> import time
        >>> def meaningoflife():
        ...     time.sleep(.2)
        ...     return 42
        >>> 
        >>> timelimit(.1)(meaningoflife)()
        Traceback (most recent call last):
            ...
        RuntimeError: took too long
        >>> timelimit(1)(meaningoflife)()
        42
    
    _Caveat:_ The function isn't stopped after `timeout` seconds but continues 
    executing in a separate thread. (There seems to be no way to kill a thread.)
    
    inspired by <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878>
    c           s      f d   } | S(   Nc            sv   d t  j f     f d     Y} |   } | j   | j   rV t d   n  | j ro | j d  n  | j S(   Nt   Dispatchc             s&   e  Z d    Z     f d   Z RS(   c         S  s=   t  j j |   d  |  _ d  |  _ |  j t  |  j   d  S(   N(	   t	   threadingt   Threadt   __init__t   NoneRa   t   errort	   setDaemonRs   t   start(   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/utils.pyR     s    		
c           s3   y       |  _  Wn t j   |  _ n Xd  S(   N(   Ra   t   syst   exc_infoR   (   R>   (   t   argst   functiont   kw(    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/utils.pyt   run  s    (   RH   RI   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/utils.pyR     s   	s   took too longi   (   R   R   t   joint   isAlivet   RuntimeErrorR   Ra   (   R   R   R   t   c(   R   t   timeout(   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/utils.pyt   _2  s    %		(    (   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/utils.pyt   _1  s    (    (   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/utils.pyR   p  s    c           B  s&   e  Z d  Z d e d  Z d   Z RS(   s  
    'Memoizes' a function, caching its return values for each input.
    If `expires` is specified, values are recalculated after `expires` seconds.
    If `background` is specified, values are recalculated in a separate thread.
    
        >>> calls = 0
        >>> def howmanytimeshaveibeencalled():
        ...     global calls
        ...     calls += 1
        ...     return calls
        >>> fastcalls = memoize(howmanytimeshaveibeencalled)
        >>> howmanytimeshaveibeencalled()
        1
        >>> howmanytimeshaveibeencalled()
        2
        >>> fastcalls()
        3
        >>> fastcalls()
        3
        >>> import time
        >>> fastcalls = memoize(howmanytimeshaveibeencalled, .1, background=False)
        >>> fastcalls()
        4
        >>> fastcalls()
        4
        >>> time.sleep(.2)
        >>> fastcalls()
        5
        >>> def slowfunc():
        ...     time.sleep(.1)
        ...     return howmanytimeshaveibeencalled()
        >>> fastcalls = memoize(slowfunc, .2, background=True)
        >>> fastcalls()
        6
        >>> timelimit(.05)(fastcalls)()
        6
        >>> time.sleep(.2)
        >>> timelimit(.05)(fastcalls)()
        6
        >>> timelimit(.05)(fastcalls)()
        6
        >>> time.sleep(.2)
        >>> timelimit(.05)(fastcalls)()
        7
        >>> fastcalls = memoize(slowfunc, None, background=True)
        >>> threading.Thread(target=fastcalls).start()
        >>> time.sleep(.01)
        >>> fastcalls()
        9
    c         C  s1   | |  _  i  |  _ | |  _ | |  _ i  |  _ d  S(   N(   t   funct   cachet   expirest
   backgroundt   running(   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/utils.pyR     s
    				c           s     t   j    f   j j   s@ t j    j  <n  t      f d  }   j k rz | d t  nY  j	 r t
 j
    j  d  j	 k r  j r t j d |  j   q |   n   j  d S(   Nc           s[    j   j |   rW z)  j      t j   f  j  <Wd   j   j   Xn  d  S(   N(   R   t   acquireR   t   timeR   t   release(   t   block(   R   R?   t   keywordsR>   (    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/utils.pyt   update  s    )R   i   t   targeti    (   RX   t   itemsR   R[   R   t   LockRW   R   Rs   R   R   R   R   R   (   R>   R   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/utils.pyRL     s    -	
N(   RH   RI   RJ   R   Rs   R   RL   (    (    (    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/utils.pyR     s   2s#   
A memoized version of re.compile.
t   _re_subm_proxyc           B  s   e  Z d    Z d   Z RS(   c         C  s   d  |  _ d  S(   N(   R   t   match(   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/utils.pyR     s    	c         C  s   | |  _  d S(   NRp   (   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/utils.pyRL     s    	(   RH   RI   R   RL   (    (    (    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/utils.pyR     s   	c         C  sA   t  |   } t   } | j | j |  | j | |  | j f S(   s   
    Like re.sub, but returns the replacement _and_ the match object.
    
        >>> t, m = re_subm('g(oo+)fball', r'f\1lish', 'goooooofball')
        >>> t
        'foooooolish'
        >>> m.groups()
        ('oooooo',)
    (   R   R   t   subRL   R   (   t   patt   replt   stringt   compiled_patt   proxy(    (    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/utils.pyR   
  s    
	c         c  s\   d   } t  |  d  s' t |   }  n  x. t rW t | |  |   } | rS | Vq* Pq* Wd S(   s   
    Returns an iterator over a series of lists of length size from iterable.
    
        >>> list(group([1,2,3,4], 2))
        [[1, 2], [3, 4]]
        >>> list(group([1,2,3,4,5], 2))
        [[1, 2], [3, 4], [5]]
    c         s  s&   x t  |  D] } t |   Vq Wd  S(   N(   t   ranget   next(   t   seqRc   t   i(    (    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/utils.pyt   take%  s    R   N(   RS   t   iterRs   RZ   (   R   t   sizeR   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/utils.pyR     s    
		c         C  sk   | p d   } t    } g  } xF |  D]> } | |  } | | k rI q% n  | j |  | j |  q% W| S(   s  
    Removes duplicate elements from a list while preserving the order of the rest.
    
        >>> uniq([9,0,2,1,0])
        [9, 0, 2, 1]
    
    The value of the optional `key` parameter should be a function that
    takes a single argument and returns a key to test the uniqueness.
    
        >>> uniq(["Foo", "foo", "bar"], key=lambda s: s.lower())
        ['Foo', 'bar']
    c         S  s   |  S(   N(    (   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/utils.pyRo   @  Rp   (   t   setRd   t   append(   R   R?   t   seenRa   Rg   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/utils.pyR   3  s    	c         #  s   d   d    d    d         f d   } t  j    } t |   } x? t |   D]1 \ } } t j j d | | | |   | Vq^ Wt j j d | | | d |  d  d	 S(
   s   
    Takes an iterable `x` and returns an iterator over it
    which prints its progress to stderr as it iterates through.
    iF   c         S  s.   d t  |   | d t t |   |  | f S(   Ns   %5.1f%% (%*d/%d)id   (   Rk   R|   RN   (   Rc   t   lenx(    (    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/utils.pyt   plainformatT  s    c         S  sY   t  t |  |  | d  } |  | rA d d |  | d } n d } d d | | f S(   Ng      ?RE   t    i   Rp   s   [%s%s]t   =(   R   Rk   (   R   Rc   R   t   valt   spacing(    (    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/utils.pyt   barsW  s
    
c         S  s~   | d k r d S| | k r+ t  |   } n t  |  | | |  } t | d  \ } } t | d  \ } } d | | | f S(   Ni    s   --:--:--i<   s   %02d:%02d:%02d(   R   t   divmod(   t   elapsedRc   R   t   secst   minst   hrs(    (    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/utils.pyt   eta_  s    c           s    | |  d } | | k r( d } n d } |  t  j    |  | |  7} |    t |  t |  | |  7} | | 7} | S(   NR   s        s    ETA (   R   R|   (   t	   starttimeRc   R   t   outt   end(   t   WIDTHR   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/utils.pyt   formatj  s    	 *
s   i   s   
N(   R   R|   t	   enumerateR   t   stderrt   write(   RT   R   R   R   Rc   t   y(    (   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/utils.pyR   M  s    			 	c           B  sD   e  Z d  Z d   Z d d  Z d   Z d   Z d   Z e Z	 RS(   s  
    Returns an object that can be used as an iterator 
    but can also be used via __getitem__ (although it 
    cannot go backwards -- that is, you cannot request 
    `iterbetter[0]` after requesting `iterbetter[1]`).
    
        >>> import itertools
        >>> c = iterbetter(itertools.count())
        >>> c[1]
        1
        >>> c[5]
        5
        >>> c[3]
        Traceback (most recent call last):
            ...
        IndexError: already passed 3
    
    It is also possible to get the first value of the iterator or None.
    
        >>> c = iterbetter(iter([3, 4, 5]))
        >>> print(c.first())
        3
        >>> c = iterbetter(iter([]))
        >>> print(c.first())
        None
    
    For boolean test, IterBetter peeps at first value in the itertor without effecting the iteration.
    
        >>> c = iterbetter(iter(range(5)))
        >>> bool(c)
        True
        >>> list(c)
        [0, 1, 2, 3, 4]
        >>> c = iterbetter(iter([]))
        >>> bool(c)
        False
        >>> list(c)
        []
    c         C  s   | d |  _  |  _ d  S(   Ni    (   R   R   (   R>   t   iterator(    (    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/utils.pyR     s    c         C  s-   y t  t |    SWn t k
 r( | SXd S(   s   Returns the first element of the iterator or None when there are no
        elements.
        
        If the optional argument default is specified, that is returned instead
        of None when there are no elements.
        N(   R   R   t   StopIteration(   R>   t   default(    (    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/utils.pyt   first  s    c         c  sB   t  |  d  r |  j Vn  x! t |  j  V|  j d 7_ q Wd  S(   Nt   _headi   (   RS   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/utils.pyt   __iter__  s
    c         C  s   | |  j  k  r( t d t |    n  yR x/ | |  j  k r\ t |  j  |  j  d 7_  q. W|  j  d 7_  t |  j  SWn# t k
 r t t |    n Xd  S(   Ns   already passed i   (   R   t
   IndexErrorRN   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/utils.pyt   __getitem__  s    c         C  se   t  |  d  r |  j   d k St  |  d  r2 t Sy t |  j  |  _ Wn t k
 r\ t SXt Sd  S(   Nt   __len__i    R   (   RS   R   Rs   R   R   R   R   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/utils.pyt   __nonzero__  s    N(
   RH   RI   RJ   R   R   R   R   R   R   t   __bool__(    (    (    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/utils.pyR   ~  s   '				c         #  s7      f d    t       x t r2    Vq! Wd S(   sT   Makes an iterator safe by ignoring the exceptions occured during the iteration.
    c             sF   x? t  rA y     SWq t k
 r-   q t j   q Xq Wd  S(   N(   Rs   R   t	   tracebackt	   print_exc(    (   t   itR   (    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/utils.pyR     s    	N(   R   Rs   (   R   t   cleanupt   ignore_errors(    (   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/utils.pyR     s    		c         C  sA   t  |  d d  } | j |  | j   t j | j |   d S(   s   Writes the content to a temp file and then moves the temp file to 
    given filename to avoid overwriting the existing file in case of errors.
    s   .tmpt   wN(   RR   R   t   closet   ost   renamet   name(   t   filenamet   contentt   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/utils.pyR     s    
c         C  s/   t  g  t |   D] \ } } | | f ^ q  S(   s   
    Returns a new dictionary with keys and values swapped.
    
        >>> dictreverse({1: 2, 3: 4})
        {2: 1, 4: 3}
    (   RF   R6   (   R]   R?   RB   (    (    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/utils.pyR     s    c         C  s1   x* t  |   D] \ } } | | k r | Sq Wd S(   s   
    Returns a key whose value in `dictionary` is `element` 
    or, if none exists, None.
    
        >>> d = {1:2, 3:4}
        >>> dictfind(d, 4)
        3
        >>> dictfind(d, 5)
    N(   R6   (   t
   dictionaryt   elementR?   RB   (    (    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/utils.pyR     s    
c         C  sC   g  } x6 t  |   D]( \ } } | | k r | j |  q q W| S(   s   
    Returns the keys whose values in `dictionary` are `element`
    or, if none exists, [].
    
        >>> d = {1:4, 3:4}
        >>> dictfindall(d, 4)
        [1, 3]
        >>> dictfindall(d, 5)
        []
    (   R6   R   (   R   R   t   resR?   RB   (    (    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/utils.pyR     s
    c         C  s(   |  j  | d  |  | c d 7<|  | S(   s   
    Increments `element` in `dictionary`, 
    setting it to one if it doesn't exist.
    
        >>> d = {1:2, 3:4}
        >>> dictincr(d, 1)
        3
        >>> d[1]
        3
        >>> dictincr(d, 5)
        1
        >>> d[5]
        1
    i    i   (   Rb   (   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/utils.pyR   $  s    c          G  s(   i  } x |  D] } | j  |  q W| S(   s   
    Returns a dictionary consisting of the keys in the argument dictionaries.
    If they share a key, the value from the last argument is used.
    
        >>> dictadd({1: 0, 2: 0}, {2: 1, 3: 1})
        {1: 0, 2: 1, 3: 1}
    (   R   (   t   dictsRa   t   dct(    (    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/utils.pyR   8  s    c         C  s#   |  j  |  } |  j d |  | S(   s   Returns the element at index after moving it to the beginning of the queue.
    
        >>> x = [1, 2, 3, 4]
        >>> requeue(x)
        4
        >>> x
        [4, 1, 2, 3]
    i    (   RV   t   insert(   t   queuet   indexRT   (    (    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/utils.pyR   G  s    	i    c         C  s    |  j  |  } |  j |  | S(   s   Returns the element at index after moving it to the top of stack.
    
           >>> x = [1, 2, 3, 4]
           >>> restack(x)
           1
           >>> x
           [2, 3, 4, 1]
    (   RV   R   (   t   stackR   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/utils.pyR   U  s    	c         C  s"   t  |   d | k  r | S|  | S(   s   
    Returns `lst[ind]` if it exists, `default` otherwise.
    
        >>> listget(['a'], 0)
        'a'
        >>> listget(['a'], 1)
        >>> listget(['a'], 1, 'b')
        'b'
    i   (   R|   (   t   lstt   indR   (    (    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/utils.pyR   c  s    
c         C  s-   y t  |   SWn t t f k
 r( | SXd S(   s   
    Returns `integer` as an int or `default` if it can't.
    
        >>> intget('3')
        3
        >>> intget('3a')
        >>> intget('3a', 0)
        0
    N(   R   t	   TypeErrorR~   (   t   integerR   (    (    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/utils.pyR    r  s    
c   	      C  sG  d d  } d } |  s d S| s4 t j j   } n  t |  j d k r^ t j j |  } n  t |   j d k r t j j |   }  nt |   j d k r t j |  j |  j |  j  }  n  | |  } t	 | j
 | | j | j d  } t |  | } | d k  r| d 9} n  | rt |  d	 k  r;| | d
  S|  j d  j d d  } |  j | j k st| d k  r| d |  j 7} n  | St	 |  rt |  d k r| | d d  St |  d k r| | d d  S| | d  Sn  | j } | j
 rt	 | j d  } n  t |  d k r6| | d d  S| | d  Sd S(   sf  
    Converts a (UTC) datetime object to a nice string representation.
    
        >>> from datetime import datetime, timedelta
        >>> d = datetime(1970, 5, 1)
        >>> datestr(d, now=d)
        '0 microseconds ago'
        >>> for t, v in iteritems({
        ...   timedelta(microseconds=1): '1 microsecond ago',
        ...   timedelta(microseconds=2): '2 microseconds ago',
        ...   -timedelta(microseconds=1): '1 microsecond from now',
        ...   -timedelta(microseconds=2): '2 microseconds from now',
        ...   timedelta(microseconds=2000): '2 milliseconds ago',
        ...   timedelta(seconds=2): '2 seconds ago',
        ...   timedelta(seconds=2*60): '2 minutes ago',
        ...   timedelta(seconds=2*60*60): '2 hours ago',
        ...   timedelta(days=2): '2 days ago',
        ... }):
        ...     assert datestr(d, now=d+t) == v
        >>> datestr(datetime(1970, 1, 1), now=d)
        'January  1'
        >>> datestr(datetime(1969, 1, 1), now=d)
        'January  1, 1969'
        >>> datestr(datetime(1970, 6, 1), now=d)
        'June  1, 1970'
        >>> datestr(None)
        ''
    c         S  s}   | r |  | }  n  t  t |    d | } t |   d k rL | d 7} n  | d 7} |  d k  ro | d 7} n
 | d 7} | S(   NR   i   RO   i    s   from nowt   ago(   RN   t   abs(   Rc   t   whatt   divisorR   (    (    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/utils.pyt   agohence  s    

iQ Rp   t   DateTimet   dategư>i    ii   t   days   %B %ds    0s     s   , %si  t   houri<   t   minutet   secondg    .Ai  t   millisecondt   microsecondN(   R   t   datetimet   utcnowR   RH   t   fromtimestampt   yeart   monthR  R   t   dayst   secondst   microsecondsR   t   strftimet   replace(	   t   thent   nowR  t   onedayt   deltat   deltasecondst	   deltadaysR   t   deltamicroseconds(    (    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/utils.pyR!     sH    !
%		c         C  s2   d j  g  t |   D] } | j   r | ^ q  S(   s   
    Removes all non-digit characters from `string`.
    
        >>> numify('800-555-1212')
        '8005551212'
        >>> numify('800.555.1212')
        '8005551212'
    
    Rp   (   R   RN   t   isdigit(   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/utils.pyR"     s    
c         C  s[   g  } xE | D]= } | d k r= | j  |  d  |  d }  q | j  |  q Wd j |  S(   s   
    Formats `string` according to `pattern`, where the letter X gets replaced
    by characters from `string`.
    
        >>> denumify("8005551212", "(XXX) XXX-XXXX")
        '(800) 555-1212'
    
    t   Xi    i   Rp   (   R   R   (   R   t   patternR   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/utils.pyR#     s    	c         C  s  |  d k r d St |   j   }  |  j d  rJ d } |  d j   }  n d } d |  k rt |  j d  \ } } n |  d } } g  } xa t t |  d d d   D]@ \ } } | r | d r | j d d	  n  | j d |  q Wd j |  } | r| d | 7} n  | | Sd S(
   s  
    Add commas to an integer `n`.
    
        >>> commify(1)
        '1'
        >>> commify(123)
        '123'
        >>> commify(-123)
        '-123'
        >>> commify(1234)
        '1,234'
        >>> commify(1234567890)
        '1,234,567,890'
        >>> commify(123.0)
        '123.0'
        >>> commify(1234.5)
        '1,234.5'
        >>> commify(1234.56789)
        '1,234.56789'
        >>> commify(' %.2f ' % -1234.5)
        '-1,234.50'
        >>> commify(None)
        >>>
    
    Nt   -i   Rp   t   .ii   i    t   ,(   R   RN   t   stripR{   t   splitR   R   R   (   Rc   t   prefixt   dollarst   centsRy   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/utils.pyR$     s&    ,c         C  s   t  |  d  S(   s3   
    Formats a numified `datestring` properly.
    s   XXXX-XX-XX XX:XX:XX(   R#   (   t
   datestring(    (    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/utils.pyR%   *  s    c         C  sW   |  d k s t   |  d d k r* d |  Si d d 6d	 d
 6d d 6j |  d d  |  S(   s1  
    Formats an ordinal.
    Doesn't handle negative numbers.
    
        >>> nthstr(1)
        '1st'
        >>> nthstr(0)
        '0th'
        >>> [nthstr(x) for x in [2, 3, 4, 5, 10, 11, 12, 13, 14, 15]]
        ['2nd', '3rd', '4th', '5th', '10th', '11th', '12th', '13th', '14th', '15th']
        >>> [nthstr(x) for x in [91, 92, 93, 94, 99, 100, 101, 102]]
        ['91st', '92nd', '93rd', '94th', '99th', '100th', '101st', '102nd']
        >>> [nthstr(x) for x in [111, 112, 113, 114, 115]]
        ['111th', '112th', '113th', '114th', '115th']
    
    i    id   i   i   i   s   %sths   %ssti   s   %sndi   s   %srdi   i
   (   i   i   i   (   t   AssertionErrorR[   (   Rc   (    (    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/utils.pyR&   1  s    c         C  s   |  r
 | S| Sd S(   s   
    Function replacement for if-else to use in expressions.
        
        >>> x = 2
        >>> cond(x % 2 == 0, "even", "odd")
        'even'
        >>> cond(x % 2 == 0, "even", "odd") + '_row'
        'even_row'
    N(    (   t	   predicatet   consequencet   alternative(    (    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/utils.pyR'   H  s    
c           B  s    e  Z d  Z d   Z d   Z RS(   s   
    Captures everything `func` prints to stdout and returns it instead.
    
        >>> def idiot():
        ...     print("foo")
        >>> capturestdout(idiot)()
        'foo\n'
    
    **WARNING:** Not threadsafe!
    c         C  s   | |  _  d  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/utils.pyR   d  s    c         O  sF   t    } t j } | t _ z |  j | |   Wd  | t _ X| j   S(   N(   R;   R   t   stdoutR   RU   (   R>   R   R   R   t	   oldstdout(    (    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/utils.pyRL   g  s    			
(   RH   RI   RJ   R   RL   (    (    (    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/utils.pyR(   X  s   
	c           B  s    e  Z d  Z d   Z d   Z RS(   s  
    Profiles `func` and returns a tuple containing its output
    and a string with human-readable profiling information.
        
        >>> import time
        >>> out, inf = profile(time.sleep)(.001)
        >>> out
        >>> inf[:10].strip()
        'took 0.0'
    c         C  s   | |  _  d  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/utils.pyR     s    c         G  s.  d d  l  } d d  l } d d  l } d d  l } | j   \ } } | j |  | j   } t j   }	 | j |  j	 |  }
 t j   |	 }	 t
   } | j | d | } | j   | j d d  | j d  | j   d t |	  d } | | j   7} y | j |  Wn t k
 r#n X|
 | f S(   Nit   streamR   t   callsi(   s   

took s	    seconds
(   t   cProfilet   pstatsR   t   tempfilet   mkstempR   R*   R   t   runcallR   R;   t   Statst
   strip_dirst
   sort_statst   print_statst   print_callersRN   RU   R   t   IOError(   R>   R   R/  R0  R   R1  R   R   t   proft   stimeRa   R   t   statsRT   (    (    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/utils.pyRL     s.    	

(   RH   RI   RJ   R   RL   (    (    (    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/utils.pyR*   u  s   
	t
   format_excc         C  s#   t    } t j |  |  | j   S(   N(   R;   R   R   RU   (   t   limitt   strbuf(    (    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/utils.pyR=    s    	c         C  s2  |  j    }  i  } x t |   D] \ } } t | d  s@ q n  | r\ | j |  r\ q n  t | d d d y$ |   } t | |  t |  Wq t d  t | d  t d d j t j   j	 d    q Xq Wt d	 d
  t d  x4 t |  D]& \ } } t d t
 |  d |  qWd S(   so  
    Tries a series of functions and prints their results. 
    `context` is a dictionary mapping names to values; 
    the value will only be tried if it's callable.
    
        >>> tryall(dict(j=lambda: True))
        j: True
        ----------------------------------------
        results:
           True: 1
    
    For example, you might have a file `test/stuff.py` 
    with a series of functions testing various things in it. 
    At the bottom, have a line:
    
        if __name__ == "__main__": tryall(globals())
    
    Then you can run `python test/stuff.py` and get the results of 
    all the tests.
    RL   t   :R   R   t   ERRORs      s   
   s   
R  i(   s   results:s     N(   t   copyR6   RS   R{   t   printR   R   R   R=  R"  RN   (   t   contextR#  t   resultsR?   RB   Ry   (    (    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/utils.pyR,     s(    	
.
c           B  s  e  Z d  Z e   Z d   Z d   Z d   Z d   Z e	 e  Z d   Z
 d   Z d   Z d   Z e Z d	   Z d
   Z d d  Z d   Z d   Z d   Z d   Z e Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z e Z RS(   s'  
    Thread local storage.
    
        >>> d = ThreadedDict()
        >>> d.x = 1
        >>> d.x
        1
        >>> import threading
        >>> def f(): d.x = 2
        ...
        >>> t = threading.Thread(target=f)
        >>> t.start()
        >>> t.join()
        >>> d.x
        1
    c         C  s   t  j j |   d  S(   N(   R-   t
   _instancesRd   (   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/utils.pyR     s    c         C  s   t  j j |   d  S(   N(   R-   RF  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/utils.pyt   __del__  s    c         C  s
   t  |   S(   N(   t   id(   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/utils.pyt   __hash__  s    c          C  s(   x! t  t j  D] }  |  j   q Wd S(   s+   Clears all ThreadedDict instances.
        N(   RZ   R-   RF  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/utils.pyt	   clear_all  s    c         C  s   |  j  | S(   N(   t   __dict__(   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/utils.pyR     s    c         C  s   | |  j  | <d  S(   N(   RL  (   R>   R?   RB   (    (    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/utils.pyt   __setitem__   s    c         C  s   |  j  | =d  S(   N(   RL  (   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/utils.pyt   __delitem__  s    c         C  s   | |  j  k S(   N(   RL  (   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/utils.pyt   __contains__  s    c         C  s   |  j  j   d  S(   N(   RL  RJ  (   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/utils.pyRJ    s    c         C  s   |  j  j   S(   N(   RL  RB  (   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/utils.pyRB    s    c         C  s   |  j  j | |  S(   N(   RL  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/utils.pyR[     s    c         C  s   |  j  j   S(   N(   RL  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/utils.pyR     s    c         C  s   t  |  j  S(   N(   R6   RL  (   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/utils.pyR6     s    c         C  s   |  j  j   S(   N(   RL  RY   (   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/utils.pyRY     s    c         C  s   t  |  j  S(   N(   t   iterkeysRL  (   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/utils.pyRP    s    c         C  s   |  j  j   S(   N(   RL  Rm   (   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/utils.pyRm   "  s    c         C  s   t  |  j  S(   N(   R5   RL  (   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/utils.pyR5   %  s    c         G  s   |  j  j | |  S(   N(   RL  RV   (   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/utils.pyRV   (  s    c         C  s   |  j  j   S(   N(   RL  t   popitem(   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/utils.pyRQ  +  s    c         C  s   |  j  j | |  S(   N(   RL  Rb   (   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/utils.pyRb   .  s    c         O  s   |  j  j | |   d  S(   N(   RL  R   (   R>   R   t   kwargs(    (    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/utils.pyR   1  s    c         C  s   d |  j  S(   Ns   <ThreadedDict %r>(   RL  (   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/utils.pyRG   4  s    N(    RH   RI   RJ   R   RF  R   RG  RI  RK  t   staticmethodR   RM  RN  RO  t   has_keyRJ  RB  R   R[   R   R6   RY   RP  R   Rm   R5   RV   RQ  Rb   R   RG   t   __str__(    (    (    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/utils.pyR-     s8   																					c         C  sC   x< t  |  D]. \ } } | d k r+ q n  t |  | |  q Wd S(   sF  
    Automatically assigns local variables to `self`.
    
        >>> self = storage()
        >>> autoassign(self, dict(a=1, b=2))
        >>> self.a
        1
        >>> self.b
        2
    
    Generally used in `__init__` methods, as in:
    
        def __init__(self, foo, bar, baz=1): autoassign(self, locals())
    R>   N(   R6   R\   (   R>   t   localsR?   RB   (    (    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/utils.pyR/   <  s    c         C  sv   |  d k  r t  d   n  d } g  } x9 |  d k rb t |  d  \ }  } | j d | |  q* Wd j |  pu d S(   s  
    Converts an integer to base 36 (a useful scheme for human-sayable IDs).
    
        >>> to36(35)
        'z'
        >>> to36(119292)
        '2k1o'
        >>> int(to36(939387374), 36)
        939387374
        >>> to36(0)
        '0'
        >>> to36(-393)
        Traceback (most recent call last):
            ... 
        ValueError: must supply a positive integer
    
    i    s   must supply a positive integert$   0123456789abcdefghijklmnopqrstuvwxyzi$   Rp   t   0(   R~   R   R   R   (   t   qt   letterst	   convertedRy   (    (    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/utils.pyR0   Q  s    s   (?<!\()(http://(\S+))c         C  sN   d d l  m  } |  rJ |  j d d  }  t j d |   }  | |   }  |  Sd S(   s	  
    Converts text to HTML following the rules of Markdown, but blocking any
    outside HTML input, so that only the things supported by Markdown
    can be used. Also converts raw URLs to links.
    
    (requires [markdown.py](http://webpy.org/markdown.py))
    i(   t   markdownt   <s   &lt;s   <\1>N(   R\  R  t   r_urlR   (   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/utils.pyR1   p  s    c         K  sO  | j  d g   } t |  | | | | |  } x| D]	} t | t  rp | j | d | d | j d   q4 t | d  r t j j	 t
 | d d   }	 t
 | d d
  }
 | j |	 | j   |
  q4 t | t  r't | d  } | j   } | j   t j j	 |  }	 | j |	 | d
  q4 t d	 t |    q4 W| j   d
 S(   s  
    Sends the email message `message` with mail and envelope headers
    for from `from_address_` to `to_address` with `subject`. 
    Additional email headers can be specified with the dictionary 
    `headers.
    
    Optionally cc, bcc and attachments can be specified as keyword arguments.
    Attachments must be an iterable and each attachment can be either a 
    filename or a file object or a dictionary with filename, content and 
    optionally content_type keys.
    
    If `web.config.smtp_server` is set, it will send the message
    to that SMTP server. Otherwise it will look for 
    `/usr/sbin/sendmail`, the typical location for the sendmail-style
    binary. To use sendmail from a different path, set `web.config.sendmail_path`.
    t   attachmentsR   R   t   content_typet   readR   Rp   t   rbs   Invalid attachment: %sN(   RV   t   _EmailMessageRM   RF   t   attachR[   RS   R   t   patht   basenamet   getattrR   Ra  t
   basestringt   openR   R~   t   reprt   send(   t   from_addresst
   to_addresst   subjectt   messaget   headersR   R_  t   mailt   aR   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/utils.pyR2     s$    '

Rc  c           B  sM   e  Z d d   Z d   Z d d  Z d   Z d   Z d   Z d   Z	 RS(   c         K  s  d   } t  |  } t  |  } t  |  } | |  } | | j d g    } | | j d g    }	 | | |	 }
 d d  l } | j j |  d |  _ g  |
 D] } | j j |  d ^ q |  _ t i | d 6d j |  d 6| d	 6| p i   |  _	 | rd j |  |  j	 d
 <n  |  j
   |  _ |  j j d d  |  j j d d  |  j j d d  |  j j | d  t |  _ d  S(   Nc         S  s=   t  |  t  s t |   g Sg  |  D] } t |  ^ q# Sd  S(   N(   RM   RZ   R   (   RT   Rr  (    (    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/utils.pyt   listify  s    t   cct   bccii   t   Froms   , t   Tot   Subjectt   Ccs   Content-Transfer-Encodingt   7bits   Content-Dispositiont   inlines   MIME-Versions   1.0s   utf-8(   R   R[   t   email.utilst   utilst	   parseaddrRl  t
   recipientsR   R   Rp  t   new_messageRo  t
   add_headert   set_payloadRW   t	   multipart(   R>   Rl  Rm  Rn  Ro  Rp  R   Rs  Rt  Ru  R  t   emailRy   (    (    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/utils.pyR     s.    	,c         C  s   d d l  m } |   S(   Ni(   t   Message(   t   email.messageR  (   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/utils.pyR    s    c         C  s  |  j  sJ |  j   } | j d d  | j |  j  | |  _ t |  _  n  d d  l } y d d l m } Wn d d l m	 } n X| p | j
 |  d p d } |  j   } | j |  | j d |  | j d d	 d
 | | j d  s| j |  n  |  j j |  d  S(   Ns   Content-Types   multipart/mixedi(   t   encoders(   t   Encodersi    s   application/octet-streams   Content-Dispositiont
   attachmentR   s   text/(   R  R  R  Rd  Ro  Rs   t	   mimetypesR  R  R  t
   guess_typeR  R{   t   encode_base64(   R>   R   R   R`  t   msgR  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/utils.pyRd    s&    		c         C  se   xU t  |  j  D]D \ } } | j   d k rA |  j j |  q |  j j | |  q Wi  |  _ d  S(   Ns   content-type(   R6   Rp  t   lowerRo  t   set_typeR  (   R>   R@   Rg   (    (    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/utils.pyt   prepare_message  s
    c         C  s  y d d l  m } Wn# t k
 r9 t d t    } n X|  j   |  j j   } | j j d  rz| j j d  } | j j d d  } | j j d  } | j j d  } | j j d	 d   } | j j d
 t
  } d d  l }	 |	 j | |  }
 | r|
 j |  n  | r5|
 j   |
 j   |
 j   n  | rT| rT|
 j | |  n  |
 j |  j |  j |  |
 j   n8| j j d  d k rd d  l } | j j d | j j d  d | j j d   } | j |  j | |  j  n | j j d d  } |  j j d  s!t d   x- |  j D]" } | j d  s+t d   q+W| d |  j g |  j } t j | d t j } | j j | j  d   | j j!   | j"   d  S(   Ni   (   t   webapit   configt   smtp_servert	   smtp_porti    t   smtp_usernamet   smtp_passwordt   smtp_debuglevelt   smtp_starttlsit   email_enginet   awst   aws_access_key_idt   aws_secret_access_keyt   sendmail_paths   /usr/sbin/sendmailR  t   securitys   -ft   stdins   utf-8(#   Rp   R  t   ImportErrorR   R  Ro  t	   as_stringR  R[   R   RW   t   smtplibt   SMTPt   set_debuglevelt   ehlot   starttlst   loginR2   Rl  R  t   quitt   boto.sest   sest   SESConnectiont   send_raw_emailR{   R'  t
   subprocesst   Popent   PIPER  R   R   R   t   wait(   R>   R  t   message_textt   servert   portt   usernamet   passwordt   debug_levelR  R  t
   smtpservert   botoR   R2   Ry   t   cmdt   p(    (    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/utils.pyRk    sN    


3 
c         C  s   d S(   Ns   <EmailMessage>(    (   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/utils.pyRG     s    c         C  s   |  j  j   S(   N(   Ro  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/utils.pyRU    s    N(
   RH   RI   R   R   R  Rd  R  Rk  RG   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/utils.pyRc    s   				,	t   __main__(    (    (    (    (    (    (_   RJ   t
   __future__R    t   __all__t   reR   R   R   t	   itertoolsR   R   R  R
  R3   t   threadlocalt
   py3helpersR4   R5   R6   R7   R8   R9   R:   R;   R  t   ioRF   R   R   R   R   R   RZ   RX   R   t	   frozensetR   Rw   Rz   R   R   R	   R
   R   R   R   R   t   compileR   R   R   R   R   R   R   R   R   Rs   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R+   RS   t	   cStringIOR=  R,   R-   R.   R/   R0   R^  R1   R2   Rc  RH   t   doctestt   testmod(    (    (    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/utils.pyt   <module>	   s   					4(	OW							8S				1\	
	
				T			3		+,a			'w