Exemplo n.º 1
0
    def __init__(self, config):
        """
       :type method: str
       :param config:
       :type config: yowsup.config.v1.config.Config
       """

        self.pvars = []
        self.port = 443
        self.type = "GET"
        self.parser = None
        self.params = []
        self.headers = {}

        self.sent = False
        self.response = None

        self._config = config
        self._p_in = str(config.phone)[len(str(config.cc)):]
        self._axolotlmanager = AxolotlManagerFactory() \
            .get_manager(self._config.phone)  # type: yowsup.axolotl.manager.Axolotlmanager

        if config.expid is None:
            config.expid = WATools.generateDeviceId()

        if config.fdid is None:
            config.fdid = WATools.generatePhoneId()

        if config.client_static_keypair is None:
            config.client_static_keypair = WATools.generateKeyPair()

        self.addParam("cc", config.cc)
        self.addParam("in", self._p_in)
        self.addParam("lg", "en")
        self.addParam("lc", "GB")
        self.addParam("mistyped", "6")
        self.addParam("authkey", self.b64encode(config.client_static_keypair.public.data))
        self.addParam("e_regid", self.b64encode(struct.pack('>I', self._axolotlmanager.registration_id)))
        self.addParam("e_keytype", self.b64encode(b"\x05"))
        self.addParam("e_ident", self.b64encode(self._axolotlmanager.identity.publicKey.serialize()[1:]))

        signedprekey = self._axolotlmanager.load_latest_signed_prekey(generate=True)
        self.addParam("e_skey_id", self.b64encode(struct.pack('>I', signedprekey.getId())[1:]))
        self.addParam("e_skey_val", self.b64encode(signedprekey.getKeyPair().publicKey.serialize()[1:]))
        self.addParam("e_skey_sig", self.b64encode(signedprekey.getSignature()))

        self.addParam("fdid", config.fdid)
        self.addParam("expid", self.b64encode(config.expid))

        self.addParam("network_radio_type", "1")
        self.addParam("simnum", "1")
        self.addParam("hasinrc", "1")
        self.addParam("pid", int(random.uniform(100, 9999)))
        self.addParam("rc", 0)
        if self._config.id:
            self.addParam("id", self._config.id)
Exemplo n.º 2
0
    def __init__(self, config):
        """
       :type method: str
       :param config:
       :type config: yowsup.config.v1.config.Config
       """

        self.pvars = []
        self.port = 443
        self.type = "GET"
        self.parser = None
        self.params = []
        self.headers = {}

        self.sent = False
        self.response = None

        self._config = config
        self._p_in = str(config.phone)[len(str(config.cc)):]
        self._axolotlmanager = AxolotlManagerFactory() \
            .get_manager(self._config.phone)  # type: yowsup.axolotl.manager.Axolotlmanager

        if config.expid is None:
            config.expid = WATools.generateDeviceId()

        if config.fdid is None:
            config.fdid = WATools.generatePhoneId()

        if config.client_static_keypair is None:
            config.client_static_keypair = WATools.generateKeyPair()

        self.addParam("cc", config.cc)
        self.addParam("in", self._p_in)
        self.addParam("lg", "en")
        self.addParam("lc", "GB")
        self.addParam("mistyped", "6")
        self.addParam("authkey",
                      self.b64encode(config.client_static_keypair.public.data))
        self.addParam(
            "e_regid",
            self.b64encode(
                struct.pack('>I', self._axolotlmanager.registration_id)))
        self.addParam("e_keytype", self.b64encode(b"\x05"))
        self.addParam(
            "e_ident",
            self.b64encode(
                self._axolotlmanager.identity.publicKey.serialize()[1:]))

        signedprekey = self._axolotlmanager.load_latest_signed_prekey(
            generate=True)
        self.addParam(
            "e_skey_id",
            self.b64encode(struct.pack('>I', signedprekey.getId())[1:]))
        self.addParam(
            "e_skey_val",
            self.b64encode(
                signedprekey.getKeyPair().publicKey.serialize()[1:]))
        self.addParam("e_skey_sig",
                      self.b64encode(signedprekey.getSignature()))

        self.addParam("fdid", config.fdid)
        self.addParam("expid", self.b64encode(config.expid))

        self.addParam("network_radio_type", "1")
        self.addParam("simnum", "1")
        self.addParam("hasinrc", "1")
        self.addParam("pid", int(random.uniform(100, 9999)))
        self.addParam("rc", 0)
        if self._config.id:
            self.addParam("id", self._config.id)
Exemplo n.º 3
0
    def __init__(self, config_or_profile):
        """
       :type method: str
       :param config_or_profile:
       :type config: yowsup.config.v1.config.Config | YowProfile
       """

        self.pvars = []
        self.port = 443
        self.type = "GET"
        self.parser = None
        self.params = []
        self.headers = {}

        self.sent = False
        self.response = None

        if isinstance(config_or_profile, Config):
            logger.warning(
                "Passing Config to WARequest is deprecated, pass a YowProfile instead"
            )
            profile = YowProfile(config_or_profile.phone, config_or_profile)
        else:
            assert isinstance(config_or_profile, YowProfile)
            profile = config_or_profile

        self._config = profile.config
        config = self._config
        self._p_in = str(config.phone)[len(str(config.cc)):]
        self._axolotlmanager = profile.axolotl_manager

        if config.expid is None:
            config.expid = WATools.generateDeviceId()

        if config.fdid is None:
            config.fdid = WATools.generatePhoneId()

        if config.client_static_keypair is None:
            config.client_static_keypair = WATools.generateKeyPair()

        self.addParam("cc", config.cc)
        self.addParam("in", self._p_in)
        self.addParam("lg", "en")
        self.addParam("lc", "GB")
        self.addParam("mistyped", "6")
        self.addParam("authkey",
                      self.b64encode(config.client_static_keypair.public.data))
        self.addParam(
            "e_regid",
            self.b64encode(
                struct.pack('>I', self._axolotlmanager.registration_id)))
        self.addParam("e_keytype", self.b64encode(b"\x05"))
        self.addParam(
            "e_ident",
            self.b64encode(
                self._axolotlmanager.identity.publicKey.serialize()[1:]))

        signedprekey = self._axolotlmanager.load_latest_signed_prekey(
            generate=True)
        self.addParam(
            "e_skey_id",
            self.b64encode(struct.pack('>I', signedprekey.getId())[1:]))
        self.addParam(
            "e_skey_val",
            self.b64encode(
                signedprekey.getKeyPair().publicKey.serialize()[1:]))
        self.addParam("e_skey_sig",
                      self.b64encode(signedprekey.getSignature()))

        self.addParam("fdid", config.fdid)
        self.addParam("expid", self.b64encode(config.expid))

        self.addParam("network_radio_type", "1")
        self.addParam("simnum", "1")
        self.addParam("hasinrc", "1")
        self.addParam("pid", int(random.uniform(100, 9999)))
        self.addParam("rc", 0)
        if self._config.id:
            self.addParam("id", self._config.id)