[19246] 2018-03-13_从py分析程序渐入dex文件格式

文档创建者:s7ckTeam
浏览次数:4
最后更新:2025-01-18
2018-03-13_从py分析程序渐入dex文件格式 p y d e x i   2 0 1 8 - 0 3 - 1 3 H A I _ i 0 x 0 0     e l f d e x d e x 便 d u m p d e x e l f 1 . d e x 2 . h e a d e r p y t h o n h e a d e r 3 . 4 . c l a s s _ d e f s 0 1 0   e d i t o r   G D A   0 x 0 1  
d e x 0 x 0 2   h e a d e r h e a d e r h e a d e r 0 1 0   e d i t o r d e x
1 . 2 . h e a d e r 使 0 1 0   e d i t o r 使 d e x d u m p d e x d e x d u m p   c l a s s e s . d e x   > d e m o . t x t
3 .   s t a r t 3 . 1   i f   _ _ n a m e _ _   = =   " _ _ m a i n _ _ " :         d f   =   D e x F i l e ( " c l a s s e s . d e x " )           d f . R e a d D e x H e a d e r ( )         d f . C a l S i g n a t u r e ( )         d f . C a l C h e c k s u m ( )         d f . C l o s e D e x F i l e ( ) d f 3 . 2   D e x F i l e ( " c l a s s e s . d e x " ) d e f   _ _ i n i t _ _ ( s e l f , f i l e p a t h ) :                 s e l f . d e x   =   o p e n ( f i l e p a t h , " r " )                 s e l f . s t r i n g s   =   [ ]                 s e l f . t y p e s   =   [ ]                 s e l f . p r o t o s   =   [ ]                 s e l f . f i e l d s   =   [ ]                 s e l f . m e t h o d   =   [ ]               s e l f . m a p _ t y p e   =   { 0 x 0 : " h e a d e r _ i t e m " ,                                           0 x 1 : " s t r i n g _ i d _ i t e m " ,                                           0 x 2 : " t y p e _ i d _ i t e m " ,                                           0 x 3 : " p r o t o _ i d _ i t e m " ,                                         0 x 4 : " f i e l d _ i d _ i t e m " ,                                           0 x 5 : " m e t h o d _ i d _ i t e m " ,                                           0 x 6 : " c l a s s _ d e f _ i t e m " ,                                           0 x 1 0 0 0 : " m a p _ l i s t " ,                                           0 x 1 0 0 1 : " t y p e _ l i s t " ,                                         0 x 1 0 0 2 : " a n n o t a t i o n _ s e t _ r e f _ l i s t " ,                                           0 x 1 0 0 3 : " a n n o t a t i o n _ s e t _ i t e m " ,                                           0 x 2 0 0 0 : " c l a s s _ d a t a _ i t e m " ,                                           0 x 2 0 0 1 : " c o d e _ i t e m " ,                                         0 x 2 0 0 2 : " s t r i n g _ d a t a _ i t e m " ,                                           0 x 2 0 0 3 : " d e b u g _ i n f o _ i t e m " ,                                           0 x 2 0 0 4 : " a n n o t a t i o n _ i t e m " ,                                           0 x 2 0 0 5 : " e n c o d e d _ a r r a y _ i t e m " ,                                         0 x 2 0 0 6 : " a n n o t a t i o n s _ d i r e c t o r y _ i t e m " } _ _ i n i t _ _ s e l f h e a d e r 3 . 3 R e a d D e x H e a d e r ( ) h e a d e r 便
3 . 3 . 1   m a g i c m a g i c d e x n 0 3 5 p r i n t   " - - - - - - - - - - - - - - - - ½ â Î ö   D e x H e a d e r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "                 s e l f . m a g i c   =   s t r u c t . u n p a c k ( " 4 s " , s e l f . d e x . r e a d ( 4 ) ) [ 0 ]                 p r i n t   " m a g i c   c o d e : " , s e l f . m a g i c ,                 i f s e l f . m a g i c   ! =   " d e x n " :                         p r i n t   " t h e   f i l e   i s   n o t   a   d e x   f i l e "                         s e l f . C l o s e D e x F i l e ( )                         e x i t ( - 1 )                         r e t u r n s t r u c t . u n p a c k p y t h o n s t r u c t . u n p a c k ( f m t ,   s t r i n g ) 4 s c h a r [ 4 ] s e l f . d e x . r e a d ( 4 ) , 4 v e r s i o n , 0 3 5 s e l f . v e r s i o n   =   s t r u c t . u n p a c k ( " 4 s " , s e l f . d e x . r e a d ( 4 ) ) [ 0 ]                 p r i n t   " v e r s i o n : " , s e l f . v e r s i o n 使 使 s t r u c t . u n p a c k 使 3 . 3 . 2   c h e c k s u m a d l e r 3 2 d e x s e l f . c h e c k s u m   =   s t r u c t . u n p a c k ( " i " , s e l f . d e x . r e a d ( 4 ) ) [ 0 ]                               p r i n t   " c h e c k s u m : " , s e l f . c h e c k s u m 0 1 0   e d i t o r
c h e c k s u m 3 . 3 . 3   s i g d e x d e x 2 0
3 . 3 . 4   f i l e s i z e 3 . 3 . 5   h e a d e r s i z e 0 x 7 0
3 . 3 . 6   e n d i a n t a g 3 . 3 . 7   l i n k _ s i z e 0 3 . 3 . 8   l i n k _ o f f _ o f f x x x 3 . 3 . 9   m a p _ o f f m a p 3 . 3 . 1 0   s t r i n g _ n u m n u m 3 . 3 . 1 1   s t r i n g _ t a b l e _ o f f s t r i n g _ t a b l e s t r i n g _ t a b l e   s t r i n g t a b l e 3 . 3 . 1 2   t y p e _ n u m t y p e 3 . 3 . 1 3   t y p e _ t a b l e _ o f f t y p e _ t a b l e
3 . 3 . 1 4   p r o t o _ n u m p r o t o   p r o t o 西 3 . 3 . 1 5     p r o t o _ o f f p r o t o 3 . 3 . 1 6   f i e l d _ n u m f i e l d 3 . 3 . 1 7   f i e l d _ o f f 3 . 3 . 1 8   m e t h o d _ n u m , ( 1 0 ) 3 . 3 . 1 9   m e t h o d _ o f f 3 . 3 . 2 0   c l a s s _ d e f _ s i z e 3 . 3 . 2 1   c l a s s _ d e f _ o f f 3 . 3 . 2 2   d a t a _ s i z e 3 . 3 . 2 3   d a t a _ o f f d e x o f f 0 x 0 3   d a t a d a t a
0 1 0   e d i t o r d e x d u m p u l e b 1 2 8 u l e b 1 2 8 1 ~ 5 p y t h o n d e f   g e t _ u l e b 1 2 8 ( c o n t e n t ) :                 v a l u e   =   0                 f o r   i   i n   x r a n g e ( 0 , 5 ) :                                 t m p   =   o r d ( c o n t e n t [ i ] )   &   0 x 7 f                                 v a l u e   =   t m p   < <   ( i   *   7 )   |   v a l u e   / / n i = 1 , 2 i = 4 5                                 i f   ( o r d ( c o n t e n t [ i ] )   &   0 x 8 0 )   ! =   0 x 8 0 :                                                 b r e a k                 i f   i   = =   4   a n d   ( t m p   &   0 x f 0 )   ! =   0 :                                 p r i n t " p a r s e   a   e r r o r   u l e b 1 2 8   n u m b e r "                                 r e t u r n   - 1                 r e t u r n   i + 1 ,   v a l u e
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则