Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. from hashlib import sha256
  2. import sqlite3
  3.  
  4. db = sqlite3.connect('../db/sql_inj.db')
  5. cursor = db.cursor()
  6.  
  7. cursor.execute('''CREATE TABLE users
  8. (id INTEGER PRIMARY KEY, username text, password text)
  9. ''')
  10.  
  11. db.commit()
  12.  
  13. admin_username = 'admin'
  14. admin_password = 'never_gonna_give_you_up'
  15. hashed_pass = sha256(admin_password.encode('utf-8')).hexdigest()
  16.  
  17. cursor.execute('''INSERT INTO users(username, password)
  18. VALUES(?,?)''', (admin_username, hashed_pass))
  19.  
  20. print('Admin user inserted')
  21.  
  22. cursor.execute('''CREATE TABLE "314159265358979"
  23. (id INTEGER PRIMARY KEY, token text, message text)
  24. ''')
  25.  
  26. db.commit()
  27.  
  28. token = 'n3v3r53nd4hum4n70d04m4chin35j0b'
  29. message = 'y0uv3 607 17!'
  30.  
  31. cursor.execute('''INSERT INTO "314159265358979"(token, message)
  32. VALUES(?,?)''', (token, message))
  33.  
  34. print('Token inserted')
  35.  
  36. db.commit()
  37. db.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement