Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2. import requests
  3. import getpass
  4.  
  5. #############################################################################################################
  6. # 1.- https://egela1718.ehu.eus/login/index.php/
  7. #############################################################################################################
  8. # Nos logeamos en eGela, pasamos como parámetros el LDAP y Passwd
  9. #############################################################################################################
  10.  
  11. LDAP_usuario = raw_input("Insert your LDAP username: ")
  12. LDAP_password = getpass.getpass("Insert your LDAP password: ")
  13.  
  14. cuerpo_peticion ={'username': LDAP_usuario,
  15. 'password': LDAP_password}
  16.  
  17. response = requests.post('https://egela1819.ehu.eus/login/index.php/', data=cuerpo_peticion)
  18.  
  19. # Realiza dos redireciones:
  20. # https://egela1819.ehu.eus/login/index.php?testsession=49879
  21. # https://egela1819s.ehu.eus/
  22. # fijarse en las cabeceras Set-cookie y Cokie de las peticiones y respuesta.
  23.  
  24. # VEMOS EL HISTORIAL DE PETICIONES
  25.  
  26. for key in response.history:
  27. print ("#######################################")
  28. print key.url
  29. print "-------------------------------------- "
  30. print " CABECERAS PETICION: "
  31. print "-------------------------------------- "
  32. for key2 in key.request.headers:
  33. print key2, ":", key.request.headers[key2]
  34. print "-------------------------------------- "
  35. print " STATUS: " + str(key.status_code)
  36. print "-------------------------------------- "
  37. print " CABECERAS RESPUESTA: "
  38. print "-------------------------------------- "
  39. for key2 in key.headers:
  40. print key2, ":", key.headers[key2]
  41.  
  42.  
  43. print ("#######################################")
  44. print "-------------------------------------- "
  45. print response.url
  46. print "----- STATUS: " + str(response.status_code)
  47.  
  48. print "-------------------------------------- "
  49. print "----- CABECERAS ULTIMA PETICION : "
  50. print "-------------------------------------- "
  51. for key in response.request.headers:
  52. print key, ":", response.request.headers[key]
  53.  
  54. print "-------------------------------------- "
  55. print "----- CABECERAS ULTIMA RESPUESTA: "
  56. print "-------------------------------------- "
  57. for key in response.headers:
  58. print key, ":", response.headers[key]
  59.  
  60. f = open("egelaAula.html", 'w')
  61. f.write(response.content)
  62. f.close()
  63.  
  64. print "-------------------------------------------------------: "
  65. print "-------------------------------------------------------: "
  66. print "-------------------------------------------------------: "
  67. print "-------------------------------------------------------: "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement