Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. from flask import Flask,render_template, request, redirect, flash, url_for
  2. from flask_sqlalchemy import SQLAlchemy
  3.  
  4.  
  5.  
  6. app = Flask(__name__)
  7.  
  8. '''
  9. #CONEXION CON LA BASE DE DATOS
  10. '''
  11. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///vuls.db'
  12. app.config['SECRET_KEY'] = "random string"
  13.  
  14. db = SQLAlchemy(app)
  15. class Vulnerabilidad(db.Model):
  16. cod = db.Column('cod', db.Integer, primary_key = True)
  17. id_vuln = db.Column(db.String(10))
  18. origen_vul = db.Column(db.String(50))
  19. cve = db.Column(db.String(12))
  20. titulo = db.Column(db.String(30))
  21. descripcion = db.Column(db.String(255))
  22. plan_acc = db.Column(db.String(255))
  23. exploit = db.Column(db.String(255))
  24. categoria = db.Column(db.String(255))
  25. impacto = db.Column(db.String(255))
  26. habilidad = db.Column(db.String(255))
  27. riesgo = db.Column(db.String(255))
  28. fecha_val = db.Column(db.String(255))
  29. nie = db.Column(db.String(255))
  30.  
  31.  
  32. def __init__(self,id_vuln, origen_vuln, cve, titulo, descripcion, plan, exploit, cat, impacto, habilidad, riesgo, fecha, nie):
  33. self.id_vuln = id_vuln
  34. self.origen_vuln = origen_vuln
  35. self.cve = cve
  36. self.titulo = titulo
  37. self.descripcion = descripcion
  38. self.plan_acc = plan_acc
  39. self.exploit = exploit
  40. self.categoria = categoria
  41. self.impacto = impacto
  42. self.habilidad = habilidad
  43. self.riesgo = riesgo
  44. self.fecha_val = fecha_val
  45. self.nie = nie
  46.  
  47.  
  48.  
  49.  
  50. db.create_all()
  51.  
  52. @app.route('/')
  53. def index():
  54. return render_template('index.html')
  55.  
  56. @app.route('/index.html')
  57. def lll():
  58. return render_template('index.html')
  59.  
  60.  
  61. @app.route('/addVul.html')
  62. def new_vul():
  63. return render_template('addVul.html')
  64.  
  65. '''
  66. Esqueleto funcion subir datos con sqlite MODIFICAR CON LA BD ELEGIDA
  67. '''
  68. @app.route('/addrec',methods = ['POST', 'GET'])
  69. def addrec():
  70.  
  71. if request.method == 'POST':
  72. try:
  73.  
  74. id_v = str(request.form['id_vuln'])
  75. ori_vul =str(request.form['origen_vuln'])
  76. cve = str(request.form['cve'])
  77. titulo = str(request.form['titulo'])
  78. descripcion = str(request.form['descripcion'])
  79. plan = str(request.form['plan_acc'])
  80. exploit = str(request.form['exploit'])
  81. cat = str(request.form['categoria'])
  82. impact = str(request.form['impacto'])
  83. hab = str(request.form['habilidad'])
  84. riesgo = str(request.form['riesgo'])
  85. fecha = str(request.form['fecha_val'])
  86. nie = str(request.form['nie'])
  87.  
  88.  
  89.  
  90. test=Vulnerabilidad(id_v, ori_vul,cve, titulo, descripcion, plan, exploit,cat, impact, hab, riesgo, fecha, nie)
  91.  
  92.  
  93. msg = "creado objeto"
  94.  
  95.  
  96. except:
  97. msg = "error"
  98. finally:
  99. return render_template('result.html', msg = msg)
  100.  
  101. if request.method == 'GET':
  102. return 'Ok'
  103.  
  104. if __name__ == '__main__':
  105. app.run(debug=True, host='0.0.0.0')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement