Advertisement
Guest User

lab6

a guest
Nov 12th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. import json
  2. import requests
  3. from Crypto.Cipher import AES
  4.  
  5. BLOCK_SIZE = 16
  6.  
  7. def get(url):
  8.     return requests.get(url, headers={'Content-Type': 'application/json', 'charset': 'utf-8'})
  9.  
  10. def post(url, text):
  11.     return requests.post(url, data = json.dumps(text), headers = {'Content-Type': 'application/json', 'charset':'utf-8'})
  12.  
  13. def xor(a, b):
  14.     return bytes([x ^ x1 for x, x1 in zip(bytes.fromhex(a), bytes.fromhex(b))])
  15.  
  16. from base64 import b64encode, b64decode
  17.  
  18.  
  19. MIN_VALUE = 10**3
  20. MAX_VALUE = 10**5
  21. CHALLENGES_ID = 21
  22. URL = 'http://192.168.56.103/api/IvIsTime/Chumak/'
  23.  
  24. cpin = get(URL + str(1) + "/encryptedpin")
  25.  
  26. for chal in range(1, CHALLENGES_ID):  
  27.     valide = get(URL + str(chal) + "/validate")
  28.    
  29.    
  30.     print('Validation pin: ', b64decode(valide.text))
  31.    
  32.     for numpin in range(MIN_VALUE, MAX_VALUE, 1):
  33.         pin = str(b64encode(bytes(str(numpin), 'utf-8')))[2:-1]
  34.  
  35.         if numpin%100 == 0:
  36.             cpin = get(URL + str(chal) + "/encryptedpin")
  37.  
  38.         encpin = post(URL + str(chal) + "/noentropy", pin)
  39.  
  40.         if cpin.text == encpin.text:
  41.             print('Encryption pin: ', numpin)
  42.             break
  43.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement