Esempio n. 1
0
    def make_jks_trust_store(self):
        """
        Prepare a JKS TrustStore, for the CA.
        """

        keytool = Configuration.executable("keytool")
        argv = [
            keytool,
            "-import",
            "-trustcacerts",
            "-noprompt",
            "-alias",
            "andsploitCA",
            "-file",
            self.ca_certificate_path(),
            "-keystore",
            self.__jks_path("andsploit-ca"),
            "-storetype",
            "JKS",
            "-storepass",
            "andsploit",
        ]

        if keytool != None:
            if os.spawnve(os.P_WAIT, argv[0], argv, os.environ) == 0:
                return self.__bks_path("andsploit-ca")
        else:
            argv[0] = "keytool"

            print "Could not compile the JKS trust store, because keytool could not be located on your system."
            print "Run:"
            print " ".join(argv)

            return False
Esempio n. 2
0
 def loadClass(self, source, klass, relative_to=None):
     """
     Load a Class from a local apk file (source) on the running Dalvik VM.
     """
     
     if relative_to == None:
         relative_to = os.path.join(os.path.dirname(__file__), "..")
     elif relative_to.find(".py") >= 0 or relative_to.find(".pyc") >= 0:
         relative_to = os.path.dirname(relative_to)
     
     if not Module.cached_klass(".".join([source, klass])):
         loader = utils.ClassLoader(source, self.__get_cache_path(), self.__get_constructor(), self.klass('java.lang.ClassLoader').getSystemClassLoader(), relative_to=relative_to)
         loader.android_path = Configuration.library("android.jar")
         loader.dx_path = Configuration.executable("dx")
         loader.javac_path = Configuration.executable("javac")
         
         Module.cache_klass(".".join([source, klass]), loader.loadClass(klass))
         
     return Module.get_cached_klass(".".join([source, klass]))
Esempio n. 3
0
    def make_bks_key_store(self, cn, p12_path, export_password, store_password, key_password):
        """
        Prepare a BouncyCastle KeyStore from a PKCS12 bundle.
        """

        keytool = Configuration.executable("keytool")
        argv = [
            keytool,
            "-importkeystore",
            "-deststorepass",
            store_password,
            "-destkeypass",
            key_password,
            "-destkeystore",
            self.__bks_path(cn),
            "-deststoretype",
            "BKS",
            "-provider",
            "org.bouncycastle.jce.provider.BouncyCastleProvider",
            "-providerpath",
            os.path.abspath(os.path.join(os.path.dirname(__file__), "bcprov-ext-jdk15on-1.46.jar")),
            "-srckeystore",
            p12_path,
            "-srcstoretype",
            "PKCS12",
            "-srcstorepass",
            export_password,
            "-alias",
            "andsploit",
        ]

        if keytool != None:
            if os.spawnve(os.P_WAIT, argv[0], argv, os.environ) == 0:
                return self.__bks_path(cn)
        else:
            argv[0] = "keytool"

            print "Could not compile the BKS keystore, because keytool could not be located on your system."
            print "Run:"
            print " ".join(argv)

            return False
Esempio n. 4
0
    def make_bks_trust_store(self):
        """
        Prepare a BouncyCastle TrustStore, for the CA.
        """

        keytool = Configuration.executable("keytool")
        argv = [
            keytool,
            "-import",
            "-trustcacerts",
            "-noprompt",
            "-alias",
            "andsploitCA",
            "-file",
            self.ca_certificate_path(),
            "-keystore",
            self.__bks_path("andsploit-ca"),
            "-storetype",
            "BKS",
            "-storepass",
            "andsploit",
            "-provider",
            "org.bouncycastle.jce.provider.BouncyCastleProvider",
            "-providerpath",
            os.path.abspath(os.path.join(os.path.dirname(__file__), "bcprov-ext-jdk15on-1.46.jar")),
        ]

        if keytool != None:
            if os.spawnve(os.P_WAIT, argv[0], argv, os.environ) == 0:
                return self.__bks_path("andsploit-ca")
        else:
            argv[0] = "keytool"

            print "Could not compile the BKS trust store, because keytool could not be located on your system."
            print "Run:"
            print " ".join(argv)

            return False