📄 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 + -