Change Packet Payload
Hi every one!
I have the next dude :D
im using libnetfilter_queue lib, its posible to change any value of the packet, source address, icmp types, payload chars, or any data of the packet received on the Handler (nfq_create_queue(h,0,&MyHandler,NULL)) and send it again with the correct checksum?
Thanks in advanced!
Hi,
Quoted 5 lines · Luis Campo Giralte
Hi every one!
im usinglibnetfilter_queuelib, its posible to change any value of the packet, source address, icmp types, payload chars, or any data of the packet received on the Handler (nfq_create_queue(h,0,&MyHandler,NULL)) and send it again with the correct checksum?
Yes, but you have to compute the checksum yourself.
BR,
Signature · 2 lines
Eric Leblond <[email protected]> INL
fre 2007-02-09 klockan 10:31 +0100 skrev Eric Leblond:
Quoted 10 lines
Hi,
Quoted 5 lines · Luis Campo Giralte
Hi every one!
im usinglibnetfilter_queuelib, its posible to change any value of the packet, source address, icmp types, payload chars, or any data of the packet received on the Handler (nfq_create_queue(h,0,&MyHandler,NULL)) and send it again with the correct checksum?Yes, but you have to compute the checksum yourself.
And also make sure conntrack isn't loaded as it does not expect QUEUE to rewrite things.. unless you QUEUE in the raw table PREROUTING before conntrack is invoked..
Regards
Henrik
Pablo Neira Ayuso
maintainerHi Eric,
Quoted 8 lines · Eric Leblond
Quoted 5 lines · Luis Campo Giralte
Hi every one!
im usinglibnetfilter_queuelib, its posible to change any value of the packet, source address, icmp types, payload chars, or any data of the packet received on the Handler (nfq_create_queue(h,0,&MyHandler,NULL)) and send it again with the correct checksum?Yes, but you have to compute the checksum yourself.
I would accept a patch to introduce a function that computes the checksum. I think that the library should provide as much helper functions as possible. We can group such helper functions by protocols in different files inside the libnetfilter_queue tree. I have already seen several post in the mailing list on how to retrieve data from the header and such.
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Hi Pablo,
I wrote this simple patch.
Any comment on it, naming conventions, better approach, etc.. appreciated
Quoted 9 lines · Pablo Neira Ayuso
I would accept a patch to introduce a function that computes the checksum. I think that the library should provide as much helper functions as possible. We can group such helper functions by protocols in different files inside the
libnetfilter_queuetree. I have already seen several post in the mailing list on how to retrieve data from the header and such.
libnetfilter_queue/Makefile.am +1 -1
@@ -1,3 +1,3 @@ -pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h +pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h protocol_any_helper.h
libnetfilter_queue/libnetfilter_queue.h +1 -2
@@ -14,9 +14,8 @@#define __LIBCTNETLINK_H#include <libnfnetlink/libnfnetlink.h> -// #include <libnfnetlink/liunx_nfnetlink.h> -#include <libnetfilter_queue/linux_nfnetlink_queue.h> +#include <libnetfilter_queue/protocol_any_helper.h> struct nfq_handle ;struct nfq_q_handle ;
libnetfilter_queue/protocol_any_helper.h +17 -0
@@ -0,0 +1,17 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +extern unsigned short nfq_compute_cksum (struct nfq_data *nfad); +
protocol_any_helper.c +53 -0
53 lines not on this page · raw message
Makefile.am +1 -1
@@ -10,7 +10,7 @@ libnetfilter_queue_la_LDFLAGS = -Wc,-nostartfiles -lnfnetlink \ -version-info $(LIBVERSION) -libnetfilter_queue_la_SOURCES = libnetfilter_queue.c +libnetfilter_queue_la_SOURCES = libnetfilter_queue.c protocol_any_helper.c libnetfilter_queue_libipq_la_LDFLAGS = -Wc,-nostartfiles \ -version-info 1:0:0
Hi Pablo,
I wrote this simple patch.
Any comment on it, naming conventions, better approach, etc.. appreciated
Quoted 8 lines · Pablo Neira Ayuso
I would accept a patch to introduce a function that computes the checksum. I think that the library should provide as much helper functions as possible. We can group such helper functions by protocols in different files inside the
libnetfilter_queuetree. I have already seen several post in the mailing list on how to retrieve data from the header and such.
libnetfilter_queue/Makefile.am +1 -1
@@ -1,3 +1,3 @@ -pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h +pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h protocol_any_helper.h
libnetfilter_queue/libnetfilter_queue.h +1 -2
@@ -14,9 +14,8 @@#define __LIBCTNETLINK_H#include <libnfnetlink/libnfnetlink.h> -// #include <libnfnetlink/liunx_nfnetlink.h> -#include <libnetfilter_queue/linux_nfnetlink_queue.h> +#include <libnetfilter_queue/protocol_any_helper.h> struct nfq_handle ;struct nfq_q_handle ;
libnetfilter_queue/protocol_any_helper.h +17 -0
@@ -0,0 +1,17 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +extern unsigned short nfq_compute_cksum (struct nfq_data *nfad); +
protocol_any_helper.c +53 -0
53 lines not on this page · raw message
Makefile.am +1 -1
@@ -10,7 +10,7 @@ libnetfilter_queue_la_LDFLAGS = -Wc,-nostartfiles -lnfnetlink \ -version-info $(LIBVERSION) -libnetfilter_queue_la_SOURCES = libnetfilter_queue.c +libnetfilter_queue_la_SOURCES = libnetfilter_queue.c protocol_any_helper.c libnetfilter_queue_libipq_la_LDFLAGS = -Wc,-nostartfiles \ -version-info 1:0:0
Quoted 5 lines · Sebastien Tricaud
Index:
src/protocol_any_helper.c
===================================================================
protocol_any_helper.c line 24
Quoted 9 lines
protocol_any_helper.c +7
-0@@ -0,0 +1,53 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation +*/ +/* (c) Richard W. Stevens */ +unsigned short nfq_compute_cksum (unsigned short *data,int len)
Do you have permission to put this under the GPL?
Quoted 8 lines · Patrick McHardy
protocol_any_helper.c line 24
Quoted 3 lines
protocol_any_helper.c +2
-0+/* (c) Richard W. Stevens */ +unsigned short nfq_compute_cksum (unsigned short *data,int len)Do you have permission to put this under the GPL?
Good point.
As far as I know, this is public domain. However I will make sure of it and be back with an answer.
This code is in several public domain or GPL tools. For example nessus uses it :
http://cvsweb.nessus.org/cgi-bin/viewcvs.cgi/nessus-libraries/libnessus/network.c?rev=1.28
It is not a proof yet but I'm pretty confident. I have the book at home and I will look at it tonight (Appendix F : Source code availability).
Quoted 19 lines · Sebastien Tricaud
Quoted 9 lines · Patrick McHardy
protocol_any_helper.c line 24
Quoted 4 lines
protocol_any_helper.c +2
-0+/* (c) Richard W. Stevens */ +unsigned short nfq_compute_cksum (unsigned short *data,int len)Do you have permission to put this under the GPL?
Good point.
As far as I know, this is public domain. However I will make sure of it and be back with an answer.
Quoted 3 lines · Sebastien Tricaud
This code is in several public domain or GPL tools. For example nessus uses it :
http://cvsweb.nessus.org/cgi-bin/viewcvs.cgi/nessus-libraries/libnessus/network.c?rev=1.28
Yes, I found some other users of this as well, but as you say, that doesn't necessarily mean its OK to use.
Quoted 2 lines
It is not a proof yet but I'm pretty confident. I have the book at home and I will look at it tonight (Appendix F : Source code availability).
Thanks.
Pablo Neira Ayuso
maintainerQuoted 7 lines · Patrick McHardy
Quoted 3 lines · Sebastien Tricaud
This code is in several public domain or GPL tools. For example nessus uses it :
http://cvsweb.nessus.org/cgi-bin/viewcvs.cgi/nessus-libraries/libnessus/network.c?rev=1.28Yes, I found some other users of this as well, but as you say, that doesn't necessarily mean its OK to use.
The code seems very similar to the one that is available in RFC1071. I recently added initial support for message checksumming to conntrackd and used that code (slightely modified) indicating the source, thus not explicitely licensing that part as GPL since I don't own the copyright of it. Can we consider examples available in a RFC as public domain code?
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Hi Pablo,
I can't find any information for licensing issues for Stevens material. However for IETF stuff, reading RFC 3978 section 3.3 seems pretty clear.
In short :
"the Contributor, and each named co-Contributor, and the organization he or she represents or is sponsored by (if any) grant a perpetual, irrevocable, non-exclusive, royalty-free, world-wide right and license to the ISOC and the IETF under all intellectual property rights in the Contribution:"
"to extract, copy, publish, display, distribute, modify and incorporate into other works, for any purpose (and not limited to use within the IETF Standards Process) any executable code or code fragments that are included in any IETF Document (such as MIB and PIB modules)"
Then there is a follow up to section 5 which states that taking code or quotes requires the following :
"Copyright (C) The Internet Society <year>. This version of this MIB module is part of RFC XXXX; see the RFC itself for full legal notices."
As for checksum computation. I think it is bad to have shared code in several libraries. How about putting everything in nfnetlink ? I that appropriated ?
Thanks,
Sebastien.
Quoted 8 lines · Pablo Neira Ayuso
The code seems very similar to the one that is available in RFC1071. I recently added initial support for message checksumming to conntrackd and used that code (slightely modified) indicating the source, thus not explicitely licensing that part as GPL since I don't own the copyright of it. Can we consider examples available in a RFC as public domain code?
Hi folks,
this is patch adds the checksum computation feature in netfilter_queue.
Thanks,
Sebastien.
libnetfilter_queue/Makefile.am +1 -1
@@ -1,3 +1,3 @@ -pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h +pkginclude_HEADERS = libnetfilter_queue.h libipq.h linux_nfnetlink_queue.h protocol_any_helper.h
libnetfilter_queue/libnetfilter_queue.h +2 -4
@@ -14,9 +14,8 @@#define __LIBCTNETLINK_H#include <libnfnetlink/libnfnetlink.h> -// #include <libnfnetlink/liunx_nfnetlink.h> -#include <libnetfilter_queue/linux_nfnetlink_queue.h> +#include <libnetfilter_queue/protocol_any_helper.h> struct nfq_handle ;struct nfq_q_handle ;
@@ -79,8 +78,7 @@extern u_int32_t nfq_get_physindev (struct nfq_data *nfad);extern u_int32_t nfq_get_outdev (struct nfq_data *nfad);extern u_int32_t nfq_get_physoutdev (struct nfq_data *nfad); - -extern int nfq_get_indev_name (struct nlif_handle *nlif_handle, +extern int nfq_get_indev_name (struct nlif_handle *nlif_handle,struct nfq_data *nfad,char *name);extern int nfq_get_physindev_name (struct nlif_handle *nlif_handle,struct nfq_data *nfad,char *name);
libnetfilter_queue/protocol_any_helper.h +17 -0
@@ -0,0 +1,17 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +extern unsigned short nfq_compute_cksum (unsigned short *addr,int count); +
configure.in +1 -1
@@ -23,7 +23,7 @@ PKG_CHECK_MODULES(LIBNFNETLINK, libnfnetlink >= $LIBNFNETLINK_REQUIRED,, AC_MSG_ERROR(Cannot find libnfnetlink >= $LIBNFNETLINK_REQUIRED)) -CFLAGS="$CFLAGS $LIBNFNETLINK_CFLAGS" +CFLAGS="$CFLAGS $LIBNFNETLINK_CFLAGS -Wpadded" LIBNFQUEUE_LIBS="$LIBNFNETLINK_LIBS" AC_SUBST(LIBNFQUEUE_LIBS)
protocol_any_helper.c +53 -0
53 lines not on this page · raw message
Makefile.am +1 -1
@@ -10,7 +10,7 @@ libnetfilter_queue_la_LDFLAGS = -Wc,-nostartfiles -lnfnetlink \ -version-info $(LIBVERSION) -libnetfilter_queue_la_SOURCES = libnetfilter_queue.c +libnetfilter_queue_la_SOURCES = libnetfilter_queue.c protocol_any_helper.c libnetfilter_queue_libipq_la_LDFLAGS = -Wc,-nostartfiles \ -version-info 1:0:0