一个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许可证(许可证)获得许可的。