home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / b4b0 / b4b0-07 / bsaver.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-27  |  3.2 KB  |  169 lines

  1. /* b4b0-saver.c
  2. *  cp4kt (see-packt) & Qytpo (pee-nis)
  3. *
  4. *  special thanks to w00w00 (Shok mainly) for their/his article on console
  5. *  ioctls. Without that, this would have taken a *lot* longer.
  6. *  This is 93.42 % Qytpos code. i love u guy. p.s. thnx vol
  7. *
  8. *  greets to #!animalcrackers
  9. *
  10. */
  11.  
  12. /* over view -- cp4kt
  13. *  
  14. *  basically, its kinda sloppy, but it works. another problem remains however 
  15. *  and that problem is the passwd[] buffer. to compile, do th1z: 
  16. *  # gcc sscr.c -o sscr -lncurses
  17. *
  18. *
  19. *  if that doesn't work, u have a problem. get ncurses fool.
  20. *  this is meant for entertainment purposes only. no real dillmonkies were harmed
  21. *  in the creation of this. thank u. 
  22. *  
  23. * ** SIDE NOTE ** to break, hit enter once. do not hold down the enter key. 
  24. */
  25.  
  26. #include <stdio.h>
  27. #include <curses.h>
  28. #include <unistd.h>
  29. #include <string.h>
  30. #include <fcntl.h>
  31. #include <sys/stat.h>
  32. #include <sys/time.h>
  33. #include <linux/kd.h>
  34. #include <linux/vt.h>
  35. #include <sys/ioctl.h>
  36. #include <signal.h>
  37.  
  38.  
  39. #define NUMWORDS 20     /* number of words in *words[] (not including NULL) */
  40.  
  41. #define  LOCK(x)     if (ioctl(fd, VT_LOCKSWITCH, 1) < 0) {         \
  42.                 perror("LOCK malfunction");            \
  43.                     exit(-1);             \
  44.                 }
  45.  
  46. #define  UNLOCK(x)     if (ioctl(fd, VT_UNLOCKSWITCH, 1) < 0) {    \
  47.                 perror("UNLOCK malfunction");        \
  48.                     exit(-1);            \
  49.                 }
  50.  
  51. static char     passwd[] = "dillmonkey" ;
  52. int         fd; 
  53.  
  54. int init_all( void ) 
  55.       initscr();
  56.       noecho();
  57.       nodelay(stdscr, TRUE);
  58.       curs_set(0);
  59.       start_color();
  60.  
  61.     signal(SIGINT, SIG_IGN);
  62.       signal(SIGTERM, SIG_IGN);
  63.       signal(SIGQUIT, SIG_IGN);
  64.       signal(SIGTSTP, SIG_IGN);
  65.  
  66. }
  67.  
  68. int main(int argc, char *argv[]) 
  69. {
  70.   WINDOW *w;
  71.   int randx, randy;
  72.   int i;
  73.   char *wordz, pbuf[20];
  74.   char *words[] = {
  75.     "DRUGZ!",
  76.     "B4B0 ROCKING THE HOUSE!",
  77.     "NIGGER!",
  78.     "CRACKHEAD!",
  79.     "CUNTLIPS!",
  80.     "FUCKASS!",
  81.     "DILLMONKEY"
  82.     "CRACK!", 
  83.     "TWEAK!", 
  84.     "CRANK!",
  85.     "VODKA!",
  86.         "PENIS!",
  87.     "BOOBS!",
  88.         "SPERM!",
  89.     "PUSSY!",
  90.         "BITCH!",
  91.     "CHINK!",
  92.     "SKANK!",
  93.         "WHORE!",
  94.         "QUEER!",
  95.     "LAMER!",
  96.     "LOSER!",
  97.     "DRUNK!",
  98.       NULL
  99.   };
  100.  
  101.   init_all();
  102.  
  103.   if((fd = open("/dev/tty", O_RDWR)) < 0) {
  104.     perror("cannot open tty");
  105.     exit(-1);
  106.   }
  107.                                                    
  108.   LOCK(fd);
  109.  
  110.   while(1) {
  111.  
  112.     srand(time(0));
  113.  
  114.     wordz = words[rand() % NUMWORDS];
  115.  
  116.     if(strlen(wordz) > 6) {
  117.  
  118.           i = (79 - (strlen(wordz) + 2)); 
  119.     randx = rand() % i;
  120.     randy = rand() % 21; 
  121.  
  122.      }
  123.  
  124.      else {
  125.  
  126.     randx = rand() % 71;
  127.     randy = rand() % 21;    
  128.  
  129.     }
  130.  
  131.      w = newwin(3, strlen(wordz) + 2, randy, randx);
  132.        mvwprintw(w, 1, 1, "%s", wordz);
  133.        box(w, ACS_VLINE, ACS_HLINE);
  134.        wrefresh(w);
  135.        sleep(1);
  136.        wclear(w);
  137.        wrefresh(w);
  138.        delwin(w);
  139.          
  140.        if(getch() > 0) {
  141.          w = newwin(3, 25, 10, 35);
  142.          mvwprintw(w, 1, 1, "password: ");
  143.          box(w, ACS_VLINE, ACS_HLINE);
  144.          wrefresh(w);
  145.      wgetstr(w, pbuf);
  146.      wrefresh(w);
  147.      if((strcmp(passwd, pbuf)) == 0) 
  148.        break; 
  149.                 
  150.       else     {    
  151.          wclear(w);
  152.         wrefresh(w);
  153.         delwin(w);    
  154.         continue; 
  155.       }    
  156.       }    
  157.   }        
  158.  
  159.   endwin();
  160.   UNLOCK(fd);
  161.   return 0;
  162.  
  163. }
  164.  
  165.  
  166.