Session.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef SESSION_H
  2. #define SESSION_H
  3. #include <vector>
  4. #include <random>
  5. #include <memory>
  6. #include <functional>
  7. #include <climits>
  8. #include <algorithm>
  9. #include "Utils.h"
  10. #include "stdlib.h"
  11. #include "ShannonConnection.h"
  12. #include "LoginBlob.h"
  13. #include "ApResolve.h"
  14. #include "PlainConnection.h"
  15. #include "Packet.h"
  16. #include "ConstantParameters.h"
  17. #include "Crypto.h"
  18. #include "NanoPBHelper.h"
  19. #include "protobuf/authentication.pb.h"
  20. #include "protobuf/keyexchange.pb.h"
  21. #define SPOTIFY_VERSION 0x10800000000
  22. #define LOGIN_REQUEST_COMMAND 0xAB
  23. #define AUTH_SUCCESSFUL_COMMAND 0xAC
  24. #define AUTH_DECLINED_COMMAND 0xAD
  25. class Session
  26. {
  27. private:
  28. ClientResponseEncrypted authRequest;
  29. ClientResponsePlaintext clientResPlaintext;
  30. ClientHello clientHello;
  31. APResponseMessage apResponse;
  32. std::shared_ptr<PlainConnection> conn;
  33. std::unique_ptr<Crypto> crypto;
  34. std::vector<uint8_t> sendClientHelloRequest();
  35. void processAPHelloResponse(std::vector<uint8_t> &helloPacket);
  36. public:
  37. Session();
  38. ~Session();
  39. std::shared_ptr<ShannonConnection> shanConn;
  40. std::shared_ptr<LoginBlob> authBlob;
  41. void connect(std::unique_ptr<PlainConnection> connection);
  42. void connectWithRandomAp();
  43. void close();
  44. std::vector<uint8_t> authenticate(std::shared_ptr<LoginBlob> blob);
  45. };
  46. #endif