简体   繁体   中英

How to send http request over TOR using PHP sockets

I just want to use PHP sockets ( NOT cURL) to connect to TOR and send HTTP content to web via TOR using SOCKS5 protocol, or get some php classes that do so.

**New Edition

When i trigger the following :

fputs($Socket, "AUTHENTICATE $auth_code\\r\\n");

where $auth_code is NULL value i got this " 250 OK "

but when i send this :

fputs($Socket, "GET /index.php HTTP/1.1\\r\\n");

i got the following error " Unrecognized command "GET" 510 "

so my question is , How can i send http raw data to TOR to forward it? **

As far as I know, there isn't a PHP library that can use SOCKS to forward data. You could roll your own, but you'd have to learn the SOCKS protocol, open a connection to the server with PHP, and then send data to it with instructions. SOCKS is not an HTTP-only protocol, it can forward any TCP connection and return the response.

This is a non-trivial task, unless you are doing something dead simple. If you don't care about the response, or your procedure is a clearly defined and simple request-response process, you can code this in no time. Just keep in mind that you're operating at the 4th layer of the OSI model, there isn't much architecture underneath you to make your life easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM