Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Forked from BosnaZmaj/helper.py
Last active January 16, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amcgregor/39f6477fa66a392c7bfe3efb6df3bc99 to your computer and use it in GitHub Desktop.
Save amcgregor/39f6477fa66a392c7bfe3efb6df3bc99 to your computer and use it in GitHub Desktop.
class Helper:
encoding = 'utf-8'
def __init__(self, udid, it_pro):
self.udid = udid
self.itpro = it_pro
def employee_id(self):
sql = "select emplid from emplid_to_alphaname where alphaname = (%s);", (self.udid, )
print(sql)
class Helper:
encoding = 'utf-8'
def __init__(self, udid, it_pro):
self.udid = udid
self.itpro = it_pro
def employee_id(self):
sql = "select emplid from emplid_to_alphaname where alphaname = (%s);" % (self.udid, )
print(sql)
In [12]: Helper("False); DROP TABLE users; -- You've been pwned. --", 42).employee_id()
select emplid from emplid_to_alphaname where alphaname = (False); DROP TABLE users; -- You've been pwned. --);
And all of your user data is now deleted. This is a demonstration of how NOT to perform variable expansion in SQL.
USE PREPARED STATEMENTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment