一個node.js框架,以模仿chrome上的人類互聯網瀏覽行為
HOSIT是一個節點。JS框架,它擴展了無頭的Chrome Api Puppeteer,並具有其他功能,從而使自動化的Internet瀏覽行為盡可能像人性化。
我們為在線服務研究開發了此框架,該框架需要我們的瀏覽器自動化盡可能像人性化。在我們的工作中,這真的是你嗎?一項關於在野外採用基於風險的身份驗證的實證研究,我們使用HOSIT來了解有關大型在線服務基於風險的身份驗證實踐的更多信息(這些公司保密)。
關於HOSIT以及如何將其用於自己的研究的更多詳細信息在我們的出版物中也會介紹,即使Turing有時也無法說出:模仿人形使用行為以探索在線服務。
我們於2019年5月17日錄製了此視頻,因此生成的搜索查詢反映了此處德國媒體涵蓋的當前事件(搜索查詢是由Hosit自動生成的)。
Puppeteer 0.13.0 | hosit |
---|---|
每個鍵的恆定打字速度 | 隨機鍵入隨著定義偏差的每個鍵而變化 |
點擊元素的精確中心 | 單擊元素中心的1/4大約有隨機偏差 |
0 ms按下和釋放鼠標按鈕之間的延遲 | 按下和釋放鼠標按鈕之間的隨機延遲 |
沒有滾動 | 滾動功能,包括讀取模擬 |
沒有搜索查詢生成 | 可擴展的搜索查詢生成器 |
沒有功能可以選擇選項卡或幀 | 選擇包含特定URL的選項卡/幀。 |
沒有記錄 | 擴展的日誌記錄功能(例如,屏幕截圖,將所有事件記錄到數據庫中) |
沒有驗證碼解決 | 自動求解(RE)CAPTCHAS (需要抗Captcha API密鑰) |
常用的工作流程會有很多代碼,尤其是在模擬人類式身份時 | 控制器類模擬用戶身份的行為,並簡化常用的Puppeteer Workflows的應用(例如初始化瀏覽器,打開/關閉選項卡,打字/單擊,進行屏幕截圖)。 |
使用NPM:
npm install hosit-browser
與紗線:
yarn install hosit-browser
注意:至少需要Node.js v7.6.0,因為此框架依賴於await
命令。使用Puppeteer所需的所有要求也適用於此框架。
該文檔可在Docs/api.md上找到
您還可以使用JSDOC自行生成文檔:
jsdoc -c jsdoc-conf.json
該代碼必須在異步環境中輸入:
( async ( ) => {
// Enter your code here
} ) ( ) ;
導入模塊:
// Import module
const HOSIT = require ( "hosit-browser" )
創建一個身份
const testidentity = new HOSIT . Identity ( "Firstname" , "Lastname" , new Date ( 1992 , 5 , 19 ) ,
"[email protected]" , "PASSW0RD" , "Company" , "Position" , 456 , 265 ,
global . GENDER_MALE ) ;
啟動控制器並將其分配給創建的身份。
// Initiate controller with test identity
const controller = await new HOSIT . Controller ( testidentity ) ;
// Start browser session and open new tab
await controller . init ( ) ;
現在,您可以使用Contoller對象控制身份,例如:
// Open example.com
await controller . goto ( "https://example.com" ) ;
// Wait until "More Information"-Link is visible
await controller . waitForSelector ( "a[href='http://www.iana.org/domains/example']" ) ;
// Wait a random time period with the standard values
await controller . randomWait ( ) ;
// Click on the "More Information"-Link
await controller . click ( "a[href='http://www.iana.org/domains/example']" ) ;
// Wait until the page is loaded
await controller . waitForNavigation ( ) ;
// Wait a random time period with the standard values
await controller . randomWait ( ) ;
// Open new page tab with example.net
await controller . newPage ( "http://ixquick.com" ) ;
// Wait around 5 seconds
await controller . randomWait ( 5000 ) ;
// Wait until the text field is loaded
await controller . waitForSelector ( "input[type='text']" ) ;
// Enter Stuff inside the text field
await controller . type ( "input[type='text']" , "Here is an example search query: " ) ;
await controller . typeSearchQuery ( "input[type='text']" ) ;
// Wait around 5 seconds
await controller . randomWait ( 5000 ) ;
// Close the new Page tab
await controller . closePage ( ) ;
// Wait around 5 seconds
await controller . randomWait ( 5000 ) ;
// Scroll to the bottom of the last opened page (Simulate reading)
await controller . scrollToBottom ( ) ;
測試腳本位於示例/示例。
由於木偶API提供的異步功能,請記住在大多數情況下使用await
。
為了盡可能模仿人類的瀏覽行為,瀏覽器以顯示(GUI)模式開始。我們發現檢測到鉻的無頭模式並被大型在線服務所部分阻止,而遙控GUI模式並非如此。
GUI模式可以通過使用X Virtual FrameBuffer(XVFB)以“頭部”模式啟動,可以在Linux服務器上無人頭。
安裝(例如Ubuntu):
# apt-get install xvfb
以1366x768像素分辨率啟動:
$ xvfb-run --server-args= " -screen 0 1366x768x24 " ./[path to your NodeJS script].js
大多數已知的無頭鉻檢測方法(2018年6月)可以通過未修飾版本的鉻/鉻的“ headful”模式消除。但是,我們建議通過其他調整(例如修改或刪除navigator.webdriver
對象)構建自己的鉻版本,以便更多地降低可檢測性。有關如何通過服務可以檢測到無頭瀏覽器的更多詳細信息,請參見Antoine Vastel的作品。
可以通過更改導入的HOSIT模塊中的設置參數來調整諸如瀏覽器的用戶代理字符串和窗口大小之類的設置。
按照上面的示例,我們可以檢查用戶代理到Firefox 58.0的使用:
HOSIT . Settings . USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0" ;
請注意,必須在Controller.init
命令之前設置某些設置才能處於活動狀態。所有可能的設置及其默認值都可以在include/settings.js中看到。
也可以在此處添加驗證碼求解所需的抗Captcha API密鑰。
您可以使用自己的RSS Feeds生成器來增強搜索查詢生成器列表。如果要為不同的地理位置化生成搜索查詢,這可能會很有用。
在我們的示例中,我們為美國地理位置的Google熱門趨勢採用RSS提要:
https://trends.google.com/trends/hottrends/atom/feed?pn=p1
定義新條目的屬性(就像您在include/settings.js中看到的那樣):
let trendsus = {
rssFeedURL : 'https://trends.google.com/trends/hottrends/atom/feed?pn=p1' ,
cacheFileName : "trendsusQueries" , // Name of the cache file created in tmp-folder
queryArrayObject : global . TRENDSUS_QUERIES , // our Array object where we're saving the queries
evaluationFunction : function ( item ) { // Function which evaluates every feed item and generates the query for it
// Writes item title in upper case for fun
return item . title . toUpperCase ( ) ;
}
} ;
將新條目添加到設置中定義的搜索查詢生成器列表:
HOSIT . Settings . SEARCH_QUERY_GENERATORS . hottrends = trendsus ;
如果要使用查詢生成器作為默認生成器,只需更改列表的默認對象:
HOSIT . Settings . SEARCH_QUERY_GENERATORS . default = trendsus ;
現在,我們可以使用以上示例在我們的情況下使用hottrends
使用的關鍵字來調用我們的新搜索查詢生成器:
await controller . typeSearchQuery ( "input[type='text']" , "hottrends" ) ;
如果已更改默認生成器,則可以使用較短的函數調用:
await controller . typeSearchQuery ( "input[type='text']" ) ;
帶有示例的測試腳本位於示例/示例new-querygenerator.js
該框架可以擴展以進行數據庫記錄(推薦MongoDB)。有關詳細信息,請參見Hosit-Logger項目。
在2017年12月至2018年3月之間,使用了該框架並用puppeteer 0.13.0進行了測試。但是,我們認為它也可與較新的木偶版本一起使用。
我們堅信,無頭檢測方法會隨著時間的流逝而改善(例如,請參見Github上的無頭貓鼠)。在發表技術論文後,在線服務很有可能試圖防止HOSIT。因此,請隨時改善此框架。
我們在以下出版物中提供有關HOSIT的更多詳細信息。在這裡,您還可以找到有關如何將HOSIT用於自己的研究研究的信息。在您自己的研究中使用HOSIT時,請引用論文:
即使是圖靈,有時也應該無法說出:模仿在線服務探索性研究的人形使用行為(2019年)
Stephan Wiefling,Nils Gruschka和Luigi Loiacono 。
第24屆北歐安全IT系統會議(Nordsec 2019) ,丹麥AALBORG。
@inproceedings { Wiefling_Even_2019 ,
author = { Wiefling, Stephan and Gruschka, Nils and Lo Iacono, Luigi } ,
title = { Even {Turing} {Should} {Sometimes} {Not} {Be} {Able} {To} {Tell}: {Mimicking} {Humanoid} {Usage} {Behavior} for {Exploratory} {Studies} of {Online} {Services} } ,
booktitle = { 24th {Nordic} {Conference} on {Secure} {IT} {Systems} ({NordSec} 2019) } ,
series = { {Lecture} {Notes} in {Computer} {Science} } ,
volume = { 11875 } ,
pages = { 188--203 } ,
isbn = { 978-3-030-35055-0 } ,
doi = { 10.1007/978-3-030-35055-0_12 } ,
publisher = { Springer Nature } ,
location = { Aalborg, Denmark } ,
month = nov,
year = { 2019 }
}
我們還使用此工具進行了一項有關基於風險的身份驗證的全面研究:
這真的是你嗎?關於野外採用基於風險的身份驗證的實證研究(2019年)
斯蒂芬·韋菲(Stephan Wiefling),路易吉(Luigi Loigono)和馬庫斯·杜爾默斯(MarkusDürmuth) 。
第34 IFIP TC-11國際信息安全與隱私保護會議(IFIP SEC 2019) ,里斯本,葡萄牙。
@inproceedings { Wiefling_Is_2019 ,
author = { Wiefling, Stephan and Lo Iacono, Luigi and D"{u}rmuth, Markus } ,
title = { Is {This} {Really} {You}? {An} {Empirical} {Study} on {Risk}-{Based} {Authentication} {Applied} in the {Wild} } ,
booktitle = { 34th {IFIP} {TC}-11 {International} {Conference} on {Information} {Security} and {Privacy} {Protection} ({IFIP} {SEC} 2019) } ,
series = { {IFIP} {Advances} in {Information} and {Communication} {Technology} } ,
volume = { 562 } ,
pages = { 134--148 } ,
isbn = { 978-3-030-22311-3 } ,
doi = { 10.1007/978-3-030-22312-0_10 } ,
publisher = { Springer International Publishing } ,
location = { Lisbon, Portugal } ,
month = jun,
year = { 2019 }
}
該項目是根據MIT許可證(許可證)獲得許可的。