Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <windows.h>
  4. #include <shlobj.h>
  5. #include <iostream>
  6. #using <System.dll>
  7.  
  8. using namespace System;
  9. using namespace System::Collections::Specialized;
  10. using namespace System::ComponentModel;
  11. using namespace System::Diagnostics;
  12. using namespace System::Net;
  13. using namespace System::IO;
  14.  
  15. std::string FindMSFolder()
  16. {
  17.     TCHAR path[MAX_PATH];
  18.  
  19.     BROWSEINFO bi = { 0 };
  20.     bi.lpszTitle = ("Please select your MapleStory folder...\nDefault C:\\Nexon\\MapleStory");
  21.  
  22.     LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
  23.  
  24.     if (pidl != 0)
  25.     {
  26.         //get the name of the folder and put it in path
  27.         SHGetPathFromIDList(pidl, path);
  28.  
  29.         //free memory used
  30.         IMalloc * imalloc = 0;
  31.         if (SUCCEEDED(SHGetMalloc(&imalloc)))
  32.         {
  33.             imalloc->Free(pidl);
  34.             imalloc->Release();
  35.         }
  36.  
  37.         return path;
  38.     }
  39.     return "C:\\Nexon\\Library\\maplestory";
  40. }
  41.  
  42. static String^ RetrieveWebAuthToken(String^ username, String^ password)
  43. {
  44.     WebClient^ wc = gcnew WebClient();
  45.  
  46.     String^ dID = Guid::NewGuid().ToString();
  47.  
  48.     NameValueCollection^ nvc = gcnew NameValueCollection();
  49.  
  50.     nvc->Add("userID", username);
  51.     nvc->Add("password", password);
  52.     nvc->Add("device_id", dID);
  53.  
  54.     try
  55.     {
  56.         wc->UploadValues("https://accounts.nexon.net/account/login/launcher", "POST", nvc);
  57.  
  58.         CookieContainer^ cookies = gcnew CookieContainer();
  59.         cookies->SetCookies(gcnew Uri("https://accounts.nexon.net/account/login/launcher"), wc->ResponseHeaders["Set-Cookie"]);
  60.  
  61.         String^ token = cookies->GetCookies(gcnew Uri("https://accounts.nexon.net/account/login/launcher"))["NPPv2"]->Value;
  62.  
  63.         return token;
  64.     }
  65.     catch (WebException^ ex)
  66.     {
  67.         Console::WriteLine("\n\n" + ex->Message);
  68.     }
  69. }
  70.  
  71. int main()
  72. {
  73.     SetConsoleTitle("MapleStory WebLogin Console");
  74.  
  75.     String^ folderPath = gcnew String(FindMSFolder().c_str());
  76.  
  77.     Console::Write("Email or ID: ");
  78.     String^ user = Console::ReadLine();
  79.  
  80.     // hide password input
  81.     HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
  82.     DWORD mode = 0;
  83.     GetConsoleMode(hStdin, &mode);
  84.     SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT));
  85.     //
  86.  
  87.     Console::Write("Password: ");
  88.     String^ pass = Console::ReadLine();
  89.  
  90.     String^ startToken = RetrieveWebAuthToken(user, pass);
  91.     if (startToken->Contains("NP12"))
  92.         Process::Start(folderPath + "\\MapleStory.exe", "WebStart " + startToken);
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement