?? loginpacket.java
字號:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.qq.packets.out;
import java.nio.ByteBuffer;
import edu.tsinghua.lumaqq.qq.PacketParseException;
import edu.tsinghua.lumaqq.qq.QQ;
import edu.tsinghua.lumaqq.qq.packets.OutPacket;
/**
* <pre>
* QQ登錄請求包,格式為
* 1. 頭部
* 2. 初始密鑰,16字節
* 3. 用戶的密碼密鑰加密一個空串得到的16字節
* 4. 一個字節0
* 5. 4字節IP,這里是空
* 6. 2字節端口,這里是空
* 7. 19個字節的固定內容
* 8. 登錄模式,隱身登錄還是什么
* 9. 16個字節的固定內容
* 10. 尾部
* </pre>
*
* @author 馬若劼
*/
public class LoginPacket extends OutPacket {
/**
* 構造函數
*/
public LoginPacket() {
super(QQ.QQ_CMD_LOGIN, true);
}
/**
* @param buf
* @param length
* @throws PacketParseException
*/
public LoginPacket(ByteBuffer buf, int length) throws PacketParseException {
super(buf, length);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.OutPacket#putBody(java.nio.ByteBuffer)
*/
protected void putBody(ByteBuffer buf) {
// 初始密鑰
buf.put(QQ.iniKey);
// 創建登陸信息數組
byte[] login = new byte[QQ.QQ_LOGIN_DATA_LENGTH];
// 開始填充登陸信息
// 頭16個字節用md5處理的密碼加密一個空字符串,這用來在服務器端校驗密碼
System.arraycopy(crypter.encrypt("".getBytes(), user.getPasswordKey()), 0, login, 0, 16);
// 第16個字節是0
login[16] = 0;
// 17-20字節存放IP,現在置空
login[17] = login[18] = login[19] = login[20] = 0;
// 21-22字節存放端口,現在置空
login[21] = login[22] = 0;
// 23-51字節是固定內容
System.arraycopy(QQ.login_23_51, 0, login, 23, 29);
// 52字節是登陸模式
login[52] = user.getLoginMode();
// 53-68字節是固定內容,也許是和不同的機器有關
System.arraycopy(QQ.login_53_68, 0, login, 53, 16);
// 加密登錄信息
login = crypter.encrypt(login, QQ.iniKey);
// 寫入登錄信息
buf.put(login);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.OutPacket#parseBody(java.nio.ByteBuffer)
*/
protected void parseBody(ByteBuffer buf) throws PacketParseException {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -