GithubHelp home page GithubHelp logo

Can't read cookies about tor-browser-selenium HOT 6 CLOSED

webfp avatar webfp commented on May 28, 2024
Can't read cookies

from tor-browser-selenium.

Comments (6)

tkell avatar tkell commented on May 28, 2024

Example using Twitter login:

from tbselenium.tbdriver import TorBrowserDriver

pref_dict = {'network.proxy.no_proxies_on': '.twitter.com'}
with TorBrowserDriver("/opt/tbb/tor-browser_en-US/", pref_dict=pref_dict) as driver:
    driver.implicitly_wait(5)

    driver.get('https://twitter.com/login')
    username_field = driver.find_element_by_css_selector('input[class="js-username-field email-input js-initial-focus"]')
    username_field.send_keys('<TWITTER_USERNAME>')
    password_field = driver.find_element_by_css_selector('input[class="js-password-field"]')
    password_field.send_keys('<TWITTER_PASSWORD>')

    submit_button = driver.find_element_by_css_selector('button[class="submit btn primary-btn"]')
    submit_button.click()

    print driver.current_url
    print driver.get_cookies()

This outputs:

https://twitter.com/
[]

from tor-browser-selenium.

gunesacar avatar gunesacar commented on May 28, 2024

Thanks for reporting.

I tried with vanilla FirefoxDriver and get the same result (no cookies).
Also, reading https://github.com/robotframework/Selenium2Library/issues/177, I'm thinking that this may be a FirefoxDriver issue.

If that's compatible with what you're doing, you can disable PBM to access cookies.
Just add "browser.privatebrowsing.autostart": False to the pref_dict you have.
(Idea from https://github.com/robotframework/Selenium2Library/issues/177#issuecomment-37808376)

Disabling PBM may have side effects like storing things on the disk, please make sure it's OK for your case.

You can also use driver.execute_script("return document.cookie"), but httponly cookies will be missing in the list.

from tor-browser-selenium.

tkell avatar tkell commented on May 28, 2024

That config fixes it, 10,000 thanks!

Feel free to close this issue – I'll circle back with SecureDrop people to see if that's an acceptable bit of config to have in the tests.

from tor-browser-selenium.

gunesacar avatar gunesacar commented on May 28, 2024

I'm glad it worked. Maybe I should add a note about this in the troubleshooting section.

Thanks again for reporting.

from tor-browser-selenium.

kushaldas avatar kushaldas commented on May 28, 2024

Note: "browser.privatebrowsing.autostart": False works when working against 127.0.0.1 address, but not with the onion addresses. Could not find an way to get the cookies.

from tor-browser-selenium.

gunesacar avatar gunesacar commented on May 28, 2024

I could print the cookies on http://www.propub3r6espa33w.onion/ using the following code: https://gist.github.com/gunesacar/0e0acfa8d71deffe6c45ccd29b8247f1

I run the following...:
python cookie_check.py /path/to/tor-browser_en-US/ https://www.propub3r6espa33w.onion/

...it prints (along with a ton of other debug messages from Firefox):

Finished loading https://www.propub3r6espa33w.onion/
Cookies: pp-tracking={"pageCount":0}; __gads=ID=5b2f86bbd40732dd:T=1517883426:S=ALNI_Mb57Tl8YkAq9jenlcBbufsbX9yLJQ```

from tor-browser-selenium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.