[14216] 2019-06-11_DEX保护之指令抽取

文档创建者:s7ckTeam
浏览次数:3
最后更新:2025-01-18
2019-06-11_DEX保护之指令抽取 D E X x i o n g c h a o c h a o   F r e e B u f   2 0 1 9 - 0 6 - 1 1 d e x I D A 使 使 X p o s e d H O O K h o o k A P I A p p d u m p d e x d u m p d e x d u m p d e x d e x 使 d u m p d e x d e x d e x c l a s s   d e f e n c o d e _ m e t h o d c o d e _ i t e m ( ) 使 d u m p d e x d e x d e x 1 d e x c l a s s p u b l i c   s t a t i c   v o i d   p a r s e C l a s s I d s ( b y t e [ ]   s r c B y t e ) {                 i n t   i d S i z e   =   C l a s s D e f I t e m . g e t S i z e ( ) ;                 i n t   c o u n t I d s   =   c l a s s I d s S i z e ; / /                 S y s t e m . o u t . p r i n t l n ( " T o t a l   "   +   S t r i n g . v a l u e O f ( c o u n t I d s )   +   "   c l a s s e s ( ) n " ) ;                 f o r ( i n t   i = 0 ; i < c o u n t I d s ; i + + ) {                         C l a s s D e f I t e m   i t e m   =   n e w   C l a s s D e f I t e m ( ) ;                         b y t e [ ]   c l a s s I t e m B y t e   =   U t i l s . c o p y B y t e ( s r c B y t e ,   c l a s s I d s O f f s e t + i * i d S i z e ,   i d S i z e ) ;                         b y t e [ ]   c l a s s I d x B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   0 ,   4 ) ;                         i t e m . c l a s s _ i d x   =   U t i l s . b y t e 2 i n t ( c l a s s I d x B y t e ) ;                         b y t e [ ]   a c c e s s F l a g s B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   4 ,   4 ) ;                         i t e m . a c c e s s _ f l a g s   =   U t i l s . b y t e 2 i n t ( a c c e s s F l a g s B y t e ) ;                         b y t e [ ]   s u p e r C l a s s I d x B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   8 ,   4 ) ;                         i t e m . s u p e r c l a s s _ i d x   =   U t i l s . b y t e 2 i n t ( s u p e r C l a s s I d x B y t e ) ;                         b y t e [ ]   i t e r f a c e s O f f B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   1 2 ,   4 ) ;                         i t e m . i t e r f a c e s _ o f f   =   U t i l s . b y t e 2 i n t ( i t e r f a c e s O f f B y t e ) ;                         b y t e [ ]   s o u r c e F i l e I d x B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   1 6 ,   4 ) ;                         i t e m . s o u r c e _ f i l e _ i d x   =   U t i l s . b y t e 2 i n t ( s o u r c e F i l e I d x B y t e ) ;                         b y t e [ ]   a n n o t a t i o n s O f f B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   2 0 ,   4 ) ;                         i t e m . a n n o t a t i o n s _ o f f   =   U t i l s . b y t e 2 i n t ( a n n o t a t i o n s O f f B y t e ) ;                         b y t e [ ]   c l a s s D a t a O f f B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   2 4 ,   4 ) ;                         i t e m . c l a s s _ d a t a _ o f f   =   U t i l s . b y t e 2 i n t ( c l a s s D a t a O f f B y t e ) ;                         b y t e [ ]   s t a t i c V a l u e O f f B y t e   =   U t i l s . c o p y B y t e ( c l a s s I t e m B y t e ,   2 8 ,   4 ) ;                         i t e m . s t a t i c _ v a l u e _ o f f   =   U t i l s . b y t e 2 i n t ( s t a t i c V a l u e O f f B y t e ) ;                         c l a s s I d s L i s t . a d d ( i t e m ) ;                 }
2 c l a s s c l a s s I t e m D a t a 3 c o d e                 } / / d i r e c t M e t h o d s                         E n c o d e d M e t h o d [ ]   s t a t i c M e t h o d s A r y   =   n e w   E n c o d e d M e t h o d [ i t e m . d i r e c t _ m e t h o d s _ s i z e ] ;                         f o r ( i n t   i = 0 ; i < i t e m . d i r e c t _ m e t h o d s _ s i z e ; i + + ) {                                 / * *                                   *     p u b l i c   b y t e [ ]   m e t h o d _ i d x _ d i f f ;                                         p u b l i c   b y t e [ ]   a c c e s s _ f l a g s ;                                         p u b l i c   b y t e [ ]   c o d e _ o f f ;                                   * /                                 E n c o d e d M e t h o d   d i r e c t M e t h o d   =   n e w   E n c o d e d M e t h o d ( ) ;                                 d i r e c t M e t h o d . m e t h o d _ i d x _ d i f f   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   d i r e c t M e t h o d . m e t h o d _ i d x _ d i f f . l e n g t h ;                                 d i r e c t M e t h o d . a c c e s s _ f l a g s   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   d i r e c t M e t h o d . a c c e s s _ f l a g s . l e n g t h ;                                 d i r e c t M e t h o d . c o d e _ o f f   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   d i r e c t M e t h o d . c o d e _ o f f . l e n g t h ;                                 s t a t i c M e t h o d s A r y [ i ]   =   d i r e c t M e t h o d ;                         }                         / / v i r t u a l M e t h o d s                         E n c o d e d M e t h o d [ ]   i n s t a n c e M e t h o d s A r y   =   n e w   E n c o d e d M e t h o d [ i t e m . v i r t u a l _ m e t h o d s _ s i z e ] ;                         f o r ( i n t   i = 0 ; i < i t e m . v i r t u a l _ m e t h o d s _ s i z e ; i + + ) {                                 / * *                                   *     p u b l i c   b y t e [ ]   m e t h o d _ i d x _ d i f f ;                                         p u b l i c   b y t e [ ]   a c c e s s _ f l a g s ;                                         p u b l i c   b y t e [ ]   c o d e _ o f f ;                                   * /                                 E n c o d e d M e t h o d   i n s t a n c e M e t h o d   =   n e w   E n c o d e d M e t h o d ( ) ;                                 i n s t a n c e M e t h o d . m e t h o d _ i d x _ d i f f   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   i n s t a n c e M e t h o d . m e t h o d _ i d x _ d i f f . l e n g t h ;                                 i n s t a n c e M e t h o d . a c c e s s _ f l a g s   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   i n s t a n c e M e t h o d . a c c e s s _ f l a g s . l e n g t h ;                                 i n s t a n c e M e t h o d . c o d e _ o f f   =   U t i l s . r e a d U n s i g n e d L e b 1 2 8 ( s r c B y t e ,   d a t a O f f s e t ) ;                                 d a t a O f f s e t   + =   i n s t a n c e M e t h o d . c o d e _ o f f . l e n g t h ;                                 i n s t a n c e M e t h o d s A r y [ i ]   =   i n s t a n c e M e t h o d ;                         } /                         S y s t e m . o u t . p r i n t f ( " t D i r e c t   m e t h o d s t - n " ) ;                         i f ( i t e m . d i r e c t _ m e t h o d s . l e n g t h   ! =   0 )   {                                 f o r ( i n t   i = 0 ;   i < i t e m . d i r e c t _ m e t h o d s . l e n g t h ;   i + + )   {                                         i n t   m e t h o d I n d e x   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . d i r e c t _ m e t h o d s [ i ] . m e t h o d _ i d x _ d i f f ) ;
                                        i n t   a c c e s s f l a g   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . d i r e c t _ m e t h o d s [ i ] . a c c e s s _ f l a g s ) ;                                         i n t   c o d e _ o f f   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . d i r e c t _ m e t h o d s [ i ] . c o d e _ o f f ) ;                                         i f ( c o d e _ o f f   = =   0 )   {                                                 S y s t e m . o u t . p r i n t f ( " t t         n u l l   c o d e   i t e m " ) ;                                                 c o n t i n u e ;                                         }                                         / / c o d e _ i t e m                                         b y t e [ ]   c o d e I t e m B y t e   =   U t i l s . c o p y B y t e ( s r c B y t e ,   c o d e _ o f f ,   1 6 ) ;                                         C l a s s C o d e I t e m   m C l a s s C o d e I t e m   =   n e w   C l a s s C o d e I t e m ( ) ;                                         m C l a s s C o d e I t e m . r e g i s t e r s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   0 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . i n s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   2 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . o u t s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   4 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . t r i e s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   6 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . d e b u g I n f o O f f   =   U t i l s . b y t e 2 i n t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   8 ,   4 ) ) ;                                         m C l a s s C o d e I t e m . i n s n s S i z e   =   U t i l s . b y t e 2 i n t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   1 2 ,   4 ) ) ;                                         b y t e [ ]   i n s t r u c t i o n _ b y t e   =   U t i l s . c o p y B y t e ( s r c B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         f o r ( i n t   j = 0 ;   j < m C l a s s C o d e I t e m . i n s n s S i z e ;   j + + )   {                                                 m C l a s s C o d e I t e m . i n s n s . a d d ( U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( i n s t r u c t i o n _ b y t e ,   2 * j ,   2 ) ) ) ;                                         }                                         S y s t e m . o u t . p r i n t f ( " t t     n a m e t : % s n " ,   s t r i n g L i s t . g e t ( m e t h o d I d s L i s t . g e t ( m e t h o d I n d e x ) . n a m e _ i d x ) ) ;                                         S y s t e m . o u t . p r i n t f ( " t t         i n s t r u c t i o n s : % s n " ,   m C l a s s C o d e I t e m . i n s n s . t o S t r i n g ( ) ) ;                                         S y s t e m . o u t . p r i n t f ( " t t         n " ) ;                                         i f ( f l a g   = =   0 )   {                                                 d e x B y t e   =   s e t _ i n s t r u 2 n u l l ( s r c B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                                 b y t e [ ]   n u l l _ i n s t r u c t i o n   =   U t i l s . c o p y B y t e ( d e x B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                                 f l a g + + ;                                         } e l s e   {                                                 d e x B y t e   =   s e t _ i n s t r u 2 n u l l ( d e x B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         }                                         b y t e [ ]   n u l l _ b y t e   =   U t i l s . c o p y B y t e ( d e x B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         S y s t e m . o u t . p r i n t l n ( " t t "   +   U t i l s . b y t e s T o H e x S t r i n g ( n u l l _ b y t e ) + " n " ) ;                                 }                         }                         i f ( i t e m . v i r t u a l _ m e t h o d s . l e n g t h   ! =   0 )   {                                 f o r ( i n t   i = 0 ;   i < i t e m . v i r t u a l _ m e t h o d s . l e n g t h ;   i + + )   {                                         i n t   m e t h o d I n d e x   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . v i r t u a l _ m e t h o d s [ i ] . m e t h o d _ i d x _ d i f f ) ;                                         i n t   a c c e s s f l a g   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . v i r t u a l _ m e t h o d s [ i ] . a c c e s s _ f l a g s ) ;                                         i n t   c o d e _ o f f   =   U t i l s . d e c o d e U l e b 1 2 8 ( i t e m . v i r t u a l _ m e t h o d s [ i ] . c o d e _ o f f ) ;                                         i f ( c o d e _ o f f   = =   0 )   {                                                 S y s t e m . o u t . p r i n t f ( " t t         n u l l   c o d e   i t e m " ) ;                                                 c o n t i n u e ;                                         }                                         / / c o d e _ i t e m                                         b y t e [ ]   c o d e I t e m B y t e   =   U t i l s . c o p y B y t e ( s r c B y t e ,   c o d e _ o f f ,   1 6 ) ;                                         C l a s s C o d e I t e m   m C l a s s C o d e I t e m   =   n e w   C l a s s C o d e I t e m ( ) ;                                         m C l a s s C o d e I t e m . r e g i s t e r s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   0 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . i n s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   2 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . o u t s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   4 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . t r i e s S i z e   =   U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   6 ,   2 ) ) ;                                         m C l a s s C o d e I t e m . d e b u g I n f o O f f   =   U t i l s . b y t e 2 i n t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   8 ,   4 ) ) ;                                         m C l a s s C o d e I t e m . i n s n s S i z e   =   U t i l s . b y t e 2 i n t ( U t i l s . c o p y B y t e ( c o d e I t e m B y t e ,   1 2 ,   4 ) ) ;                                         b y t e [ ]   i n s t r u c t i o n _ b y t e   =   U t i l s . c o p y B y t e ( s r c B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         f o r ( i n t   j = 0 ;   j < m C l a s s C o d e I t e m . i n s n s S i z e ;   j + + )   {
4 使 s e t _ i n s t r u 2 n u l l 0 0 d e x d e x d e x g i t h u b r e a d d e x . j a r 0                                         f o r ( i n t   j = 0 ;   j < m C l a s s C o d e I t e m . i n s n s S i z e ;   j + + )   {                                                 m C l a s s C o d e I t e m . i n s n s . a d d ( U t i l s . b y t e 2 S h o r t ( U t i l s . c o p y B y t e ( i n s t r u c t i o n _ b y t e ,   2 * j ,   2 ) ) ) ;                                         }                                         S y s t e m . o u t . p r i n t f ( " t t     n a m e t : % s n " ,   s t r i n g L i s t . g e t ( m e t h o d I d s L i s t . g e t ( m e t h o d I n d e x ) . n a m e _ i d x ) ) ;                                         S y s t e m . o u t . p r i n t f ( " t t         i n s t r u c t i o n s : % s n " ,   m C l a s s C o d e I t e m . i n s n s . t o S t r i n g ( ) ) ;                                         S y s t e m . o u t . p r i n t f ( " t t         n " ) ;                                         i f ( f l a g   = =   0 )   {                                                 d e x B y t e   =   s e t _ i n s t r u 2 n u l l ( s r c B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                                 f l a g + + ;                                         } e l s e   {                                                 d e x B y t e   =   s e t _ i n s t r u 2 n u l l ( d e x B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         }                                         b y t e [ ]   n u l l _ b y t e   =   U t i l s . c o p y B y t e ( d e x B y t e ,   c o d e _ o f f + 1 6 ,   m C l a s s C o d e I t e m . i n s n s S i z e * 2 ) ;                                         S y s t e m . o u t . p r i n t l n ( " t t "   +   U t i l s . b y t e s T o H e x S t r i n g ( n u l l _ b y t e ) + " n " ) ;                                 }                         }         p u b l i c   s t a t i c   b y t e [ ]   s e t _ i n s t r u 2 n u l l ( b y t e [ ]   s r c ,   i n t   s t a r t ,   i n t   l e n )   {                 i f ( s r c   = =   n u l l ) {                         r e t u r n   n u l l ;                 }                 i f ( s t a r t   >   s r c . l e n g t h ) {                         r e t u r n   n u l l ;                 }                 i f ( ( s t a r t + l e n )   >   s r c . l e n g t h ) {                         r e t u r n   n u l l ;                 }                 i f ( s t a r t < 0 ) {                         r e t u r n   n u l l ;                 }                 i f ( l e n < = 0 ) {                         r e t u r n   n u l l ;                 }                 b y t e [ ]   r e s u l t B y t e   =   n e w   b y t e [ s r c . l e n g t h ] ;                 f o r ( i n t   i = 0 ;   i < s r c . l e n g t h - 1 ;   i + + )   {                         i f ( i < s t a r t )   {                                 r e s u l t B y t e [ i ]   =   s r c [ i ] ;                         } e l s e   i f ( ( i - s t a r t )   <   l e n ) {                                 r e s u l t B y t e [ i ]   =   0 ;                         } e l s e   {                                 r e s u l t B y t e [ i ]   =   s r c [ i ] ;                         }                 }                 r e t u r n   r e s u l t B y t e ;         }
J a d x d e x d e x d e x d e x a p k c h e c k s u m   m a g i c     a d l e r 3 2   s i g n a t u r e S H A - 1   ,   m a g i c c h e c k s u m     S H A - 1   a d l e r 3 2 S H A 1 S H A 1 C R C         / /         p u b l i c   s t a t i c   v o i d   r e s e t D e x C h e c k S u m ( b y t e [ ]   s r c )   {                 b y t e [ ]   S H A 1 b y t e   =   n e w   b y t e [ s r c . l e n g t h - 3 3 ] ;                 S y s t e m . a r r a y c o p y ( s r c ,   3 2 ,   S H A 1 b y t e ,   0 ,   s r c . l e n g t h - 3 3 ) ;                 b y t e [ ]   s h a 1   =   g e t S H A 1 ( S H A 1 b y t e ) ;                 r e p l a c e B y t e ( d e x B y t e ,   1 2 ,   s h a 1 ) ;                 b y t e [ ]   c h e c k B y t e   =   c h e c k s u m _ b i n ( d e x B y t e ,   1 2 ) ;                 r e p l a c e B y t e ( d e x B y t e ,   8 ,   c h e c k B y t e ) ;         }         / /         p u b l i c   s t a t i c   v o i d   r e p l a c e B y t e ( b y t e [ ]   s r c ,   i n t   o f f s e t ,   b y t e [ ]   r e p B y t e )   {                 f o r ( i n t   i = 0 ;   i < r e p B y t e . l e n g t h ;   i + + )   {                         s r c [ o f f s e t + i ]   =   r e p B y t e [ i ] ;                 }
d e x [ 1 ]   A n d r o i d [ 2 ]   D E X * x i o n g c h a o c h a o   F r e e B u f           }         / / S H A 1         p u b l i c   s t a t i c   b y t e [ ]   g e t S H A 1 ( b y t e [ ]   b t )   {                 M e s s a g e D i g e s t   m M e s s a g e D i g e s t ;                 b y t e [ ]   m e s s a g e D i g e s t   =   n u l l ;                 t r y   {                         m M e s s a g e D i g e s t   =   M e s s a g e D i g e s t . g e t I n s t a n c e ( " S H A - 1 " ) ;                         m M e s s a g e D i g e s t . u p d a t e ( b t ) ;                         m e s s a g e D i g e s t   =   m M e s s a g e D i g e s t . d i g e s t ( ) ;                           S t r i n g B u f f e r   h e x S t r i n g   =   n e w   S t r i n g B u f f e r ( ) ;                         f o r   ( i n t   i   =   0 ;   i   <   m e s s a g e D i g e s t . l e n g t h ;   i + + )   {                                 S t r i n g   s h a H e x   =   I n t e g e r . t o H e x S t r i n g ( m e s s a g e D i g e s t [ i ]   &   0 x F F ) ;                                 i f   ( s h a H e x . l e n g t h ( )   <   2 )   {                                         h e x S t r i n g . a p p e n d ( 0 ) ;                                 }                                 h e x S t r i n g . a p p e n d ( s h a H e x ) ;                         }                 }   c a t c h   ( N o S u c h A l g o r i t h m E x c e p t i o n   e )   {                         / /   T O D O   A u t o - g e n e r a t e d   c a t c h   b l o c k                         e . p r i n t S t a c k T r a c e ( ) ;                 }                 r e t u r n   m e s s a g e D i g e s t ;         }         / / c h e c k s u m           p u b l i c   s t a t i c   b y t e [ ]   c h e c k s u m _ b i n ( b y t e [ ]   d a t a ,   i n t   o f f )   {                   i n t   l e n   =   d a t a . l e n g t h   -   o f f ;                   A d l e r 3 2   a d l e r 3 2   =   n e w   A d l e r 3 2 ( ) ;                   a d l e r 3 2 . r e s e t ( ) ;                   a d l e r 3 2 . u p d a t e ( d a t a ,   o f f ,   l e n ) ;                   l o n g   c h e c k s u m   =   a d l e r 3 2 . g e t V a l u e ( ) ;                   b y t e [ ]   c h e c k s u m b s   =   n e w   b y t e [ ] {                                   ( b y t e )   c h e c k s u m ,                                   ( b y t e )   ( c h e c k s u m   > >   8 ) ,                                   ( b y t e )   ( c h e c k s u m   > >   1 6 ) ,                                   ( b y t e )   ( c h e c k s u m   > >   2 4 ) } ;                   r e t u r n   c h e c k s u m b s ;           }

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

本版积分规则