SHARE
TWEET

Untitled

a guest Jul 17th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/ioctl.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <linux/kd.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8.  
  9. int main(int argc, char* argv[]) {
  10.  
  11.     int fd = open("/dev/console", O_WRONLY);
  12.  
  13.     if (fd < 0) {
  14.         printf("can't open console\n");
  15.         return fd;
  16.     }
  17.  
  18.     if (geteuid()) {
  19.         printf("use:\n\tsudo %s\n", argv[0]);
  20.         return -1;
  21.     }
  22.  
  23.     for (int t=0;;t++) {
  24.         int val = (t*(((t>>12)|(t>>8))&(63&(t>>4))));
  25.         printf("%d\n", val);
  26.         ioctl(fd, KIOCSOUND, val);
  27.         usleep(25000);
  28.     }
  29.  
  30.     return 0;
  31. }
RAW Paste Data
Top