username = pickle.loads(base64.decode(userlogin))
username = "admin"
query = "SELECT name FROM users WHERE name = '%s'"
conn = MySQLdb.connect('localhost', 'dbAdmin', 'lka8j30lJJal##', 'blog');
c = conn.cursor()
This is a Python script excerpt, it uses MYSQLdb to connect to a SQL database using the admin username and presumably, a hashed password.
I believe the vulnerability is in the password, or in how the query is structered. It uses a variable placeholder %s where maybe a user could inject malicious code, however, I believe the try: and except: blocks prevent this.
What are your thoughts on this code, do you spot any vulnerabilities?