Capture request with tcpdump and curl

israellopes

Israel-Lopes

Posted on December 13, 2022

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

💖 💪 🙅 🚩
israellopes
Israel-Lopes

Posted on December 13, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related