Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Tcp socket with proxy

Hello fellow Hackforums members.

I am looking for a way to connect to a tcp server (minecraft server in the current case) with a proxy.

Is there something like HttpWebRequest.Proxy for sockets? (HttpWebRequest example below)
PHP Code

<?php 
HttpWebRequest httpRquest 
= (HttpWebRequest)WebRequest.Create("random website");
            
httpRquest.Proxy = new WebProxy("proxy address"); 

Example of a socket class that needs connect to a server trough a proxy:
PHP Code

<?php 
class HFLookingForHelp
    
{
        static 
Socket mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        static 
byte[] buffer = new byte[1028];

        static 
void Main(string[] args)
        {
            
//mc.Koridorius.lt = server ip (minecraft server), 25565 = port of the minecraft server
            
ConnectToServer("mc.Koridorius.lt", 25565);
        }

        static 
void ConnectToServer(string ip, int port)
        {
            
mainSocket.BeginConnect(ip, port, new AsyncCallback(OnConnectedToServer), null);
        }

        static 
void OnConnectedToServer(IAsyncResult ar)
        {
            
Console.WriteLine("Connected to server.");

            
//Connected, begin reicing/sending bytes
        
}
    } 

I have heard about SOCKS5, but i'm not sure if it the right way to get sockets connect trough a proxy.
[Image: bjAHpdw.png]
SOCKS is just a protocol for proxy.

You can design your own protocol or use existing. If you can you should better develop your own protocol because SOCKS protocol is trash.

SOCKS protocol RFC:
ietf.org/rfc/rfc1928.txt

You have to write your own code.
I mean, I've never tried this before, but when you think it through it's actually somewhat complex.

Http works in a completely different way to TCP. Where TCP is always connected, Http is request based rather than stream based. Sure, you remember sessions, but if you're looking to have a constant connection open to another server, then relaying messages backwards and forwards, it's definitely far from as simple as setting a proxy up.

Actually, i'd be fairly interested in this project (Creating a ProxySocket system, although it would require a base server etc).
Okey got it.
Thank you very much for your answers.
[Image: bjAHpdw.png]
(May 28, 2015 08:22 AM)phrootoo Wrote:  I mean, I've never tried this before, but when you think it through it's actually somewhat complex.

Http works in a completely different way to TCP. Where TCP is always connected, Http is request based rather than stream based. Sure, you remember sessions, but if you're looking to have a constant connection open to another server, then relaying messages backwards and forwards, it's definitely far from as simple as setting a proxy up.

Actually, i'd be fairly interested in this project (Creating a ProxySocket system, although it would require a base server etc).

HTTP is a software-layer-protocol built upon TCP.

HTTP connects, sends everything it needs, receives response and closes connection because it doesn't need to do anything else.
(May 28, 2015 09:16 AM)Bulldoozer1337 Wrote:  HTTP is a software-layer-protocol built upon TCP.

HTTP connects, sends everything it needs, receives response and closes connection because it doesn't need to do anything else.

Didn't know that, thank you for the information. :)
[Image: bjAHpdw.png]
(May 28, 2015 09:16 AM)Bulldoozer1337 Wrote:  HTTP is a software-layer-protocol built upon TCP.

HTTP connects, sends everything it needs, receives response and closes connection because it doesn't need to do anything else.

I am aware. I realise it was written a little incorrectly, but the fact that the connection is completely different means that its just not feasible in the way that a normal proxy works.
I suggest you use an application like Proxifier for that purpose.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by mutateMar 7, 2022 04:55 PM 3 118 Mar 7, 2022 04:55 PM
Last Post: foxegado
[C#] by asdoxOct 13, 2020 03:02 PM 2 389 Oct 13, 2020 03:02 PM
Last Post: REEND
[C#] by 0x0_Sep 23, 2018 03:22 AM 2 336 Sep 23, 2018 03:22 AM
Last Post: Zephyros