Hi to all!

Approx. one year ago I put question - how to download some file via proxy. Now I know that I must connect to proxy:
invoke inet_addr, addr szDefProxy
mov sa.sin_addr, eax
invoke htons, proxyPort
mov word ptr ,ax

and then send request like this:
GET http://mysite.com/filename.any HTTP/1.0
Range: bytes=-0
User-Agent: MyAgent
Connection: Close
Accept: text/*,image/*,application/*,*/*

Later when proxy put it's answer I can download file:
invoke recv,Sock, addr recvbuf, 1024, 0

Good. Now program has been written and works properly.

******************************************

When I want to send a letter I do this steps:
1. I connect to server (directly) (e.g http://www.mail.com)
Then I send those commands
2. HELO mail.com ----> 250 mymail.com
3. MAIL FROM:<myname@mail.com> ----> 250 OK
4. RCPT TO:<billgates@somemail.com> ----> 250 OK
5. DATA ----> 354 Start mail input; end with <CRLF>.<CRLF>
6. Hi! and Bye! .... 13, 10, 13, 10 ----> 250 OK
7. QUIT----> 250 mail.com service closing transmission channel

This program written too and works.

*******************************************

And that's my question: how to send those commands when I connecting via proxy? In other words: how I must rewrite "GET http://mysite.com/filename.any ..." for this? Or may be you recommend me use HEAD method?

Thanks to all who want to help me!

Mike
Posted on 2004-02-19 02:56:34 by Mike
You must include "Host: mysite.com" field in HTTP request.
If mail.com has smtp server, you must find it and connect to it instead. Otherwise you need to do MX look-up on mail.com, and then connect to that smtp.
Posted on 2004-02-19 08:28:43 by comrade
Thank you.
>If mail.com has smtp server
Yes, I expect that mail.com is the name of site that have pop3 server named pop.mail.com and smtp server named smtp.mail.com.

If I understand you properly inplace strings
"HELO mail.com", 13, 10 and "MAIL FROM:<myname@mail.com>", 13, 10 I must send those:

HeloString db "HELO mail.com", 13, 10
db "Host: smtp.mail.com", 13, 10

MailFromString db "MAIL FROM:<myname@mail.com>", 13, 10
db "Host: smtp.mail.com", 13, 10

Am I right?
Mike
Posted on 2004-02-19 08:53:41 by Mike
Hi!

I write this small application (see attach) and it return me this answer:

HTTP/1.0 200 OK
Pragma: no-cache
Content-type: text/html

<HTML><HEAD><TITLE>Protocol Error</TITLE></HEAD>
<BODY><H1>Protocol Error</H1><P><P>Only HTTP, FTP and SSL are currently supported
</BODY></HTML>

Why?

Mike
Posted on 2004-02-20 01:10:22 by Mike
The problem you are having is in the HTTP method you are using. The GET method cannot be used for SMTP transactions... the only way you will be able to use a HTTP proxy server for sending mail is by using the CONNECT method. An example would look like this:

CONNECT smtp.mail.ru:25 HTTP/1.1

Then, if the connection to smtp.mail.ru is established, the server should respond with an HTTP 200 message indicating a tunnel between you and smtp.mail.ru is established. After that, any data sent to the proxy server is not interpreted, but is relayed to smtp.mail.ru. For information about the CONNECT method, see "Tunneling TCP based protocols through Web proxy servers" by Ari Luotonen ( http://www.web-cache.com/Writings/Internet-Drafts/draft-luotonen-web-proxy-tunneling-01.txt ).

Proxy connecting used to be a simple affair, but spammers and other people with less-than-noble intent have forced administrators to place significant restrictions on their proxy services. For example, you are unlikely to find a whole lot of HTTP proxy servers that are going to allow you to open a tunnel with another server on port 25, as that would allow spammers to use their server to bounce mail around.

The "solution" to this is to authenticate the user before allowing them to relay data through the proxy. This is where the SOCKS protocol comes in. There are actually 2 versions in use today -- SOCKS 4 and SOCKS 5. SOCKS 4 is fading out due to its insufficient authentication mechanism, so SOCKS 5 seems to be the way to go for a reliable way to tunnel your connections. Here are protocol specifications for both:

SOCKS 4 protocol documentation - http://archive.socks.permeo.com/protocol/socks4.protocol

SOCKS 5 protocol documentation - http://archive.socks.permeo.com/rfc/rfc1928.txt
Posted on 2004-02-28 17:10:01 by tomdfx
Hi!

Thank you for your reply. Sometimes we can't choose the type of proxy. When you are working in the office local net only network administrator decides that this proxy is the most suitable. Some admins know nothing about SOCKS; one of those can only install packs, e.g. WinGates.
HTTP server support only ftp and ssl. The most programs when it works with ftp inplace STOR comand send PUT like this:

PUT ftp://username:password@ftp.server.com/filename HTTP/1.1
Host: ftp.server.com
User-Agent: Mozilla/4.0 (compatible; Totalcmd; Windows 9x)
Content-Type: application/octet-stream
Content-Length: 3144
Connection: close

In other words one protocol is substituted by another, so I'll try your method in any case!

Mike
Posted on 2004-02-29 01:22:50 by Mike