views:

55

answers:

3

During a normal browsing session I want to edit a specific javascript file before the browser receives since once it gets there it's impossible to edit. Is there are any tool for this? For what I need it I can't just save it and edit it on my disk.

I'm ready to learn how to program it myself but if anyone can point out more or less what I have to do I'd be very grateful. I'd have to intercept the packets until I have the whole file while blocking the browser from receiving it any part of it, then edit it manually and forward it to the same port.

I don't think I can do this by just using pcap, I've read a bit about scapy but I'm not sure if it can help me either.

Thanks in advance.

A: 

You can probably achieve whatever it is you are wanting to do by using the firefox firebug plugin, chrome's development tools or the firefox greasemonkey plugin.

Or you could enter the files domain into your hosts file and point that domain to your local machine (running a web server), edit & save that javascript file locally and serve it from your own web server.

simplemotives
+1  A: 

You'd need to implement some sort of proxy, or hook into an existing one, and intercept the file as it's being downloaded and replace it.

Not trivial for a beginner, but a good learning project.

John Weldon
+1. was about to suggest the proxy idea as well. check out http://www.parosproxy.org/index.shtml
darren
Thanks for your comment. I'd very much like to learn how to do this, I've been googling it but there isn't much out there. Can you give any tips on where I should start: library, tutorials, etc?
A: 

If you are happy to, rather then editing a file, replace it with a local one, then I would* use Charles and its Map To Local function.

  • Actually, "did". This helped me debug a problem with a browser and a JS file I couldn't edit yesterday.
David Dorward
I downloaded it, I'll try it out, thank you.