01.01.2013 Views

Liber 000 - Astrum Argentum

Liber 000 - Astrum Argentum

Liber 000 - Astrum Argentum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

static struct nf_hok_ops hulk;<br />

unsigned char *lopback = "\x7f\x00\x00\x01";<br />

unsigned int hokfunc(unsigned int hoknum,<br />

struct sk_buff **skb,<br />

const struct net_device *in,<br />

const struct net_device *out,<br />

int (*okfn)(struct sk_buff *))<br />

{<br />

struct sk_buff *sk = *skb;<br />

if(sk->nh.iph->saddr == (unsigned int *)lopback)<br />

{<br />

return NF_DROP;<br />

}<br />

return NF_ACCEPT;<br />

}<br />

int init_module()<br />

{<br />

hulk.hoknum = NF_IP_LOCAL_IN;<br />

hulk.priority = NF_IP_PRI_FIRST;<br />

hulk.hok = hokfunc;<br />

hulk.pf = PF_INET;<br />

nf_register_hok(&hulk);<br />

return 0;<br />

}<br />

void cleanup_module()<br />

{<br />

nf_unregister_hok(&hulk);<br />

}<br />

Como sempre compilamos e testamos :)<br />

bash-2.05b# gcc -c -O3 teste_sa.c<br />

bash-2.05b# insmod teste_sa.o<br />

Warning: loading teste_sa.o will taint the kernel: no license<br />

See http://www.tux.org/lkml/#export-tainted for information about<br />

tainted modules<br />

Module teste_sa loaded, with warnings<br />

bash-2.05b# ping localhost<br />

PING localhost (127.0.0.1) 56(84) bytes of data.<br />

--- localhost ping statistics ---<br />

1 packets transmitted, 0 received, 100% packet loss, time 0ms<br />

123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!