Advertisement
Combreal

NCProgrammation1.cpp

Jul 9th, 2020
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string>
  5. #include <sstream>
  6. #include <windows.h>
  7. using namespace std;
  8.  
  9. LPWSTR stringToLPWSTR(const std::string& instr);
  10.  
  11. int main(void)
  12. {
  13.     ShellExecute(NULL, "open", "C:\\windows\\system32\\cmd.exe", " /C C:\\Temp\\wget.exe https://www.newbiecontest.org/epreuves/prog/prog1.php --no-check-certificate --load-cookies D:\\Documents\\NewbieContest\\Programmation\\Renvoi\\cookies.txt -p -O D:\\Documents\\NewbieContest\\Programmation\\Renvoi\\prog1.html", NULL, SW_HIDE);
  14.     FILE* file = NULL;
  15.     file = fopen("prog1.html", "r");
  16.     char line[256];
  17.     int magicNumber = 0;
  18.     if (file)
  19.     {
  20.         while (fgets(line, sizeof(line), file))
  21.         {
  22.             stringstream ss;    
  23.             ss << line;
  24.             string temp;
  25.             int found;
  26.             while (!ss.eof())
  27.             {
  28.                 ss >> temp;
  29.                 if (stringstream(temp) >> found)
  30.                     magicNumber = found;
  31.                 temp = "";
  32.             }
  33.         }
  34.         cout << "The number : " << magicNumber << endl;
  35.     }
  36.     string URL = "https://www.newbiecontest.org/epreuves/prog/verifpr1.php?solution=";
  37.     URL.append(to_string(magicNumber));
  38.     ShellExecuteW(NULL, L"open", L"C:\\Program Files\\Mozilla Firefox\\firefox.exe", stringToLPWSTR(URL), NULL, SW_SHOW);
  39.     system("pause");
  40. }
  41.  
  42. LPWSTR stringToLPWSTR(const std::string& instr)
  43. {
  44.     int bufferlen = ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), NULL, 0);
  45.     LPWSTR widestr = new WCHAR[bufferlen + 1];
  46.     ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), widestr, bufferlen);
  47.     widestr[bufferlen] = 0;
  48.     return widestr;
  49. }
  50. //export cookie addon on NewbieContest to D:\\Documents\\NewbieContest\\Programmation\\Renvoi\\cookies.txt
  51. //g++ -Wall -o tok main.cpp
  52. //got : Ce n'est pas le bon nombre.. Retente ta chance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement