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

Invalid Start Byte in email #8

Open
vi-or-die opened this issue Sep 21, 2018 · 3 comments
Open

Invalid Start Byte in email #8

vi-or-die opened this issue Sep 21, 2018 · 3 comments

Comments

@vi-or-die
Copy link

Started to see a decline in the amount of phishing emails being reported and noticed that imap2thehive wasn't importing certain messages.

Digging into my error logs on the script, I noticed that an error is being generated when it attempts to decode the message. Doing some searching on that specific byte 0xA9 is é. However other searches on the exact error message shows that there might be a problem with the way its being decoded.

Error Seen:

Traceback (most recent call last):
  File "/etc/imap2thehive/imap2thehive.py", line 496, in <module>
    main()
  File "/etc/imap2thehive/imap2thehive.py", line 492, in main
    readMail(mailConnect())
  File "/etc/imap2thehive/imap2thehive.py", line 377, in readMail
    if submitTheHive(message) == True:
  File "/etc/imap2thehive/imap2thehive.py", line 211, in submitTheHive
    body = part.get_payload(decode=True).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 16493: invalid start byte
@xme
Copy link
Owner

xme commented Sep 24, 2018

I'll have a look. Probably an UTF issue...

@xme
Copy link
Owner

xme commented Sep 24, 2018

As a temporary workaround, you can replace line 211 with:
body = part.get_payload(decode=True).decode(errors='ignore')

@vi-or-die
Copy link
Author

Thanks @xme, that helped!

After adding that on line 211 I had a similar issue for line 216. I did the same thing by modifying the line to html = part.get_payload(decode=True).decode(errors='ignore') this seemed to get things moving again.

Error Recieved

Traceback (most recent call last):
  File "/etc/imap2thehive/imap2thehive.py", line 496, in <module>
    main()
  File "/etc/imap2thehive/imap2thehive.py", line 492, in main
    readMail(mailConnect())
  File "/etc/imap2thehive/imap2thehive.py", line 377, in readMail
    if submitTheHive(message) == True:
  File "/etc/imap2thehive/imap2thehive.py", line 216, in submitTheHive
    html = part.get_payload(decode=True).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 2477: invalid continuation byte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants