• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

What is wrong

Could any experts tell what is wrong with this script :

#!/usr/bin/perl

######################################################
#                                                    #
# This E-Mail version 1.0 is created by Tan Chen Yee #
# Copyright (c) Dec 11, 1998                         #
#                                                    #
# If you want to use or modify this program, please  #
# let me know by send me an e-mail. Also, tell me    #
# the URL that use this program. Thank you !         #
#                                                    #
# My e-mail is tanc02@stcloudstate.edu               #
#                                                    #
######################################################

$mail='/usr/sbin/sendmail';
$e_mail='http://imps.stcloudstate.edu:8002/mail.html';

  read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  @pairs = split(/&/, $buffer);
  foreach $pair (@pairs)
  {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/+/ /;
    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<!--(.|\n)*-->//g;
    $DATA{$name} = $value;
  }

print "Content-type: text/html\n\n";
 
print "<html>";
print "<head>";
print "<title>E-Mail have sent !</title>";
print "</head>";
print "<body bgcolor=pink>";
print "<br><br><center><h2>This e-mail have already sent to</h2>";
print "<h3><i>$DATA{'email'}</i></h3></center>";
print "</body>";
print "</html>";
open (MAIL, "|$mail $DATA{'email'}");
   print MAIL "To : $DATA{'email'}\n";
   print MAIL "From : $DATA{'from'}\n";
   print MAIL "Subject : $DATA{'subject'}\n\n\n";
   print MAIL "$DATA{'content'}\n\n\n";
 print MAIL "**************************************************************\n\n";  
   print MAIL "This message is sent to you by E-Mail 1.0\n";
   print MAIL "$e_mail.\n\n";
 
close(MAIL);

I had ran this script, it was alright. But I have a problem.
When I save e-mail to these addresses :
 tanc02@stcloudstate.edu
 wlw08@stcloudstate.edu
it took only 1 second for sending the message, but if the address is tanc02@hotmail.com, it took 5 hours at most.

Why it took so long to send the message to tanc02@hotmail.com.

Do I forget to include anyting important code in the perl script ?

What can I do to improve the script ?

Do I have security hole in my script ?

How to detect the security hole ?
0
tanc02
Asked:
tanc02
1 Solution
 
tanc02Author Commented:
Edited text of question
0
 
ozoCommented:
Perhaps your connection to hotmail.com is just slow?

There is a security hole in your script if someone sets $DATA{'email'} to something like 'tanc02@hotmail.com ; rm *'
To close it, I'd suggest

$mail='/usr/sbin/sendmail -t';
open (MAIL, "|$mail");
0
 
tanc02Author Commented:
I don't think the connection was slow, becuase if I used something else like
tigger, condor,= to send the message to tanc02@hotmailcom, they  just took also 1 second.

How did you know there is a secuirty hole ?
And what will happed if someone sets $DATA{'email'} to something like
'tanc02@hotmail.com ; rm *'  ? what do you mean by 'someone' - me or hacker ?
And how do they set it ?

what is '-t' ?
$mail='/usr/sbin/sendmail -t';
0
 
tribal9Commented:
<man sendmail>

You can lookup all of the program extensions in the manpages.  Get to know them, they are useful.

-Matt
0
 
sdjjmCommented:
The problem is not on your end, it's with Hotmail.  They have millions of user accounts and their mail server can take hours to sort mail into the proper user boxes.  I have the same problem myself.  Mail that I send to my ISP POP account gets delivered within 5 minutes where the same email sent to Hotmail takes hours to hit my mailbox.
I have even given up checking my email at Hotmail during peek user times of the day.  At noon for example, when the whole country must be on lunch checking their personal Hotmail, I can't even read my messages as they download from Hotmail  at a whopping 68 BPS on the worst days.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now