
"b<]c           @  sE  d  Z  d d l m Z d d l m Z m Z m Z m Z m Z m	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z m Z y$ d d l m Z d d l m Z Wn- e k
 r d d l Z d d l m Z n Xy d d l Z Wn e k
 re Z n Xy d d	 l m Z m Z Wn% d d l Z e j Z e   Z n Xd
 d d d d d d d d d d d d d g Z  d Z! e j" e!  Z# d e$ f d     YZ% d e& f d     YZ' d e$ f d     YZ( d
 e$ f d     YZ) d e* f d     YZ+ e+ Z, d e* f d     YZ- d f  d      YZ. e. Z/ d!   Z0 d"   Z1 d#   Z2 d$   Z3 d%   Z4 d& d'  Z5 d(   Z6 d) f  d*     YZ7 d f  d+     YZ8 d, e8 f d-     YZ9 d. e8 f d/     YZ: e d0  Z; d1 e8 f d2     YZ< d3 e8 f d4     YZ= d5 e8 f d6     YZ> d7 e8 f d8     YZ? d9   Z@ i  ZA e d:  ZB d;   ZC eC d< e:  eC d= e9  eC d> e<  eC d? e=  eC d@ e>  eC dA e?  dB   ZD dC e* f dD     YZE dE f  dF     YZF dG e* f dH     YZG dI   ZH dJ   ZI eJ dK k rAd d lK ZK eK jL   eH   eI   n  d S(L   s   
