Advertisement
teslariu

inyeccion sql

Jan 29th, 2022
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Script que muestra prevencion inyeccion de codigo SQL
  6. """
  7. import sqlite3
  8.  
  9. conn = sqlite3.connect("base.sqlite3")
  10. cursor = conn.cursor()
  11.  
  12. nombre = input("Ingrese un nombre: ")
  13. edad = int(input("Ingrese una edad: "))
  14.  
  15. cursor.executescript(f"INSERT INTO personas VALUES('{nombre}',{edad})")
  16. conn.commit()
  17.  
  18. print("Datos ingresados correctamente")
  19.  
  20. conn.close()
  21.  
  22. # >>> Nombre:  Carlos',30); DELETE FROM personas; --
  23. # >>> Edad: 15
  24. # f"INSERT INTO personas VALUES('Carlos',30); DELETE FROM personas; --,15)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement