📄 evaaddfriendex.cpp
字号:
pos += 2; // verification string memcpy( buf+pos, m_Verification.c_str(), m_Verification.length()); pos += m_Verification.length(); // length of session string *((unsigned short*)(buf+pos)) = htons(m_Session.length()); pos += 2; // session string memcpy( buf+pos, m_Session.c_str(), m_Session.length()); pos += m_Session.length();printf("EvaAddFriendGetAuthInfoPacket\n");for(int i=0;i<pos;i++){ if(!(i%8)) printf("\n"); printf("%2x ", buf[i]);}printf("\n\n"); return pos;}/** ======================================================= */EvaAddFriendGetAuthInfoReplyPacket::EvaAddFriendGetAuthInfoReplyPacket( ) : m_IsQun(false), m_Cmd(AUTH_INFO_CMD_INFO), m_ReplyCode(AUTH_INFO_TYPE_CODE), m_CodeLen(0), m_Code(0){}EvaAddFriendGetAuthInfoReplyPacket::EvaAddFriendGetAuthInfoReplyPacket( unsigned char * buf, int len ) : InPacket(buf, len), m_IsQun(false), m_Cmd(AUTH_INFO_CMD_INFO), m_ReplyCode(AUTH_INFO_TYPE_CODE), m_CodeLen(0), m_Code(0){}EvaAddFriendGetAuthInfoReplyPacket::EvaAddFriendGetAuthInfoReplyPacket( const EvaAddFriendGetAuthInfoReplyPacket & rhs ) : InPacket(rhs), m_IsQun(false), m_Cmd(AUTH_INFO_CMD_INFO), m_ReplyCode(AUTH_INFO_TYPE_CODE), m_CodeLen(0), m_Code(0){ *this = rhs;}EvaAddFriendGetAuthInfoReplyPacket::~ EvaAddFriendGetAuthInfoReplyPacket( ){ if(m_CodeLen && m_Code){ delete []m_Code; m_CodeLen = 0; }}EvaAddFriendGetAuthInfoReplyPacket & EvaAddFriendGetAuthInfoReplyPacket::operator =( const EvaAddFriendGetAuthInfoReplyPacket & rhs ){ *((InPacket *)this) = (InPacket)rhs; m_Cmd = rhs.getSubCommand(); m_ReplyCode = rhs.getReplyCode(); m_CodeLen = rhs.getCodeLength(); m_IsQun = rhs.isQun(); if(m_CodeLen){ if(m_Code) delete [] m_Code; m_Code = new unsigned char[m_CodeLen+1]; // allocate 1 more,just in case of url string situation memcpy(m_Code, rhs.getCode(), m_CodeLen); } return *this;}void EvaAddFriendGetAuthInfoReplyPacket::parseBody( ){printf("EvaAddFriendGetAuthInfoReplyPacket\n");for(int i=0;i<bodyLength;i++){ if(!(i%8)) printf("\n"); printf("%2x ", decryptedBuf[i]);}printf("\n\n"); int offset = 0; m_Cmd = decryptedBuf[offset++]; offset++; // unknown 0x00 unsigned char tmp = decryptedBuf[offset++]; if(tmp == 0x01) m_IsQun = false; else if(tmp == 0x02) m_IsQun = true; else{ fprintf(stderr, "[EvaAddFriendGetAuthInfoReplyPacket] parse error -- unknown message type(not for QQ, not for Qun):%2x\n", tmp); return; } m_ReplyCode = decryptedBuf[offset++]; m_CodeLen = ntohs( *( (unsigned short *)(decryptedBuf + offset)) ); offset+=2; if(m_CodeLen){ if(m_Code) delete [] m_Code; m_Code = new unsigned char[m_CodeLen+1]; memcpy(m_Code, decryptedBuf + offset, m_CodeLen); } // just in case the url, give it a terminate char if(m_ReplyCode == AUTH_INFO_TYPE_GRAPHIC){ m_Code[m_CodeLen] = 0x00; m_CodeLen++;// as it is the url string, so we append a 0x00 at the end }}/** ======================================================= */EvaAddFriendAuthQuestionPacket::EvaAddFriendAuthQuestionPacket( ) : OutPacket(QQ_CMD_ADD_FRIEND_AUTH_QUESTION, true), m_AddQQNum(0), m_AuthStatus(AUTH_TYPE_QUESTION_REQUEST), m_Question(""), m_Answer(""){}EvaAddFriendAuthQuestionPacket::EvaAddFriendAuthQuestionPacket( const unsigned int id, const unsigned char auth ) : OutPacket(QQ_CMD_ADD_FRIEND_AUTH_QUESTION, true), m_AddQQNum(id), m_AuthStatus(auth), m_Question(""), m_Answer(""){}EvaAddFriendAuthQuestionPacket::EvaAddFriendAuthQuestionPacket( const EvaAddFriendAuthQuestionPacket & rhs ) : OutPacket(rhs){ *this = rhs;}EvaAddFriendAuthQuestionPacket::~EvaAddFriendAuthQuestionPacket( ){}EvaAddFriendAuthQuestionPacket & EvaAddFriendAuthQuestionPacket::operator =( const EvaAddFriendAuthQuestionPacket & rhs ){ *( (OutPacket*)(this) ) = (OutPacket)(rhs); m_AddQQNum = rhs.getAddQQ(); m_AuthStatus = rhs.getAuthStatus(); m_Question = rhs.getQuestion(); m_Answer = rhs.getAnswer(); return *this;}int EvaAddFriendAuthQuestionPacket::putBody( unsigned char * buf ){ int pos = 0; buf[pos++] = m_AuthStatus; // 0x01, 0x02, 0x03 or 0x04 if(m_AuthStatus == AUHT_TYPE_QUESTION_GET) { buf[pos++] = 0x00; return pos; } if(m_AuthStatus == AUTH_TYPE_QUESTION_SET){ printf("question(%d):%s\n", m_Question.length(), m_Question.c_str()); buf[pos++] = (unsigned char)(m_Question.length() & 0xff); memcpy(buf + pos, m_Question.c_str(), m_Question.length()); pos += m_Question.length(); buf[pos++] = (unsigned char)(m_Answer.length() & 0xff); printf("answer(%d):%s\n", m_Answer.length(), m_Answer.c_str()); memcpy(buf + pos, m_Answer.c_str(), m_Answer.length()); pos += m_Answer.length(); buf[pos++] = 0x00;printf("EvaAddFriendAuthQuestionPacket\n");for(int i=0;i<pos;i++){ if(!(i%8)) printf("\n"); printf("%2x ", buf[i]);}printf("\n\n"); return pos; } // unknown 2 bytes, always 0x0001 buf[pos++] = 0x00; buf[pos++] = 0x01; *((unsigned int *)(buf + pos)) = htonl(m_AddQQNum); pos+= 4; if(m_AuthStatus == AUTH_TYPE_QUESTION_REQUEST) return pos; buf[pos++] = (unsigned char)(m_Answer.length() & 0xff); memcpy(buf + pos, m_Answer.c_str(), m_Answer.length()); pos += m_Answer.length(); return pos;}/** ======================================================= */EvaAddFriendAuthQuestionReplyPacket::EvaAddFriendAuthQuestionReplyPacket( ) : m_AuthStatus(AUTH_TYPE_QUESTION_REQUEST), m_ReplyCode(01), m_CodeLen(0), m_Code(0), m_Answer(""){}EvaAddFriendAuthQuestionReplyPacket::EvaAddFriendAuthQuestionReplyPacket( unsigned char * buf, int len ) : InPacket(buf, len), m_AuthStatus(AUTH_TYPE_QUESTION_REQUEST), m_ReplyCode(01), m_CodeLen(0), m_Code(0), m_Answer(""){}EvaAddFriendAuthQuestionReplyPacket::EvaAddFriendAuthQuestionReplyPacket( const EvaAddFriendAuthQuestionReplyPacket & rhs ) : InPacket(rhs), m_AuthStatus(AUTH_TYPE_QUESTION_REQUEST), m_ReplyCode(01), m_CodeLen(0), m_Code(0), m_Answer(""){ *this = rhs;}EvaAddFriendAuthQuestionReplyPacket::~ EvaAddFriendAuthQuestionReplyPacket( ){ if(m_CodeLen && m_Code){ delete []m_Code; m_CodeLen = 0; }}EvaAddFriendAuthQuestionReplyPacket & EvaAddFriendAuthQuestionReplyPacket::operator =( const EvaAddFriendAuthQuestionReplyPacket & rhs ){ *((InPacket *)this) = (InPacket)rhs; m_AuthStatus = rhs.getAuthStatus(); m_ReplyCode = rhs.getReplyCode(); m_CodeLen = rhs.getCodeLength(); if(m_CodeLen){ if(m_Code) delete [] m_Code; m_Code = new unsigned char[m_CodeLen+1]; // allocate 1 more,just in case of url string situation memcpy(m_Code, rhs.getCode(), m_CodeLen); } m_Answer = rhs.getAnswer(); return *this;}void EvaAddFriendAuthQuestionReplyPacket::parseBody( ){printf("EvaAddFriendAuthQuestionReplyPacket\n");for(int i=0;i<bodyLength;i++){ if(!(i%8)) printf("\n"); printf("%2x ", decryptedBuf[i]);}printf("\n\n"); int offset = 0; m_AuthStatus = decryptedBuf[offset++]; if(m_AuthStatus == AUHT_TYPE_QUESTION_GET){ m_CodeLen = decryptedBuf[offset++]; if(m_CodeLen){ if(m_Code) delete [] m_Code; m_Code = new unsigned char[m_CodeLen+1]; memcpy(m_Code, decryptedBuf + offset, m_CodeLen); m_Code[m_CodeLen] = 0x00; offset += m_CodeLen; } unsigned int len = decryptedBuf[offset++]; if(len){ char *tmp = new char [len+1]; memcpy(tmp, decryptedBuf + offset, len); tmp[len] = 0x00; m_Answer = tmp; delete []tmp; offset += len; } return; } if(m_AuthStatus == AUTH_TYPE_QUESTION_SET){ m_ReplyCode = decryptedBuf[offset++]; // 0x00: success, (? -- 0x01: error) return; } offset+=2; // unknown 2 bytes, always be 0x0001 m_ReplyCode = decryptedBuf[offset++]; if(m_ReplyCode == 0x01){ // should be error happened return; } switch(m_AuthStatus){ case AUTH_TYPE_QUESTION_REQUEST: m_CodeLen = decryptedBuf[offset++]; break; case AUTH_TYPE_QUESTION_ANSWER:{ m_CodeLen = ntohs( *( (unsigned short *)(decryptedBuf + offset)) ); offset+=2; } break; default: fprintf(stderr, "Unknown auth status code: 0x%2x\n", m_AuthStatus); return; } if(m_CodeLen){ if(m_Code) delete [] m_Code; m_Code = new unsigned char[m_CodeLen+1]; memcpy(m_Code, decryptedBuf + offset, m_CodeLen); offset += m_CodeLen; } // just in case the url, give it a terminate char if(m_AuthStatus == AUTH_TYPE_QUESTION_REQUEST || m_AuthStatus == AUHT_TYPE_QUESTION_GET){ m_Code[m_CodeLen] = 0x00; m_CodeLen++; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -