當前位置: 首頁>>代碼示例>>Python>>正文


Python apk.APK屬性代碼示例

本文整理匯總了Python中androguard.core.bytecodes.apk.APK屬性的典型用法代碼示例。如果您正苦於以下問題:Python apk.APK屬性的具體用法?Python apk.APK怎麽用?Python apk.APK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在androguard.core.bytecodes.apk的用法示例。


在下文中一共展示了apk.APK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sign_apk

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def sign_apk(filename, keystore, storepass):
    """
    Use jarsigner to sign an APK file.

    :param filename: APK file on disk to sign (path)
    :param keystore: path to keystore
    :param storepass: your keystorage passphrase
    """
    from subprocess import Popen, PIPE, STDOUT
    # TODO use apksigner instead of jarsigner
    cmd = Popen([androconf.CONF["BIN_JARSIGNER"], "-sigalg", "MD5withRSA",
                 "-digestalg", "SHA1", "-storepass", storepass, "-keystore",
                 keystore, filename, "alias_name"],
                stdout=PIPE,
                stderr=STDOUT)
    stdout, stderr = cmd.communicate() 
開發者ID:amimo,項目名稱:dcc,代碼行數:18,代碼來源:misc.py

示例2: addAPK

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def addAPK(self, filename, data):
        """
        Add an APK file to the Session and run analysis on it.

        :param filename: (file)name of APK file
        :param data: binary data of the APK file
        :return: a tuple of SHA256 Checksum and APK Object
        """
        digest = hashlib.sha256(data).hexdigest()
        log.debug("add APK:%s" % digest)
        apk = APK(data, True)
        self.analyzed_apk[digest] = [apk]
        self.analyzed_files[filename].append(digest)
        self.analyzed_digest[digest] = filename

        dx = Analysis()
        self.analyzed_vms[digest] = dx

        for dex in apk.get_all_dex():
            # we throw away the output... FIXME?
            self.addDEX(filename, dex, dx)

        log.debug("added APK:%s" % digest)
        return digest, apk 
開發者ID:amimo,項目名稱:dcc,代碼行數:26,代碼來源:session.py

示例3: androaxml_main

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def androaxml_main(inp, outp=None, resource=None):
    ret_type = androconf.is_android(inp)
    if ret_type == "APK":
        a = apk.APK(inp)
        if resource:
            if resource not in a.files:
                print("The APK does not contain a file called '{}'".format(resource), file=sys.stderr)
                sys.exit(1)

            axml = AXMLPrinter(a.get_file(resource)).get_xml_obj()
        else:
            axml = a.get_android_manifest_xml()
    elif ".xml" in inp:
        axml = AXMLPrinter(read(inp)).get_xml_obj()
    else:
        print("Unknown file type")
        sys.exit(1)

    buff = etree.tostring(axml, pretty_print=True, encoding="utf-8")
    if outp:
        with open(outp, "wb") as fd:
            fd.write(buff)
    else:
        sys.stdout.write(highlight(buff.decode("UTF-8"), get_lexer_by_name("xml"), TerminalFormatter())) 
開發者ID:amimo,項目名稱:dcc,代碼行數:26,代碼來源:main.py

示例4: __init__

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def __init__(self, name):
        """

        :param name: filename to load
        """
        self.vma = analysis.Analysis()

        # Proper detection which supports multidex inside APK
        ftype = androconf.is_android(name)
        if ftype == 'APK':
            for d in apk.APK(name).get_all_dex():
                self.vma.add(dvm.DalvikVMFormat(d))
        elif ftype == 'DEX':
            self.vma.add(dvm.DalvikVMFormat(read(name)))
        elif ftype == 'DEY':
            self.vma.add(dvm.DalvikOdexVMFormat(read(name)))
        else:
            raise ValueError("Format not recognised for filename '%s'" % name)

        self.classes = dict((dvclass.orig_class.get_name(), dvclass.orig_class) for dvclass in self.vma.get_classes())
        # TODO why not?
        # util.merge_inner(self.classes) 
開發者ID:amimo,項目名稱:dcc,代碼行數:24,代碼來源:decompile.py

