[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
PHP IMAP and POP3 through Tor
Hello,
I thought I might try my luck and see if anyone can help point me in
the right direction.
I am trying to open a socks5 connection to a localhost tor socks
server, connect to host X and go from there.
The underlying code works fine for HTTP requests, but for POP and
IMAP, it seems to hang and die. /var/log/tor/debug.log shows loads of
this:
May 01 08:00:20.546 [debug] global_read_bucket now 6291456.
May 01 08:00:20.751 [debug] conn_read_callback(): socket 12 wants to
read.
May 01 08:00:20.751 [debug] read_to_buf_impl(): Read 1448 bytes.
99752 on inbuf.
May 01 08:00:20.751 [debug] connection_dir_process_inbuf(): Got data,
not eof. Leaving on inbuf.
May 01 08:00:20.784 [debug] conn_read_callback(): socket 12 wants to
read.
May 01 08:00:20.784 [debug] read_to_buf_impl(): Read 1448 bytes.
101200 on inbuf.
May 01 08:00:20.784 [debug] connection_dir_process_inbuf(): Got data,
not eof. Leaving on inbuf.
May 01 08:00:20.819 [debug] conn_read_callback(): socket 12 wants to
read.
May 01 08:00:20.819 [debug] read_to_buf_impl(): Read 1448 bytes.
102648 on inbuf.
May 01 08:00:20.819 [debug] connection_dir_process_inbuf(): Got data,
not eof. Leaving on inbuf.
May 01 08:00:20.870 [debug] conn_read_callback(): socket 12 wants to
read.
May 01 08:00:20.870 [debug] read_to_buf_impl(): Read 1448 bytes.
104096 on inbuf.
May 01 08:00:20.870 [debug] connection_dir_process_inbuf(): Got data,
not eof. Leaving on inbuf.
May 01 08:00:20.905 [debug] conn_read_callback(): socket 12 wants to
read.
May 01 08:00:20.905 [debug] read_to_buf_impl(): Read 1448 bytes.
105544 on inbuf.
May 01 08:00:20.905 [debug] connection_dir_process_inbuf(): Got data,
not eof. Leaving on inbuf.
May 01 08:00:21.552 [debug] global_read_bucket now 6291456.
As far as my socket shows, its connected but gets no data back. Here
is my code ($host is the host to connect to and $ICL_PORT is the port
number):
$fp= pfsockopen('127.0.0.1', 9050, $errno, $errstr);
$buf["send"] = pack("C3", 0x05, 0x01, 0x00);
fwrite($fp, $buf["send"]);
$buf["recv"] = "";
while ($buffer = fread($fp, 1024)) {
$buf["recv"] .= $buffer;
}
$response = unpack("Cversion/Cmethod", $buf["recv"]);
//if ($response["version"] == 0x05 and $response
["method"] == 0x00) {
if (ip2long($host) == -1) {
$buf["send"] = pack("C5", 0x05, 0x01, 0x00,
0x03, strlen($host)).$host.pack("n", $ICL_PORT);
} else {
$buf["send"] = pack("C4Nn", 0x05, 0x01, 0x00,
0x01, ip2long(gethostbyname($host)), $ICL_PORT);
}
fwrite($fp, $buf["send"]);
$buf["recv"] = "";
while ($buffer = fread($fp, 1024)) {
$buf["recv"] .= $buffer;
}
$response = unpack("Cversion/Cresult/Creg/Ctype/Lip/
Sport", $buf["recv"]);
if (!$response["version"] == 0x05 and $response
["result"] == 0x00) {
return false;
}
$conn->fp = $fp;
Any ideas would be gratefully received!
Thanks
Andy