kandi background
Explore Kits

smali | dex format used by dalvik, Android's Java VM implementation

 by   JesusFreke Java Version: v2.0b6 License: No License

 by   JesusFreke Java Version: v2.0b6 License: No License

Download this library from

kandi X-RAY | smali Summary

smali is a Java library. smali has no bugs, it has no vulnerabilities, it has build file available and it has high support. You can download it from GitHub, Maven.
smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on Jasmin's/dedexer's syntax, and supports the full functionality of the dex format (annotations, debug info, line info, etc.).
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • smali has a highly active ecosystem.
  • It has 5072 star(s) with 958 fork(s). There are 283 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 115 open issues and 601 have been closed. On average issues are closed in 58 days. There are 6 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of smali is v2.0b6
smali Support
Best in #Java
Average in #Java
smali Support
Best in #Java
Average in #Java

quality kandi Quality

  • smali has 0 bugs and 0 code smells.
smali Quality
Best in #Java
Average in #Java
smali Quality
Best in #Java
Average in #Java

securitySecurity

  • smali has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • smali code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
smali Security
Best in #Java
Average in #Java
smali Security
Best in #Java
Average in #Java

license License

  • smali does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
smali License
Best in #Java
Average in #Java
smali License
Best in #Java
Average in #Java

buildReuse

  • smali releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • smali saves you 43712 person hours of effort in developing the same functionality from scratch.
  • It has 51579 lines of code, 4930 functions and 743 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
smali Reuse
Best in #Java
Average in #Java
smali Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed smali and discovered the below as its top functions. This is intended to give you an instant insight into smali implemented functionality, and help decide if they suit your requirements.

  • Analyze an instruction .
  • Test a list of instructions .
  • Write code item .
  • Formats a command hierarchy into a string .
  • Returns the set of set registers .
  • Replies the default boot class path for the given dex entry .
  • Make a SectionItemAnnotator for the CDex .
  • Converts an instruction to the given instruction .
  • Annotate this annotated with the specified message .
  • Determine the bounding bounds of the try block to use .

smali Key Features

github Issue tracker - For any bugs/issues/feature requests

#smali on freenode - Free free to drop by and ask a question. Don't expect an instant response, but if you hang around someone will respond.

Official dex bytecode reference

Registers wiki page

Types, Methods and Fields wiki page

Official dex format reference

Smali moveTaskToBack

copy iconCopydownload iconDownload
java -jar apktool.jar d <file-to-decompile.apk>
const/4 v0, 0x0
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z
java -jar apktool.jar b <directory created by apktool>
-----------------------
java -jar apktool.jar d <file-to-decompile.apk>
const/4 v0, 0x0
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z
java -jar apktool.jar b <directory created by apktool>
-----------------------
java -jar apktool.jar d <file-to-decompile.apk>
const/4 v0, 0x0
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z
java -jar apktool.jar b <directory created by apktool>

How to prevent the detection of fake GPS?

copy iconCopydownload iconDownload
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
move-result v1
if-eqz v1, :cond_1e   // if v1==0 GOTO cond_1e
-----------------------
invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z
move-result v1
if-eqz v1, :cond_1e   // if v1==0 GOTO cond_1e

Why APK could not be installed after Smali patching?

copy iconCopydownload iconDownload
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Attempt installation of the rebuilt APK file
adb install -r rebuilt.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 6) Sign the rebuilt APK file
apksigner sign --ks keystore --ks-pass pass:password rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
-----------------------
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Attempt installation of the rebuilt APK file
adb install -r rebuilt.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 6) Sign the rebuilt APK file
apksigner sign --ks keystore --ks-pass pass:password rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
-----------------------
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Attempt installation of the rebuilt APK file
adb install -r rebuilt.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0

# 6) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
# 1) Install the original APK file
adb install original.apk

# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk

# 3) Apply the logic patch
patch -p1 < switch.patch

# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original

# 5) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk

# 6) Sign the rebuilt APK file
apksigner sign --ks keystore --ks-pass pass:password rebuilt-aligned.apk

# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk

Is there a way to decompile multiple android apk at the same time?

copy iconCopydownload iconDownload
cd directory_with_apks
find . -iname "*.apk" -exec apktool d -o {}_out {} \;

ApkTool splits java files in to multiple files

copy iconCopydownload iconDownload
package Abc;

class Foo {
  class Bar {}
}

Antlr4 parser ends prematurely on misplaced token in Python 3.7

copy iconCopydownload iconDownload
parse
 : expression
 ;

expression
 : expression '+' expression
 | NUMBER
 ;
parse
 : expression EOF
 ;
-----------------------
parse
 : expression
 ;

expression
 : expression '+' expression
 | NUMBER
 ;
parse
 : expression EOF
 ;

Q: Does this smali class decrypt data? what encryption is it using?

