News for hackers. Stuff that matters.
Re:Firefox and IE's "View source" can be spoofed to show any... by dave1010uk on Thursday September 08, 2011 @01:50PM (#2974889)
I've recreated a simple proof of concept here: http://taskthere.com/viewsource/

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).

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 AndyKelley on Friday September 09, 2011 @01:56AM (#2977028)
When I refresh the page, I don't see the alert again. Did you even check any referrers, or just set a flag to only show the alert once?
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 Dobbs on Thursday September 08, 2011 @04:34PM (#2975551)
If I use pentadactyl's `gf` I get the source with the alert. If I right click I get the intended result.
Re:Firefox and IE's "View source" can be spoofed to show any... by estel on Thursday September 08, 2011 @04:39PM (#2975570)
Peculiar: in FF5 I don't see the alert, but do see it in view source.