Advertisement
tinyevil

Untitled

Nov 11th, 2018
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // client:
  2. cert = read_cert("server_cert.public_key");
  3. connection = connect_ssl("https://server");
  4. if ( !connection.check_public_key(cert) ){
  5. exit();
  6. }
  7.  
  8. challenge = connection.recv();
  9.  
  10. SN = read_device_sn()
  11.  
  12. connection.send({
  13. SN: SN,
  14. response: sha256(SN + read_device_guid() + challenge),
  15. command: whatever you want to send
  16. });
  17.  
  18. // server:
  19. connection = accept();
  20.  
  21. challenge = generate_secure_random_bytes()
  22. connection.send(challenge);
  23.  
  24. request = JSON_parse(connection.recv());
  25.  
  26. SN = request.SN
  27. response = request.response
  28. guid = find_guid_for_SN_in_database(SN)
  29.  
  30. if ( sha256(SN + guid + challenge) != response ){
  31. connection.tell_them_to_fuck_off();
  32. }
  33.  
  34. execute the command
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement