Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.217.241.235
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/task/2/root/proc/3/root/proc/3/root/usr/share/doc/libmime-tools-perl/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/2/task/2/root/proc/3/root/proc/3/root/usr/share/doc/libmime-tools-perl/examples/mimeexplode
#!/usr/bin/perl -w

=head1 NAME

mimeexplode - explode one or more MIME messages

=head1 SYNOPSIS

    mimeexplode <mime-msg-file> <mime-msg-file> ...
    
    someprocess | mimeexplode -

=head1 DESCRIPTION

Takes one or more files from the command line that contain MIME
messages, and explodes their contents out into subdirectories
of the current working directory.  The subdirectories are 
just called C<msg0>, C<msg1>, C<msg2>, etc.  Existing directories are
skipped over.

The message information is output to the stdout, like this:

    Message: msg3 (inputfile1.msg)
        Part: msg3/filename-1.dat (text/plain)
        Part: msg3/filename-2.dat (text/plain)
    Message: msg5 (input-file2.msg)
        Part: msg5/dir.gif (image/gif)
        Part: msg5/face.jpg (image/jpeg)
    Message: msg6 (infile3)
        Part: msg6/filename-1.dat (text/plain)

This was written as an example of the MIME:: modules in the
MIME-parser package I wrote.  It may prove useful as a quick-and-dirty
way of splitting a MIME message if you need to decode something, and
you don't have a MIME mail reader on hand.

=head1 COMMAND LINE OPTIONS

None yet.  

=head1 AUTHOR

Eryq C<eryq@zeegee.com>, in a big hurry...

=cut

BEGIN { unshift @INC, ".." }    # to test MIME:: stuff before installing it!

require 5.001;

use strict;
use vars qw($Msgno);

use MIME::Parser;
use Getopt::Std;

#------------------------------------------------------------
# make_msg - make and return the name of a msgXXX directory
#------------------------------------------------------------
$Msgno = 0;

sub make_msg {
    while (-d "msg$Msgno") { 
	++$Msgno;
	die "self-imposed limit reached" if $Msgno == 256;
    }
    mkdir "msg$Msgno",0755 or die "couldn't make msg$Msgno: $!";
    "msg$Msgno";
}

#------------------------------------------------------------
# dump_entity - dump an entity's file info
#------------------------------------------------------------
sub dump_entity {
    my $ent = shift;
    my @parts = $ent->parts;

    if (@parts) {        # multipart...
	map { dump_entity($_) } @parts;
    }
    else {               # single part...
	print "    Part: ", $ent->bodyhandle->path, 
	      " (", scalar($ent->head->mime_type), ")\n";
    }
}

#------------------------------------------------------------
# main
#------------------------------------------------------------
sub main {
    my $file;
    my $entity;

    # Sanity:
    (-w ".") or die "cwd not writable, you naughty boy...";
    
    # Go through messages:
    @ARGV or unshift @ARGV, "-";
    while (defined($file = shift @ARGV)) {

	my $msgdir = make_msg();
	print "Message: $msgdir ($file)\n";

	# Create a new parser object:
	my $parser = new MIME::Parser;
	### $parser->parse_nested_messages('REPLACE');
    
	# Optional: set up parameters that will affect how it extracts 
	#   documents from the input stream:
	$parser->output_dir($msgdir);
    
	# Parse an input stream:
	open FILE, $file or die "couldn't open $file";
	$entity = $parser->read(\*FILE) or 
	    print STDERR "Couldn't parse MIME in $file; continuing...\n";
	close FILE;

	# Congratulations: you now have a (possibly multipart) MIME entity!
	dump_entity($entity) if $entity;
	### $entity->dump_skeleton if $entity;
    }
    1;
}

exit (&main ? 0 : -1);
#------------------------------------------------------------
1;







Anon7 - 2022
AnonSec Team