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 7574627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:28:54+00:00 2026-05-30T16:28:54+00:00

I have some large pcap (packet capture) files collected with tcpdump. I would like

  • 0

I have some large pcap (packet capture) files collected with tcpdump. I would like to filter out packets that contain a specific string. I want my output to still be in pcap format. I’ve found several ways of only displaying packets matching a regex from a pcap file, but what I need is to filter such files rather than filter out the display (e.g. stdout) of the packets. The output needs to be pcap files with the matched packets removed.

I suspect dpkt (a python module) might help, but I’d prefer to do this using an existing (C/C++) tool, if possible. I’ll accept code as an answer (maybe a good dpkt example with benchmarks will convince me to just go that way as well ;-)).

Thanks in advance!

Answer:

Per Nim’s answer, it’s possible to do this via Wireshark/tshark. For others’ reference, here’s an example commandline, where I check for the string match within udp packets (this example can be built on to do tcp or specific protocol field searching):

tshark -r infile  -R 'not udp matches "my_search_string"' -w outfile

Thanks again!

  • 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-05-30T16:28:55+00:00Added an answer on May 30, 2026 at 4:28 pm

    This website has a very nice example of how you can read the pcap file in C, a quick google search will reveal how you can re-write the file.

    Alternatively, AFAIK Wireshark may allow you to do this already – i.e. open the file, apply a filter and save the file (and a quick run through Wireshark – reveals that it does indeed offer this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some relatively large legacy method that I would like to refactor. It
I currently have some large strings that I would like use as test data
We have large files with zlib-compressed binary data that we would like to memory
I have some large .png (.jpg, ...) files that require pretty much a full
I have some large files (from several gigabytes to hundreds of gigabytes) that I'm
I have some large files (hundreds of MB) that I need to search for
I have some large JPG files that need to be downsampled in an android
I have some (fairly large) UIButtons. Instead of text, I would like to draw
We have some very large data files (5 gig to 1TB) where we need
I have an automated test running on my program that generates some large MPG

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.