Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8854771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:57:39+00:00 2026-06-14T13:57:39+00:00

Can anybody point me to some examples in using the xt_string module with netfilter

  • 0

Can anybody point me to some examples in using the xt_string module with netfilter or provide a example.
What I am trying to do is to write netfilter module that will drop packets that contain a certain string in the skb->data field.

I initially tried simply strnstr(skb->data, "mystring", strlen("mystring")) but this seem to be incorrect approach to this problem (and it does not seem to be working as i dont see any packets being dropped).

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:57:40+00:00Added an answer on June 14, 2026 at 1:57 pm

    If you mean using iptables string match in user-space, here is one example:

    iptables -I INPUT 1 -p tcp --dport 80 -m string --string "domain.com" --algo kmp -j DROP
    

    Or if you mean in kernel space, you can use textsearch API which provides KMP/BM/FSM algorithms, the following example is from kernel source lib/textsearch.c:

    int pos;
    struct ts_config *conf;
    struct ts_state state;
    const char *pattern = "chicken";
    const char *example = "We dance the funky chicken";
    conf = textsearch_prepare("kmp", pattern, strlen(pattern),
                                 GFP_KERNEL, TS_AUTOLOAD);
    if (IS_ERR(conf)) {
        err = PTR_ERR(conf);
        goto errout;
    }
    pos = textsearch_find_continuous(conf, &state, example, strlen(example));
    if (pos != UINT_MAX)
        panic("Oh my god, dancing chickens at %d\n", pos);
    textsearch_destroy(conf);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody give any working example of how to read/write Unicode text files using
Can anybody help(or point to some examples) about how to encrypt files with python?
Can anybody point me to a simple example about how to implement form based
Can anybody show with some examples the exact difference between .. and ... operator?
Can anybody point to/give a very very correct example for the Model-View-Controller paradigm? I
I've spent several hours of googling. Can anybody point me to an example of
Can anybody point me to some good tutorial about openssl and how generate correct
I am curious if anybody can point me to a good example/best practice of
Can anybody point me in the right direction to be able to encrypt a
can anybody point me in the right direction as to how I would go

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.