mirror of
https://github.com/skylot/jadx.git
synced 2024-11-27 06:31:15 +00:00
Added option flag to make androidmanifest.xml decompiling optional.
This commit is contained in:
parent
ddab4c269d
commit
aacb83290e
@ -47,6 +47,9 @@ public final class JadxCLIArgs implements IJadxArgs {
|
||||
@Parameter(names = {"-h", "--help"}, description = "print this help", help = true)
|
||||
protected boolean printHelp = false;
|
||||
|
||||
@Parameter(names = {"-x", "--xml"}, description = "try to decode the AndroidManifest.xml, save at current dir")
|
||||
protected boolean xmlTest = false;
|
||||
|
||||
private final List<File> input = new ArrayList<File>(1);
|
||||
private File outputDir;
|
||||
|
||||
@ -164,6 +167,11 @@ public final class JadxCLIArgs implements IJadxArgs {
|
||||
return printHelp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isXMLTest() {
|
||||
return xmlTest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThreadsCount() {
|
||||
return threadsCount;
|
||||
|
@ -38,4 +38,9 @@ public class DefaultJadxArgs implements IJadxArgs {
|
||||
public boolean isVerbose() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isXMLTest() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,6 @@ public interface IJadxArgs {
|
||||
boolean isShowInconsistentCode();
|
||||
|
||||
boolean isVerbose();
|
||||
|
||||
boolean isXMLTest();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import jadx.core.utils.exceptions.DecodeException;
|
||||
import jadx.core.utils.exceptions.JadxException;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
import jadx.core.utils.files.InputFile;
|
||||
import jadx.core.xmlgen.BinaryXMLParser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -202,6 +203,16 @@ public final class JadxDecompiler {
|
||||
reset();
|
||||
root = new RootNode();
|
||||
LOG.info("loading ...");
|
||||
if(this.args.isXMLTest()) {
|
||||
InputFile inf = inputFiles.get(0);
|
||||
try {
|
||||
BinaryXMLParser bxp = new BinaryXMLParser(InputFile.loadXMLBuffer(inf.getFile()), "./AndroidManifest.xml");
|
||||
//BinaryXMLParser bxp = new BinaryXMLParser(InputFile.loadXMLBuffer(inf.getFile()), "AndroidManifest.xml");
|
||||
bxp.parse();
|
||||
} catch(IOException ioe) {
|
||||
LOG.info("Decompiling AndroidManifest.xml failed!");
|
||||
}
|
||||
}
|
||||
root.load(inputFiles);
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,29 @@ public class InputFile {
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] loadXMLBuffer(File file) throws IOException { // FIXME: Public.. Please fix
|
||||
ZipFile zf = new ZipFile(file);
|
||||
ZipEntry xml = zf.getEntry("AndroidManifest.xml");
|
||||
if(null == xml) {
|
||||
zf.close();
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = zf.getInputStream(xml);
|
||||
byte[] buffer = new byte[(int) xml.getSize()]; // FIXME: long->int conversion loss
|
||||
int count;
|
||||
while ((count = in.read(buffer)) != -1) {
|
||||
bytesOut.write(buffer, 0, count);
|
||||
}
|
||||
} finally {
|
||||
if(null != in) in.close();
|
||||
zf.close();
|
||||
}
|
||||
return bytesOut.toByteArray();
|
||||
}
|
||||
|
||||
private static Dex loadFromZip(File file) throws IOException {
|
||||
ZipFile zf = new ZipFile(file);
|
||||
ZipEntry dex = zf.getEntry("classes.dex");
|
||||
|
@ -76,7 +76,27 @@ public class BinaryXMLParser {
|
||||
die("IAE");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public BinaryXMLParser(byte[] xmlfilebytes, String xmloutfilepath) {
|
||||
System.out.println("XMLOUTFILEPATH: " + xmloutfilepath);
|
||||
try {
|
||||
writer = new PrintWriter(xmloutfilepath,"UTF-8");
|
||||
} catch(FileNotFoundException fnfe) { die("FNFE"); }
|
||||
catch(UnsupportedEncodingException uee) { die("UEE"); }
|
||||
if(null==writer) die("null==writer");
|
||||
writer.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
bytes = xmlfilebytes;
|
||||
count=0;
|
||||
styleMap = new HashMap<Integer, String>();
|
||||
if(null==styleMap) die("null==styleMap");
|
||||
for(Field f : android.R.style.class.getFields()) {
|
||||
try {
|
||||
styleMap.put(f.getInt(f.getType()),f.getName());
|
||||
} catch(IllegalAccessException iae) {
|
||||
die("IAE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void parse() {
|
||||
|
Loading…
Reference in New Issue
Block a user