Database API
(part of web.py)
i(   t   print_functioni   (   t   threadeddictt   storaget   iterst
   iterbettert   safestrt   safeunicodeN(   t   PY2t   string_typest   numeric_typest	   iteritems(   t   parse(   t   unquote(   t   debugt   configt   UnknownParamstylet	   UnknownDBt   TransactionErrort   sqllistt   sqlorst   reparamt   sqlquotet   SQLQueryt   SQLParamt   sqlparamt
   SQLLiteralt
   sqlliteralt   databaset   DBs  [ \f\t]*(\\\r?\n[ \f\t]*)*(#[^\r\n]*)?(((\d+[jJ]|((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)[jJ])|((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)|(0[xX][\da-fA-F]+[lL]?|0[bB][01]+[lL]?|(0[oO][0-7]+)|(0[0-7]*)[lL]?|[1-9]\d*[lL]?))|((\*\*=?|>>=?|<<=?|<>|!=|//=?|[+\-*/%&|^=<>]=?|~)|[][(){}]|(\r?\n|[:;.,`@]))|([uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'|[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*")|[a-zA-Z_]\w*)c           B  s   e  Z d  Z RS(   s   raised for unsupported dbms(   t   __name__t
   __module__t   __doc__(    (    (    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/db.pyR   .   s   t
   _ItplErrorc           B  s   e  Z d    Z d   Z RS(   c         C  s#   t  j |   | |  _ | |  _ d  S(   N(   t
   ValueErrort   __init__t   textt   pos(   t   selfR#   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/db.pyR"   5   s    	c         C  s   d t  |  j  |  j f S(   Ns&   unfinished expression in %s at char %d(   t   reprR#   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/db.pyt   __str__:   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/db.pyR    3   s   	c           B  s   e  Z RS(    (   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/db.pyR   ?   s   c           B  s   e  Z d  Z RS(   sp   
    raised for unsupported db paramstyles
    
    (currently supported: qmark, numeric, format, pyformat)
    (   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/db.pyR   C   s   c           B  sb   e  Z d  Z d g Z d   Z d d  Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   s  
    Parameter in SQLQuery.
    
        >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam("joe")])
        >>> q
        <sql: "SELECT * FROM test WHERE name='joe'">
        >>> q.query()
        'SELECT * FROM test WHERE name=%s'
        >>> q.values()
        ['joe']
    t   valuec         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/db.pyR"   [   s    t   pyformatc         C  sP   | d k r d S| d k r  d S| d  k s8 | d k r< d St |   d  Sd  S(	   Nt   qmarkt   ?t   numerics   :1t   formatR)   s   %s(   R-   R)   (   t   NoneR   (   R%   t
   paramstyle(    (    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/db.pyt
   get_marker^   s    c         C  s   t  |  g  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/db.pyt   sqlqueryi   s    c         C  s   |  j    | S(   N(   R1   (   R%   t   other(    (    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/db.pyt   __add__l   s    c         C  s   | |  j    S(   N(   R1   (   R%   R2   (    (    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/db.pyt   __radd__o   s    c         C  s   t  |  j  S(   N(   t   strR(   (   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/db.pyR'   r   s    c         C  s   t  | t  o | j |  j k S(   N(   t
   isinstanceR   R(   (   R%   R2   (    (    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/db.pyt   __eq__u   s    c         C  s   d t  |  j  S(   Ns   <param: %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/db.pyt   __repr__x   s    (   R   R   R   t	   __slots__R"   R0   R1   R3   R4   R'   R7   R8   (    (    (    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/db.pyR   L   s   							c           B  s   e  Z d  Z d g Z d d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d d	  Z d
   Z d d d d d  Z e e  Z d   Z d   Z d   Z d   Z RS(   sM  
    You can pass this sort of thing as a clause in any db function.
    Otherwise, you can pass a dictionary to the keyword argument `vars`
    and the function will call reparam for you.
    
    Internally, consists of `items`, which is a list of strings and
    SQLParams, which get concatenated to produce the actual query.
    t   itemsc         C  s   | d k r g  |  _ ni t | t  r3 | |  _ nN t | t  rQ | g |  _ n0 t | t  ru t | j  |  _ n | g |  _ xT t |  j  D]C \ } } t | t  r t | j t  r | j j	 |  j | <q q Wd S(   s  Creates a new SQLQuery.
        
            >>> SQLQuery("x")
            <sql: 'x'>
            >>> q = SQLQuery(['SELECT * FROM ', 'test', ' WHERE x=', SQLParam(1)])
            >>> q
            <sql: 'SELECT * FROM test WHERE x=1'>
            >>> q.query(), q.values()
            ('SELECT * FROM test WHERE x=%s', [1])
            >>> SQLQuery(SQLParam(1))
            <sql: '1'>
        N(
   R.   R:   R6   t   listR   R   t	   enumerateR(   R   t   v(   R%   R:   t   it   item(    (    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/db.pyR"      s    !c         C  s   |  j  j |  d  S(   N(   R:   t   append(   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/db.pyR@      s    c         C  sK   t  | t  r | g } n t  | t  r6 | j } n t St |  j |  S(   N(   R6   R   R   R:   t   NotImplemented(   R%   R2   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/db.pyR3      s    c         C  sK   t  | t  r | g } n t  | t  r6 | j } n t St | |  j  S(   N(   R6   R   R   R:   RA   (   R%   R2   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/db.pyR4      s    c         C  sU   t  | t t f  r( |  j j |  n) t  | t  rM |  j j | j  n t S|  S(   N(   R6   R   R   R:   R@   R   t   extendRA   (   R%   R2   (    (    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/db.pyt   __iadd__   s    c         C  s   t  |  j    S(   N(   t   lent   query(   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/db.pyt   __len__   s    c         C  s   t  | t  o | j |  j k S(   N(   R6   R   R:   (   R%   R2   (    (    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/db.pyR7      s    c         C  s   g  } x |  j  D] } t | t  rJ | j |  } | j t |   q t |  } | d k r d | k r d | k r | j d d  } q n  | j |  q Wd j |  S(   s/  
        Returns the query part of the sql query.
            >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')])
            >>> q.query()
            'SELECT * FROM test WHERE name=%s'
            >>> q.query(paramstyle='qmark')
            'SELECT * FROM test WHERE name=?'
        R-   R)   t   %s   %%t    (   R-   R)   (   R:   R6   R   R0   R@   R   t   replacet   join(   R%   R/   t   st   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/db.pyRE      s    	c         C  s,   g  |  j  D] } t | t  r
 | j ^ q
 S(   s   
        Returns the values of the parameters used in the sql query.
            >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')])
            >>> q.values()
            ['joe']
        (   R:   R6   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/db.pyt   values   s    t    c         C  s   | d k r t   } n  | j } | r7 | j |  n  x t |   D]u \ } } | d k rx | d k rx | j |  n  t | t  r | j | j  qD | d k r qD qD | j |  qD W| r | j |  n  | S(   s  
        Joins multiple queries.
        
        >>> SQLQuery.join(['a', 'b'], ', ')
        <sql: 'a, b'>
        
        Optinally, prefix and suffix arguments can be provided.
        
        >>> SQLQuery.join(['a', 'b'], ', ', prefix='(', suffix=')')
        <sql: '(a, b)'>
        
        If target argument is provided, the items are appended to target instead of creating a new SQLQuery.
        i    RH   N(   R.   R   R:   R@   R<   R6   RB   (   R:   t   sept   prefixt   suffixt   targett   target_itemsR>   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/db.pyRJ      s     	c         C  s\   y7 |  j    t g  |  j   D] } t |  ^ q  SWn t t f k
 rW |  j    SXd  S(   N(   RE   t   tupleRM   t   sqlifyR!   t	   TypeError(   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/db.pyt   _str  s    7c         C  s   t  |  j    S(   N(   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/db.pyR'     s    c         C  s   t  |  j    S(   N(   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/db.pyt   __unicode__  s    c         C  s   d t  t |    S(   Ns	   <sql: %s>(   R&   R5   (   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/db.pyR8     s    N(   R   R   R   R9   R.   R"   R@   R3   R4   RC   RF   R7   RE   RM   RJ   t   staticmethodRW   R'   RX   R8   (    (    (    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/db.pyR   ~   s"   			
	
						!			c           B  s    e  Z d  Z d   Z d   Z RS(   s   
    Protects a string from `sqlquote`.
    
        >>> sqlquote('NOW()')
        <sql: "'NOW()'">
        >>> sqlquote(SQLLiteral('NOW()'))
        <sql: 'NOW()'>
    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/db.pyR"   ,  s    c         C  s   d |  j  S(   Ns   <literal: %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/db.pyR8   /  s    (   R   R   R   R"   R8   (    (    (    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/db.pyR   "  s   	c         C  sv   g  } | j  d  xI t |   D]; \ } } | d k rH | j  d  n  | j  t |   q  W| j  d  t |  S(   s@   
        >>> _sqllist([1, 2, 3])
        <sql: '(1, 2, 3)'>
    t   (i    s   , t   )(   R@   R<   R   R   (   RM   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/db.pyt   _sqllist5  s    c         C  s   t    j |  |  S| j   } t   | d <g  } xR t |   D]D \ } } | rv t | |  } | j t |   q? | j |  q? Wt j	 | d  S(   s'  
    Takes a string and a dictionary and interpolates the string
    using values from the dictionary. Returns an `SQLQuery` for the result.
    
        >>> reparam("s = $s", dict(s=True))
        <sql: "s = 't'">
        >>> reparam("s IN $s", dict(s=[1, 2]))
        <sql: 's IN (1, 2)'>
    t   __builtins__RH   (
   t   SafeEvalt   safeevalt   copyt   objectt   _interpolatet   evalR@   R   R   RJ   (   t   string_t
   dictionaryt   resultt   livet   chunkR=   (    (    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/db.pyR   E  s    
c         C  s   |  d k r d S|  t k r  d S|  t k r0 d St |  t  rI t |   St |  t j  rk t |  j    St	 r t |  t
  r |  j d  }  n  t |   Sd S(   s   
    converts `obj` to its proper SQL version
    
        >>> sqlify(None)
        'NULL'
        >>> sqlify(True)
        "'t'"
        >>> sqlify(3)
        '3'
    t   NULLs   't's   'f't   utf8N(   R.   t   Truet   FalseR6   R	   R5   t   datetimeR&   t	   isoformatR   t   unicodet   encode(   t   obj(    (    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/db.pyRU   ]  s    

c         C  s$   t  |  t  r |  Sd j |   Sd S(   s   
    Converts the arguments for use in something like a WHERE clause.
    
        >>> sqllist(['a', 'b'])
        'a, b'
        >>> sqllist('a')
        'a'
    s   , N(   R6   R   RJ   (   t   lst(    (    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/db.pyR   y  s    	c         C  s   t  | t  rY t |  } t |  } | d k r= t d  S| d k rY | d } qY n  t  | t  r t d g t g  | D] } |  t |  d g ^ q{ g   d g  S|  t |  Sd S(   s  
    `left is a SQL clause like `tablename.arg = ` 
    and `lst` is a list of values. Returns a reparam-style
    pair featuring the SQL that ORs together the clause
    for each item in the lst.
    
        >>> sqlors('foo = ', [])
        <sql: '1=2'>
        >>> sqlors('foo = ', [1])
        <sql: 'foo = 1'>
        >>> sqlors('foo = ', 1)
        <sql: 'foo = 1'>
        >>> sqlors('foo = ', [1,2,3])
        <sql: '(foo = 1 OR foo = 2 OR foo = 3 OR 1=2)'>
    i    s   1=2i   RZ   s    OR s   1=2)N(   R6   R   R;   RD   R   t   sumR   (   t   leftRr   t   lnRL   (    (    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/db.pyR     s    
5s    AND c         C  s7   t  j g  |  D]  \ } } | d t |  ^ q |  S(   s  
    Converts a two-tuple (key, value) iterable `data` to an SQL WHERE clause `SQLQuery`.
    
        >>> sqlwhere((('cust_id', 2), ('order_id',3)))
        <sql: 'cust_id = 2 AND order_id = 3'>
        >>> sqlwhere((('order_id', 3), ('cust_id', 2)), grouping=', ')
        <sql: 'order_id = 3, cust_id = 2'>
        >>> sqlwhere((('a', 'a'), ('b', 'b'))).query()
        'a = %s AND b = %s'
    s    = (   R   RJ   R   (   t   datat   groupingt   kR=   (    (    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/db.pyt   sqlwhere  s    c         C  s-   t  |  t  r t |   St |   j   Sd S(   s/  
    Ensures `a` is quoted properly for use in a SQL query.
    
        >>> 'WHERE x = ' + sqlquote(True) + ' AND y = ' + sqlquote(3)
        <sql: "WHERE x = 't' AND y = 3">
        >>> 'WHERE x = ' + sqlquote(True) + ' AND y IN ' + sqlquote([2, 3])
        <sql: "WHERE x = 't' AND y IN (2, 3)">
    N(   R6   R;   R\   R   R1   (   t   a(    (    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/db.pyR     s    	
t   Transactionc           B  s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   Database transaction.c           s     |  _  t   j  |  _  d d   f d     Y} d d	    f d     Y} d d
 d     Y} |  j r |  j  j d  r |   |  _ q |   |  _ n |   |  _ |  j j   |  j  j j |   d  S(   Nt   transaction_enginec             s;   e  Z d  Z   f d   Z   f d   Z   f d   Z RS(   s2   Transaction Engine used in top level transactions.c           s     j  d t  d  S(   Nt   unload(   t   commitRl   (   R%   (   t   ctx(    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/db.pyt   do_transact  s    c           s     j    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/db.pyt	   do_commit  s    c           s     j    d  S(   N(   t   rollback(   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/db.pyt   do_rollback  s    (   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/db.pyR|     s   t   subtransaction_enginec             s;   e  Z d  Z    f d   Z d   Z d   Z d   Z RS(   s,   Transaction Engine used in sub transactions.c           s-     j  j   }   j | t |    d  S(   N(   t   dbt   cursort
   db_executeR   (   R%   t   qt	   db_cursor(   R   t   transaction_count(    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/db.pyRE     s    c         S  s   |  j  d  d  S(   Ns   SAVEPOINT webpy_sp_%s(   RE   (   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/db.pyR     s    c         S  s   |  j  d  d  S(   Ns   RELEASE SAVEPOINT webpy_sp_%s(   RE   (   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/db.pyR     s    c         S  s   |  j  d  d  S(   Ns!   ROLLBACK TO SAVEPOINT webpy_sp_%s(   RE   (   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/db.pyR     s    (   R   R   R   RE   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/db.pyR     s
   		t   dummy_enginec           B  s   e  Z d  Z d   Z Z Z RS(   sn   Transaction Engine used instead of subtransaction_engine 
            when sub transactions are not supported.c         S  s   d  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/db.pyt   <lambda>  RH   (   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/db.pyR     s   t   ignore_nested_transactions(    (    (    (   R   RD   t   transactionsR   t   gett   engineR   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/db.pyR"     s    		c         C  s   |  S(   N(    (   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/db.pyt	   __enter__  s    c         C  s'   | d  k	 r |  j   n
 |  j   d  S(   N(   R.   R   R~   (   R%   t   exctypet   excvaluet	   traceback(    (    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/db.pyt   __exit__  s    
c         C  sH   t  |  j j  |  j k rD |  j j   |  j j |  j  |  j _ n  d  S(   N(   RD   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/db.pyR~      s    c         C  sH   t  |  j j  |  j k rD |  j j   |  j j |  j  |  j _ n  d  S(   N(   RD   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/db.pyR     s    (   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/db.pyR{     s   	/			c        	   B  s@  e  Z d  Z d   Z d   Z e e  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d e e d  Z d d d d d d d e d  Z d d d d d e d  Z d   Z d   Z d e d  Z d   Z d e d  Z d e d  Z d d e d  Z d   Z d   Z RS(   t   Databasec         C  s   | j  d d  | |  _ | |  _ t   |  _ t j d t j d t   |  _	 t |  _
 y d d l } t |  _ Wn t k
 r t |  _ n X|  j j  d t  o |  j |  _ d S(   s   Creates a database.
        t   drivert	   debug_sqlR   iNt   pooling(   t   popR.   t	   db_modulet   keywordsR   t   _ctxR   R   Rl   t   printingt   supports_multiple_insertt   DBUtilsRk   t   has_poolingt   ImportError(   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/db.pyR"     s    		!	!c         C  s,   |  j  j d  s% |  j |  j   n  |  j  S(   NR   (   R   R   t   _load_context(   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/db.pyt   _getctx   s    c           s   d   _  g    _  j r3  j  j    _ n  j  j    _  j   _ t	   j d  sx d     j _
 n  t	   j d  s d     j _ n  t    f d  }    f d   } |   _
 |   _ d  S(   Ni    R~   c           S  s   d  S(   N(   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/db.pyR   0  RH   R   c           S  s   d  S(   N(   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/db.pyR   2  RH   c           s3     j  j   |  r/  j r/  j  j  n  d  S(   N(   R   R~   R   t   _unload_contextR   (   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/db.pyR~   4  s    c             s-     j  j    j r)  j  j  n  d  S(   N(   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/db.pyR   9  s    	(   t	   dbq_countR   R   t   _connect_with_poolingR   R   t   _connectt   _db_executeR   t   hasattrR~   R   Rk   (   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/db.pyR   '  s    				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/db.pyR   A  s    c         C  s   |  j  j |   S(   N(   R   t   connect(   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/db.pyR   D  s    c           sF      f d   } t   d d   d  k r9 |    _ n   j j   S(   Nc            sa   d d l  m }  |  j j d  d j d  k  rG |  j d  j    S|  j d  j    Sd  S(   Ni(   t   PooledDBt   .s   0.9.3t   dbapit   creator(   R   R   t   __version__t   splitR   (   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/db.pyt   get_pooled_dbI  s    !t	   _pooleddb(   t   getattrR.   R   t
   connection(   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/db.pyR   G  s    c         C  s   |  j  j j   S(   N(   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/db.pyt
   _db_cursorT  s    c         C  sR   t  |  d d  } | d k r" d S| d k r2 d S| d
 k rB d St |   d	 S(   sH   Returns parameter marker based on paramstyle attribute if this database.R/   R)   R*   R+   R,   s   :1R-   s   %sN(   R-   R)   (   R   R   (   R%   t   style(    (    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/db.pyt   _param_markerW  s    c         C  s   |  j  j d 7_ yC t j   } |  j |  \ } } | j | |  } t j   } Wn_ |  j r t d t |  d t n  |  j  j	 r |  j  j	 d j
   n |  j  j
     n X|  j r t d t | | d  |  j  j t |  f d t n  | S(   s   executes an sql queryi   s   ERR:t   fileis   %s (%s): %si   (   R   R   t   timet   _process_queryt   executeR   t   printR5   R   R   R   t   round(   R%   t   curt	   sql_queryRz   RE   t   paramst   outt   b(    (    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/db.pyR   b  s     		9c         C  s7   t  |  d d  } | j |  } | j   } | | f S(   sK   Takes the SQLQuery object and returns query string and parameters.
        R/   R)   (   R   RE   RM   (   R%   R   R/   RE   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/db.pyR   w  s    c         C  s   t  | t  r" d t |  } n t  | t t f  rc t |  d k rc t | d | d  } nB t  | t  r |  j |  } n! t  | t  r n t	 | |  } | S(   Ns   id = i   i    i   (
   R6   R	   R   R;   RT   RD   R   t   dictt   _where_dictR   (   R%   t   wheret   vars(    (    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/db.pyt   _where  s    'c         C  sk   g  } xD t  t |  d d   D]' \ } } | j | d t |   q" W| rc t j | d  Sd  Sd  S(   Nt   keyc         S  s   |  d S(   Ni    (    (   t   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/db.pyR     RH   s    = s    AND (   t   sortedR
   R@   R   R   RJ   R.   (   R%   R   t   where_clausesRx   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/db.pyR     s    (c           s  | d k r i  } n  | r> t | t  r> t | |  } n  | rH | S|  j     |  j   |    j r g    j D] } | d ^ qw     f d   } t |    }   f d   | _    f d   | _	 n	   j
 } |  j j s |  j j   n  | Sd S(   sf  
        Execute SQL query `sql_query` using dictionary `vars` to interpolate it.
        If `processed=True`, `vars` is a `reparam`-style list to use 
        instead of interpolating.
        
            >>> db = DB(None, {})
            >>> db.query("SELECT * FROM foo", _test=True)
            <sql: 'SELECT * FROM foo'>
            >>> db.query("SELECT * FROM foo WHERE x = $x", vars=dict(x='f'), _test=True)
            <sql: "SELECT * FROM foo WHERE x = 'f'">
            >>> db.query("SELECT * FROM foo WHERE x = " + sqlquote('f'), _test=True)
            <sql: "SELECT * FROM foo WHERE x = 'f'">
        i    c          3  sC     j    }  x0 |  r> t t t  |     V  j    }  q Wd  S(   N(   t   fetchoneR   R   t   zip(   t   row(   R   t   names(    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/db.pyt   iterwrapper  s    	c             s   t    j  S(   N(   t   intt   rowcount(    (   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/db.pyR     RH   c            s2   g    j    D]! }  t t t  |     ^ q S(   N(   t   fetchallR   R   R   (   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/db.pyR     RH   N(   R.   R6   R   R   R   R   t   descriptionR   RF   R;   R   R   R   R~   (   R%   R   R   t	   processedt   _testRL   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/db.pyRE     s$    		 	t   *c
         C  s   | d k r i  } n  |  j | | | | | | |  }
 g  |
 D]- \ } } | d k	 r= |  j | | |  ^ q= } t j |  } |	 r | S|  j | d t Sd S(   s^  
        Selects `what` from `tables` with clauses `where`, `order`, 
        `group`, `limit`, and `offset`. Uses vars to interpolate. 
        Otherwise, each clause can be a SQLQuery.
        
            >>> db = DB(None, {})
            >>> db.select('foo', _test=True)
            <sql: 'SELECT * FROM foo'>
            >>> db.select(['foo', 'bar'], where="foo.bar_id = bar.id", limit=5, _test=True)
            <sql: 'SELECT * FROM foo, bar WHERE foo.bar_id = bar.id LIMIT 5'>
            >>> db.select('foo', where={'id': 5}, _test=True)
            <sql: 'SELECT * FROM foo WHERE id = 5'>
        R   N(   R.   t   sql_clausest
   gen_clauseR   RJ   RE   Rk   (   R%   t   tablesR   t   whatR   t   ordert   groupt   limitt   offsetR   R   t   sqlt   valt   clausest   qout(    (    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/db.pyt   select  s    	!:c   
      K  sF   |  j  |  }	 |  j | d | d | d | d | d | d | d |	 S(   s  
        Selects from `table` where keys are equal to values in `kwargs`.
        
            >>> db = DB(None, {})
            >>> db.where('foo', bar_id=3, _test=True)
            <sql: 'SELECT * FROM foo WHERE bar_id = 3'>
            >>> db.where('foo', source=2, crust='dewey', _test=True)
            <sql: "SELECT * FROM foo WHERE crust = 'dewey' AND source = 2">
            >>> db.where('foo', _test=True)
            <sql: 'SELECT * FROM foo'>
        R   R   R   R   R   R   R   (   R   R   (
   R%   t   tableR   R   R   R   R   R   t   kwargsR   (    (    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/db.pyR     s    c      	   C  sm   d | f d t  |  f d | f d | f d | f d | oK t |  j   f d | of t |  j   f f S(   Nt   SELECTt   FROMt   WHEREs   GROUP BYs   ORDER BYt   LIMITt   OFFSET(   R   R   R1   (   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/db.pyR     s    				c         C  s   t  | t  r= | d k r. d t |  } q t |  } n t  | t t f  r~ t |  d k r~ t | d | d  } nT | d k r t  | t  r |  j |  } n' t  | t  r | } n t	 | |  } d   } | | |  S(   NR   s   id = i   i    i   c         S  s&   |  r | r |  d | S|  p! | Sd  S(   NRN   (    (   Rz   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/db.pyt   xjoin	  s    (
   R6   R	   R   R   R;   RT   RD   R   R   R   (   R%   R   R   R   t   noutR   (    (    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/db.pyR     s    '		c         K  s  d   } | r t  | j   d d   } t j t d   |  d  } t j g  t d   |  D] } t |  ^ qa d  }	 d | | |  d | |	  }
 n t |  j |   }
 | r |
 S|  j   } | t k	 r |  j	 |
 | |  }
 n  t
 |
 t  r1|
 \ } } |  j | |  |  j | |  n |  j | |
  y | j   d	 } Wn t k
 rnd
 } n X|  j j s|  j j   n  | Sd
 S(   s;  
        Inserts `values` into `tablename`. Returns current sequence ID.
        Set `seqname` to the ID if it's not the default, or to `False`
        if there isn't one.
        
            >>> db = DB(None, {})
            >>> q = db.insert('foo', name='bob', age=2, created=SQLLiteral('NOW()'), _test=True)
            >>> q
            <sql: "INSERT INTO foo (age, created, name) VALUES (2, NOW(), 'bob')">
            >>> q.query()
            'INSERT INTO foo (age, created, name) VALUES (%s, NOW(), %s)'
            >>> q.values()
            [2, 'bob']
        c         S  s   d |  d S(   NRZ   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/db.pyR   !  s    R   c         S  s   |  d S(   Ni    (    (   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/db.pyR   %  RH   c         S  s   |  d S(   Ni    (    (   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/db.pyR   &  RH   s   , c         S  s   |  d S(   Ni   (    (   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/db.pyR   '  RH   s   INSERT INTO %s s    VALUES i    N(   R   R:   R   RJ   t   mapR   t    _get_insert_default_values_queryR   Rl   t   _process_insert_queryR6   RT   R   R   t	   ExceptionR.   R   R   R~   (   R%   t	   tablenamet   seqnameR   RM   R   t   sorted_valuest   _keysR=   t   _valuesR   R   t   q1t   q2R   (    (    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/db.pyt   insert  s0    	7%
c         C  s   d | S(   Ns   INSERT INTO %s DEFAULT 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/db.pyR   @  s    c         C  s>  | s
 g  S|  j  s[ g  | D]$ } |  j | d | d | | ^ q } | t k rT d S| Sn  | d j   } x/ | D]' } | j   | k rr t d   qr qr Wt |  } t d | d j |  f  } xx t |  D]j \ }	 }
 |	 d k r | j	 d  n  t j g  | D] } t
 |
 |  ^ q
d d d	 | d
 d d d q W| rM| S|  j   } | t k	 r}|  j | | |  } n  t | t  r| \ } } |  j | |  |  j | |  n |  j | |  y5 | j   d } t | t |  d | d  } Wn t k
 rd } n X|  j j s6|  j j   n  | Sd S(   s  
        Inserts multiple rows into `tablename`. The `values` must be a list of dictioanries, 
        one for each row to be inserted, each with the same set of keys.
        Returns the list of ids of the inserted rows.        
        Set `seqname` to the ID if it's not the default, or to `False`
        if there isn't one.
        
            >>> db = DB(None, {})
            >>> db.supports_multiple_insert = True
            >>> values = [{"name": "foo", "email": "foo@example.com"}, {"name": "bar", "email": "bar@example.com"}]
            >>> db.multiple_insert('person', values=values, _test=True)
            <sql: "INSERT INTO person (email, name) VALUES ('foo@example.com', 'foo'), ('bar@example.com', 'bar')">
        R   R   Ni    s   Not all rows have the same keyss   INSERT INTO %s (%s) VALUES s   , RO   RR   RP   RZ   RQ   R[   i   (   R   R   Rl   t   keysR!   R   R   RJ   R<   R@   R   R   R   R6   RT   R   R   t   rangeRD   R   R.   R   R   R~   (   R%   R   RM   R   R   R=   R   R   R   R>   R   Rx   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/db.pyt   multiple_insertC  sF    	1F%
c         K  s   | d k r i  } n  |  j | |  } t | j   d d   } d t |  d t | d  d | } | ru | S|  j   } |  j | |  |  j j	 s |  j j
   n  | j Sd S(   so  
        Update `tables` with clause `where` (interpolated using `vars`)
        and setting `values`.
        
            >>> db = DB(None, {})
            >>> name = 'Joseph'
            >>> q = db.update('foo', where='name = $name', name='bob', age=2,
            ...     created=SQLLiteral('NOW()'), vars=locals(), _test=True)
            >>> q
            <sql: "UPDATE foo SET age = 2, created = NOW(), name = 'bob' WHERE name = 'Joseph'">
            >>> q.query()
            'UPDATE foo SET age = %s, created = NOW(), name = %s WHERE name = %s'
            >>> q.values()
            [2, 'bob', 'Joseph']
        R   c         S  s   |  d S(   Ni    (    (   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/db.pyR     RH   s   UPDATE s    SET s   , s    WHERE N(   R.   R   R   R:   R   Ry   R   R   R   R   R~   R   (   R%   R   R   R   R   RM   RE   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/db.pyt   update|  s    	)c         C  s   | d k r i  } n  |  j | |  } d | } | rN | d t |  7} n  | re | d | 7} n  | ro | S|  j   } |  j | |  |  j j s |  j j   n  | j Sd S(   s  
        Deletes from `table` with clauses `where` and `using`.
        
            >>> db = DB(None, {})
            >>> name = 'Joe'
            >>> db.delete('foo', where='name = $name', vars=locals(), _test=True)
            <sql: "DELETE FROM foo WHERE name = 'Joe'">
        s   DELETE FROM s    USING s    WHERE N(	   R.   R   R   R   R   R   R   R~   R   (   R%   R   R   t   usingR   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/db.pyt   delete  s    		
c         C  s   | S(   N(    (   R%   RE   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/db.pyR     s    c         C  s   t  |  j  S(   s   Start a transaction.(   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/db.pyt   transaction  s    N(   R   R   R   R"   R   t   propertyR   R   R   R   R   R   R   R   R   R   R   R.   Rl   RE   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/db.pyR     s4   													*!		/	9	t
   PostgresDBc           B  s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   Postgres driver.c         K  s  d | k r" | j  d  | d <n  t d d d g d | j  d d   } | j d k r} d d  l } | j j | j j  n  | j d k r d	 | k r | d
 c d t | j  d	   7<n  d | k r | j  d  | d <n  d |  _	 | j
 |  _
 t j |  | |  t |  _ d  |  _ d  S(   Nt   pwt   passwordt   psycopg2t   psycopgt   pgdbt	   preferredR   it   portt   hostt   :R   R   t   postgres(   R   t   import_driverR.   R   t   psycopg2.extensionst
   extensionst   register_typet   UNICODER5   t   dbnameR/   R   R"   Rk   R   t
   _sequences(   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/db.pyR"     s     '&			c         C  sO   | d  k r4 | d } | |  j   k r4 d  } q4 n  | rK | d | 7} n  | S(   Nt   _id_seqs   ; SELECT currval('%s')(   R.   t   _get_all_sequences(   R%   RE   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/db.pyR     s    
c         C  sM   |  j  d k rF d } t g  |  j |  D] } | j ^ q(  |  _  n  |  j  S(   sD   Query postgres to find names of all sequences used in this database.s6   SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'N(   R  R.   t   setRE   t   relname(   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/db.pyR    s    1c         C  sN   t  j |  |  } y | j d  Wn$ t k
 rI | j   j d  n X| S(   Nt   UTF8s   set client_encoding to 'UTF-8'(   R   R   t   set_client_encodingt   AttributeErrorR   R   (   R%   R   t   conn(    (    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/db.pyR     s    c         C  s)   t  j |  |  } | j j j d  | S(   NR  (   R   R   t   _conR  (   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/db.pyR     s    (   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/db.pyR    s   						t   MySQLDBc           B  s#   e  Z d    Z d   Z d   Z RS(   c         K  s5  t  d d d g d | j d d   } | j d k r] d | k r] | d | d <| d =q] n  | j d k r d | k r | d | d <| d =q n  | j d k r d | k r | d | d <| d =q n  d	 | k r d
 | d	 <n | d	 d  k r | d	 =n  d |  _ | _ d |  _ t j |  | |  t |  _	 d  S(   Nt   MySQLdbt   pymysqls   mysql.connectorR	  R   R  t   passwdR  t   charsetRj   R)   t   mysql(
   R  R   R.   R   R/   R  R   R"   Rk   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/db.pyR"     s,    '
		c         C  s   | t  d  f S(   Ns   SELECT last_insert_id();(   R   (   R%   RE   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/db.pyR   
  s    c         C  s   d | S(   Ns   INSERT INTO %s () 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/db.pyR     s    (   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/db.pyR    s   		c         C  sn   | r | g }  n  x< |  D]4 } y t  | d d d g  SWq t k
 rL q Xq Wt d d j |     d S(   s;   Import the first available driver or preferred driver.
    RL   s   Unable to import s    or N(   t
   __import__R.   R   RJ   (   t   driversR	  t   d(    (    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/db.pyR    s    t   SqliteDBc           B  s#   e  Z d    Z d   Z d   Z RS(   c         K  s   t  d d d g d | j d d   } | j d k rB d | _ n  | j d | j  | j |  _ | j d  | d	 <t | d
 <d |  _ t	 j
 |  | |  d  S(   Nt   sqlite3s   pysqlite2.dbapi2t   sqliteR	  R   R*   t   detect_typesR   R   R   (   R)  s   pysqlite2.dbapi2(   R  R   R.   R   R/   t
   setdefaultt   PARSE_DECLTYPESRl   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/db.pyR"   $  s    '
	c         C  s   | t  d  f S(   Ns   SELECT last_insert_rowid();(   R   (   R%   RE   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/db.pyR   0  s    c         O  s1   t  j |  | |  } t | t  r- | ` n  | S(   N(   R   RE   R6   R   RF   (   R%   Rz   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/db.pyRE   4  s    	(   R   R   R"   R   RE   (    (    (    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/db.pyR(  "  s   		t
   FirebirdDBc           B  s5   e  Z d  Z d   Z d d d e d  Z d   Z RS(   s   Firebird Database.
    c         K  s   y d d  l  } Wn t k
 r) d  } n Xd | k rL | j d  | d <n  | j d  | d <| j |  _ t j |  | |  d  S(   NiR  R  R   R   (   t   kinterbasdbR   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/db.pyR"   ?  s    
c         C  s"   d  } t j |  | | | | |  S(   N(   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/db.pyR   L  s    c      	   C  sL   d	 d | f d | f d | f d t  |  f d | f d | f d | f f S(
   NR   RH   t   FIRSTt   SKIPR   R   s   GROUP BYs   ORDER BY(   R   RH   (   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/db.pyR   P  s    					N(   R   R   R   R"   R.   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/db.pyR/  ;  s   	t   MSSQLDBc           B  s,   e  Z d    Z d   Z d   Z d   Z RS(   c         K  sa   d d  l  } d | k r. | j d  | d <n  | j d  | d <d |  _ t j |  | |  d  S(   NiR  R  R   R   t   mssql(   t   pymssqlR   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/db.pyR"   e  s    	c         C  s=   t  |  d d  } | j |  } | j   } | t |  f S(   sK   Takes the SQLQuery object and returns query string and parameters.
        R/   R)   (   R   RE   RM   RT   (   R%   R   R/   RE   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/db.pyR   m  s    c         C  sI   d | f d | f d t  |  f d | f d | f d | f d | f f S(   NR   t   TOPR   R   s   GROUP BYs   ORDER BYR   (   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/db.pyR   v  s    					c         C  s   d S(   s  Test LIMIT.
        
            Fake presence of pymssql module for running tests.
            >>> import sys
            >>> sys.modules['pymssql'] = sys.modules['sys']
            
            MSSQL has TOP clause instead of LIMIT clause.
            >>> db = MSSQLDB(db='test', user='joe', pw='secret')
            >>> db.select('foo', limit=4, _test=True)
            <sql: 'SELECT * TOP 4 FROM foo'>
        N(    (   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/db.pyR     s    (   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/db.pyR3  c  s   				t   OracleDBc           B  s   e  Z d    Z d   Z RS(   c         K  s   d d  l  } d | k r. | j d  | d <n  | j d  | d <d |  _ d | _ | j |  _ | j d d   t j |  | |  d  S(	   NiR  R  R   t   dsnt   oracleR,   R   (   t	   cx_OracleR   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/db.pyR"     s    		c         C  s    | d  k r | S| d | Sd  S(   Ns   ; SELECT %s.currval FROM dual(   R.   (   R%   RE   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/db.pyR     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/db.pyR7    s   	c         C  sY   t  j  t |    } i | j d 6| j d 6| j d 6| j d d 6| j d 6| j d 6S(   sI  
    Takes a URL to a database and parses it into an equivalent dictionary.
    
        >>> dburl2dict('postgres:///mygreatdb') == {'pw': None, 'dbn': 'postgres', 'db': 'mygreatdb', 'host': None, 'user': None, 'port': None}
        True
        >>> dburl2dict('postgres://james:day@serverfarm.example.net:5432/mygreatdb') == {'pw': 'day', 'dbn': 'postgres', 'db': 'mygreatdb', 'host': 'serverfarm.example.net', 'user': 'james', 'port': 5432}
        True
        >>> dburl2dict('postgres://james:day@serverfarm.example.net/mygreatdb') == {'pw': 'day', 'dbn': 'postgres', 'db': 'mygreatdb', 'host': 'serverfarm.example.net', 'user': 'james', 'port': None}
        True
        >>> dburl2dict('postgres://james:d%40y@serverfarm.example.net/mygreatdb') == {'pw': 'd@y', 'dbn': 'postgres', 'db': 'mygreatdb', 'host': 'serverfarm.example.net', 'user': 'james', 'port': None}
        True
        >>> dburl2dict('mysql://james:d%40y@serverfarm.example.net/mygreatdb') == {'pw': 'd@y', 'dbn': 'mysql', 'db': 'mygreatdb', 'host': 'serverfarm.example.net', 'user': 'james', 'port': None}
        True
    t   dbnt   userR  i   R   R  R
  (   t   urlparseR   t   schemet   usernameR  t   patht   hostnameR
  (   t   urlt   parts(    (    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/db.pyt
   dburl2dict  s    

c         K  sl   |  r | r t  j d }  n  |  r3 t |   } n  | j d  } | t k r\ t | |   St |   d S(   s   Creates appropriate database using params.
    
    Pooling will be enabled if DBUtils module is available. 
    Pooling can be disabled by passing pooling=False in params.
    t   DATABASE_URLR;  N(   t   ost   environRD  R   t
   _databasesR   (   t   dburlR   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/db.pyR     s    c         C  s   | t  |  <d S(   s  
    Register a database.
    
        >>> class LegacyDB(DB): 
        ...     def __init__(self, **params): 
        ...        pass 
        ...
        >>> register_database('legacy', LegacyDB)
        >>> db = database(dbn='legacy', db='test', user='joe', passwd='secret') 
    N(   RH  (   t   namet   clazz(    (    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/db.pyt   register_database  s    R$  R  R*  t   firebirdR4  R9  c         C  s  d   } d } g  } d } x|  j  d |  } | d k  r@ Pn  |  | d } | d k r| j d |  | | !f  | d d } } xq | r | |  |  \ } } | j d \ }	 }
 |  |	 |
 !} | d k r | d } q | d	 k r | d } q q W| j d |  | d | d !f  q | | k r| j d |  | | !f  | |  | d  \ } } x| t |   k  rl|  | d
 k r| d t |   k  r|  | d | k r| |  | d  \ } } q`|  | d k rh| d d } } x} | rd| |  |  \ } } | j d \ }	 }
 |  |	 |
 !} | d d k rD| d } q| d d k r| d } qqWq`Pq`W| j d |  | d | !f  q | j d |  | | d !f  | d | d k } q W| t |   k  r| j d |  | f  n  | S(   s   
    Takes a format string and returns a list of 2-tuples of the form
    (boolean, string) where boolean says whether string should be evaled
    or not.
    
    from <http://lfw.org/python/Itpl.py> (public domain, Ka-Ping Yee)
    c         S  s@   t  j |  |  } | d  k r0 t |  |   n  | | j   f S(   N(   t	   tokenprogt   matchR.   R    t   end(   R#   R$   RO  (    (    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/db.pyt   matchorfail  s    t?   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_i    t   $i   t   {i   i   t   }R   s   ([s   )](   t   findR@   t   regsRD   (   R-   RQ  t	   namecharst   chunksR$   t   dollart   nextchart   levelRO  t   tstartt   tendt   token(    (    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/db.pyRb     sX    			%:	!t   _Nodec           B  s&   e  Z d d   Z d   Z d   Z RS(   c         C  s   | |  _  | |  _ | |  _ d  S(   N(   t   typet   firstt   second(   R%   Ra  Rb  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/db.pyR"   /  s    		c         C  sC   t  | t  oB |  j | j k oB |  j | j k oB |  j | j k S(   N(   R6   R`  Ra  Rb  Rc  (   R%   R2   (    (    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/db.pyR7   4  s    c         C  s   d |  j  |  j |  j f S(   Ns   Node(%r, %r, %r)(   Ra  Rb  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/db.pyR8   7  s    N(   R   R   R.   R"   R7   R8   (    (    (    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/db.pyR`  -  s   	t   Parserc           B  sS   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s   Parser to parse string templates like "Hello $name".
    
    Loosely based on <http://lfw.org/python/Itpl.py> (public domain, Ka-Ping Yee)
    RR  c         C  s   |  j    d  S(   N(   t   reset(   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/db.pyR"   B  s    c         C  s   d |  _  d |  _ d |  _ d  S(   Ni    RH   (   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/db.pyRe  E  s    		c         C  s   |  j    | |  _ |  j   S(   s8   Parses the given text and returns a parse tree.
        (   Re  R#   t	   parse_all(   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/db.pyR   J  s    
	c         c  s  xUt  rW|  j j d |  j  } | d k  r1 Pn  |  j | d } | |  j k r t d |  j |  j | ! V| d |  _ |  j   Vq | d k r
|  j } | d |  _ |  j   } |  j |  j d k r |  j d 7_ t d |  j |  j | ! V| VqT| |  _ Pq t d |  j |  j | d ! V| d |  _ | d k r |  j d 7_ q q W|  j t |  j  k  rt d |  j |  j  Vn  d  S(   NRS  i    i   R#   RT  i   RU  (   Rk   R#   RV  R$   RX  R`  t
   parse_exprRD   (   R%   RZ  R[  t	   saved_post   expr(    (    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/db.pyRf  Q  s2    			c         C  sL   t  j |  j |  j  } | d  k r< t |  j |  j   n  | | j   f S(   N(   RN  RO  R#   R$   R.   R    RP  (   R%   RO  (    (    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/db.pyRO  o  s    c         C  s   | o | d d k S(   Ni    s   0123456789"'(    (   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/db.pyt
   is_literalu  s    c         C  s  |  j    \ } } |  j | j    r? t d | j    } n t d |  j |  j | ! } | |  _ x8|  j t |  j  k  r|  j |  j d k r|  j d t |  j  k  r|  j |  j d |  j k r|  j d 7_ |  j    \ } } | j   } t d | |  } | |  _ qg |  j |  j d k r|  j } |  j d 7_ |  j   } |  j |  j d k r|  j d 7_ t d | |  } q| |  _ Pqg Pqg W| S(	   Nt   literalt   paramR   i   R   t   [t   ]t   getitem(	   RO  Rj  R   R`  R#   R$   RD   RX  Rg  (   R%   RO  R$   Ri  t   attrRh  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/db.pyRg  x  s.    	O		(   R   R   R   RX  R"   Re  R   Rf  RO  Rj  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/db.pyRd  ;  s   						R^   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   s5   Safe evaluator for binding params to db queries.
    c         C  sA   t    j |  } t j g  | D] } |  j | |  ^ q d  S(   NRH   (   Rd  R   R   RJ   t	   eval_node(   R%   R#   t   mappingt   nodest   node(    (    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/db.pyR_     s    c         C  s0   | j  d k r | j St |  j | |   Sd  S(   NR#   (   Ra  Rb  R   t	   eval_expr(   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/db.pyRq    s    c         C  s   | j  d k r t j | j  S| j  d k rM t |  j | j |  | j  S| j  d k r |  j | j |  |  j | j |  S| j  d k r | | j Sd  S(   NRk  R   Ro  Rl  (   Ra  t   astt   literal_evalRb  R   Ru  Rc  (   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/db.pyRu    s    &(   R   R   R   R_   Rq  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/db.pyR^     s   		c       	   C  s  d   }  |  d t  d d  g  |  d t  d d  t  d d  g  |  d t  d d  t  d	 t  d d  d
  g  |  d t  d d  t  d	 t  d d d   d  t  d d  g  |  d t  d d  t  d t  d d d   t  d d   t  d d  g  d  S(   Nc         S  sQ   t    } t | j |    } t t |   |  | | k sM t d |   d  S(   Ns   Expected %r(   Rd  R;   R   R   R&   t   AssertionError(   R#   t   expectedt   pRs  (    (    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/db.pyt   f  s    	t   HelloR#   s   Hello $names   Hello Rl  RJ  s   Hello $name.fooR   t   foos   WHERE id=$self.id LIMIT 1s	   WHERE id=R%   t   ids    LIMIT 1s   WHERE id=$self['id'] LIMIT 1Ro  Rk  s   'id'(   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/db.pyt   test_parser  s    	%$c          C  s[   d   }  t  |  d i d d 6 j  |  d i d d 6 j d t d  g k sW t  d  S(   Nc         S  s   t    j |  |  S(   N(   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/db.pyR{    s    s   WHERE id=$idi   R~  s	   WHERE id=(   R   R:   R   Rx  (   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/db.pyt   test_safeeval  s    	t   __main__(M   R   t
   __future__R    t   utilsR   R   R   R   R   R   Rm   R   RF  t   urllibt   ret
   py3helpersR   R   R	   R
   R   R=  t   urllib.parseR   R   Rv  R.   t   webapiR   R   t   syst   stderrt   __all__t   TOKENt   compileRN  R   R   R!   R    R   R   Ra   R   R   R   R   R   R\   R   RU   R   R   Ry   R   R{   R   R  R  R  R(  R/  R3  R7  RD  RH  R   RL  Rb   R`  Rd  R^   R  R  R   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/db.pyt   <module>	   s   ."
				0						G 4"(3			B[			
