Networking Forums

Networking Forums > Computer Networking > Linux Networking > Using iptables to log http request to a file?

Reply
Thread Tools Display Modes

Using iptables to log http request to a file?

 
 
xiong.xu.cn@gmail.com
Guest
Posts: n/a

 
      08-18-2006, 10:13 AM
Hi all,

Can anyone give me pointer to how to log http requset to a file by
iptables and ulogd?
Is there any ulogd plugin can parse the traffic and just log the needed
HTTP request information£¨eg. some http header field£©?
Some sample source code will be great!

Thanks in advance!

Xiong

 
Reply With Quote
 
 
 
 
Viktar Sakovich2038490794
Guest
Posts: n/a

 
      08-18-2006, 05:31 PM
On Friday 18 August 2006 13:13 (E-Mail Removed) wrote:

> Hi all,
>
> Can anyone give me pointer to how to log http requset to a file by
> iptables and ulogd?
> Is there any ulogd plugin can parse the traffic and just log the
> needed HTTP request information£¨eg. some http header field£©?
> Some sample source code will be great!
>
> Thanks in advance!
>
> Xiong
>
>


Without ULOG:
To match some string
iptables -A INPUT -p tcp --dport 80 -m string --string "Some String"-j
ACCEPT

or better use l7-filter to match some regex:
put in /etc/l7-protocols/extra/ httpmypatern.pat with content:
httpmypatern
some_rexexp.*

and use
iptables -A INPUT -p tcp --dport 80 -m layer7 --l7proto httpmypatern -j
ACCEPT





 
Reply With Quote
 
xiong.xu.cn@gmail.com
Guest
Posts: n/a

 
      08-19-2006, 03:12 AM
Thank Viktar,

By using '-j ACCEPT', all the packets matching the pattern will be
accept? or just the packets matched will be accepted?
For example, a http request composed of multiple lines, usually 'GET
....' followed by other HTTP header lines. In this case, will all the
http connection traffic be accepted?
And, which is the better way to parse the matched data and write to log
in a user defined format?
Should I use ulogd plugin? Is there any sample show me how to write a
custom log?

Thank again,
Xiong

Viktar Sakovich2038490794 写�:

> On Friday 18 August 2006 13:13 (E-Mail Removed) wrote:
>
> > Hi all,
> >
> > Can anyone give me pointer to how to log http requset to a file by
> > iptables and ulogd?
> > Is there any ulogd plugin can parse the traffic and just log the
> > needed HTTP request information(eg. some http header field)?
> > Some sample source code will be great!
> >
> > Thanks in advance!
> >
> > Xiong
> >
> >

>
> Without ULOG:
> To match some string
> iptables -A INPUT -p tcp --dport 80 -m string --string "Some String"-j
> ACCEPT
>
> or better use l7-filter to match some regex:
> put in /etc/l7-protocols/extra/ httpmypatern.pat with content:
> httpmypatern
> some_rexexp.*
>
> and use
> iptables -A INPUT -p tcp --dport 80 -m layer7 --l7proto httpmypatern -j
> ACCEPT


 
Reply With Quote
 
Viktar Sakovich2038490794
Guest
Posts: n/a

 
      08-19-2006, 09:37 PM
On Saturday 19 August 2006 06:12 (E-Mail Removed) wrote:

> Thank Viktar,
>
> By using '-j ACCEPT', all the packets matching the pattern will be
> accept? or just the packets matched will be accepted?
> For example, a http request composed of multiple lines, usually 'GET
> ...' followed by other HTTP header lines. In this case, will all the
> http connection traffic be accepted?


In case of -m string only matching packets accepted, but in case of
l7-filter all packets for conection (l7-filter use conection tracking
to match next packets of connection) accepted.

If you want to match for a connection with -m string, do following:
iptables -A INPUT -p tcp --dport 80 -m string --string "Some String"-j
CONNMARK --set-mark 0x1
iptables -A INPUT -m connmark --mark 0x1 -j ACCEPT


> And, which is the better way to parse the matched data and write to
> log in a user defined format?
> Should I use ulogd plugin? Is there any sample show me how to write a
> custom log?
>
> Thank again,
> Xiong
>
> Viktar Sakovich2038490794 写�:
>
>> On Friday 18 August 2006 13:13 (E-Mail Removed) wrote:
>>
>> > Hi all,
>> >
>> > Can anyone give me pointer to how to log http requset to a file by
>> > iptables and ulogd?
>> > Is there any ulogd plugin can parse the traffic and just log the
>> > needed HTTP request information(eg. some http header field)?
>> > Some sample source code will be great!
>> >
>> > Thanks in advance!
>> >
>> > Xiong
>> >
>> >

>>
>> Without ULOG:
>> To match some string
>> iptables -A INPUT -p tcp --dport 80 -m string --string "Some
>> String"-j ACCEPT
>>
>> or better use l7-filter to match some regex:
>> put in /etc/l7-protocols/extra/ httpmypatern.pat with content:
>> httpmypatern
>> some_rexexp.*
>>
>> and use
>> iptables -A INPUT -p tcp --dport 80 -m layer7 --l7proto httpmypatern
>> -j ACCEPT

>
>


 
Reply With Quote
 
imx
Guest
Posts: n/a

 
      08-20-2006, 01:46 PM
So, how to log just the first few, say 100, packets?

thx

