Skip to contentSkip to conversation

fisrt post on the list whit a few questions

DISCUSSION Jorge Garcia 1 participant 1 message Mar 15, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi, here is one of the codes from prhrack article:
/* Sample code to install a Netfilter hook function that will
* drop all incoming packets on an interface we specify */ #define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
/* This is the structure we shall use to register our function */
static struct nf_hook_ops nfho;

/* Name of the interface we want to drop packets from */
static char *drop_if = "lo";

/* This is the hook function itself */
unsigned int hook_func(unsigned int hooknum,
struct sk_buff **skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *))

{
    if (strcmp(in->name, drop_if) == 0) {
        printk("Dropped packet on %s...\n", drop_if);
        return NF_DROP;
    } else {
        return NF_ACCEPT;
    }
}

/* Initialisation routine */
int init_module()

{
    /* Fill in our hook structure */
    nfho.hook     = hook_func;         /* Handler function */
    nfho.hooknum  = NF_IP_PRE_ROUTING; /* First hook for IPv4 */
    nfho.pf       = PF_INET;
    nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */
  
    nf_register_hook(&nfho);
    
    return 0;
}

/* Cleanup routine */
void cleanup_module()

{
    nf_unregister_hook(&nfho);
}

OK, this filter incoming anbd outcomming connections, how do i filter for example only incoming traffic?? I have more questions abouts some codes in this article but for now i want to know how to do this. Thanx for everithing and here is the link to the phrack article that is very intresting:
http://www.phrack.org/show.php?p=61&a=13

Hi Jorge,

Quoted 4 lines · Jorge Garcia

Hi, Im from Montevideo Uruguay, so u have to excuse my english.
Im using netfilter iptables for about 4 months and i really like the product, now im reading about the netfilter programming modules that i find in a phrack article.

I recommend you reading the netfilter hacking-how. Those articles that you read are ok, but maybe they consider some things obvious.

Quoted 3 lines

The modules dont do ehat is expected to do, like in list2.c the program filter input and output interfaces.

could you could post to the list the relevance section of the source code? I don't know where's that file.

Quoted 7 lines

If i want to filter only incoming packets, how do i do that??

My second question its about security, the security advisories on the page are old ones and doesnt work for new kernels. I want to know if is there any vulneability more new for testing becouse im writing a paper about netfilter security in spanish.

as far as I know, those are all the security asvisories. If there's more, they would be published.

regards,
Pablo

http://www.latinmail.com - La forma más cómoda de enviar y recibir tus e-mails