某tv直播_sign算法

1、request参数排序

2、连接特殊字符串

3、md5


关键字:tv、_sign、HAL$#%^RTYDFGdktsf_)(*^%$


有点意思的是,登录之后返回的cookie保活,然后共享cookie,切ip做心跳访问。人气就起来了,统计ip点不太好。

string makeRequest(string strRoomNumber, string strToken, string strIdent, string strCookie)
{
    VMPBegin("fasd");
    string strPartOne = "&_appSource=417&_appVersion=2.1.2.5178&_appkey=CSAndroid&_fromPos=5&_fromView=1&_identifier=%s";
    string strPartTwo = "&_timestamp=%I64d&roomId=%s&token=%s";
    CHAR szPartOneFormat[1000] = { 0 };
    wsprintf(szPartOneFormat,
        "&_appSource=417&_appVersion=2.1.2.5178&_appkey=CSAndroid&_fromPos=5&_fromView=1&_identifier=%s",
        strIdent.c_str());
 
    time64 timestamp = getCurrentTimestamp();
    time64 timestamp_gelin = transformToTimestamp(1970, 1, 1, 8, 0, 0, 0);
    timestamp -= timestamp_gelin;
    CHAR szPartTwoFormat[1000] = { 0 };
    wsprintf(szPartTwoFormat, 
        "&_timestamp=%I64d&roomId=%s&token=%s",
        timestamp, strRoomNumber.c_str(), strToken.c_str());
    //GET http ://api.chushou.tv/api/room/heartbeat.htm?&_appSource=417&_appVersion=2.1.2.5178&_appkey=CSAndroid&_fromPos=5&_fromView=1&_identifier=4579914607&_sign=29bb59f9c0850af0fcde14b7568efb3b&_timestamp=1479016231601&roomId=2832077&token=c75baf46b7b12dd9gfd89a27 HTTP/1.1
    //User - Agent : okhttp / 2.7.2
    //Cookie : aliyungf_tc = AQAAAOY2Ohe / SwMAOWhncmGlw5oMDbzm; _i7 = 39ac9a7a7f614eb4bf3d512b4acb3b39
    //Accept: */*
    //Host: api.chushou.tv
    //Proxy-Connection: Keep-Alive
    //string strHash = "HAL$#%^RTYDFGdktsf_)(*^%$";
    //strHash += szPartOneFormat;
    //strHash += szPartTwoFormat;
    string strSign = getHashFromNet(string(szPartOneFormat) + szPartTwoFormat);
    //unsigned char md5[16] = { 0 };
    //string strSign;
    //GetMd5((unsigned char *)strHash.c_str(), strHash.length(), strSign, md5);
    string strHttpRequest;
    strHttpRequest += "GET http://api.chushou.tv/api/room/heartbeat.htm?";
    strHttpRequest += szPartOneFormat;
    strHttpRequest += "&_sign=";
    strHttpRequest += strSign;
    strHttpRequest += szPartTwoFormat;
    strHttpRequest += " HTTP/1.1\r\n";
    strHttpRequest += "User-Agent: okhttp/2.7.2\r\n";
    strHttpRequest += "Cookie:"; strHttpRequest += strCookie; strHttpRequest += "\r\n";
    strHttpRequest += "Host: api.chushou.tv\r\n";
    strHttpRequest += "Proxy-Connection: Keep-Alive\r\n";
    strHttpRequest += "\r\n";
    VMPEnd();
    return strHttpRequest;
}

原文链接



转python写法:#!/bin/sh time_stamp=`date +%s` function CheckStop() { if [ $? -ne 0 ]; then echo "execute fail, error on line_no:"$1" exit!!!" exit fi } function GenEcdsaKey() { ec_param_file_path="/tmp/ec_param.pem."$time_stamp openssl ecparam -out $ec_param_file_path -name prime256v1 -genkey CheckStop $LINENO openssl genpkey -paramfile $ec_param_file_path -out $1 CheckStop $LINENO openssl pkey -in $1 -inform PEM -out $2 -outform PEM -pubout CheckStop $LINENO rm $ec_param_file_path echo "gen_ecdsa_key succ prikey_path:"$1" pubkey_path:"$2 } function GenEcdsaSign() { ec_sign_info_file="/tmp/ec_sign_info_file."$time_stamp ec_sign_info_sha256="/tmp/ec_sign_info_sha256."$time_stamp ec_binary_sign_file="/tmp/ec_binary_sign_file."$time_stamp echo -n "$1"_"$2" > $ec_sign_info_file openssl dgst -sha256 -binary -out $ec_sign_info_sha256 $ec_sign_info_file CheckStop $LINENO openssl pkeyutl -sign -in $ec_sign_info_sha256 -out $ec_binary_sign_file -inkey $3 -keyform PEM CheckStop $LINENO openssl base64 -e -in $ec_binary_sign_file -out $4 CheckStop $LINENO rm $ec_sign_info_file $ec_sign_info_sha256 $ec_binary_sign_file echo "gen_ecdsa_sign succ sign_file_path:"$4 } function VerifyEcdsaSign() { ec_sign_info_file="/tmp/ec_sign_info_file."$time_stamp ec_sign_info_sha256="/tmp/ec_sign_info_sha256."$time_stamp ec_binary_sign_file="/tmp/ec_binary_sign_file."$time_stamp echo -n "$1"_"$2" > $ec_sign_info_file openssl dgst -sha256 -binary -out $ec_sign_info_sha256 $ec_sign_info_file CheckStop $LINENO openssl base64 -d -in $4 -out $ec_binary_sign_file CheckStop $LINENO openssl pkeyutl -verify -in $ec_sign_info_sha256 -sigfile $ec_binary_sign_file -pubin -inkey $3 -keyform PEM rm $ec_sign_info_file $ec_sign_info_sha256 $ec_binary_sign_file } function Usage() { echo "Usage:" echo "mmiot_ecdsa_sign.sh gen_ecdsa_key <private_key_file_path> <public_key_file_path>" echo "mmiot_ecdsa_sign.sh gen_ecdsa_sign <product_id> <sn> <private_
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值