teslariu

vuln

Jul 24th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import sqlite3
  5.  
  6. conn = sqlite3.connect("personas.sqlite")
  7.  
  8. cursor = conn.cursor()
  9.  
  10. cursor.execute("CREATE TABLE personas(nombre TEXT,edad NUMERIC)")
  11.  
  12. conn.commit()
  13.  
  14. nombre = input("Ingrese su nombre: ")
  15. edad = int(input("Ingrese su edad: "))
  16.  
  17. # consulta vulnerable a SQL injection
  18. cursor.executescript(f"INSERT INTO personas VALUES ('{nombre}', {edad})")
  19.  
  20. conn.commit()
  21. print("Datos ingresados correctamente")
  22.  
  23. """
  24. Si ingreso:
  25. >> nombre: Carlos', 30); DELETE FROM personas;--
  26. >> edad: 30
  27.  
  28. cursor.execute(f"INSERT INTO personas VALUES ('Carlos', 30); DELETE FROM personas;-- , 30)")
  29. """
  30.  
Advertisement
Add Comment
Please, Sign In to add comment