[15762] 2020-08-22_甲方自研分布式WAF落地全程实录

文档创建者:s7ckTeam
浏览次数:4
最后更新:2025-01-18
2020-08-22_甲方自研分布式WAF落地全程实录 W A F n J c x 9 1   F r e e B u f   2 0 2 0 - 0 8 - 2 2 W e b W e b   A p p l i c a t i o n   F i r e w a l l W A F W e b H T T P / H T T P S W e b D D D O S W A F W A F L B W A F W A F W A F O p e n R e s t y 使 L u a , I P U R L C C R e d i s A P I W A F R e d i s L u a 使 r e d i s - l u a   2 . 0 . 5 - d e v l u a s o c k e t   i n i t _ w o r k e r . l u a     n g i n x   r e l o a d     n g i n x   r e l o a d     m a s t e r 退 w o r k e r   退 i n i t . l u a     n g i n x   r e l o a d   G E T P O S T H e a d e r j s o n O p e n R e s t y i n i t _ w o r k e r . l u a   n g i n x   r e l o a d   a c c e s s . l u a , w g e t   h t t p s : / / o p e n r e s t y . o r g / d o w n l o a d / o p e n r e s t y - 1 . 1 3 . 6 . 1 . t a r . g z t a r   - z x v f   o p e n r e s t y - 1 . 1 3 . 6 . 1 . t a r . g z c d   o p e n r e s t y - 1 . 1 3 . 6 . 1 /   & &   . / c o n f i g u r e   - - p r e f i x = / u s r / l o c a l / o p e n r e s t y   - - w i t h - p c r e - j i t   - - w i t h - h t t p _ i c o n v _ m o d u l e     - - w i t h - h t t p _ g u n z i p _ m o d u l e   - - w i t h - h t t p _ a u t h _ r e q u e s t _ m o d u l e     - - w i t h / / g m a k e   & &   g m a k e   i n s t a l l m a k e   & &   m a k e   i n s t a l l l u a r o c k s - 3 . 1 . 3 w g e t   h t t p s : / / l u a r o c k s . g i t h u b . i o / l u a r o c k s / r e l e a s e s / l u a r o c k s - 3 . 1 . 3 . t a r . g z t a r   - z x v f   l u a r o c k s - 3 . 1 . 3 . t a r . g z c d   l u a r o c k s - 3 . 1 . 3 / . / c o n f i g u r e   - - p r e f i x = / u s r / l o c a l / o p e n r e s t y / l u a j i t   - - w i t h - l u a = / u s r / l o c a l / o p e n r e s t y / l u a j i t /   - - l u a - s u f f i x = j i t     - - w i t h - l u a - i n c l u d e = / u s r / l o c a l / o p e n r e s t y / l u a j i t / i n c l u d e / l u a j i t - 2 . 1 / / m a k e   & & m a k e   i n s t a l l l u a s o c k e t / u s r / l o c a l / o p e n r e s t y / l u a j i t / b i n / l u a r o c k s   i n s t a l l   l u a s o c k e t                                                                                                                                                                                                                                                                                                                                                                     b u g   / u s r / l o c a l / o p e n r e s t y / l u a j i t / l i b / l u a / 5 . 1     m i m e     s o c k e t   {         " s t a t e " :   " e n a b l e " ,         " r u l e _ i d " : " s c a n n e r _ 0 1 " ,         " r u l e _ t a g " : " s c a n n e r " ,         " r u l e _ n a m e " : " s c a n n e r _ h u n t e r " ,         " u s e r a g e n t " :   [ " ( d i r b u s t e r | p a n g o l i n | n m a p | B B B i k e | s q l m a p | w 3 a f | o w a s p | N i k t o | a p a c h e b e n c h ) " , " j i o s " ] ,         " a c t i o n " :   " d e n y " ,         " i n f o " :   " s c a n n e r   a t t a c k " } l o c a l   _ b a s e d i r   =   c o n f i g . p r o d . c o n f i g _ r u l e _ d i r _ M . r u l e _ t a b l e . r e f e r e r _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " r e f e r e r . j s o n " ) _ M . r u l e _ t a b l e . u r i _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " u r i . j s o n " ) _ M . r u l e _ t a b l e . h e a d e r _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " h e a d e r . j s o n " ) _ M . r u l e _ t a b l e . u s e r a g e n t _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " u s e r a g e n t . j s o n " )
C C C C   a c c e s s . l u a   I P k e y k e y 访 a c c e s s . l u a   k e y 1 s k e y I P I P I P a c c e s s . l u a   I P k e y 1 s k e y _ M . r u l e _ t a b l e . u s e r a g e n t _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " u s e r a g e n t . j s o n " ) _ M . r u l e _ t a b l e . c o o k i e _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " c o o k i e . j s o n " ) _ M . r u l e _ t a b l e . a r g s _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " a r g s . j s o n " ) _ M . r u l e _ t a b l e . p o s t _ r u l e   =   l o a d _ j s o n ( _ b a s e d i r . . " p o s t . j s o n " ) r u l e _ d i c t   : s a f e _ s e t ( " r u l e " , c j s o n . e n c o d e ( _ M . r u l e _ t a b l e ) , 0 ) i f   i n f o   t h e n         u t i l . w a f _ i n f o _ l o g ( u t i l . t a b l e _ t o _ j s o n ( _ M . r u l e _ t a b l e ) )         u t i l . w a f _ i n f o _ l o g ( e n v   . .   ' : l o a d r u l e . l u a   w o r k   w e l l ' ) e n d r u l e _ d i c t   : s a f e _ s e t ( " r u l e _ v e r s i o n " , 1 . 2 , 0 ) i f   c c _ p o l i c y     t h e n                 l o c a l   t i m e   =   t o n u m b e r ( u t i l . s p l i t _ s t r _ t a b l e ( c c _ p o l i c y   ,   " , " ) [ 1 ] )       - -                   l o c a l   t i m e s   =   t o n u m b e r ( u t i l . s p l i t _ s t r _ t a b l e ( c c _ p o l i c y   ,   " , " ) [ 2 ] )     - -                   l o c a l   b l o c k _ t i m e   =   t o n u m b e r ( u t i l . s p l i t _ s t r _ t a b l e ( c c _ p o l i c y   ,   " , " ) [ 3 ] )     - -                   l o c a l   r e q ,   _   =   n g x . s h a r e d . c c : g e t ( " c c _ d e n y _ " . . h o s t . . r e a l _ i p )                 i f   r e q   t h e n                         _ M . l o g _ r e c o r d ( " c c _ m o d u l e " ,   ' c c _ 0 1 ' ,   ' c c ' , ' c c ' , ' c c   a t t a c k )                         u t i l . w a f _ o u t p u t ( b l o c k _ t e m p l a t e _ c c )                         e n d                 e n d                 l o c a l   r e q _ h ,   _   =   n g x . s h a r e d . c c : g e t ( h o s t . . r e a l _ i p )                 i f   r e q _ h   t h e n                         i f   r e q _ h   > =   t i m e s   t h e n                                 n g x . s h a r e d . c c : s e t ( " c c _ d e n y _ " . . h o s t . . r e a l _ i p ,   " 1 " ,   b l o c k _ t i m e * 6 0 )                                 _ M . l o g _ r e c o r d ( " c c _ m o d u l e " ,   ' c c _ 0 1 ' ,   ' c c ' ,   ' c c ' , ' c c   a t t a c k ' )                                 u t i l . w a f _ o u t p u t ( b l o c k _ t e m p l a t e _ c c )                         e l s e                                 n g x . s h a r e d . c c : i n c r ( h o s t . . r e a l _ i p ,   1 )                         e n d                 e l s e                         n g x . s h a r e d . c c : s e t ( h o s t . . r e a l _ i p ,   1 ,   t i m e )                 e n d         e n d l o c a l   f l o w _ m a x   =   t o n u m b e r ( u t i l . s p l i t _ s t r _ t a b l e ( f l o w _ r a t e ,   " , " ) [ 1 ] )         - -   q p s         l o c a l   b l o c k _ t i m e   =   t o n u m b e r ( u t i l . s p l i t _ s t r _ t a b l e ( f l o w _ r a t e ,   " , " ) [ 2 ] )     - -           l o c a l   r e q   =   n g x . s h a r e d . f l o w _ c o n t r o l : g e t ( " f l o w _ d e n y _ " . . h o s t . . r e a l _ i p )         i f   r e q   t h e n                 _ M . l o g _ r e c o r d ( " f l o w _ m o d u l e " ,   ' f l o w _ 0 1 ' , ' f l o w ' ,   ' f l o w ' , ' f l o w   p o l i c y ' )                                 u t i l . w a f _ o u t p u t ( b l o c k _ t e m p l a t e _ f l o w )                 e n d         e n d         l o c a l   f l o w _ c o u n t ,   _   =   n g x . s h a r e d . f l o w _ c o n t r o l : g e t ( h o s t )         i f   f l o w _ c o u n t   t h e n                 i f   f l o w _ c o u n t > =   f l o w _ m a x   t h e n                         n g x . s h a r e d . f l o w _ c o n t r o l : s e t ( " f l o w _ d e n y _ " . . h o s t . . r e a l _ i p ,   " 1 " ,   b l o c k _ t i m e * 6 0 )                         _ M . l o g _ r e c o r d ( " f l o w _ m o d u l e " ,   ' f l o w _ 0 1 ' , ' f l o w ' ,   ' f l o w ' , ' f l o w   p o l i c y ' )                         u t i l . w a f _ o u t p u t ( b l o c k _ t e m p l a t e _ f l o w )                 e l s e                         n g x . s h a r e d . f l o w _ c o n t r o l : i n c r ( h o s t ,   1 )                 e n d         e l s e                 n g x . s h a r e d . f l o w _ c o n t r o l : s e t ( h o s t ,   1 ,   1 )         e n d e n d f l o w _ r a t e   = n g x . s h a r e d . f l o w _ i p _ r u l e s : g e t ( i p _ s t r _ k e y )       - -   I P   1 s i f   f l o w _ r a t e   t h e n         l o c a l   f l o w _ c o u n t ,   _   =   n g x . s h a r e d . f l o w _ c o n t r o l : g e t ( h o s t . . r e a l _ i p )         i f   f l o w _ c o u n t   t h e n                 i f   f l o w _ c o u n t > =   t o n u m b e r ( f l o w _ r a t e )   t h e n                         _ M . l o g _ r e c o r d ( " f l o w _ m o d u l e " ,   ' f l o w _ i p _ 0 1 ' , ' f l o w ' ,   ' f l o w _ i p ' , ' f l o w   p o l i c y ' )                         u t i l . w a f _ o u t p u t ( b l o c k _ t e m p l a t e _ f l o w )
W A F j s o n l o g 使 l o g s t a s h k a f k a e s W A F   l o g n g i n x w o r k e r   w w w - d a t a ,   l o g l o g h t t p w r k :   . / w r k   - t 8   - c 2 0 0   - d 1 0 s   h t t p : / / 1 1 0 . 1 1 0 . 1 1 0 . 1 1 0 / w a f u p s t r e a m   s e r v e r 1 ,   s e r v e r 2 ,   s e r v e r 3   , 8 0   ( ) i p 1 0 0 U R L 1 0 0 , 1 0 0 ,   c c 1 0 0 g e t p o s t   u a   u r l   R e q u e s t s / s e c :   1 5 4 2 3 . 3 7 L a t e n c y 2 8 . 5 9 m s                 e l s e                         n g x . s h a r e d . f l o w _ c o n t r o l : i n c r ( h o s t . . r e a l _ i p ,   1 )                 e n d         e l s e                 n g x . s h a r e d . f l o w _ c o n t r o l : s e t ( h o s t . . r e a l _ i p ,   1 ,   1 )         e n d e n d W A F 1 4 . 0 4 . 1 - U b u n t u     I P   :     1 1 0 . 1 1 0 . 1 1 0 . 1 1 0 K e r n e l   V e r s i o n :   4 . 2 . 0 - 2 7 - g e n e r i c C P U   T y p e   :   I n t e l ( R )   X e o n ( R )   C P U   E 5 - 2 6 8 0   v 4   @   2 . 4 0 G H z     *   2 M e m o r y   S i z e   :   6 4 G N e t w o r k   C a r d   :   I n t e l   1 0 - G i g a b i t   X 5 4 0 - A T 2   ( r e v   0 1 )         1 0 G T e s t i n g   d o w n l o a d   s p e e d . . . . . . . . D o w n l o a d :   5 8 8 . 1 7   M b i t / s T e s t i n g   u p l o a d   s p e e d . . . . . . . . . . U p l o a d :   3 3 2 . 2 1   M b i t / s C e n t O S   6 . 5       I P 1 1 2 . 1 1 2 . 1 1 2 . 1 1 2 T e s t i n g   d o w n l o a d   s p e e d . . . . . . . . . . . . . . . D o w n l o a d :   5 0 0 . 9 6   M b i t / s T e s t i n g   u p l o a d   s p e e d . . . . . . . . . . . . . . . . U p l o a d :   3 2 7 . 6 5   M b i t / s

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

本版积分规则