4

I'm trying running code (in Python) that can identify suspected phishing sites. I'm using Selenium's chromedriver. This is my code:

import os, os.path, sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option( "prefs", {'safebrowsing.enabled':1})

chromedriver = "my chromedriver path"
os.environ["webdriver.chrome.driver"] = chromedriver

driver = webdriver.Chrome(chromedriver, chrome_options=chrome_options)

driver.get('site url I want to check')

My code checks 'V' on "enable phishing and malware protection" in the privacy settings, but for some reason while using Chrome (not the window one opened by Python) the site I check is suspected as phishing and the Chrome window opened by my Python code is not showing anything related to phishing.

Any ideas?

Ofer
  • 41
  • 4

1 Answers1

2

Instead of using selenium, use Google Safe Browsing API directly (python wrapper):

>>> key = 'your own key'
>>> from safebrowsinglookup import SafebrowsinglookupClient
>>> client = SafebrowsinglookupClient(key)

>>> client.lookup('http://addonrock.ru/Debugger.js')
{'http://addonrock.ru/Debugger.js': 'malware'}

>>> client.lookup('http://google.com')
{'http://google.com': 'ok'}
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • i know the option to use google safe browsing api, but I'm looking for a different solution. and the code line with "safebrowsing.enabled':1" doing the same in chrome. it enables the"phishing and malware protection". – Ofer Mar 31 '15 at 08:41
  • @Ofer okay, are you sure about your last statement? Could you please refer me to the documentation? Thanks. – alecxe Mar 31 '15 at 14:51
  • i took the code from here:http://stackoverflow.com/questions/15165593/set-chrome-prefs-with-python-binding-for-selenium-in-chromedriver the 1st answer (by Xiong). i changed the "profile.default_content_settings.images" to "safebrowsing.enabled". i knew what to write instead by using the inspect element to know how this specific button is called. plus, i ran it on my computer and this button has 'V' in it. – Ofer Apr 01 '15 at 07:11
  • @Ofer you are right, the setting actually works (tested). The problem is that even if the "Phishing and malware protection" is enabled through "safebrowsing.enabled", it doesn't work - I suspect this is because we need to turn some other setting on. Haven't figured out which one yet. – alecxe Apr 01 '15 at 14:56
  • 1st of all, thank you very much for the help! do you have any ideas what it can be? i'm trying to figure it out in the past week.. no good so far – Ofer Apr 02 '15 at 06:08
  • I know this is a bit old, but from my experience the results from the SafeBrowsing API are different from what Chrome shows as malicious. But, still, I haven't had any luck making safebrowsing work on selenium. – gawry Mar 17 '16 at 00:52