[10963] 2017-01-23_Python的无状态SYN快速扫描

文档创建者:s7ckTeam
浏览次数:8
最后更新:2025-01-18
2017-01-23_Python的无状态SYN快速扫描 P y t h o n S Y N a d d a d d   F r e e B u f   2 0 1 7 - 0 1 - 2 3 f r e e b u f p y t h o n S Y N 使 s c a p y S c a p y p y t h o n 使 s c a p y # !   / u s r / b i n / p y t h o n i m p o r t   l o g g i n g l o g g i n g . g e t L o g g e r ( " s c a p y . r u n t i m e " ) . s e t L e v e l ( l o g g i n g . E R R O R ) f r o m   s c a p y . a l l   i m p o r t   * d s t _ i p   =   " 1 0 . 0 . 0 . 1 " s r c _ p o r t   =   R a n d S h o r t ( ) d s t _ p o r t = 8 0 s t e a l t h _ s c a n _ r e s p   =   s r 1 ( I P ( d s t = d s t _ i p ) / T C P ( s p o r t = s r c _ p o r t , d p o r t = d s t _ p o r t , f l a g s = " S " ) , t i m e o u t = 1 0 ) i f ( s t r ( t y p e ( s t e a l t h _ s c a n _ r e s p ) ) = = " " ) :         p r i n t   " F i l t e r e d " e l i f ( s t e a l t h _ s c a n _ r e s p . h a s l a y e r ( T C P ) ) :         i f ( s t e a l t h _ s c a n _ r e s p . g e t l a y e r ( T C P ) . f l a g s   = =   0 x 1 2 ) :                 s e n d _ r s t   =   s r ( I P ( d s t = d s t _ i p ) / T C P ( s p o r t = s r c _ p o r t , d p o r t = d s t _ p o r t , f l a g s = " R " ) , t i m e o u t = 1 0 )                 p r i n t   " O p e n "         e l i f   ( s t e a l t h _ s c a n _ r e s p . g e t l a y e r ( T C P ) . f l a g s   = =   0 x 1 4 ) :                 p r i n t   " C l o s e d " e l i f ( s t e a l t h _ s c a n _ r e s p . h a s l a y e r ( I C M P ) ) :         i f ( i n t ( s t e a l t h _ s c a n _ r e s p . g e t l a y e r ( I C M P ) . t y p e ) = = 3   a n d   i n t ( s t e a l t h _ s c a n _ r e s p . g e t l a y e r ( I C M P ) . c o d e )   i n   [ 1 , 2 , 3 , 9 , 1 0 , 1 3 ] ) :                 p r i n t   " F i l t e r e d " s y n d s t _ i p d p o r t S Y N
s c a p y s r * t i m e o u t t i m e o u t   - 1 s 使 线 t c p   f l a g s :           1 .           2 .     ( )         3 .   使 m a c k a l i         4 .   s c a p y s e n d         5 .   i p p y t h o n p y t h o n f r o m   s c a p y . a l l   i m p o r t   * i m p o r t   n e t a d d r i p   =   [ ' 1 . 3 4 . 0 . 0 / 1 6 ' ,   ' 1 . 3 3 . 0 . 0 / 1 6 ' ] p o r t   =   [ 8 0 ,   8 1 ,   8 2 ] i p A r r a y   =   [ ] p o r t A r r a y   =   [ ] f o r   i   i n   i p :   i p A r r a y . e x t e n d ( [ s t r ( i )   f o r   i   i n     n e t a d d r . I P N e t w o r k ( i ) . s u b n e t ( 2 4 ) ] ) p o r t A r r a y   =   [ p o r t [ i : i + 3 ]   f o r   i   i n   r a n g e ( 0 ,   l e n ( p o r t ) ,   3 ) ] f o r   i   i n   i p A r r a y :
        f o r   j   i n   p o r t A r r a y :                 s e n d ( I P ( d s t = i ) / T C P ( d p o r t = j ,   f l a g s = 2 ) ,   v e r b o s e = F a l s e )                 p r i n t   i ,   j 使 s c a p y n e t a d d r i p   p o r t   n e t a d d r i p s c a p y s e n d I P i p f o r c i p " 1 . 3 4 . 0 . 0 / 1 6 " I P N e t w o r k 使 s u b n e t c c i p p o r t A r r a y i p s e n d v e r b o s e F a l s e 西 T C P f l a g s 2 f l a g s S Y N f r o m   s c a p y . a l l   i m p o r t   * i f a c e   =   ' e t h 0 ' u s e r I P   =   ' 1 9 2 . 1 6 8 . 2 0 5 . 1 6 0 ' d e f   p r n ( p k t ) :         p r i n t   p k t . s p r i n t f ( " % I P . s r c % : % I P . s p o r t %     % T C P . f l a g s % " ) s n i f f ( i f a c e = i f a c e ,   f i l t e r = ' t c p   a n d   d s t   % s   a n d   t c p [ 1 3 : 1 ]   &   1 8 = = 1 8 ' % u s e r I P ,   p r n = p r n )
s c a p y i f a c e i p   u s e r I P i p 使 s n i f f s c a p y i f a c e f i l t e r p r n r o o t f i l t e r s n i f f ( i f a c e = i f a c e ,   l f i l t e r = l a m b d a   x : x . h a s l a y e r ( T C P )   a n d   x [ I P ] . d s t = = u s e r I P   a n d   x . f l a g s = = 1 8 ,   p r n = p r n ) l f i l t e r T r u e F a l s e   f i l t e r   t c p d u m p 使 f i l t e r t c p [ 1 3 : 1 ]   &   1 8 = = 1 8 s y n S Y N S Y N A C K S Y N   A C K 1 t c p A C K S Y N 2 ( S Y N )   +   1 6 ( A C K )   =   1 8 t c p [ 1 3 : 1 ] t c p d u m p t c p 1 3 ( 1 4 ) 1 f l a g s 1 8 p r n ( s p r i n t f s c a p y ) 线 线 线 s n i f f * a d d a d d F r e e B u f
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则