本帖最后由 By.清风 于 2015-7-22 11:29 编辑
[C#] 纯文本查看 复制代码 #region 登录0825
/// <summary>
/// 登录0825
/// </summary>
/// <param name="qq"></param>
/// <param name="runCount"></param>
public int SendLogin0825(int rint = 0)
{
try
{
//SetText("验证服务器中!");
this.NeedVerify = false;
byte[] head = Unit.HexStringToByteArray("02 " + PC_QQdefine.VersionNum + " 08 25");
StreamModel model = new StreamModel(PC_QQdefine.Command.send0825);
model.Add(head);
model.Add(Unit.GetSequence(2));
model.Add("00 00 00 00");
model.Add("03 00 00 00 01 01 01 00 00 67 42 ");
model.Add("00 00 00 00");
model.Add(PC_QQdefine.key0825);
StreamModel tea = new StreamModel();
tea.Add("00 18 00 16 00 01");
tea.Add(PC_QQdefine.FixedDate2);
tea.Add("00 00 00 00 00 00 00 00");
tea.Add("00 04 00 0F 00 00 00 0B");
tea.Add(Unit.HexToStr(num.ToString()));
tea.Add("03 09");
tea.Add("00 08");
tea.Add("00 01 00 00 00 00 00 04 ");
tea.Add("00 36 00 12");
tea.Add("00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ");
tea.Add("01 14 00 1D 01 02 00 19");
tea.Add(PC_QQdefine.HDKey);
byte[] s = tea.GetBytes();
model.Add(QQTea.Encrypt(s, 0, s.Length, PC_QQdefine.key0825));
model.Add("03");
int ReciveErrorCount = 0;
again0825:
//发送数据
if (PCQQ_SendData(model))
{
PC_InPacket p = PC_RecvData(QQCommand.CMD_0825, outTime);
if (p == null)
{
if (ReciveErrorCount < ReciveChangeCount)
{
ReciveErrorCount++;
goto again0825;
}
}
byte[] rtea = GetDeCodeByte(p.buf.ToByteArray());
//解密
string retString = Unit.TileHexString(QQTea.Decrypt(rtea, 0, rtea.Length, PC_QQdefine.key0825)); ;
string times = retString.Substring(retString.IndexOf("00 17 00 0E 00 01") + "00 17 00 0E 00 01 ".Length, 12);
string thisIp = retString.Substring(retString.IndexOf("00 17 00 0E 00 01") + GetUinLength(10) + 1, GetUinLength(4));
string serverIp = retString.Substring(retString.IndexOf("00 17 00 0E 00 01") + GetUinLength(22) + 1, GetUinLength(4));
QQuser.ServerIp = serverIp;
token0826 = StringConvort.GetMiddleText(retString, "00 38 ", " 00 17 00 0E 00 01");
ByteBuffer2 buf = new ByteBuffer2(Unit.HexStringToByteArray(retString));
Retcode ReplyCode = (Retcode)buf.Get(); //正常是00
buf.GetChar(); //0x0112;
int length = buf.GetUShort();
byte[] token = buf.GetByteArray(length);//一个38字节的令牌
QQuser.Token_0825 = token;
buf.Position += 6;
long time = buf.GetUInt();
// DateTime loginTime = Util2.GetDateTimeFromMillis(time * 1000);
QQuser.ServerTime = Unit.LongToByteArray(time);
this.QQuser.ClientIP = buf.GetByteArray(4);//客户端IP
//= this.QQuser.ClientIP;
int port = buf.GetUShort();
if (ReplyCode == Retcode.OK)
{
QQuser.NeedLocation = false;
////SetText("正在获取QQ号!");
return Login0836();
}
else
{
buf.GetByteArray(13);
buf.Get();//05不一定,应该是服务器的序号
buf.GetInt();//00
// QQuser.ServerIEP = new System.Net.IPEndPoint(new System.Net.IPAddress(buf.GetByteArray(4)), 8000);
byte[] ip = buf.GetByteArray(4);
QQuser.LocationIP = new System.Net.IPAddress(ip);
//最后6个0;
QQuser.NeedLocation = true;
ConnectReCount = ConnectReCount + 1;
if (ConnectReCount < ReciveChangeCount)
{
int tl = retString.IndexOf("0C 00 16 00 02");
string ips = retString.Substring(tl + GetUinLength(15) + 1, GetUinLength(4));//StringConvort.GetMiddleText(ret, "00 00 00 00 06 00 00 00 00 ", " 00 00 00 00 00");
// ip = "00 02 00 00";
string ipaddress = Unit.IPStringFromByteArray(Unit.HexStringToByteArray(ips));
PC_QQdefine.LoginIP = ipaddress;
//SetText("需要重新连接服务器!" + PC_QQdefine.LoginIP);
return Connection();
}
else
{
ReceiveMessage(this, new ObjEvgs() { type = 2, obj = "请重新登录" });
return 2;
}
}
}
}
catch
{
}
ReceiveMessage(this, new ObjEvgs() { type = 2, obj = "请重新登录" });
return 2;
}
#endregion
#region 0836登录
/// <summary>
/// 0826登录
/// </summary>
public int Login0836()
{
try
{
string head0836 = "02 " + PC_QQdefine.VersionNum + " 08 36 68 48";
byte[] QQNum = Unit.HexStringToByteArray(Unit.QQToHexString(QQnum));
StreamModel model = new StreamModel(PC_QQdefine.Command.send0836);
model.Add(head0836);
//model.Add(Unit.GetSequence(2));
model.Add("00 00 00 00");
model.Add("03 00 00 00 01 01 01 00 00 67 42");
model.Add("00 00 00 00");
model.Add("00 01 01 02 00 19");
model.Add(PC_QQdefine.HDKey);
model.Add("00 00 00 10");
model.Add(Unit.GetSequence(16));
StreamModel tea = new StreamModel();
//加密数据
tea.Add("01 12 00 38");
tea.Add(QQuser.Token_0825);
tea.Add("03 0F 00 08 00 06 57 49 4E 44 4F 57");//WINDOW
//手机?
tea.Add("00 04 00 0F 00 00 00 0B");
tea.Add(Unit.HexToStr(num.ToString()));
tea.Add("00 06 00 78");
#region 00 78
//密码加密
byte[] md5pwd1 = Md5Encrypt("111111");
byte[] md5pwd2 = Unit.HexStringToByteArray("00 00 00 00");
string md5pwd3 = Unit.QQToHexString(0);
StreamModel md5Pwd = new StreamModel();
md5Pwd.Add(md5pwd1);
md5Pwd.Add(md5pwd2);
md5Pwd.Add(md5pwd3);
byte[] pwd = Md5Encrypt(md5Pwd.GetBytes());
//加密结束
if (!NeedLogin255)
{
StreamModel Pwd = new StreamModel();
//密匙加密
byte[] laterPwd = Unit.HexStringToByteArray("F3 62 51 81 00 02");
Pwd.Add(laterPwd);
byte[] pwdQQNum = Unit.HexStringToByteArray(Unit.QQToHexString(QQnum));
Pwd.Add(pwdQQNum);
byte[] fiex = Unit.HexStringToByteArray("" + PC_QQdefine.FixedDate2 + " 00 00 01");
Pwd.Add(fiex);
byte[] md50 = Md5Encrypt("111111");
Pwd.Add(md50);
byte[] time = QQuser.ServerTime;
Pwd.Add(time);
//byte[] timecenter = Unit.HexStringToByteArray("01");
//byte[] time2 = QQsex.times;
byte[] zero = Unit.HexStringToByteArray("00 00 00 00 00 00 00 00 00 00 00 00 00");
Pwd.Add(zero);
Pwd.Add(QQuser.ServerIp);
byte[] someter = Unit.HexStringToByteArray("00 00 00 00 00 00 00 06 00 10 1B A4 9E 16 5F E9 54 25 1E B9 61 9F 7B 1B DF 31");
Pwd.Add(someter);
Pwd.Add(PC_QQdefine.key08262);
//密匙加密结束
byte[] ppp = Pwd.GetBytes();
tea.Add(QQTea.Encrypt(ppp, 0, ppp.Length, pwd));
}
else
{
tea.Add(PC_QQdefine.token255pwd);
}
#endregion
#region CRC
tea.Add("00 15 00 30 00 00");
tea.Add("01");
tea.Add("1C 26 E9 60");
tea.Add("00 10");
tea.Add("02 8D 5F 75 CB CF 4C 89 8C A4 3A 34 10 B8 57 88");
tea.Add("02");
tea.Add("B3 E8 16 3C");
tea.Add("00 10");
tea.Add("1B A4 9E 16 5F E9 54 25 1E B9 61 9F 7B 1B DF 31");
tea.Add("00 1A");
tea.Add("00 40");
//tea.Add("48 AE FD 18 1B C4 F9 3D F1 9A 7D 6D 8A 3C E8 C7 5C 95 E5 79 36 97 7C 37 CE C1 41 D6 FC 17 CE BE 93 39 8C CF 99 29 3F C3 45 21 8B A7 9D 21 EA 60 4A A1 0C E4 FE 78 3C 07 BD 5B 48 F6 62 5E 29 90");
StreamModel mcrc = new StreamModel();
mcrc.Add("00 15 00 30 00 00");
mcrc.Add("01");
mcrc.Add("1C 26 E9 60");
mcrc.Add("00 10");
mcrc.Add("02 8D 5F 75 CB CF 4C 89 8C A4 3A 34 10 B8 57 88");
mcrc.Add("02");
mcrc.Add("B3 E8 16 3C");
mcrc.Add("00 10");
mcrc.Add("1B A4 9E 16 5F E9 54 25 1E B9 61 9F 7B 1B DF 31");
byte[] crcs = mcrc.GetBytes();
crcs = QQTea.Encrypt(crcs, 0, crcs.Length, PC_QQdefine.key08262);
tea.Add(crcs);
#endregion
tea.Add("00 18 00 16 00 01 " + PC_QQdefine.FixedDate2);
tea.Add(Unit.QQToHexString(QQnum));
tea.Add("00 01 00 00 01 03 00 14 00 01");
tea.Add("00 10");
tea.Add("BD 41 FD 50 2A 59 F4 86 3C CD E0 44 BB 41 F7 28");
if (NeedVerify)
{ //yzm
tea.Add("01 10 00 3C 00 01 00 38");
tea.Add(QQuser.Token_00ba4);
tea.Add("00 32 00 63 3E 00 63 02 03 08 00 00 00 04 00 76 A1 00 00 00 00");
tea.Add("1B A4 9E 16 5F E9 54 25 1E B9 61 9F 7B 1B DF 31");
tea.Add("03 01 00 00 66 DC 14 C5 00 00 00 00 00 00 00 00 07 DE 00");
tea.Add("03 00 06 00 01 00 02 00 04 00 00 00 00");
tea.Add("00 4B E8 4F 45 7D 68 D6 89 55 B1 0D 56 8D C2 64 78 57 0B 82 C5 FF B4 87 92 7C 3C E6 FC 51 79 50 1F 68");
}
tea.Add("03 12 00 05 01 00 00 00");
tea.Add("00");//是否记住密码
tea.Add("01 02 00 62 00 01");
tea.Add("11 69 A8 1F 69 9F 52 DE 71 EF 65 E9 B4 2D 2D 8A");
tea.Add("00 38");
tea.Add("78 B9 4E 76 76 7E FD AB 4D D3 B2 B0 14 40 63 F4 8B 57 EE 27 AE F1 52 A2 8A BA 1F 03 50 F0 2B 17 A8 67 87 FE 47 D1 B1 89 C4 3C 0B E7 A7 DC 8C 81 C4 0B B6 22 C7 8E C8 5B");
tea.Add("00 14");
tea.Add("62 E1 72 E6 14 21 FE 8C 85 0C 62 89 1E FC F7 F9 3A 19 B8 92");
byte[] all = tea.GetBytes();
all = QQTea.Encrypt(all, 0, all.Length, PC_QQdefine.DecodeKey);
model.Add(all);
model.Add("03");
int ReciveErrorCount = 0;
again00836:
if (PCQQ_SendData(model))
{
PC_InPacket inpack = PC_RecvData(QQCommand.CMD_0836, outTime);
if (inpack == null)
{
if (ReciveErrorCount < ReciveChangeCount)
{
ReciveErrorCount++;
goto again00836;
}
}
byte[] retb = GetDeCodeByte(inpack.buf.ToByteArray());
// retb = Unit.HexStringToByteArray(ret);
string ret = Unit.TileHexString(QQTea.Decrypt(retb, 0, retb.Length, PC_QQdefine.DecodeKey));
string len = inpack.buf.Length.ToString();
var zt = ret.Substring(0,2);
if (zt=="FC")
{
string qqhex=StringConvort.GetMiddleText(ret, "00 05 00 06 00 01", "01 13 00 20");
var qq = Unit.GetQQNum(qqhex);
//表示追加文本
//StreamWriter sw = File.AppendText("D:\\1.txt");
//sw.Write(num+"----"+qq+"\r\n");
//sw.Close();
SetText("获取完成\r\n" + num + "----" + qq + "\r\n");
return 0;
}
else if (zt=="FF")
{
SetText("数据库中没有找到这样的值");
return 0;
}
}
}
catch (Exception ex)
{
//ErrMsg = "普通登录异常";
//SetText("在普通登录异常[错误]");
// SetAccountText1(6, "普通登录异常");
return 3;
}
return 3;
}
#endregion
核心代码 具体的算法就不公布了,因为涉及到太多
|