Upload
abitaf
View
569
Download
0
Embed Size (px)
Citation preview
Cryptoriens
09
SMTP Gmail With command line
Abitaf
Comment Envoyer un mail avec le smtp de gmail En ligne de commande :
Si vous ouvré votre boite email pour envoyé un mail a quelqu’un alors
Le protocole smtp est le responsable de l’acheminement de votre mail vers le destinataire souhaité .
Et si vous avez utilisé une application de gestion de mail comme thunderbird ; Outlook …
Alors pour les configure vous devrai avoir l’adresse du serveur smtp.
Celui de gmail est : smtp.gmail.com
Dans ce tutorial nous allons envoyé un mail en ligne de commande
Pour ce connecter a un serveur il existe des commandes comme telnet et netcat
Exemples :
Commande : telnet smtp.gmail.com 25
réponse : 220 mx.google.com ESMTP 10sm7932026eyz.51
Commande : nc -v smtp.gmail.com 25
Réponse :
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f111.google.com
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f109.google.com
gmail-smtp-msa.l.google.com [74.125.79.111] 25 (smtp) open
220 mx.google.com ESMTP 24sm8028615eyx.33
Dans ce qui suit les commandes seront en bleu et les réponse en vert.
Apres la connexion au serveur il attend que vous tapé des commandes
Il existe plusieurs commandes smtp celle qu’on va utilisé le plus sont :
HELO (ou EHLO) /* identification auprès du serveur */
AUTH LOGIN /* authentification */
MAIL FROM: /* adresse de l’expéditeur */
RCPT TO: /* adresse du destinataire */
DATA /* message a envoyé */
QUIT /* Bye Bye */
Donc la première commandes après la connexion c EHLO il faut dire bonjour au serveur
Sinon il ne répond pas , dans notre cas c sans paramètre mais on peu dire bonjour et
Donné son nom de domaine ou une IP : EHLO 193.194.89.5 ; ou EHLO usthb.dz
nc -v smtp.gmail.com 25
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f111.google.com
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f109.google.com
gmail-smtp-msa.l.google.com [74.125.79.111] 25 (smtp) open
220 mx.google.com ESMTP 28sm4639534eye.56
EHLO
250-mx.google.com at your service, [41.X.X.X]
250-SIZE 35651584
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
Pour la suite on peu soit s’authentifié soit commencé l’envoie de mail
Avec la commande MAIL FROM : dans le cas de gmail on est obligé de
s’authentifie a l’ aides des information de son compte.
car gmail interdit les mail anonymes mais il existe des serveur qui autorise les mails
anonymes c cela qu’utilise les spammeur.
Donc la suite c :
nc -v smtp.gmail.com 25
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f109.google.com
DNS fwd/rev mismatch: gmail-smtp-msa.l.google.com != ey-in-f111.google.com
gmail-smtp-msa.l.google.com [74.125.79.109] 25 (smtp) open
220 mx.google.com ESMTP 24sm8222700eyx.13
EHLO
250-mx.google.com at your service, [41.X.X.X]
250-SIZE 35651584
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
AUTH LOGIN
530 5.7.0 Must issue a STARTTLS command first. 24sm8222700eyx.13
STARTTLS
220 2.0.0 Ready to start TLS
AUTH LOGIN
Apres ca la connexion est perdu
Apres avoir demandé l’authentification gmail nous répond quand doit faire
STARTTLS cad initialisé une connexion crypté.
Donc j’exécute STARTTLS puis je refais AUTH LOGIN ,
ici la connexion est rompu par
Le serveur , c normale car netcat ou telnet ne supporte pas le
SSL « connexion sécurisé »
Il existe des serveurs smtp qui n’utilise pas le SSL pour cela la commande
aurai marché et on aurai continué avec MAIL FROM : …
mais comme on veux utilisé gmail on va devoir utilisé un autre outil pour
initialisé la connexion. Sa sera openssl .
sous linux vous devrai installé le paquet openssl et sous Windows il faut le téléchargé
a l’adresse http://www.slproweb.com/products/Win32OpenSSL.html
après l’avoir installé nous pouvons reprendre se qu’on a fait mais cette fois
on initialise la connexion avec la commande :
openssl s_client -crlf -connect smtp.gmail.com:465
la Réponse du Serveur a cette commande est un peu longue car il initialise une connexion sécurisé.
Loading 'screen' into random state - done CONNECTED(00000770) depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com verify error:num=20:unable to get local issuer certificate verify return:1 depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com verify error:num=27:certificate not trusted verify return:1 depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com verify error:num=21:unable to verify the first certificate verify return:1 --- Certificate chain 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com i:/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium --- Server certificate -----BEGIN CERTIFICATE----- MIIDYzCCAsygAwIBAgIQUR2EgGT4+hGKEhCgLMX2sjANBgkqhkiG9w0BAQUFADCB zjELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJ Q2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UE CxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhh d3RlIFByZW1pdW0gU2VydmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNl cnZlckB0aGF3dGUuY29tMB4XDTA3MDczMDAwMDAwMFoXDTEwMDcyOTIzNTk1OVow aDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDU1v dW50YWluIFZpZXcxEzARBgNVBAoTCkdvb2dsZSBJbmMxFzAVBgNVBAMTDnNtdHAu Z21haWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD+RiG+G3Mo9Q9C tcwDjpp6dJGifjiR5M2DbEbrsIOlth80nk5A7xstKCUfKobHkf/G9Y/DO24JP5yT s3hWep05ybyiCmOzGL5K0zy3jIq0vOWy+4pLv2GsDjYi9mQBhobAAx3z38tTrTL+ WF4p0/Kl014+wnukIpj4MdF35rIkgQIDAQABo4GmMIGjMB0GA1UdJQQWMBQGCCsG AQUFBwMBBggrBgEFBQcDAjBABgNVHR8EOTA3MDWgM6Axhi9odHRwOi8vY3JsLnRo YXd0ZS5jb20vVGhhd3RlUHJlbWl1bVNlcnZlckNBLmNybDAyBggrBgEFBQcBAQQm MCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLnRoYXd0ZS5jb20wDAYDVR0TAQH/ BAIwADANBgkqhkiG9w0BAQUFAAOBgQBeNYOZwMVQ7bd6b4sueAkgm57Cyv2p1Xv1 52e8bLnWqd03mWgn/+TQtrwbE1E6pVuQaZJY33ILpt8IfzwVf2TGQI+M5yazZ2fC xwArHo20iAss3MLQR8tDXWfBoH2Lk9BBsEKDRP4hp83yfpZgdY3pinHTCbqHpsiS v97epiiFBA== -----END CERTIFICATE----- subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com issuer=/C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premi No client certificate CA names sent SSL handshake has read 1017 bytes and written 306 bytes New, TLSv1/SSLv3, Cipher is RC4-MD5 Server public key is 1024 bit Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 Cipher : RC4-MD5 Session-ID: 12065D1FB37FC43409B40BDB08574584D173D71F9B614EDCB12FDD134F685475 Session-ID-ctx: Master-Key: B504DAD9FC643F6E3EE2F78445BC2319A9DCDA5E2B600F6380E9C82CD2DE4453ABE3B2C90F667FFE53A4A5A7CA17AA3D Key-Arg : None Start Time: 1247419198 Timeout : 300 (sec) Verify return code: 21 (unable to verify the first certificate) 220 mx.google.com ESMTP 28sm4309376eye.36
EHLO
250-mx.google.com at your service, [41.X.X.X]
250-SIZE 35651584
250-8BITMIME
250-AUTH LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250 PIPELINING
AUTH LOGIN
334 VXNlcm5hbWU6
--- > ici le serveur attend l’username
La commande AUTH LOGIN cette fois marche et le serveur attend l’username
Mais la problème , est que si on écrit l’username ici par exemple : abitaf
le serveur ne va pas comprendre.
AUTH LOGIN
334 VXNlcm5hbWU6
abitaf
334 UGFzc3dvcmQ6
MotDePasse
501 5.5.2 Cannot Decode response 28sm4333059eye.26
ceci est du a ce que le serveur attend des information codé en Base64
base64 est un codage principalement utilisé pour la transmission de messages
donc nous devons convertir abitaf et MotDePasse en Base64
pour cela il existe des site pour vous aider par exemple :
http://home2.paulschou.net/tools/xlate/
dans mon cas abitaf = YWJpdGFm et MotDePasse = TW90RGVQYXNzZQ==
nous pouvons maintenant continué :
AUTH LOGIN
334 VXNlcm5hbWU6
YWJpdGFm
334 UGFzc3dvcmQ6
TW90RGVQYXNzZQ==
235 2.7.0 Accepted
Login accepté ; il est temps d’envoyé notre mail :
MAIL FROM: <[email protected]>
250 2.1.0 OK 28sm4309376eye.36
RCPT TO: <[email protected]>
250 2.1.5 OK 28sm4309376eye.36
DATA
354 Go ahead 28sm4309376eye.36
est ce que ta recu ce mail from telnet ???
.
250 2.0.0 OK 1247423026 28sm4309376eye.36
quit
221 2.0.0 closing connection 28sm4309376eye.36
Apres la commandes DATA le serveur attend votre message ,
Pour terminé la dernière ligne doit contenir seulement un point.
Vous pouvez aussi faire plusieurs RCPT TO : avant DATA pour envoyé un mail
A plusieurs personne.
La commande Quit termine la connexions.
Voila j’espère que se tutorial vous sera utile .