Christophe Casalegno

How to extract email addresses from an arbitrary file

extract email

A very simple way to extract email addresses from an arbitrary file like a mysql file or another binary file, you can use the two commands strings and grep :

Example :
strings pathtoyourdatabase/* |grep -Eio '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})'|sort -u

This command will parse all your mysql files and extract them without database connexion, :

strings /var/lib/mysql/mybase/* |grep -Eio '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})'|sort -u

I have also tested with success this method on other databases like postgresql :

strings /var/lib/pgsql/data/base/19981/* grep -Eio '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})'|sort -u
 
Christophe Casalegno
You can follow me on : Twitter | Facebook | Linkedin | Telegram

Leave a Comment