This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
/
DofusRetroProxyClientReceiveCallback.cs
89 lines (71 loc) · 3.44 KB
/
DofusRetroProxyClientReceiveCallback.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using AivyData.Entities;
using AivyData.Enums;
using AivyDomain.Repository.Client;
using AivyDomain.UseCases.Client;
using NLog;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AivyDofus.Proxy.Callbacks
{
public class DofusRetroProxyClientReceiveCallback : DofusProxyClientReceiveCallback
{
static readonly Logger logger = LogManager.GetCurrentClassLogger();
public DofusRetroProxyClientReceiveCallback(ClientEntity client, ClientEntity remote, ClientRepository repository, ClientCreatorRequest creator, ClientLinkerRequest linker, ClientConnectorRequest connector, ClientDisconnectorRequest disconnector, ClientSenderRequest sender, ProxyEntity proxy, ProxyTagEnum tag = ProxyTagEnum.UNKNOW)
: base(client, remote, repository, creator, linker, connector, disconnector, sender, proxy, tag)
{
}
/// <summary>
/// to do , packet reading , this is just a test
/// </summary>
/// <param name="stream"></param>
protected override void OnReceive(MemoryStream stream)
{
byte[] arr = stream.ToArray();
string msg = Encoding.ASCII.GetString(arr);
logger.Info($"[{_tag}] : {msg}");
// ONLY FOR TEST ( set account_name and clear_password with your own dofus account information ) set to commentary if you want to disable it
if (msg.StartsWith("HC"))
{
_client.IsGameClient = true;
_remote.IsGameClient = true;
_client.CurrentToken = msg.Substring(2, msg.Length - 2);
_remote.CurrentToken = _client.CurrentToken;
string account_name = "nomdecompte";
string clear_password = "motdepasse";
string password_key = msg.Substring(2, msg.Length - 2);
// set version manualy
string version = "1.33.6\n";
string account_info = $"{account_name}\n{password_encrypt(clear_password, password_key)}\n";
string af = " Af\n";
_client_sender.Handle(_client, Encoding.ASCII.GetBytes(version));
_client_sender.Handle(_client, Encoding.ASCII.GetBytes(account_info));
_client_sender.Handle(_client, Encoding.ASCII.GetBytes(af));
return;
}
_client_sender.Handle(_remote, Encoding.ASCII.GetBytes(msg));
}
private readonly char[] character_array = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'};
private string password_encrypt(string password, string key)
{
string result = "#1";
for(int i = 0; i < password.Length; i++)
{
char ch_p = password[i];
char ch_k = key[i];
int n1 = ch_p / 16;
int n2 = ch_p % 16;
int index = (n1 + ch_k) % character_array.Length;
int n3 = (n2 + ch_k) % character_array.Length;
result = result + character_array[index] + character_array[n3];
}
return result;
}
}
}