<div dir="ltr"><div><div><div>I'm working on controlled environment for analysing malicious JS code. I use PhantomJS (based on Webkit) to execute it.<br><br></div>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:<br>Object.defineProperty(window.location, "href",<br>{<br> get: function ()<br> {<br> document.write("HOOK");<br> }<br>});<br>console.log(window.location);<br><br></div>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.<br><br></div>Could you please help me with this task? How can I make attributes "hookable" in Webkit?</div>