Re:Firefox and IE's "View source" can be spoofed to show any...
by HNatWORK on Thursday September 08, 2011 @02:30PM
(#2975060)
I believe Chrome shows the original source because when you View Source, it requests the page again. This complicates debugging Ajax requests (and also Get and Post requests).
Firefox and IE show the "current" source, which is liable to be replaced as shown by dave1010uk.
Type the following into the Chrome Dev Tools console, then the Firebug console:
Re:Firefox and IE's "View source" can be spoofed to show any...
by JoachimSchipper on Thursday September 08, 2011 @04:57PM
(#2975635)
Note that re-downloading the source prevents this attack, but does not mean that the source you are looking at is what the page is actually running - just make the web server leave out the reference to evil.js the second time an IP address requests the page...
Re:Firefox and IE's "View source" can be spoofed to show any...
by knotty66 on Thursday September 08, 2011 @08:48PM
(#2976301)
I wondered if there is anything different about the second (view source) request that could be detected and a different response provided - but I don't think so after a quick look with WireShark.
Re:Firefox and IE's "View source" can be spoofed to show any...
by tspiteri on Thursday September 08, 2011 @03:16PM
(#2975231)
To see the actual source in Firefox 6, I just viewed the source without dismissing the alert, there was no need to disable anything. The only thing is that with the alert, I couldn't right click on the page and click on "View Page Source", I had to use the menu item Tools: Web Developer: Page Source (or its keyboard shortcut).
Re:Firefox and IE's "View source" can be spoofed to show any...
by dave1010uk on Thursday September 08, 2011 @03:41PM
(#2975355)
I used an alert as a quick example. You could put any HTML or JS on the page (e.g. links for SEO value, iframes with PDF exploits, a bitcoin miner or a video of Rick Astley) and when someone views the source it looks like there's nothing malicious.
Ctrl/Cmd-u can also be used to view source in Firefox.
Re:Firefox and IE's "View source" can be spoofed to show any...
by fgaaghf on Thursday September 08, 2011 @04:19PM
(#2975503)
If you want to view the current HTML source in Firefox you can use Ctrl+A and then right-click > "View Selection Source".
I think it's more a question of what do you expect to see when you "View Source". For example, I have messed around with document.write a lot and it's pretty obvious to me that, if I use view source then it's going to give me the source and any changes done to it my document.write/open/close.
In this case since document.write is used after HTML parsing has been completed it replaces the whole page and thus makes view source rather pointless.
Re:Firefox and IE's "View source" can be spoofed to show any...
by dave1010uk on Friday September 09, 2011 @02:36AM
(#2977123)
This bug isn't showing the usual generated source but some kind of hybrid between original source and generated source.
- To see the original source, hit ctrl-u before dismissing the alert.
- To see the "hybrid" source, hit ctrl-u after dismissing the alert. I always expected this to be idential to what the webserver sent, just syntax highlighted. (Though I haven't messed around with document.close before.)
- To see the generated source, hit ctrl-a, right click & "View Selection Source". This is different to the original/hybrid source as Firefox inserts html tags to make the page valid. My example had no html, head, title or body tags. This should reflect the current page DOM, as affected by any JavaScript.
Re:Firefox and IE's "View source" can be spoofed to show any...
by tspiteri on Thursday September 08, 2011 @06:51PM
(#2976003)
My intention was to suggest an easy way to view the actual source. I think your example is actually better as an example as it is easy to see the source both before and after the function is called.
Re:Firefox and IE's "View source" can be spoofed to show any...
by dave1010uk on Friday September 09, 2011 @02:26AM
(#2977095)
Nope, it's incredibly basic, just the HTML you see. I wrote the code on my phone and didn't have time to do anything like that. Here's the source: http://i.imgur.com/zV937.png - it should work served as a local file too.
It could be your browser blocking sequential alerts or some strange caching issue.
Re:Firefox and IE's "View source" can be spoofed to show any...
by dave1010uk on Thursday September 08, 2011 @02:09PM
(#2974970)
Depending on how well your terminal deals with things like high unicode characters and RTL, I wonder if you could trick curl. You could also send the curl user agent harmless HTML and send Firefox / IE user agents a nasty exploit - that would probably fool me for a while.
Re:Firefox and IE's "View source" can be spoofed to show any...
by code_duck on Thursday September 08, 2011 @10:56PM
(#2976594)
You don't have to view the output in a terminal, though - generally I wouldn't if I was really trying to look at a file.
Server side user agent discrimination is a good point. One has have the option to send his or her own lies regarding that, though. There's always a a way to follow whatever script path to its various ends...
Re:Firefox and IE's "View source" can be spoofed to show any...
by kaitnieks on Thursday September 08, 2011 @03:35PM
(#2975325)
Older Internet Explorer and Firefox versions displayed the source that was downloaded, not the one generated/modified by scripts. It makes so much more sense, especially since there was always an option to view the generated source (by using JavaScript for an example) but I don't see how you can access the downloaded source at all if View Source is replaced by View Generated Source. Hm, actually one could use FireBug and watch Net response I suppose, but that's inconvenient.
Re:Firefox and IE's "View source" can be spoofed to show any...
by dave1010uk on Thursday September 08, 2011 @02:00PM
(#2974935)
What that means (though is not how I would word it) is a document.write that is called asynchronously. The post uses an ajax request to do it but I've recreated it here [1] like this:
Re:Firefox and IE's "View source" can be spoofed to show any...
by sjs on Friday September 09, 2011 @02:12AM
(#2977063)
Although I don't use NoScript (or NotScripts) anymore the web was far less annoying without arbitrary JavaScript. I never had to leave a site because some irrelevant box popped up over the page I was looking at, or about to be.
It will be effective at blocking the Flash-like HTML ads that are going to pop up soon as well. Unless they get really creative with CSS.
Re:Firefox and IE's "View source" can be spoofed to show any...
by sesqu on Friday September 09, 2011 @01:09AM
(#2976919)
I use NoScript, but I have it set up to allow embeds and top-level references. Denying those is a stone's throw away from just turning off javascript completely, which would be tiring.
Re:Firefox and IE's "View source" can be spoofed to show any...
by dspillett on Friday September 09, 2011 @12:03PM
(#2978605)
IIRC earlier versions of FF re-request the page when you do a view source, rather than displaying a rendering of the current (potentially changed) document state. You could still spoof the source view in this case by somehow recognising the second request (though how you'd distinguish "view source" from "f5" I don't know) and sending different content back.
Firefox and IE show the "current" source, which is liable to be replaced as shown by dave1010uk.
Type the following into the Chrome Dev Tools console, then the Firebug console:
Chrome shows boolean, firefox shows undefined.[1]: https://webcache.googleusercontent.com/search?q=cache:http:/...
It works in Firefox 6, not sure about any other browsers. If you want to see the actual source, disable JavaScript (or use Chrome or curl).
Ctrl/Cmd-u can also be used to view source in Firefox.
I think it's more a question of what do you expect to see when you "View Source". For example, I have messed around with document.write a lot and it's pretty obvious to me that, if I use view source then it's going to give me the source and any changes done to it my document.write/open/close. In this case since document.write is used after HTML parsing has been completed it replaces the whole page and thus makes view source rather pointless.
- To see the original source, hit ctrl-u before dismissing the alert.
- To see the "hybrid" source, hit ctrl-u after dismissing the alert. I always expected this to be idential to what the webserver sent, just syntax highlighted. (Though I haven't messed around with document.close before.)
- To see the generated source, hit ctrl-a, right click & "View Selection Source". This is different to the original/hybrid source as Firefox inserts html tags to make the page valid. My example had no html, head, title or body tags. This should reflect the current page DOM, as affected by any JavaScript.
It could be your browser blocking sequential alerts or some strange caching issue.
I'd have a more substantial comment, I hope, if the site was loading.
fetch http://jcs.org/tmp/nothing.html through curl:
but you just aren't seeing the content.Server side user agent discrimination is a good point. One has have the option to send his or her own lies regarding that, though. There's always a a way to follow whatever script path to its various ends...
If anyone happens to load this elusive "View Source Spoof" page, please leave a nice detailed description for the rest of us.
Our minds can draw the pictures :)
https://webcache.googleusercontent.com/search?q=cache:http:/...
The best way to access downloaded source is probably with JavaScript turned off.
I especially don't understand this part:
What is "outside of a script tag embedded inline in the page" supposed to mean?It will be effective at blocking the Flash-like HTML ads that are going to pop up soon as well. Unless they get really creative with CSS.