JesusFreke / smali

smali/baksmali
6.34k stars 1.07k forks source link

Error in dex Instruction writer, Unsigned short value out of range #690

Closed ghost closed 5 years ago

ghost commented 5 years ago

I've modified the .smali files and have hit some sort limit where a short is required in an instruction but my value is too high. It would be nice to know what limit I hit so I can massage things differently.

I've counted the methods and that doesn't seem to be it

smali has 54943 methods
smali_classes2 has 54363 methods
smali_classes3 has 19242 methods
../bin/apktool build wyze --use-aapt2
I: Using Apktool 2.4.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
Exception in thread "main" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Landroid/arch/core/internal/FastSafeIterableMap;-><init>()V
        at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:917)
        at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:341)
        at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:297)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
        at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:419)
        at brut.androlib.Androlib.buildSources(Androlib.java:350)
        at brut.androlib.Androlib.build(Androlib.java:302)
        at brut.androlib.Androlib.build(Androlib.java:269)
        at brut.apktool.Main.cmdBuild(Main.java:247)
        at brut.apktool.Main.main(Main.java:79)
Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x5
        at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1190)
        at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:913)
        ... 10 more
Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 66088
        at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
        at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:356)
        at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1150)
        ... 11 more

make[2]: *** [unsigned.apk] Error 1
make[1]: *** [build] Error 2
make: *** [all] Error 2

Maybe it's an offset or an index of some kind which requires a short. Throwing an exception showing what index or offset I overflowed would be great.

There's zip file of the directory in www.sonic.net/~crb/wyze.zip

Thanks for the wonderful work.

JesusFreke commented 5 years ago

Your dex file has too many method references

ghost commented 5 years ago

Ok, thanks, I'll check that out.

sagiashok commented 4 years ago

*] Rebuilding apk with meterpreter injection as /tmp/d20200613-1624-1iltt0j/output.apk [-] I: Using Apktool 2.4.1 I: Checking whether sources has changed... I: Smaling smali folder into classes.dex... Exception in thread "main" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Lafdh;->a()[[Ljava/lang/String; at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:917) at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:341) at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:297) at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61) at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36) at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:418) at brut.androlib.Androlib.buildSources(Androlib.java:349) at brut.androlib.Androlib.build(Androlib.java:301) at brut.androlib.Androlib.build(Androlib.java:268) at brut.apktool.Main.cmdBuild(Main.java:251) at brut.apktool.Main.main(Main.java:79) Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x2 at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1190) at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:913) ... 10 more Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65580 at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116) at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:356) at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1150) ... 11 more

Error: Unable to rebuild apk with apktool i need solution for this i tried number of days but no solution please help me

Lanchon commented 4 years ago

script kiddie up to no good...