Ejemplo n.º 1
0
    def apkinfo_dialog(self):
        self.apkinfo = MyApkInfoForm()
        self.Init_Apkinfo_text()
        csn_path = self.unpackDir + os.path.sep + "META-INF"
        if os.path.isdir(csn_path):
            f_list = os.listdir(csn_path)

            for file_name in f_list:
                if os.path.splitext(
                        file_name)[1] == '.RSA' or os.path.splitext(
                            file_name)[1] == '.DSA':
                    csn_path = csn_path + os.path.sep + file_name
                    csn = CSN(csn_path)
                    self.apkinfo.ui.edt_file.setText(str(csn.get_size()))
                    self.apkinfo.ui.edt_serial_num.setText(
                        str(csn.getCertificateSN()).upper())
                    self.apkinfo.ui.edt_publisher.setText(
                        str(csn.getCertificateIDN()))
                    self.apkinfo.ui.edt_issuer.setText(
                        str(csn.getCertificateSDN()))
                    break

        dex_path = self.unpackDir + os.path.sep + "classes.dex"
        if os.path.exists(dex_path):
            m = hashlib.md5()
            file = io.FileIO(dex_path, 'r')
            bytes = file.read(1024)
            while (bytes != b''):
                m.update(bytes)
                bytes = file.read(1024)
            file.close()
            dexmd5value = m.hexdigest()
            #print str(dexmd5value).upper()
            self.apkinfo.ui.edt_dexmd5.setText(str(dexmd5value).upper())

        apkpath = unicode(self.loadfile_path, "utf8")
        if os.path.isfile(apkpath) and self.loadfile_path != "":
            pass
        if self.loadfile_path != "":
            #apkpath = unicode(self.loadfile_path, "utf8")

            apkmd5value = self.GetFileMd5(self.loadfile_path)

            # m = hashlib.md5()
            # file = io.FileIO(self.loadfile_path, 'r')
            # bytes = file.read(1024)
            # while(bytes != b''):
            #     m.update(bytes)
            #     bytes = file.read(1024)
            # file.close()
            # apkmd5value = m.hexdigest()
            self.apkinfo.ui.edt_apkmd5.setText(apkmd5value.upper())

        path = self.unpackDir + os.path.sep + "AndroidManifest.xml"

        if os.path.exists(path):
            axml_analysis = AXML(self.unpackDir + os.path.sep +
                                 "AndroidManifest.xml")
            if axml_analysis.get_filename_abs() == 'AndroidManifest':
                self.apkinfo.ui.edt_package.setText(
                    axml_analysis.get_package())
                self.apkinfo.ui.edt_version.setText(
                    axml_analysis.get_androidversion_name())
                self.apkinfo.ui.edt_version_num.setText(
                    axml_analysis.get_androidversion_code())
                self.apkinfo.ui.edt_version_need.setText(
                    axml_analysis.getMinSdkVersion())

        self.apkinfo.show()
Ejemplo n.º 2
0
    def apkinfo_dialog(self):
        self.apkinfo = MyApkInfoForm()
        self.Init_Apkinfo_text()
        csn_path = self.unpackDir + os.path.sep + "META-INF"
        if os.path.isdir(csn_path):
            f_list = os.listdir(csn_path)

            for file_name in f_list:
                if os.path.splitext(file_name)[1] == '.RSA' or os.path.splitext(file_name)[1] == '.DSA':
                    csn_path = csn_path + os.path.sep + file_name
                    csn = CSN(csn_path)
                    self.apkinfo.ui.edt_file.setText(str(csn.get_size()))
                    self.apkinfo.ui.edt_serial_num.setText(str(csn.getCertificateSN()).upper())
                    self.apkinfo.ui.edt_publisher.setText(str(csn.getCertificateIDN()))
                    self.apkinfo.ui.edt_issuer.setText(str(csn.getCertificateSDN()))
                    break


        dex_path = self.unpackDir + os.path.sep + "classes.dex"
        if os.path.exists(dex_path):
            m = hashlib.md5()
            file = io.FileIO(dex_path, 'r')
            bytes = file.read(1024)
            while(bytes != b''):
                m.update(bytes)
                bytes = file.read(1024)
            file.close()
            dexmd5value = m.hexdigest()
            #print str(dexmd5value).upper()
            self.apkinfo.ui.edt_dexmd5.setText(str(dexmd5value).upper())

        apkpath = unicode(self.loadfile_path, "utf8")
        if os.path.isfile(apkpath) and self.loadfile_path != "":
            pass
        if self.loadfile_path != "":
            #apkpath = unicode(self.loadfile_path, "utf8")

            apkmd5value = self.GetFileMd5(self.loadfile_path)

            # m = hashlib.md5()
            # file = io.FileIO(self.loadfile_path, 'r')
            # bytes = file.read(1024)
            # while(bytes != b''):
            #     m.update(bytes)
            #     bytes = file.read(1024)
            # file.close()
            # apkmd5value = m.hexdigest()
            self.apkinfo.ui.edt_apkmd5.setText(apkmd5value.upper())


        path = self.unpackDir + os.path.sep +"AndroidManifest.xml"

        if os.path.exists(path):
            axml_analysis = AXML(self.unpackDir + os.path.sep +"AndroidManifest.xml")
            if axml_analysis.get_filename_abs() == 'AndroidManifest':
                self.apkinfo.ui.edt_package.setText(axml_analysis.get_package())
                self.apkinfo.ui.edt_version.setText(axml_analysis.get_androidversion_name())
                self.apkinfo.ui.edt_version_num.setText(axml_analysis.get_androidversion_code())
                self.apkinfo.ui.edt_version_need.setText(axml_analysis.getMinSdkVersion())



        self.apkinfo.show()
Ejemplo n.º 3
0
    def csnAnalysis(self, a_file):
        global log
        csn = CSN(a_file)

        ######################################################## 基本信息 ###############################################
        print "文件路径: ", csn.get_filename()
        print "序列号: ", csn.getCertificateSN()
        print "发行者: ", csn.getCertificateIDN()
        print "签发人: ", csn.getCertificateSDN()
        print "文件大小: ", csn.get_size() + " 字节"
        print "CSNMd5: ", csn.get_md5()
        print "CSNDigest: ", csn.get_digest()
        print "CSNSha1: ", csn.get_sha1()
        print "CSNSha256: ", csn.get_sha256()

        ######################################################## 黑名单证书 ############################################
        result_csn = csn.check_black_csn(csn.getCertificateSN())
        if result_csn:
            print "-" * 55, ""
            print "黑名单证书: ", '是 ' + result_csn
        else:
            pass
        print "-" * 55, ""
        raw_input('Done!')
        log.close()