python类PublicKey()的实例源码

loginWeibo.py 文件源码 项目:GetCheckInDataFromWeibo 作者: huangxy31 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def getSp(self, servertime, nonce, pubkey):
        rsaPublickey = int(pubkey, 16)
        key = rsa.PublicKey(rsaPublickey, 65537)
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(self.password)
        passwd = rsa.encrypt(message, key)
        sp = binascii.b2a_hex(passwd)
        return sp
cookies.py 文件源码 项目:Crawlers 作者: mi-minus 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def encrypt_passwd(passwd, pubkey, servertime, nonce):
    key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
    passwd = rsa.encrypt(message.encode('utf-8'), key)
    return binascii.b2a_hex(passwd)
weibo_login.py 文件源码 项目:Crawlers 作者: mi-minus 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def encrypt_passwd(passwd, pubkey, servertime, nonce):
    key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
    passwd = rsa.encrypt(message.encode('utf-8'), key)
    return binascii.b2a_hex(passwd)
weibo_sp.py 文件源码 项目:Crawlers 作者: mi-minus 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_sp_rsa(passwd, servertime, nonce):
    # ?preloginõ,????,?
    weibo_rsa_n = 'EB2A38568661887FA180BDDB5CABD5F21C7BFD59C090CB2D245A87AC253062882729293E5506350508E7F9AA3BB77F4333231490F915F6D63C55FE2F08A49B353F444AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D78E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4FE9E88A1BBE495927AC4A799B3181D6442443'


    weibo_rsa_e = 65537  # 10001?10
    message = str(servertime) + '\t' + str(nonce) + '\n' + passwd
    key = rsa.PublicKey(int(weibo_rsa_n, 16), weibo_rsa_e)
    encropy_pwd = rsa.encrypt(message, key)
    return binascii.b2a_hex(encropy_pwd)
SinaVendor.py 文件源码 项目:sinalevel2 作者: evanzd 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_sp(self, passwd, pubkey, servertime, nonce):
        key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
        message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
        passwd = rsa.encrypt(message.encode('utf-8'), key)
        return binascii.b2a_hex(passwd).decode('ascii')
LineApi.py 文件源码 项目:LineVodka 作者: merkremont 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _login(self, email, passwordd, certificate=None, loginName=url.systemname):
        self._thriftTransport.targetPath(url.LINE_AUTH_QUERY_PATH)
        session_json = url.get_json(url.parseUrl(url.LINE_SESSION_LINE_QUERY_PATH))
        self.certificate = certificate
        session_key = session_json['session_key']
        message = (chr(len(session_key)) + session_key +
                   chr(len(email)) + email +
                   chr(len(passwordd)) + passwordd).encode('utf-8')
        keyname, n, e = session_json['rsa_key'].split(",")
        pub_key = rsa.PublicKey(int(n, 16), int(e, 16))
        crypto = rsa.encrypt(message, pub_key).encode('hex')
        self._thriftTransport.targetPath(url.LINE_AUTH_QUERY_PATH)
        result = self._client.loginWithIdentityCredentialForCertificate(
            IdentityProvider.LINE, keyname, crypto, True, '127.0.0.1', loginName, certificate)

        if result.type == 3:
            url._pincode = result.pinCode
            self.callback.Pinverified(url._pincode)
            getAccessKey = url.get_json(
                url.parseUrl(url.LINE_CERTIFICATE_PATH), allowHeader=True)
            self.verifier = getAccessKey['result']['verifier']
            result = self._client.loginWithVerifierForCerificate(self.verifier)
            self.certificate = result.certificate
            self.authToken = result.authToken
            self.urls.set_Headers('X-Line-Access', result.authToken)

            self._thriftTransport.setAccesskey(self.authToken)
            self.onLogin()
            self._thriftTransport.targetPath(url.LINE_API_QUERY_PATH_FIR)

        elif result.type == 2:
            pass

        elif result.type == 1:
            self.authToken = result.authToken
            self.urls.set_Headers('X-Line-Access', result.authToken)
            self._thriftTransport.setAccesskey(self.authToken)
            self.onLogin()
            self._thriftTransport.targetPath(url.LINE_API_QUERY_PATH_FIR)
weibo.com.py 文件源码 项目:fuck-login 作者: xchaoinfo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_password(password, servertime, nonce, pubkey):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey, 65537)  # ????
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)  # ????js???????
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)  # ??
    passwd = binascii.b2a_hex(passwd)  # ????????16???
    return passwd
tuchong.py 文件源码 项目:fuck-login 作者: xchaoinfo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_crypt_password(message):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey, 65537)
    passwd = rsa.encrypt(message, key)
    passwd = binascii.b2a_hex(passwd)
    return passwd
weiboscript.py 文件源码 项目:reptile 作者: shawncan 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getParameter(self):
        """
        ????????????????
        su??????sp?????
        servertime?nonce?pubket???sp????
        rsakv???ticket??
        """
        '''base64?????'''
        bytesString = self.username.encode(encoding="utf-8")
        self.su = base64.b64encode(bytesString).decode('utf-8')

        '''??servertime?nonce?pubket?rsakv??'''
        params = {
            'su': self.su,
            'entry': 'openapi',
            'callback': 'sinaSSOController.preloginCallBack',
            'rsakt': 'mod',
            'checkpin': '1',
            'client': 'ssologin.js(v1.4.18)',
            '_': '1499082911503'
        }

        parameter_resp = requests.get(self.parameter_url, params=params)
        parameter = parameter_resp.text.split(',')
        self.servertime = parameter[1].split(':')[1]
        self.pcid = parameter[2].split(':')[1][1:-1]
        self.nonce = parameter[3].split(':')[1][1:-1]
        self.pubket = parameter[4].split(':')[1][1:-1]
        self.rsakv = parameter[5].split(':')[1][1:-1]

        '''????rsa??'''
        rsa_e = '65537'
        key = rsa.PublicKey(int(self.pubket, 16), int(rsa_e))
        pw_string = str(self.servertime) + '\t' + str(self.nonce) + '\n' + str(self.password)
        ps = pw_string.encode(encoding="utf-8")
        pw_encypted = rsa.encrypt(ps, key)
        passwd = binascii.b2a_hex(pw_encypted)
        self.sp = passwd.decode()
ClientVideo.py 文件源码 项目:ScrapyPythonAnalysis 作者: IMYin 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_encrypted_pw(self,data):
        """
        ??????
        """

        rsa_e = 65537 #0x10001
        pw_string = str(data['servertime']) + '\t' + str(data['nonce']) + '\n' + str(self.password)
        key = rsa.PublicKey(int(data['pubkey'],16),rsa_e)
        pw_encypted = rsa.encrypt(pw_string.encode('utf-8'), key)
        self.password = ''   #??password
        passwd = binascii.b2a_hex(pw_encypted)
        self.log.info("Password compilation completed...")
        # print(passwd)
        return passwd
login.py 文件源码 项目:weibospider 作者: SpiderClub 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_password(password, servertime, nonce, pubkey):
    rsa_publickey = int(pubkey, 16)
    key = rsa.PublicKey(rsa_publickey, 65537)
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)
    passwd = binascii.b2a_hex(passwd)
    return passwd


# post data and get the next url
Talk.py 文件源码 项目:LineChivas 作者: merkremont 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __crypt(self, mail, passwd, RSA):
    message = (chr(len(RSA.sessionKey)) + RSA.sessionKey +
                   chr(len(mail)) + mail +
                   chr(len(passwd)) + passwd).encode('utf-8')

    pub_key = rsa.PublicKey(int(RSA.nvalue, 16), int(RSA.evalue, 16))
    crypto = rsa.encrypt(message, pub_key).encode('hex')

    return crypto
new_login.py 文件源码 项目:sinaweibo_login-and-auto-Micro-blog 作者: xxNB 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_password(password, servertime, nonce, pubkey):
    rsaPublickey = int(pubkey, 16)
    key = rsa.PublicKey(rsaPublickey, 65537)  # ????
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(password)  # ????js???????
    message = message.encode("utf-8")
    passwd = rsa.encrypt(message, key)  # ??
    passwd = binascii.b2a_hex(passwd)  # ????????16???
    return passwd
weibo_login.py 文件源码 项目:sinaweibo_login-and-auto-Micro-blog 作者: xxNB 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def encrypt_passwd(passwd, pubkey, servertime, nonce):
    key = rsa.PublicKey(int(pubkey, 16), int('10001', 16))
    message = str(servertime) + '\t' + str(nonce) + '\n' + str(passwd)
    passwd = rsa.encrypt(message.encode('utf-8'), key)
    return binascii.b2a_hex(passwd)
sina.py 文件源码 项目:GetCheckInDataFromWeibo 作者: huangxy31 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def userlogin(self,username,password):
        session = requests.Session()
        url_prelogin = 'http://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su=&rsakt=mod&client=ssologin.js(v1.4.5)&_=1364875106625'
        url_login = 'http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.5)'
        #get servertime,nonce, pubkey,rsakv
        resp = session.get(url_prelogin)
        json_data  = re.search('\((.*)\)', resp.content).group(1)
        data       = json.loads(json_data)
        servertime = data['servertime']
        nonce      = data['nonce']
        pubkey     = data['pubkey']
        rsakv      = data['rsakv']

        # calculate su
        su  = base64.b64encode(urllib.quote(username))

        #calculate sp
        rsaPublickey= int(pubkey,16)
        key = rsa.PublicKey(rsaPublickey,65537)
        message = str(servertime) +'\t' + str(nonce) + '\n' + str(password)
        sp = binascii.b2a_hex(rsa.encrypt(message,key))
        postdata = {
            'entry': 'weibo',
            'gateway': '1',
            'from': '',
            'savestate': '7',
            'userticket': '1',
            'ssosimplelogin': '1',
            'vsnf': '1',
            'vsnval': '',
            'su': su,
            'service': 'miniblog',
            'servertime': servertime,
            'nonce': nonce,
            'pwencode': 'rsa2',
            'sp': sp,
            'encoding': 'UTF-8',
            'url': 'http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack',
            'returntype': 'META',
            'rsakv' : rsakv,
        }
        resp = session.post(url_login,data = postdata)
        # print resp.headers
        login_url = re.findall('replace\(\'(.*)\'\)',resp.content)
        #
        respo = session.get(login_url[0])
        self.session = session


问题


面经


文章

微信
公众号

扫码关注公众号