示例5: __init__

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def __init__(self,apkFile):
    self.sha256 = self.sha256CheckSum(apkFile)
    print "[-]Parsing APK"
    self.a = apk.APK(apkFile)
    print "[-]Baksmaling DEX files"
    self.bakmali(apkFile)
    self.manifest = self.a.get_android_manifest_axml().get_xml_obj()
    self.application = self.manifest.findall("application")[0]
    print "[+]Gathering Information"
    self.extractActivitiesWithExcludeFromRecents()
    self.extractActivitiesWithoutSecureFlag()
    print "   [-]Package Properties"
    self.extractPackageProperties()
    print "   [-]Exported Components"
    self.extractExportedComponents()
    print "   [-]Permissions"
    self.extractPermissions()
    print "   [-]Files"
    self.extractFiles()

  #Return the Android Code Name for the particular Api Level. 
開發者ID:integrity-sa,項目名稱:droidstatx,代碼行數:23,代碼來源:App.py

示例6: _analyze

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def _analyze(self):
        for i in self.__files:
            ret_type = androconf.is_android( i )
            if ret_type == "APK":
                x = apk.APK( i )
                bc = dvm.DalvikVMFormat( x.get_dex() )
            elif ret_type == "DEX":
                bc = dvm.DalvikVMFormat( read(i) )
            elif ret_type == "DEY":
                bc = dvm.DalvikOdexVMFormat( read(i) )
            elif ret_type == "ELF":
                from androguard.core.binaries import elf
                bc = elf.ELF( read(i) )
            else:
                raise( "Unknown format" )

            self.__bc.append( (i, BC( bc )) ) 
開發者ID:DroidTest,項目名稱:TimeMachine,代碼行數:19,代碼來源:androgen.py

示例7: filter_file

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def filter_file(self, log, fileraw):
    """
      This method is called in order to filer a specific app

      :param log: an object which corresponds to a unique app
      :param fileraw: the raw app (a string)

      :rtype: a set with 2 elements, the return value (boolean) if it is necessary to
      continue the analysis and the file type
    """
    file_type = androconf.is_android_raw(fileraw)
    if file_type == "APK" or file_type == "DEX" or file_type == "DEY" or file_type == "AXML" or file_type == "ARSC":
      if file_type == "APK":
        if androconf.is_valid_android_raw(fileraw):
          return (True, "APK")
      else:
        return (True, file_type)
    return (False, None) 
開發者ID:DroidTest,項目名稱:TimeMachine,代碼行數:20,代碼來源:auto.py

示例8: __init__

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def __init__(self, app_path, output_dir=None):
        """
        create an App instance
        :param app_path: local file path of app
        :return:
        """
        assert app_path is not None
        self.logger = logging.getLogger(self.__class__.__name__)

        self.app_path = app_path

        self.output_dir = output_dir
        if output_dir is not None:
            if not os.path.isdir(output_dir):
                os.makedirs(output_dir)

        from androguard.core.bytecodes.apk import APK
        self.apk = APK(self.app_path)
        self.package_name = self.apk.get_package()
        self.main_activity = self.apk.get_main_activity()
        self.permissions = self.apk.get_permissions()
        self.activities = self.apk.get_activities()
        self.possible_broadcasts = self.get_possible_broadcasts()
        self.dumpsys_main_activity = None
        self.hashes = self.get_hashes() 
開發者ID:honeynet,項目名稱:droidbot,代碼行數:27,代碼來源:app.py

示例9: get_hashes

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def get_hashes(self, block_size=2 ** 8):
        """
        Calculate MD5,SHA-1, SHA-256
        hashes of APK input file
        @param block_size:
        """
        md5 = hashlib.md5()
        sha1 = hashlib.sha1()
        sha256 = hashlib.sha256()
        f = open(self.app_path, 'rb')
        while True:
            data = f.read(block_size)
            if not data:
                break
            md5.update(data)
            sha1.update(data)
            sha256.update(data)
        return [md5.hexdigest(), sha1.hexdigest(), sha256.hexdigest()] 
開發者ID:honeynet,項目名稱:droidbot,代碼行數:20,代碼來源:app.py

示例10: get_app_name

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def get_app_name(app_path, app_dir, tools_dir, is_apk):
    """Get app name."""
    if is_apk:
        a = apk.APK(app_path)
        real_name = a.get_app_name()
        return real_name
    else:
        strings_path = os.path.join(app_dir,
                                    'app/src/main/res/values/')
        eclipse_path = os.path.join(app_dir,
                                    'res/values/')
        if os.path.exists(strings_path):
            strings_dir = strings_path
        elif os.path.exists(eclipse_path):
            strings_dir = eclipse_path
    if not os.path.exists(strings_dir):
        logger.warning('Cannot find values folder.')
        return ''
    return get_app_name_from_values_folder(strings_dir) 
