DEV Community

Cover image for Capture request with tcpdump and curl
Israel-Lopes
Israel-Lopes

Posted on

8 2

Capture request with tcpdump and curl

There are times in a front-end analysis to debug a request that we cannot visualize it because of the speed. Understanding this, I will share a way around this problem, which would be to capture and save this request.

Basically what I'm going to present here is a way to monitor the network and save the data in a temporary file.

Dependencies

  • curl
  • tcpdump

sudo apt install curl
sudo apt install tcpdump

Once everything is configured, let's follow...

# We must first check which is our network card
machine@machine~ ip addr
Enter fullscreen mode Exit fullscreen mode
# Let's check now, in my case mine and `lo`
machine@machine~ ip addr show lo
Enter fullscreen mode Exit fullscreen mode

Now let's start monitoring and save it in a temporary file in the /tmp folder, we must also specify the network card.

# Template
machine@machine~ sudo tcpdump -i <network_card> -s 0 -w /tmp/<file_name.pcap>

# Starting Capture and Saving
machine@machine~ sudo tcpdump -i lo -s 0 -w /tmp/capture2.pcap

Enter fullscreen mode Exit fullscreen mode

That done, just start the request, either by a curl or a simple request in the browser.

Then just close tcpdump and it will save the capture.

Now let's open the .pcap

# Open the package
machine@machine~ curl -v -o /tmp/<file_name.pcap> <URL>

Enter fullscreen mode Exit fullscreen mode
  • URL: Here we must put the address.

Texto alternativo da imagem

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay