mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
fix step 3
This commit is contained in:
parent
798827aecd
commit
f64abc83ea
|
|
@ -48,7 +48,7 @@ namespace ClientConsoleApp
|
|||
int ApiId = int.Parse(ConfigurationManager.AppSettings["ApiId"]);
|
||||
//string AuthCode = ConfigurationManager.AppSettings["AuthCode"];
|
||||
string MainPhoneNumber = ConfigurationManager.AppSettings["NumberToAuthenticate"];
|
||||
var client = new TelegramClient(ApiId, ApiHash, null, "session", null, "127.0.0.1", 5000);
|
||||
var client = new TelegramClient(ApiId, ApiHash);//, null, "session", null, "127.0.0.1", 5000
|
||||
var phoneCodeHash = string.Empty;
|
||||
authenticated:
|
||||
Console.WriteLine("Start app");
|
||||
|
|
|
|||
|
|
@ -91,22 +91,38 @@ namespace TlgListenerApplication
|
|||
netStream.Read(bytes, 0, (int)tcpClient.ReceiveBufferSize);
|
||||
var tcpMessage = TcpMessage.Decode(bytes);
|
||||
var binaryReader = new BinaryReader(new MemoryStream(tcpMessage.Body, false));
|
||||
var a = binaryReader.ReadInt64();
|
||||
var msgId = binaryReader.ReadInt64();
|
||||
var datalength = binaryReader.ReadInt32();
|
||||
var data = binaryReader.ReadBytes(datalength);
|
||||
|
||||
var binaryReader2 = new BinaryReader(new MemoryStream(data, false));
|
||||
|
||||
responseCode = binaryReader2.ReadUInt32();
|
||||
Console.WriteLine("Request code: " + responseCode);
|
||||
if (responseCode == step1Constructor)//---Step1_PQRequest
|
||||
var authKeyId = binaryReader.ReadInt64();
|
||||
if (authKeyId == 0)
|
||||
{
|
||||
nonceFromClient = binaryReader2.ReadBytes(16);
|
||||
var msgId = binaryReader.ReadInt64();
|
||||
var datalength = binaryReader.ReadInt32();
|
||||
var data = binaryReader.ReadBytes(datalength);
|
||||
|
||||
var binaryReader2 = new BinaryReader(new MemoryStream(data, false));
|
||||
|
||||
responseCode = binaryReader2.ReadUInt32();
|
||||
Console.WriteLine("Request code: " + responseCode);
|
||||
if (responseCode == step1Constructor) //---Step1_PQRequest
|
||||
{
|
||||
nonceFromClient = binaryReader2.ReadBytes(16);
|
||||
}
|
||||
else if (responseCode == step2Constructor) //---Step1_PQRequest
|
||||
{
|
||||
nonceFromClient = binaryReader2.ReadBytes(16);
|
||||
}
|
||||
}
|
||||
else if (responseCode == step2Constructor)//---Step1_PQRequest
|
||||
else
|
||||
{
|
||||
nonceFromClient = binaryReader2.ReadBytes(16);
|
||||
var decodeMessage = DecodeMessage(tcpMessage.Body);
|
||||
var buffer = new byte[binaryReader.BaseStream.Length - 24];
|
||||
int count;
|
||||
using (var ms = new MemoryStream())
|
||||
while ((count = binaryReader.Read(buffer, 0, buffer.Length)) != 0)
|
||||
ms.Write(buffer, 0, count);
|
||||
|
||||
//var keyData = Helpers.CalcKey(buffer, messageKey, false);
|
||||
//var data = AES.DecryptAES(keyData, buffer);
|
||||
}
|
||||
|
||||
//var obj = new Step1_PQRequest().FromBytes(data);
|
||||
|
|
@ -333,7 +349,7 @@ namespace TlgListenerApplication
|
|||
return newMessageId;
|
||||
}
|
||||
|
||||
private Tuple<byte[], ulong, int> DecodeMessage(byte[] body)
|
||||
private static Tuple<byte[], ulong, int> DecodeMessage(byte[] body)
|
||||
{
|
||||
byte[] message;
|
||||
ulong remoteMessageId;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ namespace TLSharp.Core.Auth
|
|||
using (BinaryReader dhInnerDataReader = new BinaryReader(dhInnerData))
|
||||
{
|
||||
byte[] hashsum = dhInnerDataReader.ReadBytes(20);
|
||||
var hashsumstr = Encoding.UTF8.GetString(hashsum);
|
||||
uint code = dhInnerDataReader.ReadUInt32();
|
||||
if (code != 0xb5890dba)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue