1.  蹭个热点,看到已经有个网页版本的测试浏览器是否Vulnerable to Spectre,我就弄了这么个玩意儿。
这个网页URL是:
 p, li { white-space: pre-wrap; }

http://xlab.tencent.com/special/spectre/spectre_check.html,
我研究了下,检测的JS脚本是用Ajax做的,当浏览器下载所有JS脚本后,点击测试就是在本地完成的,而且页面没有button这种html的元素存在,刚开始有点忐忑,因为知道button我可以click() ,但是怕在这里,我是对一个div click() 有点心里没底,但是结果却是非常好。

2. 代码如下:

点击(此处)折叠或打开

  1. from selenium import webdriver
  2. import time

  3. def spectre_checker(url):
  4.     #Create a Firefox session
  5.     driver = webdriver.Firefox()
  6.     driver.implicitly_wait(30)
  7.     driver.maximize_window()
  8.     
  9.     #Fetch the application home page
  10.     driver.get(url)
  11.     time.sleep(2)
  12.     clicker=driver.find_element_by_xpath('//div[@class="progressbar"]')
  13.     clicker.click()
  14.     
  15.     time.sleep(2)
  16.     answer=driver.find_element_by_xpath('//pre[@id="notification"]/span')

  17.     print(answer.text)
  18.     
  19.     #close browser window
  20.     driver.quit()

  21. url='http://xlab.tencent.com/special/spectre/spectre_check.html'
  22. spectre_checker(url)

3. 我在Pyzo里面测试的结果如下(当然我早知道这个结果了)
在微博上看到过”Libre盖子“的说法
”Firefox 可以在 about:config 里将 javascript.options.shared_memory 设置为 False“
p, li { white-space: pre-wrap; }

点击(此处)折叠或打开

  1. In [11]: %run -i /usr/local/src/py/network/scraper/selenium/spectre_check.py

  2. $ Your browser is NOT VULNERABLE to Spectre

10-12 12:50
查看更多