黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图

您现在的位置: 黑客风云 >> 黑客文章 >> 黑客进阶 >> 黑客编程 >> 正文
·没有路由密码权限时的鸽08-23·上网安全 Vista自我防范10-11
·让濒临崩溃的Windows XP10-11·有备无患,快速自制救急10-11
·要你好看!Windows看图工10-11·空间赞助网提供不同类型10-11
·讨论net.exe和net1.exe的10-10·让3389远程桌面传输更通10-10
·巧妙入侵渗透赌博站10-10·Aspx空间扫权限工具10-10
·Windows2003最新提权工具10-10·易淘乐提供100M免费全能10-10
·系统开机密码忘了不着急10-09·中意网络提供免费100M免10-09
·与众不同 Windows XP开始10-08·让桌面图标翻跟斗 在XP上10-08
·上海宽元站长资助计划-提10-08·个性化Windows XP的任务10-07
·趣盘提供3G免费网络硬盘10-07·秀山热线提供200MB免费全10-07
·一次艰辛的提权过程10-06·成功入侵IT大卖场的渗透10-06
·mysqlhack- MYSQL利用工10-06·lanker一句话PHP后门客户10-06
·WIXI提供3G免费多媒体网10-06·新人网络提供100M/ftp免10-06
·如何利用QQ带来高流量10-05·UuShare提供免费网络文件10-05
[推荐]MyQQ.cpp 非完全版本(C语言黑客编程)
      ★★★★

MyQQ.cpp 非完全版本(C语言黑客编程)

文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2006-9-2 9:20:06

unsigned char * MyQQ::gen_session_md5(int uid, unsigned char * session_key)
{
unsigned char *src, md5_str[QQ_KEY_LENGTH];
unsigned char *cursor;
md5_state_t ctx;

src = (unsigned char *)malloc(20);
cursor = src;
create_packet_dw(src, &cursor, uid);
create_packet_data(src, &cursor, session_key, QQ_KEY_LENGTH);

md5_init(&ctx);
md5_append(&ctx, src, 20);
md5_finish(&ctx, (md5_byte_t *) md5_str);

unsigned char * t = (unsigned char *)malloc(QQ_KEY_LENGTH);
memcpy(t,md5_str, QQ_KEY_LENGTH);
return t;
}

unsigned char * MyQQ::qq_get_send_im_tail(const char * font_color,
const char * font_size,
const char * font_name,
bool is_bold, bool is_italic, bool is_underline, int tail_len)
{
char *s1, *s2;
unsigned char *rgb;
int font_name_len;
unsigned char *send_im_tail;
const unsigned char simsun[] = { 0xcb, 0xce, 0xcc, 0xe5 };


font_name_len = DEFAULT_FONT_NAME_LEN;
font_name = (const char*)&(simsun[0]);

send_im_tail = (unsigned char*)malloc(tail_len);

memcpy(send_im_tail + QQ_SEND_IM_AFTER_MSG_HEADER_LEN,
font_name, tail_len - QQ_SEND_IM_AFTER_MSG_HEADER_LEN);

send_im_tail[tail_len - 1] = tail_len;

send_im_tail[0] = 0x00;
send_im_tail[1] = 10;

if (is_bold)
send_im_tail[1] |= 0x20;
if (is_italic)
send_im_tail[1] |= 0x40;
if (is_underline)
send_im_tail[1] |= 0x80;


send_im_tail[2] = send_im_tail[3] = send_im_tail[4] = 0;

send_im_tail[5] = 0x00;
send_im_tail[6] = 0x86;
send_im_tail[7] = 0x22;
return (unsigned char *) send_im_tail;
}

//处理普通的QQ消息
void MyQQ::qq_process_recv_normal_im(unsigned char * data, unsigned char ** cursor, int len)
{
int bytes;
qq_recv_normal_im_common *common;
qq_recv_normal_im_unprocessed *im_unprocessed;

if (*cursor >= (data + len - 1)) {
return;
}
else
common = (qq_recv_normal_im_common *)malloc(sizeof(qq_recv_normal_im_common));

bytes = qq_normal_im_common_read(data, cursor, len, common);
if (bytes < 0) {
return;
}

switch (common->normal_im_type) {
case QQ_NORMAL_IM_TEXT:
qq_process_recv_normal_im_text (data, cursor, len, common);
break;
case QQ_NORMAL_IM_FILE_REJECT_UDP:
//qq_process_recv_file_reject (data, cursor, len,
// common->sender_uid, gc);
break;
case QQ_NORMAL_IM_FILE_APPROVE_UDP:
//qq_process_recv_file_accept (data, cursor, len,
// common->sender_uid, gc);
break;
case QQ_NORMAL_IM_FILE_REQUEST:
//qq_process_recv_file_request (data, cursor, len,
// common->sender_uid, gc);
break;
case QQ_NORMAL_IM_FILE_CANCEL:
//qq_process_recv_file_cancel (data, cursor, len,
// common->sender_uid, gc);
break;
case QQ_NORMAL_IM_FILE_NOTIFY:
//qq_process_recv_file_notify (data, cursor, len,
// common->sender_uid, gc);
break;
default:
return;
} // normal_im_type

g_free (common->session_md5);
}

void MyQQ::qq_process_recv_normal_im_text(unsigned char * data, unsigned char ** cursor, int len, qq_recv_normal_im_common * common)
{
short gaim_msg_type;
char *name;
char *msg_with_gaim_smiley;
char *msg_utf8_encoded;
qq_recv_normal_im_text *im_text;

if (*cursor >= (data + len - 1)) {
return;
} else
im_text = (qq_recv_normal_im_text *)malloc(sizeof(qq_recv_normal_im_text));

im_text->common = common;

read_packet_w(data, cursor, len, &(im_text->msg_seq));
read_packet_dw(data, cursor, len, &(im_text->send_time));
read_packet_b(data, cursor, len, &(im_text->unknown1));
read_packet_b(data, cursor, len, &(im_text->sender_icon));
read_packet_data(data, cursor, len, (unsigned char *) & (im_text->unknown2), 3);
read_packet_b(data, cursor, len, &(im_text->is_there_font_attr));
read_packet_data(data, cursor, len, (unsigned char *) & (im_text->unknown3), 4);
read_packet_b(data, cursor, len, &(im_text->msg_type));

if (im_text->msg_type == QQ_IM_AUTO_REPLY) {
im_text->is_there_font_attr = 0x00;
im_text->msg = (unsigned char *)malloc(1024);
memcpy(im_text->msg,*cursor, data + len - *cursor);
} else {
if (im_text->is_there_font_attr) {
im_text->msg = (unsigned char *)malloc(1500);
memcpy(im_text->msg,*cursor, strlen((const char *)*cursor));
im_text->msg[strlen((const char *)*cursor)] = 0;

}
else
{ im_text->msg = (unsigned char *)malloc(1024);
memcpy(im_text->msg,*cursor, data + len - *cursor);
im_text->msg[data + len - *cursor] = 0;
}
}

MessageText = im_text->msg;
//如果需要自动回复
if(Status == 3)
{
//I_QQAutoReply()函数获取预先设置的自动回复消息内容,需自己实现
char* MText = I_QQAutoReply();
QQSendTextMessage(common->sender_uid,MText,0x01);
}

//在主界面中显示消息
//I_QQReceiveMessage((char *)MessageText,common->sender_uid);
}

int MyQQ::qq_normal_im_common_read(unsigned char * data, unsigned char ** cursor, int len, qq_recv_normal_im_common * common)
{
int bytes;

bytes = 0;

bytes += read_packet_w(data, cursor, len, &(common->sender_ver));
bytes += read_packet_dw(data, cursor, len, &(common->sender_uid));
bytes += read_packet_dw(data, cursor, len, &(common->receiver_uid));

common->session_md5 = (unsigned char *)malloc(QQ_KEY_LENGTH);
memcpy(common->session_md5,*cursor, QQ_KEY_LENGTH);
bytes += QQ_KEY_LENGTH;
*cursor += QQ_KEY_LENGTH;

bytes += read_packet_w(data, cursor, len, &(common->normal_im_type));

if (bytes != 28) {
return -1;
}

return bytes;
}

//请求获得在线好友列表
void MyQQ::qq_send_packet_get_buddies_online(unsigned char position)
{

unsigned char *raw_data, *cursor;

raw_data = (unsigned char*)malloc(5);
cursor = raw_data;

create_packet_b(raw_data, &cursor, QQ_GET_ONLINE_BUDDY_02);
// 001-001 seems it supports 255 online buddies at most
create_packet_b(raw_data, &cursor, position);
// 002-002
create_packet_b(raw_data, &cursor, 0x00);
// 003-004
create_packet_w(raw_data, &cursor, 0x0000);

qq_send_cmd(QQ_CMD_GET_FRIENDS_ONLINE, TRUE, 0, TRUE, raw_data, 5);

}

