0

I am attempting to create a proof of concept bash script to scan the network using ngrep, find appropriate cookies and then place them into a variable.

cook=`ngrep -s 1000 -l -q -d eth1 "Cookie:" tcp and port 80 |
  grep -m 1 -Po '(?<=user=)[^;]+'` 

cook2=`ngrep -s 1000 -l -q -d eth1 "Cookie:" tcp and port 80 |
  grep -m 1 -Po '(?<=ab=)[^;]+'` 

How can I store cookie & cookie2 from the ONE packet instead of having to ngrep twice?

Zombo
  • 1
  • 62
  • 391
  • 407

1 Answers1

0

Assuming the string is in this form

Cookie: foo=111; bar=222; baz=333

you can source the string, as it is valid Bash code. Example

ngrep -s 1000 -l -q -d eth1 'Cookie:' tcp and port 80 | cut -d: -f2- > v.sh
. v.sh
rm v.sh
cook="$user"
cook2="$ab"
Zombo
  • 1
  • 62
  • 391
  • 407