Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] tcprewrite: Setting infile and outfile to the same file leads to truncation. #914

Open
wesly2000 opened this issue Feb 21, 2025 · 0 comments

Comments

@wesly2000
Copy link

Describe the bug
When rewrite IP address for a .pcap file using tcprewrite, if I set --infile and --outfile to the same filename, the output file seems to be truncated (the original file contains 27 packets but the output file contains only 4 pacekts. This would happen for --pnat and -e options.

To Reproduce
Steps to reproduce the behavior:

  1. Use tcprewrite --pnat=192.168.5.0/24:10.4.0.0/24 --infile=xxx.pcapng --outfile=xxx.pcapng.
  2. The file xxx.pcapng would be truncated to have few pacekts.

Expected behavior
The resulting .pcap file should not be truncated, but only IP modified. I'm not sure if the in-place modification is not supported or a bug. Since I have many .pcap files, setting --infile and --outfile to different files would occupy much space. Currently a quick workaround for me is to write a script which use different --infile and --outfile and then delete the --infile.

I'm sorry that I didn't find similar issues here or on Stack Overflow. Any suggestions are appreciated! :)

Screenshots
The original file content:
The original file content

After using tcprewrite for IP address modification in a in-place manner:
After using tcprewrite for IP address modification in a in-place manner.

System (please complete the following information):

  • OS: Ubuntu
  • OS version 20.04.6 LTS
  • Tcpreplay Version 4.3.2 (installed using apt install)

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant