Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header extracting added #1

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)