一、目的
由于實驗需要,我想要實作一個這樣的功能,使用浏覽器浏覽一個網站時,将該網站的javascript腳本調用了哪些api記錄下來。
test.html
1.js
以上面這段代碼為例,當浏覽器浏覽test.html時,腳本引擎會解析document.write,screen.width,screen.height,screen.availLeft,,screen.availTop,并執行相應的函數,我想将哪個腳本掉用了什麼樣的函數記錄下來,也就是輸出格式如下的日志
Document::wirte onURL:test.html onJsURL:test.html
Document::write onURL:test.html onJsURL:test.html
Screen::width onURL:test.html onJsURL:test.html
Screen::height onURL:test.html onJsURL:test.html
Document::write onURL:test.html onJsURL:js/1.js
Document::write onURL:test.html onJsURL:js/1.js
Screen::availLeft onURL:test.html onJsURL:js/1.js
Screen::availTop onURL:test.html onJsURL:js/1.js
為什麼要實驗這樣的功能呢?主要是為了分析javascript代碼的行為,觀測其動作,可以進行惡意代碼檢測等。
二、chromium簡介
chromium的浏覽器核心是webkit,而webkit中使用的v8腳本引擎。所謂浏覽器核心就是要實作浏覽器的核心功能,即排版渲染功能。如下圖所示:
那麼浏覽器是如何