Viktar Sakovich2038490794 wrote:
> On Saturday 19 August 2006 06:12 (E-Mail Removed) wrote:
>
> > Thank Viktar,
> >
> > By using '-j ACCEPT', all the packets matching the pattern will be
> > accept? or just the packets matched will be accepted?
> > For example, a http request composed of multiple lines, usually 'GET
> > ...' followed by other HTTP header lines. In this case, will all the
> > http connection traffic be accepted?

>
> In case of -m string only matching packets accepted, but in case of
> l7-filter all packets for conection (l7-filter use conection tracking
> to match next packets of connection) accepted.
>
> If you want to match for a connection with -m string, do following:
> iptables -A INPUT -p tcp --dport 80 -m string --string "Some String"-j
> CONNMARK --set-mark 0x1
> iptables -A INPUT -m connmark --mark 0x1 -j ACCEPT
>
>
> > And, which is the better way to parse the matched data and write to
> > log in a user defined format?
> > Should I use ulogd plugin? Is there any sample show me how to write a
> > custom log?
> >
> > Thank again,
> > Xiong
> >
> > Viktar Sakovich2038490794 写�:
> >
> >> On Friday 18 August 2006 13:13 (E-Mail Removed) wrote:
> >>
> >> > Hi all,
> >> >
> >> > Can anyone give me pointer to how to log http requset to a file by
> >> > iptables and ulogd?
> >> > Is there any ulogd plugin can parse the traffic and just log the
> >> > needed HTTP request information(eg. some http header field)?
> >> > Some sample source code will be great!
> >> >
> >> > Thanks in advance!
> >> >
> >> > Xiong
> >> >
> >> >
> >>
> >> Without ULOG:
> >> To match some string
> >> iptables -A INPUT -p tcp --dport 80 -m string --string "Some
> >> String"-j ACCEPT
> >>
> >> or better use l7-filter to match some regex:
> >> put in /etc/l7-protocols/extra/ httpmypatern.pat with content:
> >> httpmypatern
> >> some_rexexp.*
> >>
> >> and use
> >> iptables -A INPUT -p tcp --dport 80 -m layer7 --l7proto httpmypatern
> >> -j ACCEPT

> >
> >


 
Reply With Quote
 
Viktar Sakovich2038490794
Guest
Posts: n/a

 
      08-20-2006, 08:45 PM
On Sunday 20 August 2006 16:46 imx wrote:

> So, how to log just the first few, say 100, packets?
>
> thx


Use connbytes, i. e. something like this:

iptables -A INPUT -p tcp --dport 80 -m connbytes --connbytes 0:100
--connbytes-dir both --connbytes-mode packets -j ACCEPT

>
> Viktar Sakovich2038490794 wrote:
>> On Saturday 19 August 2006 06:12 (E-Mail Removed) wrote:
>>
>> > Thank Viktar,
>> >
>> > By using '-j ACCEPT', all the packets matching the pattern will be
>> > accept? or just the packets matched will be accepted?
>> > For example, a http request composed of multiple lines, usually
>> > 'GET ...' followed by other HTTP header lines. In this case, will
>> > all the http connection traffic be accepted?

>>
>> In case of -m string only matching packets accepted, but in case of
>> l7-filter all packets for conection (l7-filter use conection tracking
>> to match next packets of connection) accepted.
>>
>> If you want to match for a connection with -m string, do following:
>> iptables -A INPUT -p tcp --dport 80 -m string --string "Some
>> String"-j CONNMARK --set-mark 0x1
>> iptables -A INPUT -m connmark --mark 0x1 -j ACCEPT
>>
>>
>> > And, which is the better way to parse the matched data and write to
>> > log in a user defined format?
>> > Should I use ulogd plugin? Is there any sample show me how to write
>> > a custom log?
>> >
>> > Thank again,
>> > Xiong
>> >
>> > Viktar Sakovich2038490794 写�:
>> >
>> >> On Friday 18 August 2006 13:13 (E-Mail Removed) wrote:
>> >>
>> >> > Hi all,
>> >> >
>> >> > Can anyone give me pointer to how to log http requset to a file
>> >> > by iptables and ulogd?
>> >> > Is there any ulogd plugin can parse the traffic and just log the
>> >> > needed HTTP request information(eg. some http header field)?
>> >> > Some sample source code will be great!
>> >> >
>> >> > Thanks in advance!
>> >> >
>> >> > Xiong
>> >> >
>> >> >
>> >>
>> >> Without ULOG:
>> >> To match some string
>> >> iptables -A INPUT -p tcp --dport 80 -m string --string "Some
>> >> String"-j ACCEPT
>> >>
>> >> or better use l7-filter to match some regex:
>> >> put in /etc/l7-protocols/extra/ httpmypatern.pat with content:
>> >> httpmypatern
>> >> some_rexexp.*
>> >>
>> >> and use
>> >> iptables -A INPUT -p tcp --dport 80 -m layer7 --l7proto
>> >> httpmypatern -j ACCEPT
>> >
>> >

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to log http request newbiegalore Linux Networking 0 04-06-2008 11:05 PM
How do i Re-direct specific http request to another gateway DK Linux Networking 1 01-25-2006 09:50 PM
Virtual Domain and host info in http request Ohmster Linux Networking 12 10-20-2005 07:19 AM
HTTP 1.1 Request Headers sniffing router Albretch Linux Networking 2 12-14-2004 08:45 PM
HTTP request generator Bill So Linux Networking 2 07-30-2004 12:21 PM



1 2 3 4 5 6 7 8 9 10 11