exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

obsd_nospoof.c

obsd_nospoof.c
Posted May 23, 2000
Authored by s0ftpj, Pigpen | Site s0ftpj.org

Anti-spoofing lkm for OpenBSD via setsockopt() - detects and logs IP header manipulation.

tags | spoof
systems | openbsd
SHA-256 | fca4eaa52977935a2efb9a116a709ae0a74a82aa8047fb6d7c04baf8fddfd9e4

obsd_nospoof.c

Change Mirror Download
/*
* Name: NoSpoof v1beta
* Date: May 23 04:06:37 2000
* Author: pIGpEN [ pigpen@s0ftpj.org, deadhead@sikurezza.org ]
*
* SoftProject Digital Security for Y2K
* Sikurezza.org Italian Security Mailing List
*
* COFFEE-WARE LICENSE - This source code is like "THE BEER-WARE LICENSE" by
* Poul-Henning Kamp <phk@FreeBSD.ORG> but you can give me in return a coffee.
*
* Tested on: OpenBSD 2.6 kern#0 i386
*/

#define DONT_PERMIT

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/syscall.h>
#include <sys/mount.h>
#include <sys/conf.h>
#include <sys/syscallargs.h>
#include <sys/exec.h>
#include <sys/lkm.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/errno.h>

#include <sys/proc.h>
#include <sys/syslog.h>

#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <netinet/in.h>



int my_setsockopt __P((struct proc *, void *, register_t *));


MOD_MISC("NoSpoof");

static int
NoSpoof_load(struct lkm_table *lkmtp, int cmd)
{
if(cmd == LKM_E_LOAD) {
printf("EXtern Sp00fiNG Pr0tection\n");
printf("(c) Coffeeware - SoftProject Y2k\n");
printf("pIGpEN / s0ftpj\n");
sysent[SYS_setsockopt].sy_call = my_setsockopt;
}

return 0;
}


static int
NoSpoof_unload(struct lkm_table *lkmtp, int cmd)
{
if(cmd == LKM_E_UNLOAD) {
printf("NoSp00f unloaded\n");
sysent[SYS_setsockopt].sy_call = sys_setsockopt;
}

return 0;
}


NoSpoof( lkmtp, cmd, ver)
struct lkm_table *lkmtp;
int cmd;
int ver;
{
DISPATCH(lkmtp, cmd, ver, NoSpoof_load, NoSpoof_unload, lkm_nofunc);
}


int
my_setsockopt(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
register struct sys_setsockopt_args *uap = v;
struct file *fp;
struct mbuf *m = NULL;
int error;

if(SCARG(uap, level) == IPPROTO_IP &&
SCARG(uap, name) == IP_HDRINCL) {
log(LOG_INFO, "detect IP_HDRINCL invoked by %s\n", p->p_comm);
#ifdef DONT_PERMIT
log(LOG_INFO, "ip header manipulation denied!\n");
return EPERM;
#endif
}

if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
if (SCARG(uap, valsize) > MLEN)
return (EINVAL);
if (SCARG(uap, val)) {
m = m_get(M_WAIT, MT_SOOPTS);
if (m == NULL)
return (ENOBUFS);
error = copyin(SCARG(uap, val), mtod(m, caddr_t),
SCARG(uap, valsize));
if (error) {
(void) m_free(m);
return (error);
}
m->m_len = SCARG(uap, valsize);
}
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
SCARG(uap, name), m));
}

/*

SRCS=obsd_nospoof.c
OBJS=$(SRCS:.c=.o)

MODOBJ=NoSpoof.o

KMOD=NoSpoof
CFLAGS+= -D_KERNEL -I/sys

all: $(MODOBJ)

clean:
rm -f $(OBJS) $(KOBJS) $(MODOBJ) $(KMOD)

load:
modload -o $(KMOD) -e$(KMOD) $(MODOBJ)

unload:
modunload -n $(KMOD)

$(MODOBJ): $(OBJS) $(KOBJS)
$(LD) -r -o $(MODOBJ) $(OBJS) $(KOBJS)
*/
Login or Register to add favorites

File Archive:

October 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    39 Files
  • 2
    Oct 2nd
    23 Files
  • 3
    Oct 3rd
    18 Files
  • 4
    Oct 4th
    20 Files
  • 5
    Oct 5th
    0 Files
  • 6
    Oct 6th
    0 Files
  • 7
    Oct 7th
    17 Files
  • 8
    Oct 8th
    66 Files
  • 9
    Oct 9th
    25 Files
  • 10
    Oct 10th
    20 Files
  • 11
    Oct 11th
    21 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    14 Files
  • 15
    Oct 15th
    49 Files
  • 16
    Oct 16th
    0 Files
  • 17
    Oct 17th
    0 Files
  • 18
    Oct 18th
    0 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close