HelpConnecting to the proxy server.

Posts 1–14 of 14 · Page 1 of 1
Connecting to the proxy server.
so.

i was making a thing so i could connect to the proxy server.

i swear to god if anyone says "just use krelay" ill fkin do something

So proxy server connects to 127.0.0.1 2050.

When you listen on that port, you get no errors. But the game does not start. Why? Because the game tries to send packets to the server to connect.

Right now the game is trying to connect to local 2050, but local 2050 only listens on that port, it doesnt do anything.

So I started making a program. At start it listens on 127.0.0.1 port 2050
Then it receives all packets send there. Like the hello packet the game tries to send to the server.

So I would need to send that hello packet to the server right? Because thats what the game tries to do if you're not connected to the proxy server.

The game tries to send packets to the server, the server responds with its own packet, the game sees it and sends more etc..



So I would think that if I made something that forwards the packets from the game to the server, I could then receive any responses and send them to the 127.0.0.1 2050.

However look at my code.
Code:
Imports System.Net.Sockets
Imports System.Net

Module Module1
    Dim listener As TcpListener = New TcpListener(IPAddress.Parse("127.0.0.1"), 2050)
    Dim textz As String
    Dim texts As String 'the one server sent
    Dim clientsendpacket As Boolean = False
    Dim serversendpacket As Boolean = False
    Sub Main()
        getfrom()
        Console.ReadLine()

    End Sub
    Sub sendto()
        Dim txp As TcpClient = New TcpClient
        txp.Connect("52.77.221.237", 2050)
        Console.WriteLine("> Connected to Game Server")
        Using ns As NetworkStream = txp.GetStream
            While True
                Do Until clientsendpacket = True

                Loop
                Try
                    Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(textz)
                    ns.Write(msg, 0, msg.Length)
                    Console.WriteLine("> Packet send to Game Server")
                    clientsendpacket = False
                Catch ex As Exception
                    Console.WriteLine("DAMN IT FUCK SHIT")
                    MsgBox(ex.ToString)
                End Try
                Dim receive(255) As Byte
                Dim length As Integer = ns.Read(receive, 0, receive.Length)
                texts = System.Text.Encoding.ASCII.GetString(receive, 0, length)
                Console.WriteLine(texts.Length.ToString)
                serversendpacket = True
            End While

        End Using
    End Sub
    Sub getfrom()
        listener.Start()
        Console.WriteLine("Listening on 127.0.0.1, port 2050.")
        Dim tcp As TcpClient = listener.AcceptTcpClient
        Using ns As NetworkStream = tcp.GetStream
            If True Then
                Console.WriteLine("> Client connected to local")
            End If
            While True
                Try
                    Dim receive(255) As Byte
                    Dim length As Integer = ns.Read(receive, 0, receive.Length)
                    textz = System.Text.Encoding.ASCII.GetString(receive, 0, length)
                    Console.WriteLine("> Packet received from client")
                    clientsendpacket = True
                Catch ex As Exception
                    Console.WriteLine("WTF?")
                    MsgBox(ex.ToString)
                    Return
                End Try
                'Forward to server
                Try
                    sendto()
                Catch ex As Exception
                    Console.WriteLine(ex.ToString)
                End Try
                Do Until serversendpacket = True

                Loop

                Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(texts)
                ns.Write(msg, 0, msg.Length)
                serversendpacket = False
            End While
        End Using



    End Sub

End Module
Especially this piece
Code:
                Dim receive(255) As Byte
                Dim length As Integer = ns.Read(receive, 0, receive.Length)
                texts = System.Text.Encoding.ASCII.GetString(receive, 0, length)
When the hello packet is send, I dont receive any response from the server. Which is weird.


I think it could be from the encoding, the server doesnt understand it? idk.

Help is appreciated.
Is that... Visual basic? xD
Quote Originally Posted by New View Post
So proxy server connects to 127.0.0.1 2050.
When you listen on that port, you get no errors. But the game does not start. Why?
Right now the game is trying to connect to local 2050, but local 2050 only listens on that port, it doesnt do anything.
TcpListener is for Client <--> Proxy communication. The proxy then forwards client information to the server via TcpClient.

If the client isn't getting the Connected! message then there is something wrong with your listener.

