diff -Nru pyaxmlparser-0.3.11/debian/changelog pyaxmlparser-0.3.13/debian/changelog --- pyaxmlparser-0.3.11/debian/changelog 2018-12-02 11:09:20.000000000 +0000 +++ pyaxmlparser-0.3.13/debian/changelog 2018-12-02 11:09:20.000000000 +0000 @@ -1,3 +1,12 @@ +pyaxmlparser (0.3.13-1) unstable; urgency=low + + * New upstream release. + * Add a watch file. + * Clean up a few minor lintian things. + * Add a dependency on python3-pkg-resources. + + -- Andres Salomon Sun, 02 Dec 2018 00:26:50 +0000 + pyaxmlparser (0.3.11-1) unstable; urgency=low * New upstream release. @@ -9,4 +18,3 @@ * New upstream release. -- Andres Salomon Fri, 08 Jun 2018 03:40:59 +0000 - diff -Nru pyaxmlparser-0.3.11/debian/control pyaxmlparser-0.3.13/debian/control --- pyaxmlparser-0.3.11/debian/control 2018-12-02 11:09:20.000000000 +0000 +++ pyaxmlparser-0.3.13/debian/control 2018-12-02 11:09:20.000000000 +0000 @@ -7,22 +7,23 @@ python3, python3-setuptools, python3-lxml -Standards-Version: 4.1.4.1 +Standards-Version: 4.2.1.5 Homepage: https://github.com/appknox/pyaxmlparser Package: python3-pyaxmlparser Architecture: all Depends: ${python3:Depends}, ${misc:Depends} -Description: Simple python library to parse Android XML files +Description: Simple Python library to parse Android XML files A simple parsing library for Android XML files. This allows parsing without pulling in larger libraries (unlike Androguard). Package: apkinfo Architecture: all Depends: python3-pyaxmlparser, + python3-pkg-resources, python3-click, ${python3:Depends}, ${misc:Depends} -Description: Simple CLI script to display info about an APK file. +Description: Simple CLI script to display info about an APK file This command-line script displays information about an Android APK file. diff -Nru pyaxmlparser-0.3.11/debian/copyright pyaxmlparser-0.3.13/debian/copyright --- pyaxmlparser-0.3.11/debian/copyright 2018-12-02 11:09:20.000000000 +0000 +++ pyaxmlparser-0.3.13/debian/copyright 2018-12-02 11:09:20.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: pyaxmlparser Source: https://github.com/appknox/pyaxmlparser diff -Nru pyaxmlparser-0.3.11/debian/watch pyaxmlparser-0.3.13/debian/watch --- pyaxmlparser-0.3.11/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ pyaxmlparser-0.3.13/debian/watch 2018-12-02 11:09:20.000000000 +0000 @@ -0,0 +1,3 @@ +version=4 +opts=dversionmangle=auto \ +https://github.com/appknox/pyaxmlparser/releases .*/v(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) diff -Nru pyaxmlparser-0.3.11/pyaxmlparser/arscparser.py pyaxmlparser-0.3.13/pyaxmlparser/arscparser.py --- pyaxmlparser-0.3.11/pyaxmlparser/arscparser.py 2018-09-27 15:11:38.000000000 +0000 +++ pyaxmlparser-0.3.13/pyaxmlparser/arscparser.py 2018-11-04 17:05:41.000000000 +0000 @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from pyaxmlparser import bytecode import collections from struct import unpack @@ -24,7 +25,8 @@ import pyaxmlparser.constants as const from pyaxmlparser.utils import complexToFloat from xml.sax.saxutils import escape -from warnings import warn + +log = logging.getLogger("pyaxmlparser.arscparser") class ARSCParser(object): @@ -102,7 +104,7 @@ # Read all other headers while self.buff.get_idx() <= package_data_end - ARSCHeader.SIZE: pkg_chunk_header = ARSCHeader(self.buff) - warn("Found a header: {}".format(pkg_chunk_header)) + log.debug("Found a header: {}".format(pkg_chunk_header)) if pkg_chunk_header.start + pkg_chunk_header.size > package_data_end: # we are way off the package chunk; bail out break @@ -117,7 +119,7 @@ self.packages[package_name].append(a_res_type) self.resource_configs[package_name][a_res_type].add(a_res_type.config) - warn("Config: {}".format(a_res_type.config)) + log.debug("Config: {}".format(a_res_type.config)) entries = [] for i in range(0, a_res_type.entryCount): @@ -143,7 +145,7 @@ # Not sure if this is a good solution though self.buff.set_idx(ate.start) elif pkg_chunk_header.type == const.RES_TABLE_LIBRARY_TYPE: - warn("RES_TABLE_LIBRARY_TYPE chunk is not supported") + log.warning("RES_TABLE_LIBRARY_TYPE chunk is not supported") else: # silently skip other chunk types pass @@ -274,7 +276,7 @@ const.DIMENSION_UNITS[ate.key.get_data() & const.COMPLEX_UNIT_MASK]) ] except IndexError: - warn("Out of range dimension unit index for %s: %s" % ( + log.warning("Out of range dimension unit index for %s: %s" % ( complexToFloat(ate.key.get_data()), ate.key.get_data() & const.COMPLEX_UNIT_MASK)) return [ate.get_value(), ate.key.get_data()] @@ -630,7 +632,7 @@ raise ValueError("'rid' must be an int") if rid not in self.resource_values: - warn("The requested rid could not be found in the resources.") + log.warning("The requested rid could not be found in the resources.") return [] res_options = self.resource_values[rid] @@ -638,7 +640,7 @@ if config in res_options: return [(config, res_options[config])] elif fallback and config == ARSCResTableConfig.default_config(): - warn("No default resource config could be found for the given rid, using fallback!") + log.warning("No default resource config could be found for the given rid, using fallback!") return [list(self.resource_values[rid].items())[0]] else: return [] diff -Nru pyaxmlparser-0.3.11/pyaxmlparser/arscutil.py pyaxmlparser-0.3.13/pyaxmlparser/arscutil.py --- pyaxmlparser-0.3.11/pyaxmlparser/arscutil.py 2018-09-27 15:11:38.000000000 +0000 +++ pyaxmlparser-0.3.13/pyaxmlparser/arscutil.py 2018-11-04 17:05:41.000000000 +0000 @@ -15,11 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from struct import unpack -from warnings import warn import pyaxmlparser.constants as const from pyaxmlparser.utils import format_value +log = logging.getLogger("pyaxmlparser.arscutil") + class ARSCResTablePackage(object): def __init__(self, buff, header): @@ -178,7 +180,7 @@ self.exceedingSize = self.size - 36 if self.exceedingSize > 0: - warn("Skipping padding bytes!") + log.debug("Skipping padding bytes!") self.padding = buff.read(self.exceedingSize) # TODO there is screenConfig2 diff -Nru pyaxmlparser-0.3.11/pyaxmlparser/axmlparser.py pyaxmlparser-0.3.13/pyaxmlparser/axmlparser.py --- pyaxmlparser-0.3.11/pyaxmlparser/axmlparser.py 2018-09-27 15:11:38.000000000 +0000 +++ pyaxmlparser-0.3.13/pyaxmlparser/axmlparser.py 2018-11-04 17:05:41.000000000 +0000 @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from struct import unpack -from warnings import warn from collections import defaultdict import pyaxmlparser.constants as const @@ -25,6 +25,8 @@ from pyaxmlparser import public from . import arscutil +log = logging.getLogger("pyaxmlparser.axmlparser") + class AXMLParser(object): def __init__(self, raw_buff): @@ -45,14 +47,14 @@ if axml_file >> 16 == 0x0008: self.axml_tampered = True - warn( + log.warning( "AXML file has an unusual header, most malwares like " "doing such stuff to anti androguard! But we try to parse " "it anyways. Header: 0x{:08x}".format(axml_file) ) else: self.valid_axml = False - warn("Not a valid AXML file. Header 0x{:08x}".format(axml_file)) + log.warning("Not a valid AXML file. Header 0x{:08x}".format(axml_file)) return # Next is the filesize @@ -129,7 +131,7 @@ # Check size: < 8 bytes mean that the chunk is not complete # Should be aligned to 4 bytes. if chunkSize < 8 or chunkSize % 4 != 0: - warn("Invalid chunk size in chunk RESOURCEIDS") + log.warning("Invalid chunk size in chunk RESOURCEIDS") for i in range(0, (chunkSize // 4) - 2): self.m_resourceIDs.append( @@ -140,7 +142,7 @@ # FIXME, unknown chunk types might cause problems if chunkType < const.CHUNK_XML_FIRST or \ chunkType > const.CHUNK_XML_LAST: - warn("invalid chunk type 0x{:08x}".format(chunkType)) + log.warning("invalid chunk type 0x{:08x}".format(chunkType)) # Fake START_DOCUMENT event. if chunkType == const.CHUNK_XML_START_TAG and event == -1: @@ -206,7 +208,7 @@ self.visited_ns.remove((uri, prefix)) else: - warn( + log.warning( "Reached a NAMESPACE_END without having the " "namespace stored before? Prefix ID: {}, URI ID: " "{}".format(prefix, uri) @@ -329,7 +331,7 @@ # FIXME Packers like Liapp use empty uri to fool XML Parser # FIXME they also mess around with the Manifest, thus it can not be parsed easily if prefix_uri == '': - warn("Empty Namespace URI for Namespace {}.".format(prefix_str)) + log.warning("Empty Namespace URI for Namespace {}.".format(prefix_str)) self.packerwarning = True # if prefix is (null), which is indicated by an empty str, then do not print : @@ -345,12 +347,12 @@ def getAttributeOffset(self, index): # FIXME if self.m_event != const.START_TAG: - warn("Current event is not START_TAG.") + log.warning("Current event is not START_TAG.") offset = index * 5 # FIXME if offset >= len(self.m_attributes): - warn("Invalid attribute index") + log.warning("Invalid attribute index") return offset diff -Nru pyaxmlparser-0.3.11/pyaxmlparser/core.py pyaxmlparser-0.3.13/pyaxmlparser/core.py --- pyaxmlparser-0.3.11/pyaxmlparser/core.py 2018-09-27 15:11:38.000000000 +0000 +++ pyaxmlparser-0.3.13/pyaxmlparser/core.py 2018-11-04 17:05:41.000000000 +0000 @@ -1,8 +1,12 @@ + +import logging from pyaxmlparser.arscparser import ARSCParser from pyaxmlparser.axmlprinter import AXMLPrinter from pyaxmlparser.arscutil import ARSCResTableConfig from pyaxmlparser.utils import get_zip_file, NS_ANDROID -from warnings import warn + + +log = logging.getLogger("pyaxmlparser.core") class APK: @@ -132,7 +136,7 @@ res_id, ARSCResTableConfig.default_config())[0][1] except Exception as e: - warn("Exception selecting app name: %s" % e) + log.warning("Exception selecting app name: %s" % e) app_name = self.package return app_name @@ -154,7 +158,7 @@ hex_value = self.arsc.get_id(value, int(key, 0))[1] rsc = self.arsc.get_string(value, hex_value)[1] except Exception as e: - warn(str(e)) + log.warning(str(e)) rsc = None return rsc @@ -222,7 +226,7 @@ app_icon = file_name current_dpi = dpi except Exception as e: - warn("Exception selecting app icon: %s" % e) + log.warning("Exception selecting app icon: %s" % e) return self.zip_file.read(app_icon) diff -Nru pyaxmlparser-0.3.11/pyaxmlparser/stringblock.py pyaxmlparser-0.3.13/pyaxmlparser/stringblock.py --- pyaxmlparser-0.3.11/pyaxmlparser/stringblock.py 2018-09-27 15:11:38.000000000 +0000 +++ pyaxmlparser-0.3.13/pyaxmlparser/stringblock.py 2018-11-04 17:05:41.000000000 +0000 @@ -15,8 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from struct import unpack -from warnings import warn + + +log = logging.getLogger("pyaxmlparser.stringblock") + # Flags in the STRING Section SORTED_FLAG = 1 << 0 @@ -51,7 +55,7 @@ # Check if they supplied a stylesOffset even if the count is 0: if self.styleOffsetCount == 0 and self.stylesOffset > 0: - warn("Styles Offset given, but styleCount is zero.") + log.warning("Styles Offset given, but styleCount is zero.") self.m_stringOffsets = [] self.m_styleOffsets = [] @@ -78,7 +82,7 @@ # FIXME unaligned if (size % 4) != 0: - warn("Size of strings is not aligned by four bytes.") + log.warning("Size of strings is not aligned by four bytes.") self.m_charbuff = buff.read(size) @@ -87,7 +91,7 @@ # FIXME unaligned if (size % 4) != 0: - warn("Size of styles is not aligned by four bytes.") + log.warning("Size of styles is not aligned by four bytes.") for i in range(0, size // 4): self.m_styles.append(unpack('