1

I have been using the following on my Raspberry pi which basically captures data from a weather hub I have connected to a USB port on the PI.

sudo tcpdump -A -n -p -l -i eth1 -s0 -w - tcp dst port 80 |
  stdbuf -oL strings -n8 |
  ./parser

The output buffer is read via a python script.

I want to move the whole process onto a windows (10) machine and so far I have the following working via CMD under Win10.

tcpdump -A -n -p -l -i eth1 -s0 -w - tcp dst port 80

The output however, is totally unreadable because I can not figure out the rest of the command under windows. Specifically

| stdbuf -oL strings -n8 |./parser

Any help with this would greatly be appreciated

I have tried this under PowerShell but I end up with the same garbled text

./tcpdump -A -n -p -l -i 5 | ForEach-Object {
  [Console]::WriteLine($_)
  [Console]::Out.Flush()
  $_
} | Set-Content program.log

====================================== When I issue the following command RaspPi

sudo tcpdump -A -n -p -l -i eth1 -s0 -w - tcp dst port 80 | stdbuf -oL strings -n8

I will get the following output

    tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
GET /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1
&id=24C86E010F25&mt=tower&sensor=00015666
&humidity=74&tempf=26.6
&baromin=30.39&battery=normal&rssi=4
 HTTP/1.1
hubapi.myacurite.com
User-Agent: Hub/224
Connection: close
9
  • 2
    stdbuf is a Linuxism -- and it only serves to change the buffering defaults for strings, telling it to write output as fast as it can; you don't need it. strings -n8 is searching for runs of printable characters -- you should be able to write your own code to do that. Powershell has regex functionality, right? Search for strings matching [[:graph:][:space:]]{8,}, print only those matches one-per-line and there you are, adjusting the syntax for whichever regex engine is in use. Commented Dec 26, 2024 at 17:42
  • Mind, I'd argue that there are generally much better tools to use than strings, but we'd need to know the content of the packets you're intercepting. I would be not one tiny bit surprised, though, if we could get the output you wanted just with a better tcpdump command (or a tshark command or similar) once we knew the packet format. Commented Dec 26, 2024 at 17:44
  • @CharlesDuffy unfortunately powershell doesn't support those regex classes like [:graph:] and [:space:] Commented Dec 26, 2024 at 18:21
  • @js2010, right, hence the "adjusting the syntax" provision. (That said, I'm... disappointed, but not as surprised as it would be if it were anyone other than Microsoft, that they're disregarding the POSIX BRE specification). Commented Dec 26, 2024 at 18:41
  • 1
    It's unclear what ./parser is an does, but note that there's a downloadable strings.exe SysInternals utility, which seem to support the option you're looking for. Commented Dec 26, 2024 at 18:57

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.