403Webshell
Server IP : 104.21.38.3  /  Your IP : 104.23.175.202
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/libmime-tools-perl/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/libmime-tools-perl/examples/mimedump
#!/usr/bin/perl -w

=head1 NAME

mimedump - dump out the contents of a parsed MIME message

=head1 DESCRIPTION

Read a MIME stream from the stdin, and dump its contents to the stdout.

=head1 SYNOPSIS

    mimedump < mime.msg

=head1 AUTHOR

Andreas Koenig suggested this, and wrote the original code.
Eryq perverted the hell out of it.

=cut

use MIME::Parser;

#------------------------------
#
# dump_entity ENTITY, NAME
#
# Recursive routine for dumping an entity.
#
sub dump_entity {
    my ($entity, $name) = @_;
    defined($name) or $name = "'anonymous'";
    my $IO;

    # Output the head:
    print "\n", '=' x 60, "\n";
    print "Message $name: ";
    print "\n", '=' x 60, "\n\n";
    print $entity->head->original_text;
    print "\n";

    # Output the body:
    my @parts = $entity->parts;
    if (@parts) {                     # multipart...
	my $i;
	foreach $i (0 .. $#parts) {       # dump each part...
	    dump_entity($parts[$i], ("$name, part ".(1+$i)));
	}
    }
    else {                            # single part...	

	# Get MIME type, and display accordingly...
	my ($type, $subtype) = split('/', $entity->head->mime_type);
	my $body = $entity->bodyhandle;
	if ($type =~ /^(text|message)$/) {     # text: display it...
	    if ($IO = $body->open("r")) {
		print $_ while (defined($_ = $IO->getline));
		$IO->close;
	    }
	    else {       # d'oh!
		print "$0: couldn't find/open '$name': $!";
	    }
	}
	else {                                 # binary: just summarize it...
	    my $path = $body->path;
	    my $size = ($path ? (-s $path) : '???');
	    print ">>> This is a non-text message, $size bytes long.\n";
	    print ">>> It is stored in ", ($path ? "'$path'" : 'core'),".\n\n";
	}
    }
    1;
}

#------------------------------
#
# main
#
sub main {
    print STDERR "(reading from stdin)\n" if (-t STDIN);

    # Create a new MIME parser:
    my $parser = new MIME::Parser;
    
    # Create and set the output directory:
    (-d "mimedump-tmp") or mkdir "mimedump-tmp",0755 or die "mkdir: $!";
    (-w "mimedump-tmp") or die "can't write to directory";
    $parser->output_dir("mimedump-tmp");
    
    # Read the MIME message:
    $entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";

    # Dump it out:
    dump_entity($entity);
}
exit(&main ? 0 : -1);

#------------------------------
1;


Youez - 2016 - github.com/yon3zu
LinuXploit