Hi,

Note that the interface between the application and TCP is just a stream of bytes. It's not broken up into discrete units (packets/segments/whatever).

That interface occurs when the application does a write() or whatever on a socket, so if you really want to intercept the data there, it's going to be *in the application*, (or kernel, but you probably don't want to do that).

A data-mutating proxy doesn't really intercept anything at the level that your original post described.

Here's an example of intercepting the data in the app:

#!/usr/bin/perl -w package IO::Socket::INET::Interceptor; use base qw(IO::Socket::INET); sub write { my ($self, $buf, $len, $offset) = @_; $buf =~ s/cats/dogs/g; $self->SUPER::write($buf, $len, $offset); } package main; my $sock = IO::Socket::INET::Interceptor->new("localhost:80") or die $ +!; $sock->write("GET /cats/cats/cats.html HTTP/1.0\r\n\r\n"); print <$sock>;
I do agree that the proxy example is more interesting, but it's not what you described.

In reply to Re: Intercept segmets before arriving to the TCP stack from App Layer by PreferredUserName
in thread Intercept segmets before arriving to the TCP stack from App Layer by mosh

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.