diff --git a/src/command.cpp b/src/command.cpp index d412b55..6bb2122 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -80,8 +80,6 @@ string command::run(const string url, map map) }, cpr::Parameters{ params }); - cout << response.status_code << endl; - return response.text; } diff --git a/src/command.hpp b/src/command.hpp index 9a03313..e48f3e2 100644 --- a/src/command.hpp +++ b/src/command.hpp @@ -38,6 +38,28 @@ public: virtual string execute(const vector& args) = 0; virtual SERVICE_TYPE get_service_type() = 0; + inline string get_category() + { + switch (get_service_type()) + { + case PROD_ROS: + return "prod.ros"; + break; + case PROD_ROS_LAUNCHER: + return "prod.ros (launcher)"; + break; + case PROD_SCAPI_AMC: + return "SCAPI"; + break; + case PROD_CLOUD: + return "cloud"; + break; + default: + return "unknown"; + break; + } + } + static ROSCrypt* m_launcher_ros; static ROSCrypt* m_ros; }; diff --git a/src/commands/prod.ros.rockstargames.com/Auth/CreateTicket.cpp b/src/commands/prod.ros.rockstargames.com/Auth/CreateTicket.cpp index 989a43b..bbce651 100644 --- a/src/commands/prod.ros.rockstargames.com/Auth/CreateTicket.cpp +++ b/src/commands/prod.ros.rockstargames.com/Auth/CreateTicket.cpp @@ -110,7 +110,10 @@ class CreateTicket : command } } - string data = command::get(hash()("getaccountinfo"))->execute({}); + string data = ""; + if (!TICKET.empty()) + data = command::get(hash()("getaccountinfo"))->execute({}); + if (data.empty() || data.contains("Internal Server Error") || data.contains("AuthenticationFailed")) { cout << "Auth -> Cached session is no longer valid... recreating now." << endl; diff --git a/src/commands/scapi.rockstargames.com/Search/SearchCrew.cpp b/src/commands/scapi.rockstargames.com/Search/SearchCrew.cpp new file mode 100644 index 0000000..99bf887 --- /dev/null +++ b/src/commands/scapi.rockstargames.com/Search/SearchCrew.cpp @@ -0,0 +1,26 @@ +#include "../../../command.hpp" +#include + +class SearchCrew : command +{ + using command::command; + + SERVICE_TYPE get_service_type() { return SERVICE_TYPE::PROD_SCAPI_AMC; } + + virtual string execute(const vector& args) + { + map map; + map["title"] = "gtav"; + map["platform"] = "pc"; + map["includeCommentCount"] = "false"; + //map["searchTerm"] = "looping"; + //map["sort"] = "membercount"; + //map["dateRange"] = "any"; + //map["pageSize"] = "1"; + //map["crewtype"] = "rockstar"; + + return run("https://scapi.rockstargames.com/search/crew", map); + } +}; + +SearchCrew g_search_crew("searchcrew"); \ No newline at end of file diff --git a/src/commands/scapi.rockstargames.com/Search/SearchMission.cpp b/src/commands/scapi.rockstargames.com/Search/SearchMission.cpp index 4c2aec9..10acab7 100644 --- a/src/commands/scapi.rockstargames.com/Search/SearchMission.cpp +++ b/src/commands/scapi.rockstargames.com/Search/SearchMission.cpp @@ -13,6 +13,12 @@ class SearchMission : command map["title"] = "gtav"; map["platform"] = "pc"; map["includeCommentCount"] = "false"; + map["searchTerm"] = "looping"; + //map["sort"] = "date"; + //map["dateRange"] = "any"; + //map["creatorRockstarId"] = "12345678"; + map["pageSize"] = "1"; + //map["filter"] = "friends"; return run("https://scapi.rockstargames.com/search/mission", map); } diff --git a/src/commands/scapi.rockstargames.com/Search/SearchPhoto.cpp b/src/commands/scapi.rockstargames.com/Search/SearchPhoto.cpp new file mode 100644 index 0000000..791ff85 --- /dev/null +++ b/src/commands/scapi.rockstargames.com/Search/SearchPhoto.cpp @@ -0,0 +1,30 @@ +#include "../../../command.hpp" +#include + +class SearchPhoto : command +{ + using command::command; + + SERVICE_TYPE get_service_type() { return SERVICE_TYPE::PROD_SCAPI_AMC; } + + virtual string execute(const vector& args) + { + map map; + map["title"] = "gtav"; + map["platform"] = "pc"; + map["includeCommentCount"] = "false"; + //map["searchTerm"] = "looping"; + //map["sort"] = "date"; + //map["dateRange"] = "any"; + //map["creatorRockstarId"] = "12345678"; + //map["pageSize"] = "1"; + //map["filter"] = "friends"; + //map["regularPhoto"] = "true"; + //map["selfie"] = "true"; + //map["mugshot"] = "true"; + + return run("https://scapi.rockstargames.com/search/photo", map); + } +}; + +SearchPhoto g_search_photo("searchphoto"); \ No newline at end of file diff --git a/src/commands/scapi.rockstargames.com/Search/SearchVideo.cpp b/src/commands/scapi.rockstargames.com/Search/SearchVideo.cpp new file mode 100644 index 0000000..74faac5 --- /dev/null +++ b/src/commands/scapi.rockstargames.com/Search/SearchVideo.cpp @@ -0,0 +1,27 @@ +#include "../../../command.hpp" +#include + +class SearchVideo : command +{ + using command::command; + + SERVICE_TYPE get_service_type() { return SERVICE_TYPE::PROD_SCAPI_AMC; } + + virtual string execute(const vector& args) + { + map map; + map["title"] = "gtav"; + map["platform"] = "pc"; + map["includeCommentCount"] = "false"; + //map["searchTerm"] = "looping"; + //map["sort"] = "date"; + //map["dateRange"] = "any"; + //map["creatorRockstarId"] = "12345678"; + //map["pageSize"] = "1"; + //map["filter"] = "friends"; + + return run("https://scapi.rockstargames.com/search/video", map); + } +}; + +SearchVideo g_search_video("searchvideo"); \ No newline at end of file diff --git a/src/commands/scapi.rockstargames.com/UGC/MissionComments.cpp b/src/commands/scapi.rockstargames.com/UGC/MissionComments.cpp new file mode 100644 index 0000000..22e6107 --- /dev/null +++ b/src/commands/scapi.rockstargames.com/UGC/MissionComments.cpp @@ -0,0 +1,24 @@ +#include "../../../command.hpp" +#include + +class MissionComments : command +{ + using command::command; + + SERVICE_TYPE get_service_type() { return SERVICE_TYPE::PROD_SCAPI_AMC; } + + virtual string execute(const vector& args) + { + cout << "Specify the contentId" << endl; + string contentId; + cin >> contentId; + + map map; + map["title"] = "gtav"; + map["contentId"] = contentId; + + return run("https://scapi.rockstargames.com/ugc/mission/comments", map); + } +}; + +MissionComments g_mission_comments("getmissioncomments"); \ No newline at end of file diff --git a/src/commands/scapi.rockstargames.com/UGC/MissionDetails.cpp b/src/commands/scapi.rockstargames.com/UGC/MissionDetails.cpp new file mode 100644 index 0000000..08163bd --- /dev/null +++ b/src/commands/scapi.rockstargames.com/UGC/MissionDetails.cpp @@ -0,0 +1,24 @@ +#include "../../../command.hpp" +#include + +class MissionDetails : command +{ + using command::command; + + SERVICE_TYPE get_service_type() { return SERVICE_TYPE::PROD_SCAPI_AMC; } + + virtual string execute(const vector& args) + { + cout << "Specify the contentId" << endl; + string contentId; + cin >> contentId; + + map map; + map["title"] = "gtav"; + map["contentId"] = contentId; + + return run("https://scapi.rockstargames.com/ugc/mission/details", map); + } +}; + +MissionDetails g_mission_details("getmissiondetails"); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index d368356..f677f22 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,11 +114,15 @@ int main() SESSION_TICKET = string(session_ticket, 88); SESSION_KEY = Botan::base64_encode(reinterpret_cast(session_key), sizeof(session_key)); } + else + { + cout << "GTA5.exe was not found... trying to use cached session."; + } #endif cout << "Help:" << endl; for (auto& it : g_commands) { - cout << it.second->get_name() << endl; + cout << it.second->get_category() << " - " << it.second->get_name() << endl; } if (!TICKET.empty()) @@ -126,29 +130,43 @@ int main() cout << "Ticket " << TICKET << endl; cout << "Session Ticket " << SESSION_TICKET << endl; cout << "Session Key " << SESSION_KEY << endl; - - cout << "Enter the endpoint:" << endl; - cin >> ws >> endpoint; } - else - { - string response = command::get(hash()("createticket"))->execute({}); + else { + cout << "Do you want to proceed without session credentials? (y/n)" << endl; + cout << "If so you are not able to use most of the prod.ros endpoints" << endl; - if (TICKET.length() > 20) + string skipSessionCredentials; + cin >> skipSessionCredentials; + + if (skipSessionCredentials != "y") { - cout << "Ticket " << TICKET << endl; - cout << "Session Ticket " << SESSION_TICKET << endl; - cout << "Session Key " << SESSION_KEY << endl; + string _temp = command::get(hash()("createticket"))->execute({}); + + if (TICKET.length() > 20) + { + cout << "Ticket " << TICKET << endl; + cout << "Session Ticket " << SESSION_TICKET << endl; + cout << "Session Key " << SESSION_KEY << endl; + } } } + cout << "Enter the endpoint:" << endl; + cin >> ws >> endpoint; + while (true) { transform(endpoint.begin(), endpoint.end(), endpoint.begin(), ::tolower); static command* command = command::get(hash()(endpoint)); if (command) { - cout << command->execute({ }) << endl; + string response = command->execute({ }); + if (command->get_service_type() == SERVICE_TYPE::PROD_SCAPI_AMC && response.starts_with("{") && response.ends_with("}")) + { + response = nlohmann::json::parse(response).dump(4); + } + + cout << response << endl; } cout << "Enter the endpoint:" << endl; cin >> ws >> endpoint;