Created
April 17, 2013 14:12
-
-
Save alesleoignis/5404612 to your computer and use it in GitHub Desktop.
URL Extraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://n3t.awardspace.us/content/tcpdump-url-extraction | |
#!/bin/bash | |
# | |
# reset variables | |
myhost=""; | |
myurl=""; | |
tcpdump -s 0 -w - -l $@ | strings | | |
while read line; | |
do | |
# filter GET requests | |
myurl=`echo $line | grep GET | sed -r "s/GET (.*) HTTP.*/\1/"`; | |
if [ "$myurl" == "" ]; then myurl=$myoldurl; fi | |
# filter Host headers | |
myhost=`echo $line | grep Host | sed -r "s/Host: (.*)/\1/"`; | |
if [ "$myhost" == "" ]; then myhost=$myoldhost; fi | |
# once we have a data pair, put them together and echo | |
if [ "$myhost" != "" ] | |
then | |
url="http://$myhost$myurl"; | |
echo $url; | |
myhost=""; | |
myurl=""; | |
fi | |
myoldurl=$myurl; | |
myoldhost=$myhost; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment