tags:

views:

44

answers:

4

Imagine an application that while running injects a "Hello world" message on every web page you visit.

How do I monitor and modify all HTTP traffic happening on an OS X machine?

Monitoring and modifying all browser traffic would be good enough as well.

Solution can be language agnostic; Python would be awesome.

A: 

GlimmerBlocker achieves this by implementing a HTTP proxy server and routing all traffic through it — allowing it to modify pages as it goes along. In this instance, it blocks adverts and modifies pages to provide more features.

I imagine that most other ways of implementing this would require root etc access to do.

iKenndac
This is a great link! I'll look through its source to find out what it does. Thank you!
Marcus Westin
+1  A: 

You can try tcpdump for monitoring. If You are interested in editing html try adding custom javascript for example with greasemonkey. If You want change headers and stuff like that try http://portswigger.net/proxy/.

Maciek Sawicki
The solution needs to be cross-browser. A grease monkey script would unfortunately not do the job
Marcus Westin
so only way is proxy (or lower level staff like tcp sniffing). But I will on computers that You can control or that are in network that you can control.
Maciek Sawicki
A: 

Charles has a rewrite facility.

David Dorward
I need a programmatic solution. Thanks for the link though!
Marcus Westin
A: 

How about writing "proxy" app in php? Fetching web pages in php is easy. You can make form for taking url, fetch the website, customize it and then output it...

Maciek Sawicki