2

I want to be able to connect to a remote host (e.g FTP, SMTP, POP) through Socks5 using fsockopen in PHP.

Please how do I go about it?

hakre
  • 193,403
  • 52
  • 435
  • 836
user431949
  • 165
  • 1
  • 8

1 Answers1

4

fsockopen just opens a socket connection. You should manually create request packets and parse responses to implement Socks5 since there is no built-in support in PHP. See here to know how Socks5 works.

Alternatively you can use something like this SOCKS 5 class.

fardjad
  • 20,031
  • 6
  • 53
  • 68
  • Thanks for the swift response. Checked the Socks5 Class and I think it should serve the purpose. One more thing, what would the headers be like if I were to be connecting to a SMTP Server or FTP Server? – user431949 Nov 16 '11 at 04:06
  • 1
    SMTP and FTP requests through SOCKS5 are just like the regular requests, but you should first connect and authenticate to the `Socks5` server, send a connect command with the host address of your FTP or SMTP server and once you receive `connected` response packet from socks server, you can send ordinary FTP or SMPT requests. – fardjad Nov 16 '11 at 04:17
  • Thanks once again. Will I just send `CONNECT ftp.server.com` or `CONNECT smtp.server.com` alone? – user431949 Nov 16 '11 at 04:53