copy iconCopydownload iconDownload
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class SimpleDecryption {
    public static void main(String[] args) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IOException, BadPaddingException, IllegalBlockSizeException {
        System.out.println("Simple decryption method for\n" +
                "https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java");
        String filename = "cipher.dat";
        byte[] fixedKey = hexStringToByteArray("e409c02fb48745a14f5e1c03e3c6f0ca");
        Cipher aesCipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
        SecretKeySpec secretKeySpec = new SecretKeySpec(fixedKey, "AES");
        aesCipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
        System.out.println("decrypted text: " + new String(aesCipher.doFinal(Files.readAllBytes(Paths.get(filename))),"UTF-8"));
    }
    public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }
}
Simple decryption method for
https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
decrypted text: This text needs to get encrypted
-----------------------
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class SimpleDecryption {
    public static void main(String[] args) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IOException, BadPaddingException, IllegalBlockSizeException {
        System.out.println("Simple decryption method for\n" +
                "https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java");
        String filename = "cipher.dat";
        byte[] fixedKey = hexStringToByteArray("e409c02fb48745a14f5e1c03e3c6f0ca");
        Cipher aesCipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
        SecretKeySpec secretKeySpec = new SecretKeySpec(fixedKey, "AES");
        aesCipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
        System.out.println("decrypted text: " + new String(aesCipher.doFinal(Files.readAllBytes(Paths.get(filename))),"UTF-8"));
    }
    public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }
}
Simple decryption method for
https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
decrypted text: This text needs to get encrypted

Frida: Replace string literal in class method

copy iconCopydownload iconDownload
Java.perform(function() {
  var ObfuscatedClass = Java.use('o.bdq$if');
  ObfuscatedClass.ॱ.implementation = function(string, stringArray) { // replace original implementation
    var modifiedStringArray = ...; // do your stuff with the stringArray that contains your hash
    return this.ॱ(string, modifiedStringArray); // call original method with modified string array containing new hash
  }
});

frida:java.lang.ClassCastException: java.lang.Object[] cannot be cast to android.content.Intent[]

copy iconCopydownload iconDownload
Java.perform(function () {
    Java.use('com.xxx.xxx.processManager.g').doInBackground.overload('[Ljava.lang.Object;').implementation = function (objectArray) {
        return this.a.overload('[Landroid.content.Intent;').call(this, intentArray); 
    }
})

Frida - access to a class attribute that has the desired type

copy iconCopydownload iconDownload
const eaxe = Java.use("e.a.x.e");
for (f of eaxe.class.getDeclaredFields()) {
    if (f.getType().getName() == "e.a.x.e") {
        f.setAccessible(true);
        var fieldValue = f.get(this);
        console.log("Field of type e.a.x.e has value: " + fieldValue);
    }
}
-----------------------
var lo_fld_eaxe;
var lv_found = false;
var lt_fields = this.getClass().getDeclaredFields();
for (var i = 0; i < lt_fields.length && lv_found == false; i++) {
    if(lt_fields[i].getName().toString() == 'a' &&  lt_fields[i].getType().getName().toString() == 'e.a.x.e' ){
       lo_fld_eaxe = lt_fields[i];
       lv_found = true; 
  }
}
if(lv_found == true) {
   lo_fld_eaxe.setAccessible(true);
   try{ 
          var       lv_e_a_x_e = lo_fld_eaxe.get(this);   
   }
   catch(err){
          console.log("Error:"+err);
   }
 }

Community Discussions

Trending Discussions on smali
  • Smali moveTaskToBack
  • how to locate the register problem in Android after modifying some smali code of an APK?
  • How to get dex file from apk when using v2 signature?
  • How to prevent the detection of fake GPS?
  • Why APK could not be installed after Smali patching?
  • Smali - lots of &quot;move-object&quot;
  • Android Device Monitor / DDMS does not show threads from device
  • Is it possible to analyze dex file directly with mobsf?
  • Is there a way to decompile multiple android apk at the same time?
  • How do i work with .smali files to easily understand and modify Codes?
Trending Discussions on smali

QUESTION

Smali moveTaskToBack

Asked 2022-Mar-25 at 10:28

I just started in smali and I'm trying to add moveTaskToBack(true) in main activity (smali) but I don't know how to convert it.

Btw here's what I tried:

invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z

ANSWER

Answered 2022-Mar-25 at 10:28

Use apktool to decompile

java -jar apktool.jar d <file-to-decompile.apk>

Then edit the smali file where you want to insert the code.

But you have to make sure that at the point where you insert the code v0 already contains the value 1 for true, or you have to set it to 1 but then make sure v0 does not contain a value that is used later:

const/4 v0, 0x0
invoke-virtual {p0, v0}, Landroid/androapp/Main;->moveTaskToBack(Z)Z

Afterwards rebuild the app using apktool.

java -jar apktool.jar b <directory created by apktool>

If apktool succeeds you find the generated apk file in the dist/ subdirectory.

Depending on the APK file that is modified you may have to align the apk using zipalign 4 <modified apk file> or zipalign -p 4 <modified apk file> (the latter has to be used in case the app defines extractNativeLibs=false in it's AndroidManifest.xml).

Now you have to resign the apk using e.g. apksigner for Android SDK.

Source https://stackoverflow.com/questions/71599987

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install smali

You can download it from GitHub, Maven.
You can use smali like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the smali component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.