開發者ID:MobSF,項目名稱:Mobile-Security-Framework-MobSF,代碼行數:21,代碼來源:static_analyzer.py

示例11: check_apk

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def check_apk(self, apk):
        """
            Check if a signature matches the application

            @param apk : an L{APK} object
            @rtype : None if no signatures match, otherwise the name of the signature
        """
        if self.debug:
            print "loading apk..",
            sys.stdout.flush()

        classes_dex = apk.get_dex()
        ret, l = self.p._check_dalvik( classes_dex )

        if ret == None:
            #ret, l1 = self.p._check_bin( apk )
            l1 = []
            l.extend( l1 )

        return ret, l 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:22,代碼來源:dalvik_elsign.py

示例12: check_one_directory

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def check_one_directory(directory):
    for root, dirs, files in os.walk( directory, followlinks=True ):
        if files != []:
            for f in files:
                real_filename = root
                if real_filename[-1] != "/":
                    real_filename += "/"
                real_filename += f

                print "filename: %s ..." % real_filename
                ret_type = androconf.is_android( real_filename )
                if ret_type == "APK":
                    a = apk.APK( real_filename )
                    d1 = dvm.DalvikVMFormat( a.get_dex() )
                elif ret_type == "DEX":
                    d1 = dvm.DalvikVMFormat( read(real_filename) )

                dx1 = analysis.VMAnalysis( d1 )
                check_one_file( d1, dx1 ) 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:21,代碼來源:androappindb.py

示例13: main

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def main(options, arguments):
    if options.input != None and options.database != None:
        ret_type = androconf.is_android( options.input )
        if ret_type == "APK":
            a = apk.APK( options.input )
            d1 = dvm.DalvikVMFormat( a.get_dex() )
        elif ret_type == "DEX":
            d1 = dvm.DalvikVMFormat( read(options.input) )

        dx1 = analysis.VMAnalysis( d1 )

        check_one_file(d1, dx1)

    elif options.directory != None and options.database != None:
      check_one_directory( options.directory )

    elif options.database != None and options.listdatabase != None:
        db = DBFormat( options.database )
        db.show()

    elif options.version != None:
        print "Androappindb version %s" % androconf.ANDROGUARD_VERSION 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:24,代碼來源:androappindb.py

示例14: main

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def main(options, arguments):
    if options.input != None:
        buff = ""

        ret_type = androconf.is_android(options.input)
        if ret_type == "APK":
            a = apk.APK(options.input)
            buff = a.get_android_manifest_xml().toprettyxml(encoding="utf-8")
        elif ".xml" in options.input:
            ap = apk.AXMLPrinter(read(options.input))
            buff = minidom.parseString(ap.get_buff()).toprettyxml(
                encoding="utf-8")
        else:
            print "Unknown file type"
            return

        if options.output != None:
            fd = codecs.open(options.output, "w", "utf-8")
            fd.write(buff)
            fd.close()
        else:
            print buff

    elif options.version != None:
        print "Androaxml version %s" % androconf.ANDROGUARD_VERSION 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:27,代碼來源:androaxml.py

示例15: filter_file

# 需要導入模塊: from androguard.core.bytecodes import apk [as 別名]
# 或者: from androguard.core.bytecodes.apk import APK [as 別名]
def filter_file(self, log, fileraw):
        """
      This method is called in order to filer a specific app

      :param log: an object which corresponds to a unique app
      :param fileraw: the raw app (a string)

      :rtype: a set with 2 elements, the return value (boolean) if it is necessary to
      continue the analysis and the file type
    """
        file_type = androconf.is_android_raw(fileraw)
        if file_type == "APK" or file_type == "DEX" or file_type == "DEY" or file_type == "AXML" or file_type == "ARSC":
            if file_type == "APK":
                if androconf.is_valid_android_raw(fileraw):
                    return (True, "APK")
            else:
                return (True, file_type)
        return (False, None) 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:20,代碼來源:auto.py


注:本文中的androguard.core.bytecodes.apk.APK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。