Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. from Crypto.Cipher import DES
  2. import base64
  3. from hashlib import sha1
  4. import hmac
  5.  
  6.  
  7. def pad(s): # per standard PKCS#5 is padding to blocksize 8, PKCS#7 is for any block size 1 to 255
  8.     return s + (block_size - len(s) % block_size) * chr(block_size - len(s) % block_size)
  9.  
  10. block_size = DES.block_size
  11. key = "JsF9876-"
  12. #SnNGOTg3Ni0=
  13.  
  14.  
  15. ######################
  16.  
  17. f=open("out-pay.txt", "r")
  18. viewstate = f.read()
  19. f.close()
  20.  
  21. print ("#" * 150)
  22. print (" 2 . Decoded viewstate " + viewstate + "\n\n\n\n")
  23.  
  24.  
  25. obj = DES.new(key, DES.MODE_ECB)
  26. encrypted_viewstate = obj.encrypt(pad(viewstate))
  27. print ("#" * 150)
  28. print (" 3 . Encrypted viewstate " + encrypted_viewstate + "\n\n\n\n")
  29.  
  30.  
  31. hmac_obj  = hmac.new(key,encrypted_viewstate,sha1)
  32. digested_hmac =  hmac_obj.digest()
  33. print ("#" * 150)
  34. print (" 4 . digested_hmac " + digested_hmac + "\n\n\n\n")
  35.  
  36.  
  37. final_payload = base64.b64encode(encrypted_viewstate+digested_hmac)
  38.  
  39. print ("#" * 150)
  40. print (" 5 . final_payload \n\n\n\n" + final_payload + "\n\n\n\n")
  41.  
  42. f= open("final_enc.txt","w")
  43. f.write (final_payload)
  44. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement