I’m trying to write a PHP script that tunnels some non-http traffic through TOR, but I’m having some problems doing this. Is there a way I can bind TOR to a port and have everything coming in on that port routed through TOR to the intended host/port and then have the response routed back to the port it bound on, thus sending the data back to my PHP application.

I would like to avoid interacting directly with the TOR network in my code. So that’s why I’m looking for some kind of easy proxy solution.

I was able to use the program "socat" to get this working.

socat TCP4-LISTEN:6667,fork SOCKS4A:localhost:irc.hack3r.com:6667,socksport=9050

tor provides a fully compliant socks v4/v5 interface. Socks works by making connection s on behalf of the client. The client tells the proxy to open a connection to the target and on which port (It doesn't have to be HTTP). The proxy opens the connection and the forwards traffic back and for through the proxy. You really just need to read the socks RFC or just wrap your application in something that abstracts the SOCKS implementation for you.

Yeah, I was just looking for the easiest way possible to do this. I didn't want to spend more than 10 minutes getting it to work, just not that important.