Skip to content

Instantly share code, notes, and snippets.

@joshdevins
Last active November 12, 2019 12:11
Show Gist options
  • Save joshdevins/0f12ac594db1afd39991311d7d648276 to your computer and use it in GitHub Desktop.
Save joshdevins/0f12ac594db1afd39991311d7d648276 to your computer and use it in GitHub Desktop.
Capture Elasticsearch queries
# everything
sudo tcpdump -i lo0 -A -n -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# POST only
sudo tshark -i lo0 -Y 'http.request.method == "POST"' -T fields -e http.request.uri -e http.file_data 'tcp dst port 9200' > dump.txt
# then look for search queries
cat dump.txt | grep search | sed -n 's/.*\\n\({\"query\":.*\)\\n/\1/p' | jq -C .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment