Advertisement
metalx1000

Mail Base64 Extraction JPEG

Aug 28th, 2015
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  1. #!/bin/bash
  2. #extracts base64 attachment form mailbox file
  3. #if jpg and decodes it into a file based on
  4. #subject name and date
  5.  
  6. dir="~/mail/new/*"
  7. for i in `ls $dir`;
  8. do
  9.   ext="$(grep 'Content-Type: image/jpeg;' $i |cut -d\" -f2|cut -d\. -f2)"
  10.   if [ $ext ]
  11.   then
  12.     sub="$(grep "^Subject:" $i|cut -d\: -f2| sed -e 's/^[ \t]*//')"
  13.     file="$(echo "${sub}_$(date +%s).jpg")"
  14.    echo "$file"
  15.    sed '1,/X-Attachment-Id/d' $i |\
  16.      tail -n +2|\
  17.      sed '$ d'|\
  18.      base64 --decode > "$file"
  19.  fi
  20. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement