Skip to content

Commit

Permalink
Merge pull request #1 from keraattin/development
Browse files Browse the repository at this point in the history
Header extracting added
  • Loading branch information
keraattin authored Nov 25, 2022
2 parents 19dc5ad + e1aed4d commit d77489e
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions email-analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

SUPPORTED_FILE_TYPES = ["eml"]

def get_headers(mail_data : str):
'''Get & Print Headers from mail data'''
print(pyfiglet.figlet_format("Headers")) # Print Banner
# Get Headers from mail data
headers = HeaderParser().parsestr(mail_data, headersonly=True)
# Print Headers
for key,val in headers.items():
print("_"*70)
print(key+":")
print(val)
print("_"*70)

# Main
if __name__ == '__main__':
Expand All @@ -18,8 +29,15 @@
help="Name of file",
required=True
)
parser.add_argument(
"-H",
"--headers",
help="Headers of the eml file",
required=False,
action="store_true"
)
args = parser.parse_args()

# Filename
if args.filename:
# Get Filename
Expand All @@ -31,4 +49,9 @@
sys.exit(-1) #Exit with error code

with open(filename,"r",encoding="utf-8") as file:
data = file.read().rstrip(
data = file.read().rstrip()

# Headers
if args.headers:
# Get & Print Headers
get_headers(data)

0 comments on commit d77489e

Please sign in to comment.