Capture http token with tcpdump

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















My server runs curl commands to some API using a token. For example:



curl --header "Private-Token: aaaaaaaaaaaaaa" http://mysite.example.com/api/v4/any


Can i capture with tcpdump all of the requests to that API with this a specific token? If so, How? Other ideas will be great as well.










share|improve this question
























  • If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

    – Rui F Ribeiro
    Jan 2 at 17:35












  • I just want to investigate something using tcpdump. That's is.

    – Omri
    Jan 2 at 17:44















2















My server runs curl commands to some API using a token. For example:



curl --header "Private-Token: aaaaaaaaaaaaaa" http://mysite.example.com/api/v4/any


Can i capture with tcpdump all of the requests to that API with this a specific token? If so, How? Other ideas will be great as well.










share|improve this question
























  • If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

    – Rui F Ribeiro
    Jan 2 at 17:35












  • I just want to investigate something using tcpdump. That's is.

    – Omri
    Jan 2 at 17:44













2












2








2








My server runs curl commands to some API using a token. For example:



curl --header "Private-Token: aaaaaaaaaaaaaa" http://mysite.example.com/api/v4/any


Can i capture with tcpdump all of the requests to that API with this a specific token? If so, How? Other ideas will be great as well.










share|improve this question
















My server runs curl commands to some API using a token. For example:



curl --header "Private-Token: aaaaaaaaaaaaaa" http://mysite.example.com/api/v4/any


Can i capture with tcpdump all of the requests to that API with this a specific token? If so, How? Other ideas will be great as well.







curl http tcpdump






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 17:53









Rui F Ribeiro

39.5k1479132




39.5k1479132










asked Jan 2 at 17:08









OmriOmri

1224




1224












  • If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

    – Rui F Ribeiro
    Jan 2 at 17:35












  • I just want to investigate something using tcpdump. That's is.

    – Omri
    Jan 2 at 17:44

















  • If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

    – Rui F Ribeiro
    Jan 2 at 17:35












  • I just want to investigate something using tcpdump. That's is.

    – Omri
    Jan 2 at 17:44
















If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

– Rui F Ribeiro
Jan 2 at 17:35






If curl is making the requests and getting the answer, why not saving the answer? Why using tcpdump at all?

– Rui F Ribeiro
Jan 2 at 17:35














I just want to investigate something using tcpdump. That's is.

– Omri
Jan 2 at 17:44





I just want to investigate something using tcpdump. That's is.

– Omri
Jan 2 at 17:44










1 Answer
1






active

oldest

votes


















2














For listening to HTTP traffic with tcpdump, and seeing the actual packets contents, you can do it with:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com"


However, filtering on data can only be done at specific packet positions in tcpdump and is not viable on this case.



So in addition, you can use also ngrep to listen for lines with the specific string data on the network interface.



sudo ngrep -q "Private-Token: aaaaaaaaaaaaaa" "port 80 and host mysite.example.com"


As for the actual host/port filters, see this (short) summary about tcpdump/BPF filters: TCPDUMP expressions



Also, the wireshark @StephenHarris recommendation, is quite good, for having a graphical interface. To do a tcpdump writing raw data in a file for later use in wireshark, you do:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com" -w mycapture.pcap


You can also capture the packet requests at application level, using sysdig. (Not so sure about the answers without testing)



sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains "Private-Token: aaaaaaaaaaaaaa"





share|improve this answer

























  • See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

    – Stephen Harris
    Jan 2 at 18:03











  • @StephenHarris wireshark for a graphical interface is a good recommendation.

    – Rui F Ribeiro
    Jan 2 at 18:07










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492050%2fcapture-http-token-with-tcpdump%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














For listening to HTTP traffic with tcpdump, and seeing the actual packets contents, you can do it with:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com"


However, filtering on data can only be done at specific packet positions in tcpdump and is not viable on this case.



So in addition, you can use also ngrep to listen for lines with the specific string data on the network interface.



sudo ngrep -q "Private-Token: aaaaaaaaaaaaaa" "port 80 and host mysite.example.com"


As for the actual host/port filters, see this (short) summary about tcpdump/BPF filters: TCPDUMP expressions



Also, the wireshark @StephenHarris recommendation, is quite good, for having a graphical interface. To do a tcpdump writing raw data in a file for later use in wireshark, you do:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com" -w mycapture.pcap


You can also capture the packet requests at application level, using sysdig. (Not so sure about the answers without testing)



sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains "Private-Token: aaaaaaaaaaaaaa"





share|improve this answer

























  • See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

    – Stephen Harris
    Jan 2 at 18:03











  • @StephenHarris wireshark for a graphical interface is a good recommendation.

    – Rui F Ribeiro
    Jan 2 at 18:07















2














For listening to HTTP traffic with tcpdump, and seeing the actual packets contents, you can do it with:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com"


However, filtering on data can only be done at specific packet positions in tcpdump and is not viable on this case.



So in addition, you can use also ngrep to listen for lines with the specific string data on the network interface.



sudo ngrep -q "Private-Token: aaaaaaaaaaaaaa" "port 80 and host mysite.example.com"


As for the actual host/port filters, see this (short) summary about tcpdump/BPF filters: TCPDUMP expressions



Also, the wireshark @StephenHarris recommendation, is quite good, for having a graphical interface. To do a tcpdump writing raw data in a file for later use in wireshark, you do:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com" -w mycapture.pcap


You can also capture the packet requests at application level, using sysdig. (Not so sure about the answers without testing)



sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains "Private-Token: aaaaaaaaaaaaaa"





share|improve this answer

























  • See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

    – Stephen Harris
    Jan 2 at 18:03











  • @StephenHarris wireshark for a graphical interface is a good recommendation.

    – Rui F Ribeiro
    Jan 2 at 18:07













2












2








2







For listening to HTTP traffic with tcpdump, and seeing the actual packets contents, you can do it with:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com"


However, filtering on data can only be done at specific packet positions in tcpdump and is not viable on this case.



So in addition, you can use also ngrep to listen for lines with the specific string data on the network interface.



sudo ngrep -q "Private-Token: aaaaaaaaaaaaaa" "port 80 and host mysite.example.com"


As for the actual host/port filters, see this (short) summary about tcpdump/BPF filters: TCPDUMP expressions



Also, the wireshark @StephenHarris recommendation, is quite good, for having a graphical interface. To do a tcpdump writing raw data in a file for later use in wireshark, you do:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com" -w mycapture.pcap


You can also capture the packet requests at application level, using sysdig. (Not so sure about the answers without testing)



sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains "Private-Token: aaaaaaaaaaaaaa"





share|improve this answer















For listening to HTTP traffic with tcpdump, and seeing the actual packets contents, you can do it with:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com"


However, filtering on data can only be done at specific packet positions in tcpdump and is not viable on this case.



So in addition, you can use also ngrep to listen for lines with the specific string data on the network interface.



sudo ngrep -q "Private-Token: aaaaaaaaaaaaaa" "port 80 and host mysite.example.com"


As for the actual host/port filters, see this (short) summary about tcpdump/BPF filters: TCPDUMP expressions



Also, the wireshark @StephenHarris recommendation, is quite good, for having a graphical interface. To do a tcpdump writing raw data in a file for later use in wireshark, you do:



sudo tcpdump -X -s 1500 "port 80 and host mysite.example.com" -w mycapture.pcap


You can also capture the packet requests at application level, using sysdig. (Not so sure about the answers without testing)



sudo sysdig -s 2000 -A -c echo_fds fd.port=80 and evt.buffer contains "Private-Token: aaaaaaaaaaaaaa"






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 15:46

























answered Jan 2 at 17:49









Rui F RibeiroRui F Ribeiro

39.5k1479132




39.5k1479132












  • See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

    – Stephen Harris
    Jan 2 at 18:03











  • @StephenHarris wireshark for a graphical interface is a good recommendation.

    – Rui F Ribeiro
    Jan 2 at 18:07

















  • See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

    – Stephen Harris
    Jan 2 at 18:03











  • @StephenHarris wireshark for a graphical interface is a good recommendation.

    – Rui F Ribeiro
    Jan 2 at 18:07
















See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

– Stephen Harris
Jan 2 at 18:03





See also wireshark which can capture data, or read pre-saved tcpdump pcap files, and filter on contents.

– Stephen Harris
Jan 2 at 18:03













@StephenHarris wireshark for a graphical interface is a good recommendation.

– Rui F Ribeiro
Jan 2 at 18:07





@StephenHarris wireshark for a graphical interface is a good recommendation.

– Rui F Ribeiro
Jan 2 at 18:07

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492050%2fcapture-http-token-with-tcpdump%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?