Monday, March 31, 2014

ngrep

ngrep is the packet capture tool I always wanted. I always found tcpdump and wireshark etc too intimidating. ngrep prints everything it capture on stdout and like any other command line tool on *nix, the output can be further piped into other tools like grep, awk, sed or cut. Let me show a few examples

1. Capture all requests on port 80
sudo ngrep -q -W byline '' 'dst port 80'

2. Capture all http get requests on port 80 and headers

sudo ngrep -W byline -q -t '(^GET .* HTTP)' 'port 80'

3. Capture all GET requests on port 80
sudo ngrep -W byline -q -t '(^GET .* HTTP)' 'port 80'|grep -E '^GET /.*' 

4. Capture all GET/POST requests and responses (not in sync)
sudo ngrep -W byline -q -t '(^GET .* HTTP)|(^HTTP/1.1)'|grep -E '^(HTTP/1.1)|(GET /)' -B1


2 comments:

Vantikommu Harish Reddy said...

Hi Piyush,

How to add color to a cell or a row in google spreadsheet by using google drive gem, I have seen your question in stack overflow.

Piyush Ranjan said...

You cannot. That api only allows data to be filled. To add formatting you need the JS api