# Python Script for Analyzing Email Headers, which helps to identify spam and
spoofed mails
# Save the script as emailanalysis.py
# Copy Mail header in a file and give it as this script's input
import re
def matchre(data,*args):
for regstr in args:
matchObj = re.search( regstr+'.*', data, re.M|re.I)
if matchObj:
print matchObj.group(0).lstrip().rstrip()
else:
print "No ",regstr,"found"
print
print("Email Header Analysis by Jeffin")
print
filename= raw_input("Enter path for email header file: ");
print
fo = open(filename, "r") #fo=filehandle
data=fo.read()
matchre(data,"From:")
print
matchre(data,"Subject:")
print
matchre(data,"Date:")
print
matchre(data,"To:")
print
#matchre(data,"delivered-to:")
#print
matchre(data,"X-Originating-IP:")
print
matchre(data,"Reply-To:")
print
matchre(data,"Return-path:")
print
matchre(data,"X-Spam-Flag:")
print
matchre(data,"MIME-version:")
print
matchre(data,"Message-ID:")
print
fo.close()
#Envelope-To: user@example.com
#Delivery-Date:
#X-Spam-Status:
spoofed mails
# Save the script as emailanalysis.py
# Copy Mail header in a file and give it as this script's input
import re
def matchre(data,*args):
for regstr in args:
matchObj = re.search( regstr+'.*', data, re.M|re.I)
if matchObj:
print matchObj.group(0).lstrip().rstrip()
else:
print "No ",regstr,"found"
print("Email Header Analysis by Jeffin")
filename= raw_input("Enter path for email header file: ");
fo = open(filename, "r") #fo=filehandle
data=fo.read()
matchre(data,"From:")
matchre(data,"Subject:")
matchre(data,"Date:")
matchre(data,"To:")
#matchre(data,"delivered-to:")
matchre(data,"X-Originating-IP:")
matchre(data,"Reply-To:")
matchre(data,"Return-path:")
matchre(data,"X-Spam-Flag:")
matchre(data,"MIME-version:")
matchre(data,"Message-ID:")
fo.close()
#Envelope-To: user@example.com
#Delivery-Date:
#X-Spam-Status:
No comments:
Post a Comment