//处理在线好友列表消息
void MyQQ::qq_process_get_buddies_online_reply(unsigned char * buf, int buf_len)
{
int len, bytes;
unsigned char *data, *cursor, position;
qq_buddy *q_bud;
qq_friends_online_entry *fe;
QQFriend *p;

len = buf_len;
data = (unsigned char *)malloc(len);
cursor = data;

if (MCrypter.qq_crypt(DECRYPT, buf, buf_len, SessionKey, data, &len))
{
read_packet_b(data, &cursor, len, &position);

fe = (qq_friends_online_entry *)malloc(sizeof(qq_friends_online_entry));
qq_buddy_status * s = (qq_buddy_status *)malloc(sizeof(qq_buddy_status));

while (cursor < (data + len))
{

bytes = 0;

// 000-003: uid
bytes += read_packet_dw(data, &cursor, len, &s->uid);
// 004-004: 0x01
bytes += read_packet_b(data, &cursor, len, &s->unknown1);
// 005-008: ip
s->ip = (unsigned char*)malloc(4);
bytes += read_packet_data(data, &cursor, len, s->ip, 4);
// 009-010: port
bytes += read_packet_w(data, &cursor, len, &s->port);
// 011-011: 0x00
bytes += read_packet_b(data, &cursor, len, &s->unknown2);
// 012-012: status
bytes += read_packet_b(data, &cursor, len, &s->status);
// 013-014:
bytes += read_packet_w(data, &cursor, len, &s->unknown3);
// 015-030: unknown key
s->unknown_key = (unsigned char*)malloc(QQ_KEY_LENGTH);
bytes += read_packet_data(data, &cursor, len, s->unknown_key, QQ_KEY_LENGTH);

// 031-032: unknown4
bytes += read_packet_w(data, &cursor, len, &fe->unknown1);
// 033-033: flag1
bytes += read_packet_b(data, &cursor, len, &fe->flag1);
// 034-034: comm_flag
bytes += read_packet_b(data, &cursor, len, &fe->comm_flag);
// 035-036:
bytes += read_packet_w(data, &cursor, len, &fe->unknown2);
// 037-037:
bytes += read_packet_b(data, &cursor, len, &fe->ending); // 0x00

p = FriendListHead;
while(p != NULL)
{
if(p->Buddy->uid == s->uid)
{
p->Buddy->status = s->status;
break;
}
p = p->next;
}
} // while cursor

if(position != 0xFF)
{
//如果类表为接收完,继续发消息请求
qq_send_packet_get_buddies_online(position);
}
else
{
//更新好友的状态
p = FriendListHead;
while(p != NULL)
{
if(p->Buddy->status != QQ_BUDDY_ONLINE_OFFLINE)
{
//I_QQChangeBuddyStatus(p->Buddy->uid, p->Buddy->status);
}
p = p->next;
}
}
}
}

//请求获得好友列表
void MyQQ::qq_send_packet_get_buddies_list(short position)
{
unsigned char *raw_data, *cursor;
int data_len;

data_len = 3;
raw_data = (unsigned char*)malloc(data_len);
cursor = raw_data;
// 000-001 starting position, can manually specify
create_packet_w(raw_data, &cursor, position);

create_packet_b(raw_data, &cursor, 0x00);

qq_send_cmd(QQ_CMD_GET_FRIENDS_LIST, TRUE, 0, TRUE, raw_data, data_len);
}

//处理好友列表消息
void MyQQ::qq_process_get_buddies_list_reply(unsigned char * buf, int buf_len)
{
qq_buddy *q_bud;
int len, bytes, bytes_expected, i;
short position = 0, unknown;
unsigned char *data, *cursor, bar;//, pascal_len;
unsigned short pascal_len;
char *name;


len = buf_len;
data = (unsigned char *)malloc(len);
cursor = data;

if (MCrypter.qq_crypt(DECRYPT, buf, buf_len, SessionKey, data, &len)) {
read_packet_w(data, &cursor, len, &position);
i = 0;
while (cursor < (data + len)) {
q_bud = (qq_buddy *)malloc(sizeof(qq_buddy));
bytes = 0;
// 000-003: uid
bytes += read_packet_dw(data, &cursor, len, &q_bud->uid);
// 004-004: 0xff if buddy is self, 0x00 otherwise
bytes += read_packet_b(data, &cursor, len, &bar);
// 005-005: icon index (1-255)
bytes += read_packet_b(data, &cursor, len, &q_bud->icon);
// 006-006: age
bytes += read_packet_b(data, &cursor, len, &q_bud->age);
// 007-007: gender
bytes += read_packet_b(data, &cursor, len, &q_bud->gender);

//这里如果字符集不同还要进行转换
pascal_len = cursor[0];
q_bud->nickname = (unsigned char*)malloc(pascal_len+1);
memcpy(q_bud->nickname,cursor+1,pascal_len);
q_bud->nickname[pascal_len] = 0;
pascal_len++;


cursor += pascal_len;
bytes += pascal_len;
bytes += read_packet_w(data, &cursor, len, &unknown);

bytes += read_packet_b(data, &cursor, len, &q_bud->flag1);
bytes += read_packet_b(data, &cursor, len, &q_bud->comm_flag);

bytes_expected = 12 + pascal_len;

if (q_bud->uid == 0 || bytes != bytes_expected) {

continue;
} else
i++;

//这里应是将好友信息写入本地好友列表
AddBuddyToList(q_bud);
} // while cursor

if (position == 0xFFFFFFFF) {
//在主界面上显示好友列表
//I_QQUpdateBuddyList();

//若接收完毕,则请求在线好友列表
qq_send_packet_get_buddies_online(QQ_FRIENDS_ONLINE_POSITION_START);
} else //继续请求好友列表
qq_send_packet_get_buddies_list(position);
}
}

 

上一页  [1] [2] [3] [4] 下一页

文章录入:cainiaowang    责任编辑:cainiaowang 
【字体:
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886