[19049] 2018-11-28_MySQLconnectfileread

文档创建者:s7ckTeam
浏览次数:5
最后更新:2025-01-18
2018-11-28_MySQLconnectfileread M y S Q L   c o n n e c t   f i l e   r e a d r u s s i a n s e c u r i t y   i n n 0 t e a m   2 0 1 8 - 1 1 - 2 8 H o w d y ,   g u y s .   T o d a y   I   w a n t   t o   t e l l   y o u   a b o u t   M y S Q L   &   M a r i a D B   p r o t o c o l   f e a t u r e   w h i c h   c a n   h e l p   y o u   r e a d   f i l e s   f r o m   c l i e n t . I t   w o r k s   o n   a l l   p l a t f o r m s   a n d   a l l   v e r s i o n s   o f   M y S Q L / M a r i a D B   s e r v e r . O v e r v i e w . F o r   t e s t i n g   p u r p o s e s   I m   i n s t a l l   i n s t a n c e   o f   M y S Q L   s e r v e r .   I   w a s   u s e d   a   W i r e s h a r k   a s   t r a f f i c   a n a l y z e r   t o o l   a n d   t c p d u m p   f o r   c a p t u r e . I m   c o n n e c t   t o   m y   s e r v e r   f r o m   m y s q l   c l i e n t   w i t h   e n a b l e - l o c a l - i n f i l e   o p t i o n   a n d   r u n   L O A D   D A T A   L O C A L   I N F I L E   / e t c / p a s s w d   I N T O T A B L E   t e s t   F I E L D S   T E R M I N A T E D   B Y   n ;   q u e r y . M y S Q L   l o c a l   d a t a   i n f i l e L e t s   s e e   i n   d e p t h   h o w   L O C A L   D A T A   I N F I L E   q u e r y   w o r k s . 1 .   C l i e n t   c o n n e c t s   t o   T C P   3 3 0 6   p o r t
2 .   S e r v e r   s e n d   g r e e t i n g   p a c k e t   w i t h   p r o t o c o l   t h r e a d   i d ,   v e r s i o n ,   t y p e   o f   m y s q l   a u t h e n t i c a t i o n   e t c . M y S Q L   g r e e t i n g   p a c k e t 3 .   N e x t   p a c k e t   f r o m   c l i e n t   i s   a u t h e n t i c a t i o n   p a c k e t   w i t h   u s e r n a m e ,   p a s s w o r d ,   d a t a b a s e .   T h e r e   i s   c l i e n t   c a p a b i l i t i e s   b i n a r y   m a s k   w i t h   C a n   U s e L O A D   D A T A   L O C A L   o p t i o n   ( r e m e m b e r   e n a b l e - l o c a l - i n f i l e ) . M y S Q L   a u t h   p a c k e t 4 .   A f t e r   t h a t   t h e r e   a r e   s o m e   p a c k e t   w i t h   c l i e n t   s p e c i f i e d   q u e r i e s   l i k e :   s h o w   d a t a b a s e s ,   s e l e c t   @ @ v e r s i o n _ c o m m e n t   l i m i t   1   e t c .
M y S Q L   p a c k e t s   w i t h   s p e c i f i e d   q u e r i e s 5 .   A n d   n o w   w e   c a n   s e e   p a c k e t   f r o m   c l i e n t   w i t h   o u r   q u e r y   w i t h   L O A D   D A T A   L O C A L   I N F I L E   / e t c / p a s s w d   I N T O   T A B L E   t e s t F I E L D S   T E R M I N A T E D   B Y   n L o c a l   d a t a   i n f i l e   p a c k e t L o o k   a t   t h e   s e r v e r   r e s p o n s e   p a c k e t
L o c a l   d a t a   i n f i l e   s e r v e r   r e s p o n s e T h i s   p a c k e t   i s   s a y   t o   o u r   c l i e n t :   H e y   c l i e n t ,   p l e a s e   r e a d   t h e   / e t c / p a s s w d   f i l e   a n d   s e n d   t o   i t   m e   I l l   s e e   w h a t   I   c a n   d o   f o r   y o u . W h a t s   h a p p e n s   i f   w e   a r e   c r a f t   p a c k e t   l i k e   t h i s   m a n u a l l y   a n d   s e n d   t o   c l i e n t ?   T h a t s   r i g h t   w e l l   r e a d   f i l e   f r o m   c l i e n t   m a c h i n e . E x p l o i t . T o   e x p l o i t   t h i s   y o u   n e e d : 1 .   G r e e t   M y S Q L   c l i e n t 2 .   W a i t   f o r   q u e r y   p a c k e t   ( 0 3 ) 3 .   A n s w e r   w i t h   l o c a l   d a t a   f i l e   r e q u e s t   ( 0 c   0 0   0 0   0 1   f b   2 f   6 5   7 4   6 3   2 f   7 0   6 1   7 3   7 3   7 7   6 4 ) .   F i r s t   t w o   b y t e s   i s   s i z e   o f   p a c k e t   ( 0 c ) .   N e x t   6   b y t e s i s   p a c k e t   n u m b e r   ( 0 0   0 0   0 1 ) .   N e x t   t w o   b y t e s   i s   p a c k e t   t y p e   ( f b )   a n d   t h e n   f i l e n a m e   ( 2 f   6 5   7 4   6 3   2 f   7 0   6 1   7 3   7 3   7 7   6 4   / e t c / p a s s w d ) . Y o u   c a n   f i n d   p s e u d o   M y S Q L   s e r v e r   f o r   t h i s   f e a t u r e   e x p l o i t a t i o n   h e r e   h t t p s : / / g i t h u b . c o m / G i f t s / R o g u e - M y S q l - S e r v e r .   T h a n k s   t o   G i f t s f r o m   P o s i t i v e   T e c h o n o l i g e s   ( h t t p : / / w w w . p t s e c u r i t y . c o m / )   f o r   s h a r e   t h a t .   R e a d   f i l e s   a r e   w r i t t e n   t o   m y s q l . l o g . F o r   s u c c e s s f u l l y   e x p l o i t a t i o n   y o u   n e e d   a t   l e a s t   o n e   q u e r y   t o   s e r v e r .   F o r t u n a t e l y   m o s t   o f   m y s q l   c l i e n t s   m a k e s   a t   l e a s t   o n e   q u e r y   l i k e   S E T n a m e s   u t f 8   o r   s o m e t h i n g . H e r e   ( h t t p s : / / g i t h u b . c o m / a l l y s h k a / R o g u e - M y S q l - S e r v e r )   y o u   c a n   s e e   m y   f o r k   w h i c h   w o r k i n g   w i t h   l a t e s t   M y S Q L   v e r s i o n s .   E d i t   s o u r c e   c o d e a n d   s p e c i f y   f i l e s   t o   r e a d .
R e a d   f i l e   t h r o u g h   a d m i n e r E x p l o i t   d i f f e r e n t   c l i e n t s . P H P P H P   h a s   s o m e   m y s q l   c l i e n t   e x t e n s i o n s   l i k e   m y s q l ,   m y s q l i ,   p d o .   A l l   o f   t h e m   a r e   e x p l o i t a b l e   i n s t e a d   o f   P D O .   I n   P D O   l o a d   d a t a   l o c a l   i s   d i s a b l e d b y   d e f a u l t .   I f   y o u   t r y   t o   r e a d   f i l e   t h e n   y o u   r e c e i v e   a n   e r r o r   m e s s a g e . F o r   e n a b l e   e x p l o i t a t i o n   y o u   c a n   s e t   P D O : : M Y S Q L _ A T T R _ L O C A L _ I N F I L E   t o   t r u e   i n   c o n n e c t   o p t i o n s   h t t p : / / p h p . n e t / m a n u a l / e n / r e f . p d o - m y s q l . p h p # p d o . c o n s t a n t s . m y s q l - a t t r - l o c a l - i n f i l e .   B u t   n e i t h e r   d e v e l o p e r s   e n a b l e   t h i s   o p t i o n   o f   c o u r s e . L o o k   c l o s e r   a t   m y s q l n d   l i b r a r y .   M y s q l n d     M y S Q L   n a t i v e   d r i v e r   f o r   P H P   i s   a   d r o p - i n   r e p l a c e m e n t   f o r   t h e   M y S Q L   C l i e n t   L i b r a r y   ( l i b m y s q l ) f o r   t h e   P H P   s c r i p t   l a n g u a g e . M y s q l n d   i s   d e f a u l t   P H P   d r i v e r   f r o m   5 . 4   v e r s i o n .   I f   P H P   r u n n i n g   w i t h   t h a t   l i b r a r y   y o u   c a n   u s e   w r a p p e r s   d u r i n g   e x p l o i t a t i o n . E d i t   M y S Q L   e x p l o i t I   w a s   c r e a t e d   s i m p l e   c o d e   f o r   t e s t i n g   p u r p o s e s :
A n d   t r y   t o   r e a d   Y a n d e x   s t a r t   p a g e   t h r o u g h   r e s o u r c e   f i l t e r   p h p : / / f i l t e r / c o n v e r t . b a s e 6 4 - e n c o d e / r e s o u r c e = h t t p : / / y a . r u : m y s q l n d   P H P   w r a p p e r   r e a d I t s   w o r k i n g   v e r y   w e l l     M o v e   n e x t . P y t h o n I f   s e r v e r   u s e s   M y S Q L d b   a s   c l i e n t   l i b r a r y   t h e   e x p l o i t   d o e s n t   w o r k .   l o c a l _ i n f i l e   c o n n e c t   o p t i o n   i s   r e q u i r e d   t o   s e t   u p .   B u t   w i t h   m y s q l . c o n n e c t o r e x p l o i t   w o r k i n g   v e r y   w e l l .   T h a t s   a l l   f o r   n o w .   Y o u   c a n   t r y   t o   c h e c k   f o r   s u c c e s s f u l   e x p l o i t a t i o n   i n   o t h e r   l a n g u a g e   b y   y o u r s e l f .   H a v e   n i c e   d a y   a n d   g o o d   l u c k .
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则