I've posted this originally on SO, but it may as well be for here.
As you know, with many e-mail services, you can get tricked into believing an e-mail has been sent from a different address.
Using smtplib
in Python, you can easily do the trick by manipulating the From
argument.
gmail
is not prone to that as they print the via
argument which shows the original server.
However, what I cannot find anywhere is how do you retrieve the original (not manipulated) server name, the same as gmail
does with their via
functionality?
I've tried Python and its imaplib
and email
libraries, but there I can only access the already manipulated sender.
Any ideas?
Is that solely linked to the configuration of a particular provider (e.g. Google
, Outlook
, hotmail
, etc.), or can something be done regardless of that - not only in Python, but perhaps in other languages, or in Kali
?
Here is part of the code I'm currently using in Python (no success):
import imaplib
import email
obj = imaplib.IMAP4('imap', portn)
obj.login('username', 'password')
obj.select('INBOX')
uidl_list = [68720]
resp, data = obj.uid('FETCH', ','.join(map(str, uidl_list)) , '(BODY.PEEK[HEADER.FIELDS (From Subject)] RFC822.SIZE)')
I'm aware that this may be considered a duplicate, however in no other spoofing-related topics have I seen any discussion about how to tackle this.
That's perhaps because it is not possible, and it completely depends on the provider, but any clarification is nevertheless welcome.
Received
header lines?