def main(options, arguments) : if options.input != None and options.output != None : buff = "" if ".apk" in options.input : a = apk.APK( options.input ) buff = a.xml[ "AndroidManifest.xml" ].toprettyxml() elif ".xml" in options.input : ap = apk.AXMLPrinter( open(options.input, "rb").read() ) buff = minidom.parseString( ap.getBuff() ).toprettyxml() else : print "Unknown file type" return fd = codecs.open(options.output, "w", "utf-8") fd.write( buff ) fd.close() elif options.version != None : print "Androaxml version %s" % misc.ANDROAXML_VERSION
def main(options, arguments): if options.input != None: buff = "" if ".xml" in options.input: ap = apk.AXMLPrinter(open(options.input, "rb").read()) buff = ap.get_xml_obj().toprettyxml() else: print("Unknown file type") return if options.output != None: fd = open(options.output, "w") fd.write(buff) fd.close() else: print(buff) else: print("Use axmlprinter.py -h for command line options.")
#!/usr/bin/env python import sys PATH_INSTALL = "./" sys.path.append(PATH_INSTALL + "/core") sys.path.append(PATH_INSTALL + "/core/bytecodes") from xml.dom import minidom import apk ap = apk.AXMLPrinter(open("apks/tmp/AndroidManifest.xml", "r").read()) print minidom.parseString(ap.getBuff()).toxml()
from xml.dom import minidom def test(got, expected): if got == expected: prefix = ' OK ' else: prefix = ' X ' print '%s got: %s expected: %s' % (prefix, repr(got), repr(expected)), return (got == expected) TESTS = [ "./examples/axml/AndroidManifest.xml", "./examples/axml/AndroidManifest-Chinese.xml", # "./examples/axml/test.xml", "./examples/axml/test1.xml", "./examples/axml/test2.xml", "./examples/axml/test3.xml" ] import codecs for i in TESTS : in1 = open( i, mode="rb" ) ap = apk.AXMLPrinter( in1.read() ) minidom.parseString( ap.getBuff() ) print "PASSED", i #out = codecs.open("res.xml", "w", "utf-8") #out.write( s ) #out.close()