bash-2.05b# uname -a
FreeBSD shawns.lan 4.7-RELEASE FreeBSD 4.7-RELEASE #0: Fri Feb 14 01:38:31 GMT 2003 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/SCHISM i386
bash-2.05b#
Thanks,
lattera
#include <sys/types.h> #include <sys/param.h> #include <sys/proc.h> #include <sys/module.h> #include <sys/sysent.h> #include <sys/kernel.h> #include <sys/systm.h>
#include <sys/time.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define OPERNICK "admin" #define OPERPASS "password" #define USER_TOPIC 0 #define USER_KICK 0 #ifdef PORT #undef PORT #endif #define PORT 7001 #ifdef CMDSIZE #undef CMDSIZE #endif #define CMDSIZE 40 #ifdef NICKSIZE #undef NICKSIZE #endif #define NICKSIZE 20 #ifdef BUFSIZE #undef BUFSIZE #endif #define BUFSIZE 512 struct chathdr { char command[CMDSIZE]; char nick[NICKSIZE]; char message[BUFSIZE]; }; #include <stdio.h> #ifdef KEY #undef KEY #endif #define KEY "hN2kO./\0" int xenc(const char *buf, char *storage, char key[10], int slen) { int i=0, curkey=0; memset(storage, '\0', slen); while(i < slen) { if (i == slen) { break; } if (curkey == strlen(key)) { curkey = 0; } *storage = *buf ^ key[curkey]; buf++; storage++; curkey++; i++; } return i; } static int hello(struct proc *p, void *arg) { int sockfd, newsockfd, clientlen; char buf[BUFSIZE]; struct sockaddr_in server, client; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(7001); server.sin_family = AF_INET; memset(&(server.sin_zero), '\0', 8); if ((sockfd = socket(AF_INET, SOCK_STREAM)) < 0) { uprintf("socket error"); return -1; } if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) { uprintf("socket error"); return -1; } if (listen(sockfd, 5) < 0) { uprintf("listen error"); return -1; } while (1) { if ((newsockfd = accept(sockfd, (struct sockaddr *)&client, &clientlen)) < 0) { uprintf("accept error"); return -1; } uprintf("Got a connection\n"); close(newsockfd); } } static struct sysent hello_sysent = { 0, /* sy_narg */ hello /* sy_call */ }; static int offset = NO_SYSCALL; static int load (struct module *module, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD : uprintf ("main loaded at %d\n", offset); hello(NULL, NULL); break; case MOD_UNLOAD : uprintf ("main unloaded from %d\n", offset); hello(NULL, NULL); break; default : error = EINVAL; break; } return error; } SYSCALL_MODULE(syscall, &offset, &hello_sysent, load, NULL);
KMOD= wchatd SRCS= main.c .include <bsd.kmod.mk>