LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-10-2009, 09:47 PM   #1
linuxlrnr
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
Bug / problem with iptables v 1.4.1.1


Hi,

I am using ubuntu 9.0.4
Kernel version 2.6.28-16-generic.
I gave an iptables command

iptables -A INPUT -m string --hex-string "|66 61 63 65 62 6f 6f 6b|" --algo bm -j DROP

The string means facebook and

This blocks access to facebook.com
Also blocks downloading of a file containing word facebook where the file contents are

this file should not get downloaded. It has facebook.


Output of iptables -nL is following

Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0 STRING match "facebook" ALGO name bm TO 65535

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination



But if I go to google.com and search for facebook it returns me the results and is not blocking the contents having keyword "facebook" - where the string starts with small f.

Why is the firewall not blocking the contents/packets containing the keyword?

Thanks for your willingness to help and replies in advance.

regards,

linuxlrnr
 
Old 12-11-2009, 02:41 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Using string match to block emerging worm threads on the fly, when you do not run an IDS, would be a useful example. Using it to block access to websites is a bad example because iptables string matches are expensive, allow for circumvention and as such do not completely match your purpose. Why not use a filtering proxy instead?
 
Old 12-11-2009, 05:42 AM   #3
linuxlrnr
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Hi unSpawn,

Thanks for your answer explaining use of iptables.
In fact, I wrote a program to catch worm patterns and am using iptables to block the specific pattern.

In my case, during demo I am using small pattern size(8 bytes) as a worm and facebook pattern is one of the pattern (random selection - for demo purpose - no big thought on selection) - that is to be consideerd as worm (again for demo purpose). So, my program is generating iptables rule for that pattern and I expected iptables pattern matching to work fine but in demo it did not worked the way it should.

The firewall rule blocks search in

m.www.yahoo.com - yahoo home page
altavista.com
www.wikipedia.org

it blocks even facebook.com

but, it does not block search in

search.yahoo.com
google.com
bing.com
ask.com
...

My point is should not it block the pattern it is set to block.
In spite of my purpose being catching worms only, I am more concerned about functioning of iptables.

I will appreciate if you can explain me why it did not blocked some pages while blocked the others.

Thanks for your previous reply.

linuxlrnr
 
Old 12-11-2009, 06:31 AM   #4
Web31337
Member
 
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
interesting, i think i also will listen to reply.
i was also wondering what if i enter not "facebook" but "fAcebook". will that rule still block it? =) or will you try all letters in all cases?
 
Old 12-11-2009, 10:53 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Matches like '/sbin/iptables -t raw -I PREROUTING 1 -m string --algo bm --hex-string "|68 74 74 70 3a 2f 2f|" -j LOG --log-prefix "string_http "' work OK for me. iptables 1.3.5 (-5.3.el5_4.1) here though. You could test different major iptables versions or get on the netfilter mailing list.


Quote:
Originally Posted by linuxlrnr View Post
I wrote a program to catch worm patterns and am using iptables to block the specific pattern
Not to keep you from reinventing the wheel or so but have you ever looked at fwsnort or L7 or distributions that ship them as part of their default setup?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Rather huge IPtables chain, iptables: Memory allocation problem. Gangrif Linux - Networking 10 09-11-2009 03:30 PM
LXer: 2008 CES: Bug Labs Introduces BUG, BUGbase. So Cool! LXer Syndicated Linux News 0 01-09-2008 01:21 AM
possible iptables/ifconfig bug nik.martin Linux - Networking 9 11-15-2005 05:35 PM
FYI - iptables bug (?) in Mandrake 10.2 Malibyte Mandriva 0 05-23-2005 02:29 PM
Bug in iptables-SAVE RedHat 8.0?? gruger Linux - Distributions 1 05-23-2003 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:34 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration