refactor: further cleanup
This commit is contained in:
parent
d2ef1034f1
commit
8fbca94140
3 changed files with 7 additions and 22 deletions
|
@ -1,5 +1,4 @@
|
||||||
using System.Security.Cryptography;
|
using System.Text;
|
||||||
using System.Text;
|
|
||||||
using MassTransit.Mediator;
|
using MassTransit.Mediator;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NetCoreServer;
|
using NetCoreServer;
|
||||||
|
@ -21,37 +20,19 @@ public abstract class AuthSession : TcpSession
|
||||||
protected override void OnReceived(byte[] buffer, long offset, long size)
|
protected override void OnReceived(byte[] buffer, long offset, long size)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Length: {size} & offset: {offset}");
|
Console.WriteLine($"Length: {size} & offset: {offset}");
|
||||||
//Console.WriteLine(BitConverter.ToString(buffer.ToArray()).Replace("-", string.Empty));
|
|
||||||
Span<byte> decryptedBuffer = new byte[size];
|
Span<byte> decryptedBuffer = new byte[size];
|
||||||
|
|
||||||
|
|
||||||
// xor every value after the first 8 bytes
|
// xor every value after the first 8 bytes
|
||||||
// then apply AES decryption
|
|
||||||
var dataBuffer = Decrypt(new ArraySegment<byte>(buffer, 8, (int)size - 8).ToArray());
|
var dataBuffer = Decrypt(new ArraySegment<byte>(buffer, 8, (int)size - 8).ToArray());
|
||||||
/*using (var ms = new MemoryStream(dataBuffer))
|
|
||||||
using (var cs = new CryptoStream(ms, _decryptor, CryptoStreamMode.Read))
|
|
||||||
{
|
|
||||||
cs.Read(decryptedBuffer);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Length " + BitConverter.ToUInt16(buffer, 0));
|
Console.WriteLine("Length " + BitConverter.ToUInt16(buffer, 0));
|
||||||
var opCode = BitConverter.ToUInt16(buffer.ToArray(), 2);
|
var opCode = BitConverter.ToUInt16(buffer.ToArray(), 2);
|
||||||
Console.WriteLine("Packet Op Code: " + opCode);
|
Console.WriteLine("Packet Op Code: " + opCode);
|
||||||
Console.WriteLine("Some Value: " + buffer[4]);
|
Console.WriteLine("Some Value: " + buffer[4]);
|
||||||
/*
|
|
||||||
* 20s = 5
|
|
||||||
* 15s = 4
|
|
||||||
* 10s = 3
|
|
||||||
*
|
|
||||||
* client alive time * 5s => uptime
|
|
||||||
*/
|
|
||||||
var clientAliveTime = BitConverter.ToUInt16(buffer.ToArray(), 5);
|
var clientAliveTime = BitConverter.ToUInt16(buffer.ToArray(), 5);
|
||||||
Console.WriteLine("Client Alive time: " + clientAliveTime);
|
Console.WriteLine("Client Alive time: " + clientAliveTime);
|
||||||
Console.WriteLine("Might be a flag:" + buffer[7]);
|
Console.WriteLine("Might be a flag:" + buffer[7]);
|
||||||
|
|
||||||
Console.WriteLine("username: " + Encoding.ASCII.GetString(dataBuffer.ToArray(), 0, 20));
|
|
||||||
Console.WriteLine("password: " + Encoding.ASCII.GetString(dataBuffer.ToArray(), 20, 32));
|
|
||||||
Console.WriteLine("Full buffer: " + Encoding.ASCII.GetString(dataBuffer.ToArray()));
|
Console.WriteLine("Full buffer: " + Encoding.ASCII.GetString(dataBuffer.ToArray()));
|
||||||
|
|
||||||
RawPacket rawPacket = new RawPacket((OperationCode)opCode, dataBuffer, clientAliveTime, buffer[0],
|
RawPacket rawPacket = new RawPacket((OperationCode)opCode, dataBuffer, clientAliveTime, buffer[0],
|
||||||
|
|
|
@ -23,6 +23,12 @@ public class RawPacket
|
||||||
SessionId = sessionId;
|
SessionId = sessionId;
|
||||||
Session = session;
|
Session = session;
|
||||||
OperationCode = operationCode;
|
OperationCode = operationCode;
|
||||||
|
/*
|
||||||
|
* 20s = 5
|
||||||
|
* 15s = 4
|
||||||
|
* 10s = 3
|
||||||
|
* client alive time * 5s => uptime
|
||||||
|
*/
|
||||||
ClientAliveTime = TimeSpan.FromSeconds(5 * aliveTime);
|
ClientAliveTime = TimeSpan.FromSeconds(5 * aliveTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using MassTransit;
|
|
||||||
using MassTransit.Mediator;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
Loading…
Add table
Reference in a new issue