Exemplo n.º 1
0
DWORD IRCMsgThread::Run() {
	onSysMsg(L"IRCMsgThread Start");
	iStatus=IRC_NORMAL;
	IRCMsgQueue.clear();
	unsigned int bufferlen;
	std::string recvstring,msg,umsg; //TwitchIRC use MultiByte
	while(!bKillThread ) { 	
		//Receive First
		bufferlen=0;		
		memset(buffer, 0, DEFAULT_BUFLEN);
		if(TheSocketPtr->recv_data((char*)buffer, bufferlen)) { //Disconnected
			iStatus=IRC_DISCONNECTED;
			break;
		}
		recvstring=std::string(buffer,bufferlen);
		//onDebugMsg(L"%ls",from_utf8(recvstring).c_str());
		if(recvstring.compare(":tmi.twitch.tv NOTICE * :Login unsuccessful\r\n")==0 || //Twitch
		   recvstring.compare(":tmi.twitch.tv NOTICE * :Error encountered while attempting login\r\n")==0 ){ //Justin
			Sleep(100); //Wait for logging
			onSysMsg(L"Login unsuccessful");
			iStatus=IRC_WRONGLOGIN;
			break;
		}//else if(recvstring.compare(":[email protected] PRIVMSG #append :break\r\n")==0){TheSocketPtr->CloseSocket();}
		//Basic parsing: make it into a string, check for PING, if not-send for further parsing.
		std::stringstream recvstr(recvstring);
		while( recvstr.tellg() < bufferlen ) {
			std::getline(recvstr,msg,'\n');
			//Old Style
			//:[email protected] PRIVMSG #ptken :what song is this ?
			//PING LAG1967655232
			//int colon_pos = (int)msg.find(":");
			//if (msg[0] != ':' && colon_pos > 0) msg=msg.substr(colon_pos); //if an irc message begins with " ", then trim the leading spaces   
			//
			//New Style
			// @color=#FF4500;display-name=Gm470520;emotes=;mod=0;room-id=47281189;subscriber=1;turbo=0;user-id=24255667;user-type= :[email protected] PRIVMSG #tetristhegrandmaster3 :這片到底在沖三小w
			int at_pos = (int)msg.find("@");
			if (msg[0] != '@' && at_pos > 0) msg=msg.substr(at_pos); //if an irc message begins with " ", then trim the leading spaces   
			if (msg[msg.length()-1]=='\r') msg=msg.substr(0,msg.length()-1); //trim the CR: getline only trim the LF		                   
			log(from_utf8(msg), LogType(RECEIVE)); //Although log file is in UTF8....using vswprintf
			//Ping Check
			umsg=msg.substr(0,5);
			ToUpperString(umsg);
            if (!umsg.compare("PING ")) sendRaw( L"PONG " + from_utf8(msg.substr(5)) ); // respond to PINGs //Reply Immediately 
			//Then parse the message
            else parseMessage(from_utf8(msg)); 
		}
		Sleep(100);
	}
	//Determine the reason to break the loop.
	if(!bKillThread) {
		if(iStatus==IRC_DISCONNECTED) onSysMsg(L"IRCMsgThread: Disconnect Unexpectedly");
		if(iStatus==IRC_WRONGLOGIN) onSysMsg(L"IRCMsgThread: Wrong Login Information");
	}
	else iStatus=IRC_CLOSED;
	//onDebugMsg(L"[Last Buffer]%ls",from_utf8(recvstring).c_str());
	onSysMsg(L"IRCMsgThread Close");
	thread=0;
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	char	EncodingString[2048];
	int	Index = 0;
	int	ErrorCode = 0;
	DEVICE_INFO_T	DeviceInfo;
	Q_ENTRY	*req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	SvcLog = NULL;
	SvcLog = openLog("DEVICEINFO", LOG_FILE, LOG_MODE);

	memset(&DeviceInfo, 0x00, sizeof(DEVICE_INFO_T));
	memset(EncodingString, 0x00, 2048);

	if((ErrorCode = GetParams(req, EncodingString)) == SDRM_NO_ERROR)	{
		if(strncmp(EncodingString, "IA", 2) == 0)  {
			Index = 2;
		}
		else if(strncmp(EncodingString, "EA", 2) == 0)  {
			Index = 2;
		}

		ErrorCode = DecodingDeviceString4MGR(EncodingString+Index, &DeviceInfo);
		ToUpperString(DeviceInfo.UUID, strlen(DeviceInfo.UUID));
		ToUpperString(DeviceInfo.SecondaryUUID, strlen(DeviceInfo.SecondaryUUID));

		printLog(HEAD, "ClientIP(%s)Input(%s)\t\n<=>UUID(%s)SecondaryUUID(%s)UUIDTypes(%s)DeviceName(%s)OSVersion(%s)AppVersion(%s)RegVersion(%s)BuildNum(%s)ErrorCode(%d)\n",
			getenv("REMOTE_ADDR"), EncodingString, DeviceInfo.UUID, DeviceInfo.SecondaryUUID, DeviceInfo.UUIDTypes, 
			DeviceInfo.DeviceName, DeviceInfo.OSVersion, DeviceInfo.AppVersion, DeviceInfo.RegisterVersion, DeviceInfo.BuildNumber, ErrorCode);

	}
	else	{
		printLog(HEAD, "CientIP(%s)InvalidParams...\n", getenv("REMOTE_ADDR"));
	}
	qCgiResponseSetContentType(req, "text/html");
	printResultDeviceInfo(ErrorCode, DeviceInfo);

	closeLog(SvcLog);

	return 0;
}
Exemplo n.º 3
0
jstring Java_com_thinkware_i3dlite_AuthConfirm_GetAuthParam(JNIEnv *env, jobject thiz, jobject activity)
{

	char AllPropString[512];
	char PropName[32];
	char PropValue[32];
	char DeviceID[32];
	char Mdn[32];

	int index = 0;
	int i = 0;
	int retry = 0;

	memset(AllPropString, 0, sizeof(AllPropString));
	memset(PropName, 0, sizeof(PropName));
	memset(PropValue, 0, sizeof(PropValue));
	memset(DeviceID, 0, sizeof(DeviceID));	//IMEI
	memset(Mdn, 0, sizeof(Mdn));

	for(i=0; i<DEVICE_PROPERTY_COUNT; i++) {

		memset(PropName, 0, sizeof(PropName));
		memset(PropValue, 0, sizeof(PropValue));

		sprintf(PropName, "val%d", i+1);
		strcpy(AllPropString+index, PropName);
		index += strlen(PropName);
		AllPropString[index] = '=';
		index++;
		__system_property_get(PropNameList[i], PropValue);
		if( strcmp(PropNameList[i], "ril.wifi_macaddr") == 0 ) {
			if( strlen(PropValue) == 0 ) {	// ril.wifi_macaddr로 못가져왔을때
				while(retry < GET_WIFI_MAC_RETRY_CNT) {
					GetWifiMac(env, activity, PropValue);
					if(strlen(PropValue) >= 12) break;
					else Delay(1000);

					retry++;
				}
			}
			ToUpperString(PropValue, strlen(PropValue));
			RemoveColonDashSpace(PropValue, strlen(PropValue));
			//if(strlen(PropValue)<12) {		// 최종적으로 WIFI MAC을 못가져왔을때 "NONE"으로 채워서 내보낸다.
			//	strcpy(PropValue, NONE_VALUE_STRING);
			//}

		} else if( strcmp(PropNameList[i], "ro.serialno") == 0 ) {	// ro.serialno로 못가져왔을때
			if( strlen(PropValue) == 0 ) {
				GetBuildSerial(env, activity, PropValue);
			}
			ToUpperString(PropValue, strlen(PropValue));
		} else if( strcmp(PropNameList[i], "ro.product.model") == 0 ) {
			ToUpperString(PropValue, strlen(PropValue));
		}

		// 값이 없는것들은 "NONE"으로 내보내기
		if(strlen(PropValue) == 0) {
			strcpy(PropValue, NONE_VALUE_STRING);
		}

		strcpy(AllPropString+index, PropValue);
		index += strlen(PropValue);

		AllPropString[index] = '|';
		index++;
	}

	// DeviceID(IMEI)
	GetDeviceID(env, activity, DeviceID);
	strcpy(AllPropString+index, "val5");
	index += strlen("val5");
	AllPropString[index] = '=';
	index++;
	if(strlen(DeviceID) == 0) {	// 값 없으면 "NONE"으로 내보내기
		strcpy(DeviceID, NONE_VALUE_STRING);
	}
	strcpy(AllPropString+index, DeviceID);
	index += strlen(DeviceID);
	AllPropString[index] = '|';
	index++;

	// MDN
	GetMdn(env, activity, Mdn);
	verifyMdn(Mdn);		// 전화번보 +82로 시작하는거 0으로 바꾸기
	strcpy(AllPropString+index, "val6");
	index += strlen("val6");
	AllPropString[index] = '=';
	index++;
	if(strlen(Mdn) == 0) {	// 값 없으면 "NONE"으로 내보내기
		strcpy(Mdn, NONE_VALUE_STRING);
	}
	strcpy(AllPropString+index, Mdn);
	index += strlen(Mdn);
	AllPropString[index] = '|';
	index++;

	return (*env)->NewStringUTF(env, AllPropString);
}
Exemplo n.º 4
0
//	Interface chaged by [email protected]
//	from
//	int decode_crypt_data_from_file(const char * file_name, 
//			const long start_offset, const long exist_offset, DRMInfo * info, char* map_version)
//	to
int decode_crypt_data_from_file(const char * file_name, 
		const long start_offset, const long exist_offset, DRMInfo * info, DRMInfo DeviceDRMInfo)
{
	FILE *fptr = NULL ;
	char data[320] = "" ;
	long read_byte = 0 ;
	int	i;
	struct stat stbuf ;
	char exist_flag = 0 ;
	char	MAP_CATEGORY, MAP_CATEGORY_2;

	D("DEBUG: decode_crypt_data_from_file:%s:%d:%d:%s\n", 
		file_name, start_offset, exist_offset, DeviceDRMInfo.map_ver) ;
	if(stat(file_name, &stbuf) != 0) {
		D("ERR: %s file read fail (file not found)!\n", file_name) ;
		return DRM_ERR_NOFILE ;
	}
	
	fptr = fopen(file_name, "rb") ;
	if(fptr == NULL) {
		D("ERR: %s file read fail (file not found)!\n", file_name) ;
		return DRM_ERR_NOFILE ;
	}

	if(exist_offset> 0) {
		fseek(fptr, exist_offset, SEEK_SET) ;
		read_byte = fread(&exist_flag, 1, 1, fptr) ;
		D("DEBUG: exist_flag[%d]\n", exist_flag) ;
		if(exist_flag == 0) {
			fclose(fptr) ;	
			return DRM_ERR_NONE ;
		}
		else if(exist_flag != 1) {
			D("ERR: exist_flag[%d]\n", exist_flag) ;
			fclose(fptr) ;	
			return DRM_ERR_DECODE ;
		}
	}

	fseek(fptr, start_offset, SEEK_SET) ;
	read_byte = fread(data, 1, 320, fptr) ;

	if (read_byte != 320) {
		D("ERR: %s file auth fail (read_byte:%d)!\n", file_name, read_byte) ;
	
		fclose(fptr) ;	
		return DRM_ERR_READ;
	}

	int ret = getAuthData_Beecryption_(data, info);
	D("DEBUG - uuid(%s)device(%s)\n", info->uuid, info->device) ;

	if (ret != 1) {
		D("ERR: %s file auth fail (decode)!\n", file_name);
	
		fclose(fptr) ;
		return DRM_ERR_DECODE;
	}
	D("DEBUG: info->file_size[%s] stbuf.st_size(%d)\n", info->file_size, stbuf.st_size) ;

	fclose(fptr) ;

	if(stbuf.st_size != atoi(info->file_size)) {
		D("ERR: %s file Not Match File Size(r:%d vs i:%s)\n", file_name, stbuf.st_size, info->file_size) ;
		return DRM_ERR_NOMATCHFILESIZE;
	}

	D("DEBUG::UUID(%s) VS Primary(%s)Secondary(%s)\n", info->uuid, DeviceDRMInfo.uuid, DeviceDRMInfo.secondary_uuid);
	if (strncmp(info->uuid, DeviceDRMInfo.uuid, sizeof(info->uuid)) != 0) {
		if (strncmp(info->uuid, DeviceDRMInfo.secondary_uuid, sizeof(info->uuid)) != 0) {
			//	Convert UUID from MapData to uppercase and re-compare
			ToUpperString(info->uuid, strlen(info->uuid));
			if (strncmp(info->uuid, DeviceDRMInfo.uuid, sizeof(info->uuid)) != 0) {
				if (strncmp(info->uuid, DeviceDRMInfo.secondary_uuid, sizeof(info->uuid)) != 0) {

					D("ERR: %s file auth fail (not match uuid) AuthUUID(%s) V.S. PrimayUUID(%s)SecondayUUID(%s)!! \n", file_name, info->uuid, DeviceDRMInfo.uuid, DeviceDRMInfo.secondary_uuid) ;
					return DRM_ERR_NOMATCHUUID;
				}
			}
		}
	}

#ifndef	__NO_DRM	//	ON DRM
	if (strncmp(info->device, DeviceDRMInfo.device, REALDEVICENAME_LEN) != 0) {
		D("ERR: %s file auth fail\n", file_name);
		D("(not match device(%.12s)(%.12s))!\n", info->device, DeviceDRMInfo.device) ;
		return DRM_ERR_NOMATCH_DEVICE;
	}
#endif

	if( strncmp(info->map_ver, DeviceDRMInfo.map_ver, strlen(DeviceDRMInfo.map_ver)) != 0 ) {	
		D("ERR: %s not match map_version\n", info->map_ver) ;
		D("(not match Mapver(%.12s)(%.12s))!\n", info->map_ver, DeviceDRMInfo.map_ver) ;
		return DRM_ERR_NOMATCH_MAPVER;
	}

	if( strcmp(DeviceDRMInfo.register_ver, DEVICE_PND3D) == 0 || strcmp(DeviceDRMInfo.register_ver, DEVICE_PND3F) == 0)	{
		MAP_CATEGORY = MAP_DEVICE_TW_PND;
		MAP_CATEGORY_2 = MAP_DEVICE_TW_PND2;
	}
	else	{
		MAP_CATEGORY = MAP_DEVICE_NON_TWL;
		MAP_CATEGORY_2 = MAP_DEVICE_NON_TWR;
	}
	//	Map Device Type Check
	if(DeviceDRMInfo.map_ver[DEVICE_CHECK_POSITION] != MAP_CATEGORY &&
		DeviceDRMInfo.map_ver[DEVICE_CHECK_POSITION] != MAP_CATEGORY_2)	{
		D("ERR: %s not match map_version (%c) category (%c) or (%c)\n", info->map_ver, DeviceDRMInfo.map_ver[DEVICE_CHECK_POSITION], MAP_CATEGORY, MAP_CATEGORY_2) ;
		D("(not match Mapver(%.12s)(%.12s))!\n", info->map_ver, DeviceDRMInfo.map_ver) ;
		return DRM_ERR_NOMATCH_MAPVER;
	}
/*
	if (strncmp(info->app_build_num, DeviceDRMInfo.app_build_num, sizeof(info->app_build_num)) != 0) {
		D("ERR: %s file auth fail\n", file_name);
		D("(not match buildNum(%.8s)(%.8s))!\n", info->app_build_num, DeviceDRMInfo.app_build_num) ;
		return DRM_ERR_NOMATCH_BUILDNUM;
	}
*/
	D("EXP(%s)ispaid(%c)info->exceed_days(%s)reserv(%s)\n", info->expire_date, info->ispaid, info->exceed_days, info->reserved);
//	memcpy(DeviceDRMInfo.expire_date, info->expire_date, 8);
//	memcpy(DeviceDRMInfo.reserved, info->reserved, 12);

	D("[OK] %s file auth success!\n", file_name);
	return DRM_ERR_NONE ;
}