<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=SMTP</id>
	<title>SMTP - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=SMTP"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=SMTP&amp;action=history"/>
	<updated>2026-05-08T18:46:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=SMTP&amp;diff=2426&amp;oldid=prev</id>
		<title>Kenneth: /* LOGIN Authentication */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=SMTP&amp;diff=2426&amp;oldid=prev"/>
		<updated>2015-08-19T15:11:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;LOGIN Authentication&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Interactive telnet session with Mail server ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telnet oeey.com 25&lt;br /&gt;
Trying 50.50.251.110...&lt;br /&gt;
Connected to oeey.com.&lt;br /&gt;
Escape character is &amp;#039;^]&amp;#039;.&lt;br /&gt;
ehlo bob&lt;br /&gt;
220 ******************************&lt;br /&gt;
250-oeey.com&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-SIZE 10240000&lt;br /&gt;
250-VRFY&lt;br /&gt;
250-ETRN&lt;br /&gt;
250-AUTH CRAM-MD5 LOGIN DIGEST-MD5 GSSAPI NTLM PLAIN&lt;br /&gt;
250-AUTH=CRAM-MD5 LOGIN DIGEST-MD5 GSSAPI NTLM PLAIN&lt;br /&gt;
250 8BITMIME&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The contents of your message file should resemble this example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HELO host.example.com&lt;br /&gt;
MAIL FROM: &amp;lt;test@host.example.com&amp;gt;&lt;br /&gt;
RCPT TO: &amp;lt;bob@example.com&amp;gt;&lt;br /&gt;
DATA&lt;br /&gt;
From: [Alice] &amp;lt;alice@geek.com&amp;gt;&lt;br /&gt;
To: &amp;lt;bob@example.com&amp;gt;&lt;br /&gt;
Date: Mon, 12 Apr 2010 14:21:26 -0400&lt;br /&gt;
Subject: Test Message&lt;br /&gt;
&lt;br /&gt;
Hi there! This is supposed to be a real email...&lt;br /&gt;
&lt;br /&gt;
Have a good day!&lt;br /&gt;
Alice&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
QUIT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now feed message to netcat:&lt;br /&gt;
 /usr/bin/nc smtp.domain.com 25 &amp;lt; /tmp/message&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# telnet oeey.com 25&lt;br /&gt;
Trying 50.50.251.110...&lt;br /&gt;
Connected to oeey.com.&lt;br /&gt;
Escape character is &amp;#039;^]&amp;#039;.&lt;br /&gt;
220 ******************************&lt;br /&gt;
EHLO trogdor&lt;br /&gt;
250-oeey.com&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-SIZE 10240000&lt;br /&gt;
250-VRFY&lt;br /&gt;
250-ETRN&lt;br /&gt;
250-AUTH CRAM-MD5 LOGIN DIGEST-MD5 GSSAPI NTLM PLAIN&lt;br /&gt;
250-AUTH=CRAM-MD5 LOGIN DIGEST-MD5 GSSAPI NTLM PLAIN&lt;br /&gt;
250 8BITMIME&lt;br /&gt;
AUTH LOGIN&lt;br /&gt;
334 VXNlcm5hbWU6                           ## Username:&lt;br /&gt;
a2VubmV0aC5idXJnZW5lcg==                   ## ***&lt;br /&gt;
334 UGFzc3dvcmQ6                           ## Password:&lt;br /&gt;
SW1CQjE5OTkh                               ## ****&lt;br /&gt;
235 Authentication successful&lt;br /&gt;
RCPT TO: &amp;lt;kenneth@oeey.com&amp;gt;&lt;br /&gt;
503 Error: need MAIL command&lt;br /&gt;
MAIL FROM: &amp;lt;kenneth@oeey.com&amp;gt;&lt;br /&gt;
250 Ok&lt;br /&gt;
RCPT TO: &amp;lt;kenneth@oeey.com&amp;gt;&lt;br /&gt;
250 Ok&lt;br /&gt;
DATA&lt;br /&gt;
354 End data with &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;.&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;br /&gt;
Subject: This is a test&lt;br /&gt;
From: Kenneth &amp;lt;kenneth@oeey.com&amp;gt;&lt;br /&gt;
To: Kenneth &amp;lt;kenneth@oeey.com&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a test&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
250 Ok: queued as 8E2FD52095&lt;br /&gt;
500 Error: bad syntax&lt;br /&gt;
quit&lt;br /&gt;
221 Bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SMTP Authentication ===&lt;br /&gt;
&lt;br /&gt;
* IndiMail: Authenticated SMTP tutorial - http://indimail.blogspot.com/2010/03/authenticated-smtp-tutorial.html&lt;br /&gt;
* Tutorial: SMTP Authentication - http://www.fehcom.de/qmail/smtpauth.html&lt;br /&gt;
* http://jetmore.org/john/code/gen-auth&lt;br /&gt;
* SMTP AUTH for sendmail 8.10: Realms and Examples - http://www.sendmail.org/~ca/email/authrealms.html&lt;br /&gt;
&lt;br /&gt;
Use base64 tool to encode decode:&lt;br /&gt;
 echo -n &amp;quot;[pass]&amp;quot; | /usr/bin/base64&lt;br /&gt;
 echo -n &amp;quot;[encpass]&amp;quot; | /usr/bin/base64 -d&lt;br /&gt;
 printf &amp;quot;\0postmaster@example.com\0pass&amp;quot; | /var/indimail/bin/base64&lt;br /&gt;
 printf &amp;#039;VXNlcm5hbWU6&amp;#039; | mimencode -u ; echo&lt;br /&gt;
&lt;br /&gt;
=== LOGIN Authentication ===&lt;br /&gt;
&lt;br /&gt;
This method accepts username and password as supplemental args.  It simply&lt;br /&gt;
returns each string Base64 encoded.  This provides only minimal advantages&lt;br /&gt;
over using ENCODE twice.  One advantage is hiding the password if you&lt;br /&gt;
provide it on STDIN&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LOGIN: (base64) [http://www.webpan.com/Customers/Email/SMTP_Authentication_Telnet_Test.htm] [http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
EHLO trogdor&lt;br /&gt;
AUTH LOGIN&lt;br /&gt;
334 VXNlcm5hbWU6                           ## Username:&lt;br /&gt;
a2VubmV0aC5idXJnZW5lcg==                   ## ****&lt;br /&gt;
334 UGFzc3dvcmQ6                           ## Password:&lt;br /&gt;
SW1CQjE5OTkh                               ## ***&lt;br /&gt;
235 Authentication successful&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to Test SMTP AUTH using Telnet [Wiki] | NDCHost [https://www.ndchost.com/wiki/mail/test-smtp-auth-telnet]:&lt;br /&gt;
 perl -MMIME::Base64 -e &amp;#039;print encode_base64(&amp;quot;username&amp;quot;);&amp;#039;    # dXNlcm5hbWUuY29t&lt;br /&gt;
 perl -MMIME::Base64 -e &amp;#039;print encode_base64(&amp;quot;password&amp;quot;);&amp;#039;    # bXlwYXNzd29yZA==&lt;br /&gt;
 telnet mailserver.com 25&lt;br /&gt;
   EHLO mailserver.com&lt;br /&gt;
   AUTH LOGIN&lt;br /&gt;
   dXNlcm5hbWUuY29t&lt;br /&gt;
   bXlwYXNzd29yZA==&lt;br /&gt;
&lt;br /&gt;
=== PLAIN Authentication ===&lt;br /&gt;
&lt;br /&gt;
This type generates a PLAIN (RFC 2595) authentication string.  It accepts&lt;br /&gt;
supplemental arguments of username and password.  It generates a Base64&lt;br /&gt;
encoded string &amp;quot;\0&amp;lt;username&amp;gt;\0&amp;lt;password&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
PLAIN: (base64 on single line) [http://qmail.jms1.net/test-auth.shtml]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
EHLO trogdor&lt;br /&gt;
AUTH PLAIN&lt;br /&gt;
334&lt;br /&gt;
AGtlbm5ldGguYnVyZ2VuZXIASW1CQjE5OTkh       ## \000***\000***&lt;br /&gt;
235 Authentication successful&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
 perl -MMIME::Base64 -e &amp;#039;print encode_base64(&amp;quot;\000jms1\@jms1.net\000not.my.real.password&amp;quot;)&amp;#039; &lt;br /&gt;
 perl -MMIME::Base64 -e &amp;#039;print encode_base64(&amp;quot;\000***\000***&amp;quot;)&amp;#039;&lt;br /&gt;
 AGtlbm5ldGguYnVyZ2VuZXIASW1CQjE5OTkh&lt;br /&gt;
&lt;br /&gt;
This also works:&lt;br /&gt;
 AUTH PLAIN AGtlbm5ldGguYnVyZ2VuZXIASW1CQjE5OTkh       ## \000***\000***&lt;br /&gt;
&lt;br /&gt;
=== CRAM-MD5 ===&lt;br /&gt;
&lt;br /&gt;
CRAM-MD5 (RFC 2195) accepts three supplemental arguments.  The first is the username and&lt;br /&gt;
the second is the password.  The third is the challenge string provided&lt;br /&gt;
by the server.  This string can be either Base64 encoded or not.  The RFC states&lt;br /&gt;
that all (unencoded) challenge strings must start w/ &amp;#039;&amp;lt;&amp;#039;.  This is used to&lt;br /&gt;
whether the string is Base64 encoded or not.&lt;br /&gt;
&lt;br /&gt;
CRAM-MD5 uses the challenge and the supplied password to generate a digest.&lt;br /&gt;
it then returns the Base64 encoded version of the string md5(&amp;quot;&amp;lt;username&amp;gt; &amp;lt;challenge&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* http://indimail.blogspot.com/2010/03/authenticated-smtp-tutorial.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
3. AUTH CRAM-MD5&lt;br /&gt;
&lt;br /&gt;
The CRAM-MD5 is a challenge-response method where the password is not sent over the network. It is expected that the password is stored in the clear in IndiMail&amp;#039;s backend database MySQL.&lt;br /&gt;
&lt;br /&gt;
% sudo /var/indimail/bin/vpasswd postmaster@example.com -e pass&lt;br /&gt;
&lt;br /&gt;
Next step is to write a script named cram-md5&lt;br /&gt;
&lt;br /&gt;
% cat &amp;gt; cram-md5 &amp;lt;&amp;lt;&amp;gt;&amp;quot;&lt;br /&gt;
sys.exit(1)&lt;br /&gt;
str=cram_md5_response(sys.argv[1], sys.argv[2], sys.argv[3]);&lt;br /&gt;
print &amp;quot;%s&amp;quot; %str&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
% sudo chmod +x ./cram-md5&lt;br /&gt;
&lt;br /&gt;
Now when you do (see below) auth cram-md5, the server will issue a challenge&lt;br /&gt;
e.g. in the below example, the challenge is&lt;br /&gt;
&lt;br /&gt;
PDIwMTM3LjEyNjc1ODUxMDBAaW5kaW1haWwub3JnPg==&lt;br /&gt;
&lt;br /&gt;
if you decode this, i.e.&lt;br /&gt;
&lt;br /&gt;
% echo PDIwMTM3LjEyNjc1ODUxMDBAaW5kaW1haWwub3JnPg== | base64 -d&lt;br /&gt;
&amp;lt;20137.1267585100@indimail.org&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response for the challenge can be generated using the cram-md5 shell script which we created above. i.e.&lt;br /&gt;
&lt;br /&gt;
% ./cram-md5 PDIwMTM3LjEyNjc1ODUxMDBAaW5kaW1haWwub3JnPg==&lt;br /&gt;
cG9zdG1hc3RlckBleGFtcGxlLmNvbSBjZWU4Mzk3YWIxMjNhMGQ0ZjNhN2ZkZGJiOWNiODcxOQ==&lt;br /&gt;
&lt;br /&gt;
% telnet 0 smtp&lt;br /&gt;
Trying 0.0.0.0...&lt;br /&gt;
Connected to 0.&lt;br /&gt;
Escape character is &amp;#039;^]&amp;#039;.&lt;br /&gt;
220 indimail.org (NO UCE) ESMTP IndiMail 1.137 3 Mar 2010 08:28:17 +0530&lt;br /&gt;
auth cram-md5&lt;br /&gt;
334 PDIwMTM3LjEyNjc1ODUxMDBAaW5kaW1haWwub3JnPg==&lt;br /&gt;
cG9zdG1hc3RlckBleGFtcGxlLmNvbSBjZWU4Mzk3YWIxMjNhMGQ0ZjNhN2ZkZGJiOWNiODcxOQ==&lt;br /&gt;
235 ok, go ahead (#2.0.0)&lt;br /&gt;
&lt;br /&gt;
Please do take a look at Erwin Hoffman&amp;#039;s excellent tutorial on the same subject at&lt;br /&gt;
http://www.fehcom.de/qmail/smtpauth.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CRAM-SHA1 ===&lt;br /&gt;
&lt;br /&gt;
This behaves the same as CRAM-MD5 but uses SHA1 digesting rather than MD5.&lt;br /&gt;
&lt;br /&gt;
=== DIGEST-MD5 ===&lt;br /&gt;
&lt;br /&gt;
* http://www.sendmail.org/~ca/email/authrealms.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5&lt;br /&gt;
250 HELP&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; AUTH DIGEST-MD5&lt;br /&gt;
334 bm9uY2U9IkFKUlVjNUp4MFVRYnY1U0o5Rm95VW5hWnBxWklIRGhMVFUrQXduL0swVXc9Iixxb3A9ImF1dGgsYXV0aC1pbnQsYXV0aC1jb25mIixjaXBoZXI9InJjNC00MCxyYzQtNTYscmM0LGRlcywzZGVzIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dXNlcm5hbWU9InRlc3QiLHJlYWxtPSJ3aXouZXhhbXBsZS5jb20iLG5vbmNlPSJBSlJVYzVKeDBVUWJ2NVNKOUZveVVuYVpwcVpJSERoTFRVK0F3bi9LMFV3PSIsY25vbmNlPSJBSlJVYzVKeDBVUWJ2NVNKOUZveVVuYVpwcVpJSERoTFRVK0F3bi9LMFV3PSIsbmM9MDAwMDAwMDEscW9wPWF1dGgtY29uZixjaXBoZXI9InJjNCIsY2hhcnNldD11dGYtOCxkaWdlc3QtdXJpPSJzbXRwL2xvY2FsaG9zdC5zZW5kbWFpbC5jb20uIixyZXNwb25zZT0wZTdjZmNhZTcxN2VlYWM5NzJmYzlkNTYwNmExMDgzZA==&lt;br /&gt;
334 cnNwYXV0aD03NDM5ODBjODQ0MmRiYjcxNmQ0ZWE5ZTQ5OTNiMDFkMA==&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; &lt;br /&gt;
235 2.0.0 OK Authenticated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Decoded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nonce=&amp;quot;AJRUc5Jx0UQbv5SJ9FoyUnaZpqZIHDhLTU+Awn/K0Uw=&amp;quot;,qop=&amp;quot;auth,auth-int,auth-conf&amp;quot;,cipher=&amp;quot;rc4-40,rc4-56,rc4,des,3des&amp;quot;,charset=utf-8,algorithm=md5-sess&lt;br /&gt;
&lt;br /&gt;
username=&amp;quot;test&amp;quot;,realm=&amp;quot;wiz.example.com&amp;quot;,nonce=&amp;quot;AJRUc5Jx0UQbv5SJ9FoyUnaZpqZIHDhLTU+Awn/K0Uw=&amp;quot;,cnonce=&amp;quot;AJRUc5Jx0UQbv5SJ9FoyUnaZpqZIHDhLTU+Awn/K0Uw=&amp;quot;,nc=00000001,qop=auth-conf,cipher=&amp;quot;rc4&amp;quot;,charset=utf-8,digest-uri=&amp;quot;smtp/localhost.sendmail.com.&amp;quot;,response=0e7cfcae717eeac972fc9d5606a1083d&lt;br /&gt;
&lt;br /&gt;
rspauth=743980c8442dbb716d4ea9e4993b01d0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== GSSAPI ===&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface&lt;br /&gt;
&lt;br /&gt;
=== NTLM ===&lt;br /&gt;
&lt;br /&gt;
Although it may be advertised as one of the above types, this method of authentication if refered to singularly as NTLM.  This is a multi-step authentication type.  The first 3 arguments must be supplied up front.  They are username, password, and domain, in that order.  These three strings are used to generate an &amp;quot;Auth Request&amp;quot; string.  This string should be passed verbatim to the server.  The server will then respond with a challenge.  This challenge is the fourth argument.  After receiving the server challenge, gen-auth will produce an &amp;quot;Auth Response&amp;quot;.  Posting this response to the server completes the NTLM authentication transaction.&lt;br /&gt;
&lt;br /&gt;
This authentication method requires the Authen::NTLM perl module to be installed.  See EXAMPLES for an example of this transaction.  Note also that &amp;#039;domain&amp;#039; is often blank from client or ignored by server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Complicated challenge response:&lt;br /&gt;
* http://curl.haxx.se/rfc/ntlm.html&lt;br /&gt;
* http://davenport.sourceforge.net/ntlm.html&lt;br /&gt;
* [http://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;cd=2&amp;amp;sqi=2&amp;amp;ved=0CB4QFjAB&amp;amp;url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F9%2F5%2Fe%2F95ef66af-9026-4bb0-a41d-a4f81802d92c%2F%255BMS-SMTP%255D.pdf&amp;amp;rct=j&amp;amp;q=telnet%20smtp%20auth%20NTML&amp;amp;ei=gwxCTYTRCo2LswadqtSdDg&amp;amp;usg=AFQjCNFj1yvCOttxEsT1iRQzJ4Y8iT3TrQ&amp;amp;cad=rja]&lt;br /&gt;
&lt;br /&gt;
== keywords ==&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>