[webkit-help] How to set getter on document.location?

Владимир Мартьянов vilgeforce at gmail.com
Thu Jul 9 03:23:32 PDT 2015


I'm working on controlled environment for analysing malicious JS code. I
use PhantomJS (based on Webkit) to execute it.

Now I'm trying to intercept get acces to window.location to return fake
location to analysed script, but I can't do it. My test JS code:
Object.defineProperty(window.location, "href",
{
  get: function ()
  {
    document.write("HOOK");
  }
});
console.log(window.location);

When I try to execute it I got "Attempting to change access mechanism for
an unconfigurable property.". I patched Location.idl: added "Deletable" to
"attribute DOMString href", rebuilt the project and test it again. This
won't work too. I tried to patch DOMWindow.idl (Deletable on attribute
location) and other files and now I gave up with it.

Could you please help me with this task? How can I make attributes
"hookable" in Webkit?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-help/attachments/20150709/49709832/attachment.html>


More information about the webkit-help mailing list