Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK output from a tcp stream

Status
Not open for further replies.

tommyspain

Technical User
Jan 26, 2003
6
0
0
ES
How to massage this input

#--------------------------------------------------
interface: eth0 (172.26.0.0/255.255.255.0)
filter: ip and ( dst net 212.22.34.154 )
match: GET|POST
T 172.26.0.2:33104 -> 212.22.34.154:80 [AP]
GET /?idprod=3875 HTTP/1.1..Host: Mozilla/5
.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Epiphany/1.0.6..Accep
t: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1..Accept-Language: es
,en;q=0.5..Accept-Encoding: gzip,deflate..Accept-Charset: ISO-8859-1,utf-8;
q=0.7,*;q=0.7..Keep-Alive: 300..Connection: keep-alive..Referer: .novabinary.net/..Cookie:
#---------------------------------------------------------


Like This
Host: GET: ?idprod=3875
Referer:
Thanks
 
Quick and ugly hack:
Code:
           if ( (match($0,/Host:.*\.\.U/)) > 0) {
                    Host = substr($0,RSTART + 5,(RLENGTH - 8))
               }
               if ( (match($0,/\/\?.*=[0-9]+/)) > 0) {
                    Get = substr($0,RSTART + 2,RLENGTH - 2)
               }
               if ( (match($0,/Referer:/)) > 0) {
                    a[0] = substr($0,RLENGTH,(length($0) - RLENGTH + 1))
                    getline
                    if ( (match($0,/.*\//)) > 0) {
                       a[1] = substr($0,RSTART,RLENGTH - 1)
                    }
                    Referer = a[0] a[1] ; gsub(/.*\.\./,"",Referer)
               }
}
END {
    print "Host = ", Host
    print "Get = ", Get
    print "Referer = ", Referer
}

Still needs some tweaks, hope this gives you an idea
of one way to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top