Support
Quality
Security
License
Reuse
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.
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
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?
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?
# 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?
cd directory_with_apks
find . -iname "*.apk" -exec apktool d -o {}_out {} \;
ApkTool splits java files in to multiple files
package Abc;
class Foo {
class Bar {}
}
Antlr4 parser ends prematurely on misplaced token in Python 3.7
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?
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
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[]
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
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);
}
}
QUESTION
Smali moveTaskToBack
Asked 2022-Mar-25 at 10:28I 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:28Use 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.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Save this library and start creating your kit