Last active
December 1, 2015 16:42
-
-
Save JosephRedfern/662131ceb2119abf3e83 to your computer and use it in GitHub Desktop.
dx variable name destruction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class DecompilationTest{ | |
public int SomeField = 123; | |
public static void main(String args[]){ | |
DecompilationTest dt = new DecompilationTest(); | |
dt.SomeMethod(); | |
} | |
public void SomeMethod(){ | |
System.out.print("Enter a number: "); | |
Scanner in = new Scanner(System.in); | |
int someInteger = in.nextInt(); | |
System.out.println(String.format("Your number is: %d", someInteger)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiled from "DecompilationTest.java" | |
public class DecompilationTest { | |
public int SomeField; | |
public DecompilationTest(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: bipush 123 | |
7: putfield #2 // Field SomeField:I | |
10: return | |
public static void main(java.lang.String[]); | |
Code: | |
0: new #3 // class DecompilationTest | |
3: dup | |
4: invokespecial #4 // Method "<init>":()V | |
7: astore_1 | |
8: aload_1 | |
9: invokevirtual #5 // Method SomeMethod:()V | |
12: return | |
public void SomeMethod(); | |
Code: | |
0: getstatic #6 // Field java/lang/System.out:Ljava/io/PrintStream; | |
3: ldc #7 // String Enter a number: | |
5: invokevirtual #8 // Method java/io/PrintStream.print:(Ljava/lang/String;)V | |
8: new #9 // class java/util/Scanner | |
11: dup | |
12: getstatic #10 // Field java/lang/System.in:Ljava/io/InputStream; | |
15: invokespecial #11 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V | |
18: astore_1 | |
19: aload_1 | |
20: invokevirtual #12 // Method java/util/Scanner.nextInt:()I | |
23: istore_2 | |
24: getstatic #6 // Field java/lang/System.out:Ljava/io/PrintStream; | |
27: ldc #13 // String Your number is: %d | |
29: iconst_1 | |
30: anewarray #14 // class java/lang/Object | |
33: dup | |
34: iconst_0 | |
35: iload_2 | |
36: invokestatic #15 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; | |
39: aastore | |
40: invokestatic #16 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; | |
43: invokevirtual #17 // Method java/io/PrintStream.println:(Ljava/lang/String;)V | |
46: return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.class public LDecompilationTest; | |
.super Ljava/lang/Object; | |
.source "DecompilationTest.java" | |
# instance fields | |
.field public SomeField:I | |
# direct methods | |
.method public constructor <init>()V | |
.registers 2 | |
.prologue | |
.line 3 | |
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | |
.line 4 | |
const/16 v0, 0x7b | |
iput v0, p0, LDecompilationTest;->SomeField:I | |
return-void | |
.end method | |
.method public static main([Ljava/lang/String;)V | |
.registers 2 | |
.prologue | |
.line 7 | |
new-instance v0, LDecompilationTest; | |
invoke-direct {v0}, LDecompilationTest;-><init>()V | |
.line 8 | |
invoke-virtual {v0}, LDecompilationTest;->SomeMethod()V | |
.line 9 | |
return-void | |
.end method | |
# virtual methods | |
.method public SomeMethod()V | |
.registers 6 | |
.prologue | |
.line 12 | |
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; | |
const-string v1, "Enter a number: " | |
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->print(Ljava/lang/String;)V | |
.line 13 | |
new-instance v0, Ljava/util/Scanner; | |
sget-object v1, Ljava/lang/System;->in:Ljava/io/InputStream; | |
invoke-direct {v0, v1}, Ljava/util/Scanner;-><init>(Ljava/io/InputStream;)V | |
.line 15 | |
invoke-virtual {v0}, Ljava/util/Scanner;->nextInt()I | |
move-result v0 | |
.line 17 | |
sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; | |
const-string v2, "Your number is: %d" | |
const/4 v3, 0x1 | |
new-array v3, v3, [Ljava/lang/Object; | |
const/4 v4, 0x0 | |
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer; | |
move-result-object v0 | |
aput-object v0, v3, v4 | |
invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; | |
move-result-object v0 | |
invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V | |
.line 18 | |
return-void | |
.end method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joe@satan:~/Downloads/bin$ ./jadx /tmp/demo/DecompilationTest.dex | |
16:41:39 INFO - output directory: DecompilationTest | |
16:41:39 INFO - loading ... | |
16:41:39 INFO - processing ... | |
16:41:39 INFO - done | |
joe@satan:~/Downloads/bin$ cat DecompilationTest/defpackage/DecompilationTest.java | |
package defpackage; | |
import java.util.Scanner; | |
public class DecompilationTest { | |
public int SomeField = 123; | |
public static void main(String[] strArr) { | |
new DecompilationTest().SomeMethod(); | |
} | |
public void SomeMethod() { | |
System.out.print("Enter a number: "); | |
int nextInt = new Scanner(System.in).nextInt(); | |
System.out.println(String.format("Your number is: %d", new Object[]{Integer.valueOf(nextInt)})); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joe@satan:/tmp/demo$ strings DecompilationTest.class | |
SomeField | |
<init> | |
Code | |
LineNumberTable | |
main | |
([Ljava/lang/String;)V | |
SomeMethod | |
SourceFile | |
DecompilationTest.java | |
DecompilationTest | |
Enter a number: | |
java/util/Scanner | |
Your number is: %d | |
java/lang/Object | |
java/lang/System | |
Ljava/io/PrintStream; | |
java/io/PrintStream | |
(Ljava/lang/String;)V | |
Ljava/io/InputStream; | |
(Ljava/io/InputStream;)V | |
nextInt | |
java/lang/Integer | |
valueOf | |
(I)Ljava/lang/Integer; | |
java/lang/String | |
format | |
9(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; | |
println |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joe@satan:/tmp/demo$ strings DecompilationTest.dex | |
<init> | |
DecompilationTest.java | |
Enter a number: | |
LDecompilationTest; | |
Ljava/io/InputStream; | |
Ljava/io/PrintStream; | |
Ljava/lang/Integer; | |
Ljava/lang/Object; | |
Ljava/lang/String; | |
Ljava/lang/System; | |
Ljava/util/Scanner; | |
SomeField | |
SomeMethod | |
Your number is: %d | |
[Ljava/lang/Object; | |
[Ljava/lang/String; | |
format | |
main | |
nextInt | |
println | |
valueOf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment