I'm not familiar with NetPacket specifically, but it looks like it processes, well, packets when what you need is to look at assembled TCP conversations, the packets of which may be fragmented and arrive out-of-sequence.

Unless you find a module that does that work for you, you need to accumulate packets and associate them with HTTP requests yourself.

In the simple case, you can stop accumulating data from a particular connection once you successfully match a GET header, and then clear it from the temporary store. This is not true for HTTP/1.1 connections though, since they may have several requests in them.

That said, a very quick'n'dirty and unreliable way that may work some of the time is to match the payload of each packet with something that looks like a GET request:

print "Requested: $1\n" if $payload =~ /GET (\S+)/;

Here too there is place for added robustness; many things can look like a URI and you only want to match the ones from an actual header.

Oh: and if you know which end of the connection is the web client, only look for GETs in packets sent from that end :)


In reply to Re: recreate dsniff in perl by gaal
in thread recreate dsniff in perl by nashr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.