0

I'm new to Python and was wondering about some security aspects of the input() function, especially in combination with Selenium. When researching the topic of using Selenium to log into a website in an automated way I found some users on forum posts that didn't point out that hard-coding the user name and password into the .py file can be dangerous (because I would assume if your .py file was accidentally shared with a third party the user name and password could just be checked in the file). A better solution would probably be to let the user input their credentials via input(). I was wondering if this is a safe approach and have a few questions:

  1. Is it somehow possible to retrieve the user name or password that was given via input() by the user after the script is finished?
  2. Are there are other security aspects that have to be considered when using Selenium? Is user input or even parts of the code somehow shared (e.g. with Google when using the Chromedriver)?
  3. Are there better ways that I am not aware of to log into a website with Selenium?

1 Answers1

0
getpass.getpass()

getpass.getuser()

https://docs.python.org/3/library/getpass.html#:~:text=Prompt%20the%20user%20for%20a,replace%20error%20handler%20if%20needed.

Use this instead , this will not show users password when they type it

Other than that you are any way storing it to a varaible so there no other safety concerns .

If you are sending this information through network then use encryption

PDHide
  • 18,113
  • 2
  • 31
  • 46