Skip to contentSkip to conversation

(unknown)

DISCUSSION David Boulding 2 participants 7 messages Jul 27, 2008 – Jul 29, 2008 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hey all,

I'm developing with libnetfilter_queue, using "iptables -A FORWARD ." to capture packets of interest on a bridge for analysis (firewall). I use nfq_get_payload() to grab everything from the IP layer and on, but I was wondering if there was any way to get the raw MAC layer. Is there any command like nfq_get_payload() that will return everything similar to what you would get using wireshark or ethereal?

Thanks,

Dave

#1 lore raw

Re: your mail

Hello,

Quoted 8 lines · David Boulding

Hey all,

I'm developing with libnetfilter_queue, using "iptables -A FORWARD ." to capture packets of interest on a bridge for analysis (firewall). I use nfq_get_payload() to grab everything from the IP layer and on, but I was wondering if there was any way to get the raw MAC layer. Is there any command like nfq_get_payload() that will return everything similar to what you would get using wireshark or ethereal?

You can use nfq_get_packet_hw():

Retrieves the hardware address associated with the given queued packet. For ethernet packets, the hardware address returned (if any) will be the MAC address of the packet source host. The destination MAC address is not known until after POSTROUTING and a successful ARP request, so cannot currently be retrieved.

The nfqnl_msg_packet_hw structure is defined in "libnetfilter_queue/libnetfilter_queue.h" as:

struct nfqnl_msg_packet_hw {
u_int16_t hw_addrlen;
u_int16_t _pad;
u_int8_t hw_addr[8];
} __attribute__ ((packed));
.

http://lists.netfilter.org/pipermail/netfilter-devel/2006-February/023286.html

BR,

Signature · 3 lines
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
#2 lore raw

Re: your mail

Thanks for the reply.
I knew of nfq_get_packet_hw(), but I'm looking for a way to get the raw byte array of the header that I get from the nfq_get_payload() call. I'm not only looking for the MAC header information (which nfq_get_packet_hw() will give me easy enough), but whatever else is there, for example PPPoE and PPP header information. Is there anyway to get that?

Thanks,

Dave

Quoted 37 lines · Eric Leblond

Hello,

Quoted 8 lines · David Boulding

Hey all,

I'm developing with libnetfilter_queue, using "iptables -A FORWARD ." to capture packets of interest on a bridge for analysis (firewall). I use nfq_get_payload() to grab everything from the IP layer and on, but I was wondering if there was any way to get the raw MAC layer. Is there any command like nfq_get_payload() that will return everything similar to what you would get using wireshark or ethereal?

You can use nfq_get_packet_hw():

Retrieves the hardware address associated with the given queued packet. For ethernet packets, the hardware address returned (if any) will be the MAC address of the packet source host. The destination MAC address is not known until after POSTROUTING and a successful ARP request, so cannot currently be retrieved.

The nfqnl_msg_packet_hw structure is defined in "libnetfilter_queue/libnetfilter_queue.h" as:

struct nfqnl_msg_packet_hw {
u_int16_t hw_addrlen;
u_int16_t _pad;
u_int8_t hw_addr[8];
} __attribute__ ((packed));
.

http://lists.netfilter.org/pipermail/netfilter-devel/2006-February/023286.html

BR,
--
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/

#4 lore raw

Re: your mail

In reply to a message not in the archive

Hello,

Quoted 5 lines · David Boulding

Thanks for the reply.
I knew of nfq_get_packet_hw(), but I'm looking for a way to get the raw byte

Quoted 3 lines
Quoted 3 lines

I'm developing with libnetfilter_queue, using "iptables -A FORWARD ." to capture packets of interest on a bridge for analysis (firewall).

As you said "analysis", you may only want to "sniff" packet. In that case, you can use NFLOG (latest git) or ULOG.

NFQUEUE moudle uses the dev_parse_header() function which only return the source hardware address. You will not be able to retrieve the wanted information without patching the kernel.

BR,

Signature · 3 lines
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
#5 lore raw

Re: your mail

I've never heard of NFLOG or ULOG, is there any documentation under netfilter on how to use it? How would I get the data that I want (to sniff) using NFLOG/ULOG?

Dave

Quoted 31 lines · Eric Leblond

Hello,

Quoted 5 lines · David Boulding

Thanks for the reply.
I knew of nfq_get_packet_hw(), but I'm looking for a way to get the raw byte

Quoted 3 lines
Quoted 3 lines

I'm developing with libnetfilter_queue, using "iptables -A FORWARD ." to capture packets of interest on a bridge for analysis (firewall).

As you said "analysis", you may only want to "sniff" packet. In that case, you can use NFLOG (latest git) or ULOG.

NFQUEUE moudle uses the dev_parse_header() function which only return the source hardware address. You will not be able to retrieve the wanted information without patching the kernel.

BR,
--
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkiN2x0ACgkQnxA7CdMWjzJSmQCdHBt2ro5Tx7m5GbWhl7uGZz7l 5H8Anjc9CaBwO/tOVaywfm+WwzeeBayE
=felb
-----END PGP SIGNATURE-----

#6 lore raw

Re: your mail

Hello,

Quoted 3 lines · David Boulding

I've never heard of NFLOG or ULOG, is there any documentation under netfilter on how to use it? How would I get the data that I want (to sniff) using NFLOG/ULOG?

For ULOG, you can have a look at ulogd or ulogd2 code.

	http://git.netfilter.org/cgi-bin/gitweb.cgi?p=ulogd2.git;a=blob;f=input/packet/ulogd_inppkt_ULOG.c;h=c00d9bf8a965be7f961738892e19191efcf8f691;hb=0b789ea9bf810497845456e9b83bff8c5ae5ca23

By the way, as ulogd2 uses a plugin mechanism, you may be able to build what you want by coding an ulogd2 plugin. It can provide you a way to code something independant from low level (NFLOG or ULOG can be used as input without changing your plugin).

A mini doc about ulogd2 hacking is available here:

	http://home.regit.org/?page_id=90

For NFLOG, you need to use latest git for kernel and libnetfilter_log.

The following functions are available:

- nflog_get_hwtype: to fetch hardware type (and thus give the parser to use)
- nflog_get_msg_packet_hwhdrlen: to get hardware header len
- nflog_get_msg_packet_hwhdr: get hardware datas

BR,

Signature · 3 lines
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
#7 lore raw

Re: your mail

Thanks for the help!

Dave

Quoted 41 lines · Eric Leblond

Hello,

Quoted 3 lines · David Boulding

I've never heard of NFLOG or ULOG, is there any documentation under netfilter on how to use it? How would I get the data that I want (to sniff) using NFLOG/ULOG?

For ULOG, you can have a look at ulogd or ulogd2 code.

       http://git.netfilter.org/cgi-bin/gitweb.cgi?p=ulogd2.git;a=blob;f=input/packet/ulogd_inppkt_ULOG.c;h=c00d9bf8a965be7f961738892e19191efcf8f691;hb=0b789ea9bf810497845456e9b83bff8c5ae5ca23

By the way, as ulogd2 uses a plugin mechanism, you may be able to build what you want by coding an ulogd2 plugin. It can provide you a way to code something independant from low level (NFLOG or ULOG can be used as input without changing your plugin).

A mini doc about ulogd2 hacking is available here:

       http://home.regit.org/?page_id=90

For NFLOG, you need to use latest git for kernel and libnetfilter_log.

The following functions are available:

- nflog_get_hwtype: to fetch hardware type (and thus give the parser to use)
- nflog_get_msg_packet_hwhdrlen: to get hardware header len
- nflog_get_msg_packet_hwhdr: get hardware datas

BR,
--
Eric Leblond
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIjsKinxA7CdMWjzIRAofmAJ9mi4P5SRkPugu8wADwtmB2LlHmigCfWjNn E77TPzKV3LStdfYgpFCobVA=
=ruvK
-----END PGP SIGNATURE-----