Created
April 15, 2011 11:14
-
-
Save ehamberg/921537 to your computer and use it in GitHub Desktop.
Old perl script for dumping JPEG images from an mbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use MIME::Base64; | |
| use Encode 'from_to'; | |
| open(MBOX, $ARGV[0]); | |
| @mailbox = <MBOX>; | |
| $b = join('', @mailbox); | |
| @a = split(/\nFrom /, $b); | |
| foreach $mail (@a) { | |
| if ($mail =~ m/Subject: .*Foto/) { | |
| $mail =~ m/Content-Type: TEXT\/PLAIN;.*BASE64\n\n(.*)----_.*Content-Disposition: attachment;\n.*?filename="(.*?)"\n.*?\n\n(.*)----_/s; | |
| #print $1; | |
| #print $2; | |
| $c = join('', $3); | |
| $file = "/tmp/$2"; | |
| open(FILE, ">$file"); | |
| print FILE decode_base64($c); | |
| close(FILE); | |
| #print pack("C*", unpack("U*", decode_base64($1))); | |
| $text = decode_base64($1); | |
| print "$text\n"; | |
| print length($text); | |
| print "\n"; | |
| } | |
| } | |
| close(MBOX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment