LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-05-2006, 01:02 AM   #1
venkatesh111
Member
 
Registered: Mar 2006
Posts: 34

Rep: Reputation: 15
displaying STOLEN packets stolen using NF_STOLEN


Hi,
i have a simple netfilter program from which im trying to steal the packets passing accross the network im using NF_STOLEN and i need to display the stolen packets


my netfilter program:

//Filtering packets based on their source address
/* Sample code to install a Netfilter hook function that will
* drop all incoming packets from an IP address we specify */

// #define __KERNEL__
// #define MODULE

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/ip.h> /* For IP header */
#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;

/* IP address we want to drop packets from, in NB order */
static unsigned char *drop_ip = "\xac\x01\x02\x6a"; /*172.1.2.106*/

/* 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 *))
{
struct sk_buff *sb = *skb;

if (sb->nh.iph->saddr ==*(unsigned int*) drop_ip) {
/*here im just tryng to print srcaddr and total length just for my refeence*/
printk("\n\nIP source address:%d",sb->nh.iph->saddr);
printk("\n\nTotal Length:%d",sb->nh.iph->tot_len);
/*printk("Dropped packet from... %d.%d.%d.%d\n",
*drop_ip, *(drop_ip + 1),
*(drop_ip + 2), *(drop_ip + 3));
return NF_DROP;*/
return NF_STOLEN;

} 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 for IPv4 */
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST; /* Make our func first */

nf_register_hook(&nfho);

return 0;
}

/* Cleanup routine */
void cleanup_module()
{
nf_unregister_hook(&nfho);
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("VENKAT");

then i compiled the above program using :

gcc -I/lib/modules/`uname -r`/build/include -D__KERNEL__ -DMODULE -DLINUX -O2 -c -o nfaddr.o nfaddr.c

compilation successfull.....

i inserted the module using:
insmod nfaddr.o

module insertion succesfull........

then next step was

ping 172.1.2.106

output on console was:

[root@localhost venki]# ping 172.1.2.106
PING 172.1.2.106 (172.1.2.106) 56(84) bytes of data.

--- 172.1.2.106 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2025ms

so this means that the packets are not received and they are stolen now where are these stolen packets and how do i display them on to console....



The below statements were just to check if module was successfull r not.
i cheacked the messages at /var/log/messages

Apr 6 11:37:06 localhost kernel:
Apr 6 11:37:06 localhost kernel:
Apr 6 11:37:06 localhost kernel: IP source address:1778516396
Apr 6 11:37:06 localhost kernel:
Apr 6 11:37:07 localhost kernel: Total Length:21504
Apr 6 11:37:07 localhost kernel:
Apr 6 11:37:07 localhost kernel: IP source address:1778516396
Apr 6 11:37:07 localhost kernel:
Apr 6 11:37:08 localhost kernel: Total Length:21504
Apr 6 11:37:08 localhost kernel:
Apr 6 11:37:08 localhost kernel: IP source address:1778516396
Apr 6 11:37:08 localhost kernel:


now how do i display the stolen packets

Last edited by venkatesh111; 04-05-2006 at 01:09 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My case just got stolen... BinJajer General 9 01-08-2006 04:27 PM
Hostname Stolen!!! cmsustud19 Linux - Newbie 3 04-02-2004 12:22 PM
Stolen sound ! ecsfan Linux - Hardware 1 04-02-2004 05:42 AM
Stolen Code HCour General 5 02-03-2004 02:02 PM
My games were stolen... :( vbp6us General 12 03-15-2003 02:47 AM


All times are GMT -5. The time now is 05:22 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration