예제 #1
0
파일: warden.cpp 프로젝트: kwolekr/horizon
void WardenParseCommand1(char *data, int len, int index) {
	char buf[128];
	if (rawmodule) {					
		memcpy(rawmodule + moddlprog, data + 3, *(__int16 *)(data + 1));
		moddlprog += *(__int16 *)(data + 1);
		//sprintf(buf, "%d/%d bytes (%d%%)", moddlprog, modsize,
		//	int((float)moddlprog / (float)modsize * 100.f));
		//AddChat(vbGreen, buf, bot[index]->hWnd_rtfChat);
	}		
	if (moddlprog >= modsize) {
		dling = 0;
		sprintf(buf, "Module downloaded, dl @ %d kB/s",
			(int)((float)(modsize) / (float)(GetTickCount() - startedtick)));
		AddChat(vbGreen, buf, bot[index]->hWnd_rtfChat);
		int fail = WardenDecryptInflateModule(modname, rawmodule, modsize, moddecryptkey, index);
		if (fail) {																					
			sprintf(buf, "Warden module decryption/inflation failure %d (%s).", 
				fail, wextracterrstrs[fail - 1]);
			AddChat(vbRed, buf, bot[index]->hWnd_rtfChat);
		} else {
			WardenPrepareModule(modname);
			WardenModuleInitalize((LPWMODHEADER)currentmodule);
			*buf = 1;
			RC4Crypt(bot[index]->wardenkey_out, (unsigned char *)buf, 1);
			InsertByte(*buf);
			SendPacket(0x5E, index);
		}
	}
}
예제 #2
0
파일: profile.cpp 프로젝트: kwolekr/horizon
void Send0x27(int index) {
	char asdf[512];
	InsertDWORD(0x01);
	InsertDWORD(0x03);
	InsertByte(0x00);
	InsertNTString("profile\\sex");
	InsertNTString("profile\\location");
	InsertNTString("profile\\description");
	GetWindowText(GetDlgItem(hWnd_Profile, PROFILE_TXTSEX), asdf, sizeof(asdf));
	InsertNTString(asdf);
	GetWindowText(GetDlgItem(hWnd_Profile, PROFILE_TXTLOCATION), asdf, sizeof(asdf));
	InsertNTString(asdf);
	GetWindowText(GetDlgItem(hWnd_Profile, PROFILE_TXTDESCRIPTION), asdf, sizeof(asdf));
	InsertNTString(asdf);
	SendPacket(0x27, index);
}
예제 #3
0
/****************************************************************************
 *
 *  NAME        : EdenProtocolDecode
 *
 *  INPUT       : Data byte
 *
 *  OUTPUT      : None.
 *
 *  DESCRIPTION : Decode a byte from a message.                                        
 *
 ****************************************************************************/
void OHDBEdenProtocolDecode(BYTE RData)
{
	int xdata MsgHandle;
  BYTE xdata *Message;

	MsgHandle = GetAvailableMsgHandle(&MsgRingBuff);
	if (MsgHandle == -1)
		return;
	
	Message = GetMsgPtrByHandle(&MsgRingBuff, MsgHandle);
	if (Message == NULL)
		return;

  switch (RcvRingBufferPtr->DecodeState)
  {
  	case E_MSG_Header:
		// When Bytes is the first header byte
		// -----------------------------------
    	if (RData == C_1stHeaderByte)
    		RcvRingBufferPtr->DecodeState = E_MSG_InHeader;
    	break;

    case E_MSG_InHeader:
		// When Bytes is the second header byte move to detect the length
		// --------------------------------------------------------------
   		if (RData== C_2ndHeaderByte)
      	RcvRingBufferPtr->DecodeState = E_MSG_LengthLow;
  	//When any other case go back to search header
		// -------------------------------------------
      else
      	RcvRingBufferPtr->DecodeState = E_MSG_Header;
      break;

    case E_MSG_LengthLow:
    	RcvRingBufferPtr->MassegeLen        =    RData;
      RcvRingBufferPtr->PreviosByteIsSync =    (RData == C_1stHeaderByte);
      RcvRingBufferPtr->DecodeState       =    E_MSG_LengthFiller;
      RcvRingBufferPtr->NextState         =    E_MSG_LengthHigh;
      break;

    case E_MSG_LengthFiller:
      if (RData== C_LenFillerByte)
      	RcvRingBufferPtr->DecodeState = RcvRingBufferPtr->NextState;
      else
      {
      	if(RcvRingBufferPtr->PreviosByteIsSync)
        { 
        	if(RData == C_2ndHeaderByte)
        		RcvRingBufferPtr->DecodeState = E_MSG_LengthLow;
        	else
        		RcvRingBufferPtr->DecodeState = E_MSG_Header;                 
        }
        else
        {    
          //Error state : reset state
          RcvRingBufferPtr->DecodeState = E_MSG_Header;
          RcvRingBufferPtr->PreviosByteIsSync = CLEAR; 
				}
       }
       break;

    case E_MSG_LengthHigh  :
    	// Keep flag in case this byte is A sync byte 
			// ------------------------------------------
      RcvRingBufferPtr->PreviosByteIsSync =    (RData == C_1stHeaderByte);  

      // Save high nibble of length
			// --------------------------
      RcvRingBufferPtr->MassegeLen = RcvRingBufferPtr->MassegeLen | ((RData) << 8);

      // Verify the length validity
			// --------------------------
      if (RcvRingBufferPtr->MassegeLen > 0 && RcvRingBufferPtr->MassegeLen <= EDEN_PROTOCOL_MAX_MSG_LENGTH)
      {
      	// Reset the buffer index
				// ----------------------
        RcvRingBufferPtr->BytesRcv = 0;
        RcvRingBufferPtr->DataBytesOnly = 0;

        //Reset the CheckSum byte
				// ----------------------
        RcvRingBufferPtr->CheckSum = 0;
        
		    RcvRingBufferPtr->NextState = E_MSG_SourceId;
        RcvRingBufferPtr->DecodeState     = E_MSG_LengthFiller;
      }
      else
      {
      	if(RData == C_1stHeaderByte)
        	RcvRingBufferPtr->DecodeState = E_MSG_InHeader;  
        else
        	// Wait for HEADER again
					// ---------------------
          RcvRingBufferPtr->DecodeState  = E_MSG_Header;
      }
      break;

    case E_MSG_SourceId:
			//When Byte is the SYNC HEADER byte
			if (RData== C_1stHeaderByte)
      {
      	RcvRingBufferPtr->DecodeState     = E_MSG_Filler;
        RcvRingBufferPtr->NextState = E_MSG_DestinationId;
      }
      else
      	RcvRingBufferPtr->DecodeState  = E_MSG_DestinationId;

      RcvRingBufferPtr->BytesRcv++;
      RcvRingBufferPtr->DataBytesOnly++;

			//Calculate CheckSum
      RcvRingBufferPtr->CheckSum = RcvRingBufferPtr->CheckSum + RData;

			// insert the source id to the msg buffer 
			InsertByte(&MsgRingBuff,MsgHandle,RData);
      break;

    case E_MSG_DestinationId:
			// When Byte is the SYNC HEADER byte
			// ---------------------------------
      if (RData== C_1stHeaderByte)
      {
      	RcvRingBufferPtr->DecodeState     = E_MSG_Filler;
        RcvRingBufferPtr->NextState = E_MSG_TransactionId;
      }
      else
      	RcvRingBufferPtr->DecodeState     = E_MSG_TransactionId;
        
      RcvRingBufferPtr->BytesRcv++;
      RcvRingBufferPtr->DataBytesOnly++;

			// Calculate CheckSum
   		// ------------------
      RcvRingBufferPtr->CheckSum = RcvRingBufferPtr->CheckSum+RData;

			// insert the destination id to the msg buffer 
			// -------------------------------------------
			InsertByte(&MsgRingBuff,MsgHandle,RData);
      break;

    case E_MSG_TransactionId:
			// When Byte is the SYNC HEADER byte
			// ---------------------------------
      if (RData== C_1stHeaderByte)
      {
      	RcvRingBufferPtr->DecodeState     = E_MSG_Filler;
        RcvRingBufferPtr->NextState = E_MSG_Data;
      }
      else
      	RcvRingBufferPtr->DecodeState    = E_MSG_Data;
        
      RcvRingBufferPtr->BytesRcv++;
      RcvRingBufferPtr->DataBytesOnly++;

			// Calculate CheckSum
			// ------------------
      RcvRingBufferPtr->CheckSum =RcvRingBufferPtr->CheckSum + RData;

			// insert the transaction id to the msg buffer 
			// -------------------------------------------
			InsertByte(&MsgRingBuff,MsgHandle,RData);
			break;

   case E_MSG_Data:
		// When Byte is the SYNC HEADER byte
		// ---------------------------------
    if (RData== C_1stHeaderByte)
    {
    	RcvRingBufferPtr->DecodeState     = E_MSG_Filler;
      RcvRingBufferPtr->NextState = E_MSG_Data;
    }

    InsertByte(&MsgRingBuff,MsgHandle,RData);

		// Calculate CheckSum
		// ------------------
    RcvRingBufferPtr->CheckSum =RcvRingBufferPtr->CheckSum + RData;

		// Advance counters
		// ----------------
    RcvRingBufferPtr->DataBytesOnly++;
    RcvRingBufferPtr->BytesRcv++;

		// When all bytes received EXCEPT CheckSum byte
		// --------------------------------------------
    if (RcvRingBufferPtr->BytesRcv >= RcvRingBufferPtr->MassegeLen)
    {
			// Move to CheckSum State
			// ----------------------
      RcvRingBufferPtr->DecodeState = E_MSG_CheckSum;
    }
    break;

  case E_MSG_CheckSum:
  	// When Checksum is correct
		// ------------------------
    if ((RcvRingBufferPtr->CheckSum & 0xff) != RData)
			RcvRingBufferPtr->CheckSumErrors++;
		else
 	  {
			// If checksum is ok then inc to the next buffer 
			// ---------------------------------------------
			MarkMsgAsReady(&MsgRingBuff);

			// We don't ResetCommunicationTimeout() here, but in the MessageDecode(), to make sure
			// We Reset only on messages accepted from EDEN Application, and not on messages accepted from OCB.
			// ResetCommunicationTimeout();
    }
    //And wait for HEADER again
    RcvRingBufferPtr->DecodeState  = E_MSG_Header;
    break;

       /*  to be used in the decode function 
             if (Message_Buffer.MsgBufFlage < MAX_MSG_BUF_SELECT)     
                 Message_Buffer.MsgBufIndex++                 
             else 
                 Message_Buffer.MsgBufFlage = 0;
      */
  case E_MSG_Filler:
		// When the byte is the filler byte
		// --------------------------------
    if (RData == C_FillerByte)
    {
    	if (RcvRingBufferPtr->BytesRcv + 1 >= RcvRingBufferPtr->MassegeLen)
      	RcvRingBufferPtr->DecodeState = E_MSG_CheckSum;
      else
      	RcvRingBufferPtr->DecodeState = RcvRingBufferPtr->NextState;

			// When in DATA state count the filler byte also
			// ---------------------------------------------	
	    if ((RcvRingBufferPtr->NextState == E_MSG_Data) ||
	        (RcvRingBufferPtr->NextState == E_MSG_DestinationId ) ||
	         (RcvRingBufferPtr->NextState == E_MSG_TransactionId ))
	    {
				// Advance counter
				// ---------------
	      RcvRingBufferPtr->BytesRcv++;
	
				//Calculate CheckSum
				RcvRingBufferPtr->CheckSum = RcvRingBufferPtr->CheckSum + RData;
	     }
    }
		else
		{
			// When the byte is the second Sync byte (0x33) then
			// maybe it is a sync header, moving to detect source
			//--------------------------------------------------
      if (RData == C_2ndHeaderByte)
      	RcvRingBufferPtr->DecodeState = E_MSG_LengthLow;
  		else
				// When any other case Filler error - try to Resync
				// ------------------------------------------------
      	RcvRingBufferPtr->DecodeState = E_MSG_Header;
    } 
    RcvRingBufferPtr->RcvCharIndex++;        
    break;
  }
}
예제 #4
0
파일: warden.cpp 프로젝트: kwolekr/horizon
void WardenParseCommand0(char *data, int len, int index) {
	char buf[128];
	unsigned char outbuf;
	*(__int32 *)(modname) = 'udom';	
	*(__int32 *)(modname + 4) = '\\sel';
	for (int i = 0; i != 16; i++)
		sprintf(modname + 8 + (i << 1), "%02x", (unsigned char)data[i + 1]);
	modname[40] = '.';
	*(int *)(modname + 41) = 'dom';
	sprintf(buf, "Warden module %s requested.", modname + 8);
	AddChat(vbYellow, buf, bot[index]->hWnd_rtfChat);
	if (currentmodule) {
		if (cmphash(modhash, data + 1)) {
			AddChat(vbGreen, "Module already loaded, using that.", bot[index]->hWnd_rtfChat);
			goto send1;
		} else {
			WardenUnloadModule();
			AddChat(vbYellow, "New warden module requested, loading that.", bot[index]->hWnd_rtfChat);
			goto contwprocessing;
		}
	} else {
contwprocessing:
		__asm {
			cld
			mov esi, data
			inc esi
			lea edi, [modhash]
			movsd
			movsd
			movsd
			movsd
			lea edi, [moddecryptkey]
			movsd
			movsd
			movsd
			movsd
			lea edi, [modsize]
			movsd
		}  
		/**(__int32 *)(modhash)        = *(__int32 *)(data + 1);
		*(__int32 *)(modhash + 0x04) = *(__int32 *)(data + 5);
		*(__int32 *)(modhash + 0x08) = *(__int32 *)(data + 9);
		*(__int32 *)(modhash + 0x0C) = *(__int32 *)(data + 13);

		*(__int32 *)(moddecryptkey)	       = *(__int32 *)(data + 17);
		*(__int32 *)(moddecryptkey + 0x04) = *(__int32 *)(data + 21);
		*(__int32 *)(moddecryptkey + 0x08) = *(__int32 *)(data + 25);
		*(__int32 *)(moddecryptkey + 0x0C) = *(__int32 *)(data + 29);

		modsize = *(__int32 *)(data + 33);
		*/
		if (GetFileAttributes(modname) == INVALID_FILE_ATTRIBUTES) {
			if (dling) {
				AddChat(vbYellow, "Module already being downloaded, waiting!", bot[index]->hWnd_rtfChat); 
				goto send1;
			}
			AddChat(vbYellow, "Module not found, downloading...", bot[index]->hWnd_rtfChat);
			rawmodule = (char *)malloc(modsize);
			moddlprog = 0;
			outbuf = 0;
			startedtick = GetTickCount();
			dling = 1;
		} else {
			WardenPrepareModule(modname);
			WardenModuleInitalize((LPWMODHEADER)currentmodule);
send1:
			outbuf = 1;
		}
	}
	RC4Crypt(bot[index]->wardenkey_out, &outbuf, 1);
	InsertByte(outbuf);
	SendPacket(0x5E, index);
}