C# Simplest Proxy

11/07/2015 22:20 ImSaSuKi#46
@vietnguyen09

I think that because is disconnect (but is catched like exception) from gateway and need inmediatly to connect to agent server, I try catch it but in many ways it give me C9 error.
Try this, is my way of make it run only for test without many changes (Using edxLoader for redirect the client to the proxy) :)

VirusTotal doesn't work for me right now, sorry :p
12/07/2015 21:08 guusjuhh#47
Hi,
I'm trying to connect to vsro private server through the code provided by drew, however it doesn't seem to receive the 0xa102 login response. So i can't login using this code. Anyone has an idea on how to fix this or how to find the problem?
02/06/2016 23:19 n3oze3kr#48
Hi everybody.

I need to run this but inverse mode, thats means, When some program or somebody wants to go to a public IP Address (like "127.43.64.38:13500") I need to force conection to "127.0.0.1:9382". But, when I try to run my proxy, compiler gives me this error:

"Uncaught exception 'System.Net.Sockets.SocketException' on System.dll
Aditional information: The requested address is not valid on this context"

Anybody can help me, please?
08/08/2021 07:20 Astronaut03#49
Thank you pushedx.

I finally got it. I'm working for Turkish Servers so I think some of the opcodes are different for me. Before I found this topic, I try to use phConnector and phAnalyzer. When I send the login credential to the gateway server I can able to login my char but I can't get any information on phAnalyzer. In phAnalyzer, gateway IP and port were okay, login credentials (username, password, secondary passcode, etc.) were also okay. The last thing needed for the actual game connection is the Agent Server IP address and port. But when are came from the server I wasn't can get any packet data from the phAnalyzer. So after all I tried to use combine two phConnectors together, another proxy sniffer called "XSniff" is not worked for me.

In the end, I found this article. But in this application something was wrong. For example, you used OP:0xA102 for connecting the client to the agent server. But in TrSro this opcode changed to 0xA10A. I was able to fix it after adding some console.writeline actions. When I try to use this state of this program some things still went wrong. When I was looked from phAnalyzer I can see this packet:


But in this Application I saw this packet:


The first two bytes in this packet are the "result" and "id" variables which already comes from the actual server, I learned from this application. I don't know anything about the later five bytes. But I know before the IP address part, I have to see seven bytes of data. After these seven bytes, the agent server IP and port are coming. I can able to see the IP addresses easily when I remove the 3's from the sixteens position in a byte and change 0x2E's with dots. Their sizes depend on their lengths. For example, I'm using localhost and it needs 6 bytes for numerical writing. But actual TrSro server using an IP address, which needs 10 bytes. There are the same amount dots( I mean 3 dots). I didn't explain the last three bytes from the output of the phAnalyzer. The first two of the last three bytes are the agent server port in little-endian format. I can easily swap bytes locations between them and convert them from hexadecimal to decimal.

Together with these most of the thing is okay. So well the last byte of the packet? I really can't understand. When I look to especially agent server information packets, there is always one byte after the port information and it contains this "0x01" data. What does the last byte mean? I'm really want to know.

But as you can see this proxy application doesn't send this "0x01" byte to the client. And I usually saw the "result" variable contains my wanted value and I repeated the sending process for the "result" variable. Finally, I can able to get the whole data stream.

As a result, I don't know how can I give my regards. So much thanks pushedx. After a week, I was able to do something.
08/08/2021 09:32 JellyBitz#50
Quote:
Originally Posted by Astronaut03 View Post
I don't know anything about the later five bytes.
Looks like it's the same [Only registered and activated users can see links. Click Here To Register...] but a different opcode.

PHP Code:
SERVER_GATEWAY_LOGIN_RESPONSE 0xA102

1   byte    result
if(result == 0x01)
{
    
4   uint    AgentServer.Token
    2   ushort  AgentServer
.IP.Length
    
*   string  AgentServer.IP
    2   ushort  AgentServer
.Port

08/08/2021 15:37 Astronaut03#51
Quote:
Originally Posted by JellyBitz View Post
Looks like it's the same [Only registered and activated users can see links. Click Here To Register...] but a different opcode.

PHP Code:
SERVER_GATEWAY_LOGIN_RESPONSE 0xA102

1   byte    result
if(result == 0x01)
{
    
4   uint    AgentServer.Token
    2   ushort  AgentServer
.IP.Length
    
*   string  AgentServer.IP
    2   ushort  AgentServer
.Port

Nah, I think it's not correct.
For login to different servers these packets received to client:

PHP Code:
For Myra:
01 7b 00 00 00 0d 00 39 34 2e 31 39 39 2e 31 30    .{.....94.199.10
33 2e 37 34 d8 56 01                                    3.74
.V..........

For 
Pergamon:
01 1e 01 00 00 0d 00 39 34 2e 31 39 39 2e 31 30    .......94.199.10
33 2e 37 39 d8 56 01                                   3.79
.V..........

For 
Zeugma:
01 85 00 00 00 0d 00 39 34 2e 31 39 39 2e 31 30    .......94.199.10
33 2e 37 36 d8 56 01                                    3.76
.V.......... 
And as you can see IP addresses nearly has no change besides the last digit. We can assume all the same because of their sizes. And the port is the same. At the end of the packet, we can see "0x01" which I didn't understand.

But first seven bytes doesn't match with your
PHP Code:
SERVER_GATEWAY_LOGIN_RESPONSE 0xA102

1   byte    result
if(result == 0x01)
{
    
4   uint    AgentServer.Token
    2   ushort  AgentServer
.IP.Length
    
*   string  AgentServer.IP
    2   ushort  AgentServer
.Port

IP length is the same. Port length depends on size but the same. 1-byte result same but 4uint Token not same with my packet, I think.
In example packets, I have 6 bytes of data, not 4 bytes. And also one more byte coming after the port data.

For the last part, I want to add something. After a few changes in this code, I connected to game and got all the packets.


As I said before I couldn't connect before the making 6th change.
12/01/2024 05:47 dunght#52
finally, I updaded this old program to work on VTC Silkroad :D
02/12/2025 17:34 KaraxSro#53
I cleaned and changed the code a bit (you dont have to use loader, and restarts itself on disconnect), put it to github, you can download the built version here [Only registered and activated users can see links. Click Here To Register...]