jstring Java_cn_knet_seal_financial_api_KnetFinancialHttpApi_pt( JNIEnv* env,jobject thiz, jstring u, jstring t, jstring p) { char* ustr = jstringTostring(env,u); char* tstr = jstringTostring(env,t); char* pstr = jstringTostring(env,p); char md5c[33]={0}; char c_char[20480]=""; strcat(c_char,ustr); strcat(c_char,pstr); strcat(c_char,tstr); getmd5(c_char,md5c); strToLower(md5c); jstring result = (*env)->NewStringUTF(env,md5c); return result; }
Window::Window(QWidget *parent) : QMainWindow(parent), ui(new Ui::Window) { clipboard = QApplication::clipboard(); ui->setupUi(this); abtdlg = new AboutDialog(this); connect(ui->bCopy, SIGNAL(clicked()), this, SLOT(copyText())); connect(ui->bPaste, SIGNAL(clicked()), this, SLOT(pasteText())); connect(ui->bEncode, SIGNAL(clicked()), this, SLOT(encodeText())); connect(ui->bDecode, SIGNAL(clicked()), this, SLOT(decodeText())); connect(ui->bmd5, SIGNAL(clicked()), this, SLOT(getmd5())); connect(ui->bAbout, SIGNAL(clicked()), abtdlg, SLOT(show())); connect(ui->bExit, SIGNAL(clicked()), qApp, SLOT(quit())); }
//校验请求是否正确 int CLogin4399::check_login(const char* plat_name, const char* pszReq, string& strAccountGot) { // if ( m_str_plat_name != (string)plat_name) // { // LogWarning("check_login", "plat :%s != %s", plat_name, m_str_plat_name.c_str()); // return ENUM_LOGIN_PLAT_NAME_ERROR; // } //port=123&suid=xxx×tamp=12345&sign=xxx&platid=111&plataccount=xxx&token=xxx //解析登录是否合法 map<string, string> dictParams; SplitStringToMap(pszReq, '&', '=', dictParams); //校验客户端发来的loginapp端口是否在合法 //uLoginappPort = (uint16_t)atoi(get_dict_field(dictParams, "port").c_str()); //if(uLoginappPort < LOGINAPP_MIN_PORT || uLoginappPort > LOGINAPP_MAX_PORT) //{ // LogError("login_porterr", "req=%s", pszReq); // return ENUM_LOGIN_INNER_ERR; //} //loginapp端口改为读配置 //uint16_t unPortFromClient = (uint16_t)atoi(get_dict_field(dictParams, "port").c_str()); //平台的时间戳 const string& strTime = get_dict_field(dictParams, "timestamp"); int nTimestamp = atoi(strTime.c_str()); int nTimeNow = time(NULL); //比服务器时间滞后超过20分钟,或者超前多于5分钟算时间无效 if(nTimeNow > nTimestamp + 1200 || nTimestamp > nTimeNow + 300) { LogError("login_timeout", "req=%s", pszReq); return ENUM_LOGIN_TIME_ILLEGAL; } const string& strSuid = get_dict_field(dictParams, "suid"); const string& strSign = get_dict_field(dictParams, "sign"); //检查md5是否匹配 //flag=md5("$suid&$timestamp&%key") { std::ostringstream oss; oss << strSuid << '&' << strTime << '&' << this->get_cfg_value("key", sg_szLoginKey); const string& strOss = oss.str(); string __md5 = getmd5(strOss); if(strcasecmp(__md5.c_str(), strSign.c_str()) != 0 ) { //md5签名不匹配,错误的请求 return ENUM_LOGIN_SIGN_ILLEGAL; } } //到平台验证tocken是否正确 const string& strTocken = get_dict_field(dictParams, "tocken"); const string& strAccount = get_dict_field(dictParams, "plataccount"); { string resp = ""; string strUrl = this->get_cfg_value("url", sg_szVerifyUrl).append(strTocken); int ret = GetUrl_new(strUrl.c_str(), resp); if (ret != CURLE_OK) { LogWarning("login_urlerr", "ret=%d;req=%s", ret, pszReq); return ENUM_LOGIN_SERVER_BUSY; } Trim(resp); JsonHelper jsonhp(resp); int rst = 0; if (!jsonhp.GetJsonItem("code", rst)) { //平台返回字符串解析失败 LogWarning("login_jsonfailed", "json=%s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } if (rst != 1) { //结果码为1表示验证成功,其他值都是失败 LogWarning("login_verifyfailed", "rst=%d;req=%s", rst, pszReq); return ENUM_LOGIN_SDK_VERIFY_FAILED; } } //需要返回的参数值 strAccountGot.assign(strSuid); LogInfo("login_req", "%s", pszReq); return ENUM_LOGIN_SUCCESS; }
//校验请求是否正确 int CLoginUC::check_login(const char* plat_name, const char* pszReq, string& strAccountGot) { if ( m_str_plat_name != (string)plat_name) { LogWarning("check_login", "plat :%s != %s", plat_name, m_str_plat_name.c_str()); return ENUM_LOGIN_PLAT_NAME_ERROR; } map<string, string> dictParams; SplitStringToMap(pszReq, '&', '=', dictParams); const string& strSuid = get_dict_field(dictParams, "suid"); //账号 //到平台验证tocken是否正确 const string& strTocken = get_dict_field(dictParams, "tocken"); const string& strAccount = get_dict_field(dictParams, "plataccount"); string cfg_url = this->get_cfg_value("url", ""); string cfg_cpId = this->get_cfg_value("cpId", ""); string cfg_gameId = this->get_cfg_value("gameId", ""); string cfg_apiKey = this->get_cfg_value("apiKey", ""); string cfg_severId = this->get_cfg_value("severId", ""); string cfg_channelId = this->get_cfg_value("channelId", ""); { string resp = ""; ostringstream url_params; ostringstream pre_md5; //MD5(cpId+sid=...+apiKey) pre_md5 <<cfg_cpId.c_str() << "sid=" << strTocken.c_str() << cfg_apiKey.c_str(); string req_sign = getmd5(pre_md5.str()); url_params << "{\r\n"; url_params <<"\"id\":"<<time(NULL)<<",\r\n"; url_params <<"\"service\":\"ucid.user.sidInfo\",\r\n"; url_params <<"\"data\":{\"sid\":\""<< strTocken.c_str() << "\"},\r\n"; url_params <<"\"game\":{\"cpId\":"<< cfg_cpId.c_str() << ",\"gameId\":"<< cfg_gameId.c_str() <<",\"channelId\":\""<<cfg_channelId.c_str()<<"\",\"serverId\":"<<cfg_severId.c_str()<<"},\r\n"; url_params <<"\"sign\":\""<<req_sign.c_str()<<"\"\r\n"; url_params <<"}"; string req_url = cfg_url; int ret = http_post(req_url.c_str(), url_params.str().c_str(), resp); //这里是post请求 if (ret != CURLE_OK) { LogWarning("check_login", "ret=%d;req=%s, params=%s", ret, req_url.c_str(),url_params.str().c_str() ); return ENUM_LOGIN_SERVER_BUSY; } LogDebug("check_login", "http_post ok ret = %s, params=%s", resp.c_str(),url_params.str().c_str()); Trim(resp); JsonHelper jsonhp(resp); int state = 0; if (!jsonhp.GetJsonItem2("state", "code", state)) { LogWarning("parse json", "state.code not found in %s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } if (state != 1 ) { LogWarning("parse json", "state.code(%d) != 1 ", state); return ENUM_LOGIN_SDK_VERIFY_FAILED; } int ucid = 0; if (!jsonhp.GetJsonItem2("data", "ucid", ucid)) { LogWarning("parse json error", "data.ucid not found in %s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } ostringstream oss_ucid; oss_ucid<<ucid; //需要返回的参数值 strAccountGot.assign(oss_ucid.str()); } //strAccountGot.assign(oss_ucid.str()); LogInfo("login_req", "%s", pszReq); return ENUM_LOGIN_SUCCESS; }
//校验请求是否正确 int CLoginDangle::check_login(const char* plat_name, const char* pszReq, string& strAccountGot) { if ( m_str_plat_name != (string)plat_name) { LogWarning("check_login", "plat :%s != %s", plat_name, m_str_plat_name.c_str()); return ENUM_LOGIN_PLAT_NAME_ERROR; } map<string, string> dictParams; SplitStringToMap(pszReq, '&', '=', dictParams); const string& strSuid = get_dict_field(dictParams, "suid"); //账号 //到平台验证tocken是否正确 const string& strTocken = get_dict_field(dictParams, "tocken"); const string& strAccount = get_dict_field(dictParams, "plataccount"); string cfg_url = this->get_cfg_value("url", ""); string app_key = this->get_cfg_value("key", ""); int app_id = this->get_cfg_value("app_id", 0); { string resp = ""; string req_url = cfg_url; stringstream ss_pre_md5; stringstream ss_url_params; //MD5(token|mid) ss_pre_md5 << strTocken.c_str() << "|" <<app_key.c_str(); string req_sign = getmd5(ss_pre_md5.str().c_str()); //params ss_url_params << "?app_id=" << app_id << "&mid=" <<strSuid.c_str()<< "&token=" <<strTocken.c_str()<<"&sig="<< req_sign.c_str(); req_url += ss_url_params.str().c_str(); LogDebug("check_login", "plat :%s post url:%s params:%s", m_str_plat_name.c_str(), req_url.c_str(), ss_url_params.str().c_str()); int ret = GetUrl_new(req_url.c_str(), resp); //这里是get请求 if (ret != CURLE_OK) { LogWarning("check_login", "ret=%d;req=%s", ret, req_url.c_str()); return ENUM_LOGIN_SERVER_BUSY; } LogDebug("check_login", "http_post ok ret = %s", resp.c_str()); Trim(resp); JsonHelper jsonhp(resp); int rst = 0; if (!jsonhp.GetJsonItem("error_code", rst)) { //平台返回字符串解析失败 LogWarning("login_jsonfailed", "json=%s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } if (rst != 0) { //结果码为0表示验证成功,其他值都是失败 LogWarning("login_verifyfailed", "rst=%d;req=%s", rst, pszReq); return ENUM_LOGIN_SDK_VERIFY_FAILED; } } //需要返回的参数值 strAccountGot.assign(strSuid); LogInfo("login_req", "%s", pszReq); return ENUM_LOGIN_SUCCESS; }
//校验请求是否正确 int CLogin91::check_login(const char* plat_name, const char* pszReq, string& strAccountGot) { if ( m_str_plat_name != (string)plat_name) { LogWarning("check_login", "plat :%s != %s", plat_name, m_str_plat_name.c_str()); return ENUM_LOGIN_PLAT_NAME_ERROR; } map<string, string> dictParams; SplitStringToMap(pszReq, '&', '=', dictParams); const string& strSuid = get_dict_field(dictParams, "suid"); //账号 //到平台验证tocken是否正确 const string& strTocken = get_dict_field(dictParams, "tocken"); const string& strAccount = get_dict_field(dictParams, "plataccount"); string key_91 = this->get_cfg_value("key", ""); string cfg_url = this->get_cfg_value("url", ""); int app_id_91 = this->get_cfg_value("app_id", 1078); { string resp = ""; string req_url = cfg_url; stringstream ss_pre_md5; stringstream ss_url_params; int nAct = 4; //MD5(Act=3&AppId=1078&SessionId=d891b6f03f361128b10c69d440c92c34&Uin=1326&Version=1.07a123456789b123456789c123456789d1) //ss_pre_md5 << "Act=4&AppId=" << app_id_91 << "&SessionId=" <<strTocken.c_str() << "&Uin=" <<strSuid.c_str()<<"&Version=1.07"<< key_91.c_str(); ss_pre_md5 << app_id_91 << nAct << strSuid.c_str() << strTocken.c_str() << key_91.c_str(); string req_sign = getmd5(ss_pre_md5.str().c_str()); //?Act=3&AppId=1078&SessionId=d891b6f03f361128b10c69d440c92c34&Uin=1326&Version=1.07&Sign=090868eeaaf9ba3d8fcfecdeb1e6bc2e ss_url_params << "AppId=" << app_id_91 << "&Act="<<nAct << "&Uin=" <<strSuid.c_str() <<"&Sign="<< req_sign.c_str() << "&SessionId=" <<strTocken.c_str() ; LogDebug("check_login", "plat :%s post url:%s params:%s", m_str_plat_name.c_str(), req_url.c_str(), ss_url_params.str().c_str()); int ret = http_post(req_url.c_str(), ss_url_params.str().c_str(), resp); //这里是post请求 if (ret != CURLE_OK) { LogWarning("check_login", "ret=%d;req=%s, params=%s", ret, req_url.c_str(), ss_url_params.str().c_str()); return ENUM_LOGIN_SERVER_BUSY; } LogDebug("check_login", "http_post ok ret = %s", resp.c_str()); Trim(resp); JsonHelper jsonhp(resp); string rst ; if (!jsonhp.GetJsonItem("ErrorCode", rst)) { //平台返回字符串解析失败 LogWarning("login_jsonfailed", "json=%s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } if (rst != "1") { //结果码为"1"表示验证成功,其他值都是失败 LogWarning("login_verifyfailed", "rst=%s;req=%s", rst.c_str(), pszReq); return ENUM_LOGIN_SDK_VERIFY_FAILED; } } //需要返回的参数值 strAccountGot.assign(strSuid); LogInfo("login_req", "%s", pszReq); return ENUM_LOGIN_SUCCESS; }
int getSaveSize(int romtype,void*data,int size,int&even) { BYTE*romdata=(BYTE*)data; even=both_bytes; if(romtype==md_rom||romtype==s32x_rom) { even=odd_bytes;//malformed headers? if(size>0x1bf) { if(size>(2*MB+0x200)) { if(compareHeaderString(data,size,0x180,"GM MK-1563 -00")) { /* s&k "GM MK-1563 -00" s1 "GM 00001009-00" "GM 00004049-01" s2 "GM 00001051-00" "GM 00001051-01" "GM 00004049-01" s3 "GM MK-1079 -00" */ int ss; ss=getSaveSize(romtype,romdata,2*MB,even); if(ss>0) { return ss; } ss=getSaveSize(romtype,romdata+2*MB,size-2*MB,even); if(ss>0) { return ss; } if(compareHeaderString(data,size,2*MB+0x180,"GM MK-1079 -00")) { even=odd_bytes; return 1*KB; } return 0; } } for(int i=0;i<save_table_size;i++) { if(compareHeaderString(data,size,0x180,save_table[i].game_id)) { WORD chk; load_word_be(romdata+0x18e,chk); if((save_table[i].chk==0)||(save_table[i].chk==chk)) { if(compareHeaderString(data,size,0x180,"GM 00000000-00")&&(memcmp(romdata,"DNLD",4)!=0)) { return 0; } if(save_table[i].eeprom==1) { return 1; } else { even=odd_bytes; return save_table[i].ssize; } } } } if((romdata[0x1b0]==0x52)&&(romdata[0x1b1]==0x41)) { DWORD begin,end; load_dword_be(romdata+0x1b4,begin); load_dword_be(romdata+0x1b8,end); if(end<begin) { return 64*KB; } else { //even=romdata[0x1b2]==0x20?odd_bytes:(romdata[0x1b2]>>3)&3; if((end-begin)<2) { return 1; } int ssize=(end-begin+2)&(~1); ssize=Min(ssize,64*KB); return ssize; } } } } if(romtype==md_rom) { if(size==4*MB) { const md5struct x_md5[]= { {0x52,0x8e,0x17,0x12,0x64,0xeb,0xfd,0x90,0xe5,0x3f,0xd9,0x66,0x7d,0x1c,0x61,0xd1},//Xin Qi Gai Wang Zi (China) (Unl) {0x80,0x94,0xc9,0xa1,0xc0,0xcf,0x82,0xb2,0x66,0x21,0xa3,0x82,0xd3,0xee,0x47,0x24},//Xin Qi Gai Wang Zi (China) (Alt) (Unl) }; md5struct md5; getmd5(data,size,md5); if(memcmp(md5,x_md5[0],16)==0||memcmp(md5,x_md5[1],16)==0) { even=odd_bytes; return 64*KB; } } } if(romtype==scd_bram||romtype==scd_bios_bram) { return 64*KB; } if(romtype==sms_rom) { static int sms_sorted=0; static DWORD sms_save_table_index[sms_save_table_size]; if(sms_sorted==0) { sms_sorted=1; for(int i=0;i<sms_save_table_size;i++) { sms_save_table_index[i]=i; } quickSort(sms_save_table_index,0,sms_save_table_size-1,ap_sortbysize,sms_save_table); } md5struct md5; int md5size=0; for(int i=0;i<sms_save_table_size;i++) { if(size>=sorted(sms_save_table,i).size) { if(md5size!=sorted(sms_save_table,i).size) { if(md5size==0||md5size>sorted(sms_save_table,i).size) { getmd5(data,sorted(sms_save_table,i).size,md5); } else { updatemd5(((BYTE*)data)+md5size,sorted(sms_save_table,i).size-md5size,md5); } md5size=sorted(sms_save_table,i).size; } if(memcmp(md5,sorted(sms_save_table,i).md5,16)==0) { return sorted(sms_save_table,i).ssize; } } } } return 0; }
int autoPatchRom(void*data,int size) { static int ap_sorted=0; static DWORD auto_patch_table_index[auto_patch_table_size]; if(ap_sorted==0) { ap_sorted=1; for(int i=0;i<auto_patch_table_size;i++) { auto_patch_table_index[i]=i; } quickSort(auto_patch_table_index,0,auto_patch_table_size-1,ap_sortbysize,auto_patch_table); } md5struct md5; int md5size=0; for(int i=0;i<auto_patch_table_size;i++) { if(size>=sorted(auto_patch_table,i).size) { if(md5size!=sorted(auto_patch_table,i).size) { if(md5size==0||md5size>sorted(auto_patch_table,i).size) { getmd5(data,sorted(auto_patch_table,i).size,md5); } else { updatemd5(((BYTE*)data)+md5size,sorted(auto_patch_table,i).size-md5size,md5); } md5size=sorted(auto_patch_table,i).size; } if(memcmp(md5,sorted(auto_patch_table,i).md5,16)==0) { if(getoption(enableKnownPatches)) { if(sorted(auto_patch_table,i).patch[0].offset!=-1) { for(int j=0;sorted(auto_patch_table,i).patch[j].offset!=-1;j++) { //printf("\n\toffset: %.4x\tvalue: %.4x\n",sorted(auto_patch_table,i).patch[j].offset,sorted(auto_patch_table,i).patch[j].value); store_word_be(sorted(auto_patch_table,i).patch[j].value,((BYTE*)data)+sorted(auto_patch_table,i).patch[j].offset); } printf("\tauto patched: %s\n",sorted(auto_patch_table,i).name); } if(getoption(savePatchedFiles)) { char rname[1024]; sprintf(rname,"%s_auto_patched.bin",sorted(auto_patch_table,i).name); SaveFile(rname,(char*)data,size); } } if(sorted(auto_patch_table,i).romtype==scd_bios) { if((size>(sorted(auto_patch_table,i).size+16))&&(memcmp(((BYTE*)data)+sorted(auto_patch_table,i).size,"\xff\x04\xff\x04\xff\x04\xff\x04\xff\x04\xff\x04\xff\x04\xff\x04",16)==0)) { return scd_bios_bram; } } return sorted(auto_patch_table,i).romtype; } } } return unknown_rom; }
//校验请求是否正确 int CLoginDuokoo::check_login(const char* plat_name, const char* pszReq, string& strAccountGot) { if ( m_str_plat_name != (string)plat_name) { LogWarning("check_login", "plat :%s != %s", plat_name, m_str_plat_name.c_str()); return ENUM_LOGIN_PLAT_NAME_ERROR; } map<string, string> dictParams; SplitStringToMap(pszReq, '&', '=', dictParams); const string& strSuid = get_dict_field(dictParams, "suid"); //账号 //到平台验证tocken是否正确 const string& strTocken = get_dict_field(dictParams, "tocken"); const string& strAccount = get_dict_field(dictParams, "plataccount"); string cfg_url = this->get_cfg_value("url", ""); int cfg_appid = this->get_cfg_value("appid", 0); string cfg_appkey = this->get_cfg_value("appkey", ""); string cfg_appsecret = this->get_cfg_value("appsecret", ""); { string resp = ""; string req_url = cfg_url; stringstream ss_pre_md5; stringstream ss_url_params; //strtolower(md5($appid$appkey$uid$sessionid$AppSecret)); ss_pre_md5 << cfg_appid << cfg_appkey.c_str() << strSuid.c_str() << cfg_appsecret.c_str(); string req_sign = getmd5(ss_pre_md5.str().c_str()); //?appid=3&AppId=1078&SessionId=d891b6f03f361128b10c69d440c92c34&Uin=1326&Version=1.07&Sign=090868eeaaf9ba3d8fcfecdeb1e6bc2e ss_url_params << "?appid=" << cfg_appid << "&appkey=" <<cfg_appkey.c_str() << "&uid=" <<strSuid.c_str()<<"&sessionid="<< strTocken.c_str() <<"&clientsecret=" <<req_sign.c_str(); req_url += ss_url_params.str(); LogDebug("check_login", "plat :%s post url:%s params:%s", m_str_plat_name.c_str(), req_url.c_str(), ss_url_params.str().c_str()); int ret = GetUrl_new(req_url.c_str(), resp); //这里是get请求 也可以post if (ret != CURLE_OK) { LogWarning("check_login", "ret=%d;req=%s, params=%s", ret, req_url.c_str(), ss_url_params.str().c_str()); return ENUM_LOGIN_SERVER_BUSY; } LogDebug("check_login", "get_url ok ret = %s", resp.c_str()); Trim(resp); int rst = 0; JsonHelper jsonhp(resp); if (!jsonhp.GetJsonItem("error_code", rst)) { LogWarning("login_jsonfailed", "json=%s", resp.c_str()); return ENUM_LOGIN_SDK_VERIFY_FAILED; } if (rst != 0) { //结果码为0表示验证成功,其他值都是失败 LogWarning("login_verifyfailed", "rst=%d;req=%s", rst, pszReq); return ENUM_LOGIN_SDK_VERIFY_FAILED; } } //需要返回的参数值 strAccountGot.assign(strSuid); LogInfo("login_req", "%s", pszReq); return ENUM_LOGIN_SUCCESS; }