Last active
January 3, 2018 03:31
-
-
Save walio/ca674e4a7838fc9b3026134a81e01fb4 to your computer and use it in GitHub Desktop.
inject log info to apk
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.io.*; | |
import java.util.Arrays; | |
public class crack{ | |
public static void puts(Object s){ | |
try{ | |
String path= "/sdcard/debug.txt"; | |
FileOutputStream outStream = new FileOutputStream(path,true); | |
OutputStreamWriter writer = new OutputStreamWriter(outStream,"gb2312"); | |
writer.write(s.toString()); | |
writer.write("\r\n"); | |
writer.flush(); | |
writer.close(); | |
outStream.close(); | |
} | |
catch (Exception e){ | |
} | |
} | |
public static void puts(Object s,String tag){ | |
try{ | |
String path= "/sdcard/debug.txt"; | |
FileOutputStream outStream = new FileOutputStream(path,true); | |
OutputStreamWriter writer = new OutputStreamWriter(outStream,"gb2312"); | |
writer.write(tag); | |
writer.write(" : "); | |
writer.write(s.toString()); | |
writer.write("\r\n"); | |
writer.flush(); | |
writer.close(); | |
outStream.close(); | |
} | |
catch (Exception e){ | |
} | |
} | |
public static void puts(Object[] s,String tag){ | |
try{ | |
String path= "/sdcard/debug.txt"; | |
FileOutputStream outStream = new FileOutputStream(path,true); | |
OutputStreamWriter writer = new OutputStreamWriter(outStream,"gb2312"); | |
writer.write(tag); | |
writer.write(" : "); | |
writer.write(Arrays.toString(s)); | |
writer.write("\r\n"); | |
writer.flush(); | |
writer.close(); | |
outStream.close(); | |
} | |
catch (Exception e){ | |
} | |
} | |
public static void main(String [] args){ | |
StringBuilder m = new StringBuilder("test log"); | |
StringBuilder[] l = new StringBuilder[2]; | |
l[0] = new StringBuilder("test log0"); | |
l[1] = new StringBuilder("test log1"); | |
crack.puts(m); | |
crack.puts(m,"tag"); | |
crack.puts(l,"tag"); | |
} | |
} |
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 Lcrack; | |
.super Ljava/lang/Object; | |
.source "crack.java" | |
# direct methods | |
.method public constructor <init>()V | |
.registers 1 | |
.prologue | |
.line 3 | |
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | |
return-void | |
.end method | |
.method public static main([Ljava/lang/String;)V | |
.registers 6 | |
.prologue | |
.line 51 | |
new-instance v0, Ljava/lang/StringBuilder; | |
const-string v1, "test log" | |
invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V | |
.line 52 | |
const/4 v1, 0x2 | |
new-array v1, v1, [Ljava/lang/StringBuilder; | |
.line 53 | |
const/4 v2, 0x0 | |
new-instance v3, Ljava/lang/StringBuilder; | |
const-string v4, "test log0" | |
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V | |
aput-object v3, v1, v2 | |
.line 54 | |
const/4 v2, 0x1 | |
new-instance v3, Ljava/lang/StringBuilder; | |
const-string v4, "test log1" | |
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V | |
aput-object v3, v1, v2 | |
.line 55 | |
invoke-static {v0}, Lcrack;->puts(Ljava/lang/Object;)V | |
.line 56 | |
const-string v2, "tag" | |
invoke-static {v0, v2}, Lcrack;->puts(Ljava/lang/Object;Ljava/lang/String;)V | |
.line 57 | |
const-string v0, "tag" | |
invoke-static {v1, v0}, Lcrack;->puts([Ljava/lang/Object;Ljava/lang/String;)V | |
.line 58 | |
return-void | |
.end method | |
.method public static puts(Ljava/lang/Object;)V | |
.registers 4 | |
.prologue | |
.line 6 | |
:try_start_0 | |
const-string v0, "/sdcard/debug.txt" | |
.line 7 | |
new-instance v1, Ljava/io/FileOutputStream; | |
const/4 v2, 0x1 | |
invoke-direct {v1, v0, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;Z)V | |
.line 8 | |
new-instance v0, Ljava/io/OutputStreamWriter; | |
const-string v2, "gb2312" | |
invoke-direct {v0, v1, v2}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;Ljava/lang/String;)V | |
.line 9 | |
invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String; | |
move-result-object v2 | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 10 | |
const-string v2, "\r\n" | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 11 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->flush()V | |
.line 12 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->close()V | |
.line 13 | |
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V | |
:try_end_24 | |
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_24} :catch_25 | |
.line 17 | |
:goto_24 | |
return-void | |
.line 15 | |
:catch_25 | |
move-exception v0 | |
goto :goto_24 | |
.end method | |
.method public static puts(Ljava/lang/Object;Ljava/lang/String;)V | |
.registers 5 | |
.prologue | |
.line 20 | |
:try_start_0 | |
const-string v0, "/sdcard/debug.txt" | |
.line 21 | |
new-instance v1, Ljava/io/FileOutputStream; | |
const/4 v2, 0x1 | |
invoke-direct {v1, v0, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;Z)V | |
.line 22 | |
new-instance v0, Ljava/io/OutputStreamWriter; | |
const-string v2, "gb2312" | |
invoke-direct {v0, v1, v2}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;Ljava/lang/String;)V | |
.line 23 | |
invoke-virtual {v0, p1}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 24 | |
const-string v2, " : " | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 25 | |
invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String; | |
move-result-object v2 | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 26 | |
const-string v2, "\r\n" | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 27 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->flush()V | |
.line 28 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->close()V | |
.line 29 | |
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V | |
:try_end_2c | |
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_2c} :catch_2d | |
.line 33 | |
:goto_2c | |
return-void | |
.line 31 | |
:catch_2d | |
move-exception v0 | |
goto :goto_2c | |
.end method | |
.method public static puts([Ljava/lang/Object;Ljava/lang/String;)V | |
.registers 5 | |
.prologue | |
.line 36 | |
:try_start_0 | |
const-string v0, "/sdcard/debug.txt" | |
.line 37 | |
new-instance v1, Ljava/io/FileOutputStream; | |
const/4 v2, 0x1 | |
invoke-direct {v1, v0, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;Z)V | |
.line 38 | |
new-instance v0, Ljava/io/OutputStreamWriter; | |
const-string v2, "gb2312" | |
invoke-direct {v0, v1, v2}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;Ljava/lang/String;)V | |
.line 39 | |
invoke-virtual {v0, p1}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 40 | |
const-string v2, " : " | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 41 | |
invoke-static {p0}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String; | |
move-result-object v2 | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 42 | |
const-string v2, "\r\n" | |
invoke-virtual {v0, v2}, Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V | |
.line 43 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->flush()V | |
.line 44 | |
invoke-virtual {v0}, Ljava/io/OutputStreamWriter;->close()V | |
.line 45 | |
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V | |
:try_end_2c | |
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_2c} :catch_2d | |
.line 49 | |
:goto_2c | |
return-void | |
.line 47 | |
:catch_2d | |
move-exception v0 | |
goto :goto_2c | |
.end method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment