RejectedSoftware Forums

Sign up

proxy injecting html

Going with a group somewhere in a month or so. At that location we have wifi but our bandwith is severely limited yet some people like to download movies causing everything to slow down. My plan this year was to use some monitoring tool to see who is downloading movies and using arp spoofing to redirect their traffic through my laptop so I can inject an iframe with some javascript giving an informative message :p

I can always redirect them to a text page with the message but I thought it'd be more fun if some javascript alert poped up while they're surfing. (in this manner I can even 'chat' a bit with anyone on the network). This is my first vibed application and I'm probably doing something wrong. Currently the traffic gets redirected to my machine on port 2876, the code I use is :
http://pastebin.com/44f42Wq2

It appears to work great, except that some websites (like youtube) don't render completely. It seems as if the inputstream only transfers a piece of the returned result to the serverResponse. Can this be avoided?
Is what I'm doing a stupid idea or can this actually be made to work? (I could optionally install a standard proxy server that supports plugins and go from there)

Also, when I run the vibe application, I get this output at startup:
"Listening for HTTP requests on :::2876
Failed to listen on 0.0.0.0:2876"
Is that normal? failed to listen?

Re: proxy injecting html

In a hopeless attempt I've tried to use rawbodywriter, but then you can't inject stuff because you will run into problems with content-length (which I assume I'm not doing now )

I've written a little class that 'appends' a dynamic array after an inputstream (because I assumed writing a stream and then some text to bodywriter wouldn't work). Even that doesn't work. While my laptop claims it received all data from clientRequest, by the time it reaches my computer I get 'took to long to respond' or some sort.
When extending to https, I get the lovely informative "Handling of connection failed: Operating on closed TCPConnection." spammed a gazillion times in the terminal.

Am I missing something obvious? or is piping an outputstream through a inputstream broken?

At some point I even got the path to my libevent.a file spawned with a random string at the end. I think it's supposed to be a warning/error/exception?

Re: proxy injecting html

On Wed, 12 Jun 2013 07:53:21 GMT, maarten wrote:

In a hopeless attempt I've tried to use rawbodywriter, but then you can't inject stuff because you will run into problems with content-length (which I assume I'm not doing now )

I've written a little class that 'appends' a dynamic array after an inputstream (because I assumed writing a stream and then some text to bodywriter wouldn't work). Even that doesn't work. While my laptop claims it received all data from clientRequest, by the time it reaches my computer I get 'took to long to respond' or some sort.
When extending to https, I get the lovely informative "Handling of connection failed: Operating on closed TCPConnection." spammed a gazillion times in the terminal.

Am I missing something obvious? or is piping an outputstream through a inputstream broken?

At some point I even got the path to my libevent.a file spawned with a random string at the end. I think it's supposed to be a warning/error/exception?

This is what I see when reading the source of youtube.com:
(insert perfectly valid html)

<li class="guide-channel" >

<a class="guide-item yt-uix-sessionlink  "
  href="/feed/UCn8zNIfYAQNdrFRrr8oibKw"
    title="vice"
  data-channel-id="UCn8zNIfYAQNdrFRrr8oibKw"
  data-sessionlink="ei=7FC4UeGyNJy5hgHk9IGgBQ&amp;ved=CBkQgB8oDA&amp;feature=g-channel"
>
  <span class="" >
      <span class="thumb">    <span class="video-thumb  yt-thumb yt-thumb-18"
  >
  <span class="yt-thumb-squ

It's like it's getting cut off, like the connection is getting flushed prematurely.

Re: proxy injecting html

On Wed, 12 Jun 2013 07:53:21 GMT, maarten wrote:

In a hopeless attempt I've tried to use rawbodywriter, but then you can't inject stuff because you will run into problems with content-length (which I assume I'm not doing now )

Did you use readRawBody in conjunction with writeRawBody or the normal bodyReader? The former, I think, should work if the contents are not modified.

I've written a little class that 'appends' a dynamic array after an inputstream (because I assumed writing a stream and then some text to bodywriter wouldn't work). Even that doesn't work. While my laptop claims it received all data from clientRequest, by the time it reaches my computer I get 'took to long to respond' or some sort.
When extending to https, I get the lovely informative "Handling of connection failed: Operating on closed TCPConnection." spammed a gazillion times in the terminal.

Am I missing something obvious? or is piping an outputstream through a inputstream broken?

This part is supposed to work, but maybe the partial reply is just a symptom caused by something else (such as a wrong HTTP header). (for reference: issue #243).

At some point I even got the path to my libevent.a file spawned with a random string at the end. I think it's supposed to be a warning/error/exception?

That sounds bad. Do you still have the exact output lying around?

Re: proxy injecting html

On Wed, 12 Jun 2013 11:11:10 GMT, maarten wrote:

This is what I see when reading the source of youtube.com:
(insert perfectly valid html)

(...)

It's like it's getting cut off, like the connection is getting flushed prematurely.

Using the pasted code youtube works fine for me, at least on Windows (also using the libevent back end). I think this needs some debugging by looking at the exact TCP traffic.

Re: proxy injecting html

Yes, appears to work with the pasted code now.

I didn't use rawbody/rawwrite for things that shouldn't be modified and that is a good idea.

I think the libevent error/warning arose when I tried to combine writerawbody with bodywriter. I really should've kept the source...

Is there an easy way to operate on streams? or is the prefered way to write a stream class that takes a stream and operates on it while writing out?

On Thu, 20 Jun 2013 05:46:31 GMT, Sönke Ludwig wrote:

On Wed, 12 Jun 2013 11:11:10 GMT, maarten wrote:

This is what I see when reading the source of youtube.com:
(insert perfectly valid html)

(...)

It's like it's getting cut off, like the connection is getting flushed prematurely.

Using the pasted code youtube works fine for me, at least on Windows (also using the libevent back end). I think this needs some debugging by looking at the exact TCP traffic.