Advertisement
teslariu

sql injection

Nov 25th, 2022
1,397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import sqlite3
  5. # ataque por SQL Injection
  6. # INSERT INTO personas VALUES ('Ale',30); DELETE FROM personas; --', 30
  7.  
  8. # >> Ingrese su nombre: Ale',30); DELETE FROM personas;--
  9. # >> Ingrese su edad: 30
  10.  
  11. # ¿Como queda la consulta?
  12. # "INSERT INTO personas VALUES('Ale',30); DELETE FROM personas;--,30)"
  13.  
  14. conn = sqlite3.connect("base.sqlite")
  15.  
  16. cursor = conn.cursor()
  17.  
  18. nombre = input("Ingrese su nombre: ")
  19. edad = int(input("Ingrese su edad: "))
  20.  
  21.  
  22. # agrego los datos a la tabla
  23. cursor.executescript(f"INSERT INTO personas VALUES('{nombre}',{edad})")
  24. conn.commit()
  25.  
  26.  
  27. cursor.execute("SELECT * FROM personas")
  28. valores = cursor.fetchall()
  29. print(valores)
  30.  
  31.  
  32. conn.close()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement