Exemplo n.º 1
0
    def test_appupdateA(self):
        rsapubRts = Login.get_rsapub(self.serveradd, self.rsaurl)
        testheader = Login.get_token(self.serveradd, self.loginurl, rsapubRts,
                                     self.secret, self.passwd, self.account)
        self.params['timestamp'] = testheader['timestamp']
        params = {}
        params['device_id'] = device_id
        params['package_name'] = package_name
        params['version_code'] = version_code
        params['version_name'] = version_name
        params['timestamp'] = testheader['timestamp']
        # print(sorted(params.items(), key=lambda d: d[0], reverse=False))
        tmpsignOri = sorted(params.items(), key=lambda d: d[0], reverse=False)
        mystr = ""
        for item in tmpsignOri:
            mystr = mystr + "&" + str(item[0]) + "=" + str(item[1])
        mystrFal = mystr + "#" + self.secret
        # print(mystrFal[1:-1])
        tmpsign = md5(mystrFal[1:])

        params = {
            'device_id': device_id,
            'package_name': package_name,
            'version_code': version_code,
            'version_name': version_name,
            'timestamp': params['timestamp'],
            'sign': tmpsign
        }
        # print(params)
        header = {}
        testRts = requests.post(self.serveradd + self.testurl,
                                headers=header,
                                json=params)
        print(testRts.content)
        pass
Exemplo n.º 2
0
def get_token(serverAdd,loginUrl,rsaPubInfo,secret,passwd,account):
    print(rsaPubInfo)
    captchacode = 0
    empoent = rsaPubInfo["empoent"]
    module = rsaPubInfo["module"]
    rsa_id = rsaPubInfo["rsa_id"]
    rsa_id1 = "slkv2-rsaid-h4GaLZTNKMFQV4T6"
    passwd = passwd
    EnpasswdAES = EncryptByAES(empoent,module,passwd)
    enpasswd = EnpasswdAES.encrypt_with_pubkey(passwd)
    # print(enpasswd)
    # enpasswd1="6712eb247223e630ce31d6267ece93824c28c5db8e42aa08569e3e35c966366b4967edbfcddc727a16f1ccf9f5284816f40f233dfc929d2618ca3ca4849a2470f325291043b3b2db63fe4059276029b6d90e95545254b5a03dd2103ec420299772689287edc323a7c7769a9b4409af84e7a30086a789e2f2cde5675bd7afe422"
    loginHeaders = {"LANGUAGE": "zh",
                    "CHANNEL": "1"}
    if captchacode:
        loginParams = {
            'account': account,
            'password': enpasswd,
            'rsa_id': rsa_id,
            'csessionid': "ewrtwertwert",
            'scene': "login",
            'sig': "2ad0557fc8ff5bf1c4d5f0f7c9395492"
        }
    else:
        loginParams = {
            'account': account,
            'password': enpasswd,
            'rsa_id': rsa_id
        }
    print(loginParams)
    testloginRts = requests.post(serverAdd+loginUrl,headers=loginHeaders,json=loginParams,verify=False)
    # testloginRts1 = requests.post(serverAdd + loginUrl, headers=loginHeaders, json=loginParams1, verify=False)
    print(testloginRts.content.decode("utf-8"))
    print("&&&&&&&&&&&&&&&&")
    if testloginRts.status_code == 200:
        print(testloginRts.content.decode("utf-8"))
        logginRts = json.loads(testloginRts.content)
        # return logginRts['data']
    else:
        print("get Token Failed!")
    # print(testloginRts1.content.decode("utf-8"))
    if testloginRts.status_code == "200":
        login_token = logginRts['data']['token']
        timestamp = int(time.time()*1000)
        print(timestamp)
        sign = md5("AUTH-TIMESTAMP=" + str(timestamp) + "&AUTH-TOKEN=" + login_token+ "#" + secret)
        headers = {"LANGUAGE": "zh", "AUTH-TIMESTAMP": str(timestamp), "AUTH-TOKEN": login_token,
                        "AUTH-SIGN": sign, 'Referer': serverAdd + '/sign/signRecord', 'TIME-ZONE': 'GMT+08:00'}
        tmpheader = {"login_token":login_token,
                     "request_headers":headers,
                     "timestamp":str(timestamp)
        }
        return tmpheader
    else:
        print("get token failed!")
        print(testloginRts.content.decode("utf-8"))
def face_login(loginParam):
    print(loginParam)
    timestamp = int(time.time() * 1000)
    print("face_login")
    faceloginUrl = "/sl/v2/staff/face/login"
    rsapubRts = get_rsapub(loginParam['serverAdd'], loginParam['rsapubUrl'])
    # testheader = get_token(serverAdd,faceloginUrl,rsapubRts,secret,passwd,account)
    # params = {'mobile':'15507558325',
    #           'area_code':'86',
    #           'cap_photo':self.loginavater,
    #           'company_id':1
    # }
    params = {
        'mobile': loginParam['mobile'],
        'area_code': loginParam['areacode'],
        'cap_photo': loginParam['cap_photo'],
        'company_id': loginParam['company_id']
    }
    # print(params)
    header = {}
    testLoginRts = requests.post(loginParam['serverAdd'] + faceloginUrl,
                                 headers=header,
                                 json=params,
                                 verify=False)
    # print(testLoginRts.content.decode('utf-8'))
    testLoginJson = json.loads(testLoginRts.content)
    sign = md5("AUTH-TIMESTAMP=" + str(timestamp) + "&AUTH-TOKEN=" +
               testLoginJson['data']['token'] + "#" + secret)
    headers = {
        "LANGUAGE": "en",
        "AUTH-TIMESTAMP": str(timestamp),
        "AUTH-TOKEN": testLoginJson['data']['token'],
        "AUTH-SIGN": sign,
        "Referer": "http://www.sensetime.com"
    }
    tmpheader = {
        "login_token": testLoginJson['data']['token'],
        "request_headers": headers,
        "timestamp": str(timestamp)
    }
    # print(tmpheader)
    return tmpheader