Unless you're trying to do something totally different?
Quote Originally Posted by Kushala Daora View Post
Unless you're trying to do something totally different?
Trying to make the game connect to say "USW" from the proxy server.

It does say connected!



But the Game Server doesnt send me any responses to the packet I send.

And yeah the client doesnt go in game obviously, because it doesnt get any response to its hello packet.

- - - Updated - - -

Quote Originally Posted by PimpOrPosh View Post
Is that... Visual basic? xD
saddap kieron xd
Quote Originally Posted by New View Post
But the Game Server doesnt send me any responses to the packet I send.
And yeah the client doesnt go in game obviously, because it doesnt get any response to its hello packet
After the client sends the hello, the server responds with a MapInfo, then the client responds back with create/load.

It's either you're not listening for the MapInfo or something is wrong with the hello packet.
Quote Originally Posted by Kushala Daora View Post
After the client sends the hello, the server responds with a MapInfo, then the client responds back with create/load.

It's either you're not listening for the MapInfo or something is wrong with the hello packet.
Code:
 Dim receive(255) As Byte
                Dim length As Integer = ns.Read(receive, 0, receive.Length)
                texts = System.Text.Encoding.ASCII.GetString(receive, 0, length)
I do listen for the mapinfo, but I think it falls off at me sending the hello packet.

This is how I receive the hello packet:
Code:
 Dim receive(255) As Byte
                    Dim length As Integer = ns.Read(receive, 0, receive.Length)
                    textz = System.Text.Encoding.ASCII.GetString(receive, 0, length)
                    Console.WriteLine("> Packet received from client")
see how I convert it to a string with system.text.encoding.ascii.getstring

and this is how I send it to the game server, converting it back to bytes.

Code:
 Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(textz)
                    ns.Write(msg, 0, msg.Length)
Is this the correct way? Getting the bytes -> convert to ascii -> convert to bytes -> send to server (?)

And

Is there any better way of, instead of going thru the process of encoding / decoding the packet, instead send it immidiately, its received, and automatically sent, that would be optimal.
Quote Originally Posted by New View Post
Code:
 Dim receive(255) As Byte
                Dim length As Integer = ns.Read(receive, 0, receive.Length)
                texts = System.Text.Encoding.ASCII.GetString(receive, 0, length)
OHHH I see your problem. You need to encrypt and unencrypt the packets to and from RC4. Other than the hello packet (which the server will accept in raw form), you'll need to de encrypt the packets the server sends.

If you need just use the rc4 cipher from krelay and pass the information through there.
Quote Originally Posted by Kushala Daora View Post
OHHH I see your problem. You need to encrypt and unencrypt the packets to and from RC4. Other than the hello packet (which the server will accept in raw form), you'll need to de encrypt the packets the server sends.

If you need just use the rc4 cipher from krelay and pass the information through there.
But I send the hello packet and the response comes after multiple seconds, and it's literally a question mark, and its only 1 in length (message.Length) so idk
Quote Originally Posted by New View Post
But I send the hello packet and the response comes after multiple seconds, and it's literally a question mark, and its only 1 in length (message.Length) so idk
The game was just updated so update your hello packet too.
Quote Originally Posted by Kushala Daora View Post
The game was just updated so update your hello packet too.
dude no, im not sending the hello packets, the game is. and if I open the game with krelay it works.

im listening on 127.0.0.1 2050 and im on proxyserver so i just forward the packets from the game to me and from me to the server and vice versa
Quote Originally Posted by New View Post
im listening on 127.0.0.1 2050 and im on proxyserver so i just forward the packets from the game to me and from me to the server and vice versa
You're doing it fine, like I said, just need to encrypt and unencrypt with RC4.
Quote Originally Posted by Kushala Daora View Post
You're doing it fine, like I said, just need to encrypt and unencrypt with RC4.
But you said the hello packet which was sent at the start didn't need encryption :s. Anyways ill try that and post back results later.
Does KRelay have the current RC4 encryption key?
Quote Originally Posted by New View Post
But you said the hello packet which was sent at the start didn't need encryption :s. Anyways ill try that and post back results later.
Does KRelay have the current RC4 encryption key?
It does. //////
I don't know anything about this coding and such,so can someone reply the download link when/if they're done? Thanks a bunch guys,really appreciate it!
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?