/***********************************************
 * released under (E) licensing ...            *
 *        (E) RULES AND REGULATIONS            *
 * permission to use/rewrite/add     : granted *
 * permission to trojan/steal        : denied  *
 * permission to use illegally       : denied  *
 * permission to use on /dev/urandom : denied  *
 ***********************************************/
/* contact el8@press.co.jp for full license    */
/* code copyrighted by ~el8 -- don't infringe! */

/*
   PAGER.C BY CHEIF ROTTINGHAM
   catch me on dalnet im there #2600 usually or #hack
   ok this proggie is very simple, operation ramprat helped me out alot,
   i give him great thanks
   heres how it works define your pass
   default pass is ~el8
   you can define yuur own pagerport which is quite cool too
   and maxsleeptime is how long the tone plays
   if yuu run the proggie with an argument, /bin/pager 1
   itll only sleep 1 second when paged
   yuu likely will no t hear it etc
   i got one quote
   fuck you script kiddies learn code, lamers
 */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/kd.h>
#define P4SSWD "~el8"
#define PAGERPORT 6971
#define BACKL0G 1
int MAXSLEEPTIME = 10;
int d0p4g3r(void);
int d0p4g3r(void)
{
    int k0q;
    if ((k0q = open("/dev/console", O_RDWR | O_NOCTTY)) < 0) {
	perror("0p3n");
	exit(-1);
    }
    if (ioctl(k0q, KIOCSOUND, 2600) < 0) {
	perror("10ctl");
	exit(-1);
    }
    sleep(MAXSLEEPTIME);
    if (ioctl(k0q, KIOCSOUND, 0) < 0) {
	perror("10ctl");
	exit(-1);
    }
    close(k0q);
    return 1;
}
int daem0n(void)
{
    pid_t pid;
    if ((pid = fork()) != 0)
	exit(0);
    setsid();
    signal(SIGHUP, SIG_IGN);
    if ((pid = fork()) != 0)
	exit(0);
    chdir("/");
    umask(0);
    signal(SIGHUP, SIG_DFL);
    return (1);
}
int main(int argc, char *argv[])
{
    int sfd;
    int nfd;
    char pass[520];
    struct sockaddr_in yoyo;
    unsigned int maxtime;
    if (argv[1] != '\0') {
	maxtime = atoi(argv[1]);
	printf("%i\n", maxtime);
	MAXSLEEPTIME = maxtime;
    }
    if (!daem0n())
	exit(-1);
    bzero(&yoyo, sizeof(yoyo));
    yoyo.sin_family = AF_INET;
    yoyo.sin_port = htons(PAGERPORT);
    yoyo.sin_addr.s_addr = INADDR_ANY;
    sfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sfd < 0) {
	perror("s0ck3t");
	exit(-1);
    }
    if (bind(sfd, (struct sockaddr *) &yoyo, sizeof(yoyo)) < 0) {
	perror("b1nd");
	exit(-1);
    }
    listen(sfd, BACKL0G);
    for (;;) {
	if ((nfd = accept(sfd, 0, 0)) < 0) {
	    perror("4cc3pt");
	    exit(-1);
	}
	if (send(nfd, "3nt3r p4sswd>\r\n", strlen("3nt3r p4sswd>\r\n"), 0) < 0) {
	    perror("s3nd");
	    exit(-1);
	}
	if (recv(nfd, pass, sizeof pass, 0) < 0) {
	    perror("r3cv");
	    exit(-1);
	}
	if (!strncmp(pass, P4SSWD, strlen(P4SSWD))) {
	    if (send(nfd, "C()X\r\n", 6, 0) < 0) {
		perror("s3nd");
		exit(-1);
	    }
	    d0p4g3r();
	    break;
	}
	close(nfd);
    }
    return 1;
}


syntax highlighted by Code2HTML, v. 0.9.1