Testing Linux skills
Bryan Sant
bryan.sant at gmail.com
Wed Jan 18 19:59:52 MST 2006
On 1/18/06, Michael Halcrow <mike at halcrow.us> wrote:
> Heh. Here, I've got something to throw in root's crontab:
>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <time.h>
> #include <stdio.h>
>
> int main()
> {
> int fd;
> unsigned long offset;
> char buf;
>
> srand(time(NULL));
> offset = rand() % 2000000;
> buf = offset % 255;
> fd = open("/proc/kcore", O_WRONLY); /* You need SE Linux ;-) */
> if (fd == -1) {
> printf("Run me as root\n");
> return 1;
> }
> lseek(fd, offset, SEEK_SET);
> write(fd, &buf, 1);
> close(fd);
> return 0;
> }
Or for the lazy:
while true; do
cat /dev/random > /proc/kcore
done
More information about the PLUG
mailing list