Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. // ConsoleApplication4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <Windows.h>
  6. #include "base64.h"
  7. #include <iostream>
  8. #include <wchar.h>
  9. #include <stdio.h>
  10.  
  11.  
  12. using namespace std;
  13.  
  14. char buffer[100]; // Yes i know i should'nt use globals! *hug*
  15. char filename[256] = "stub"; // Yes i know i should'nt use globals! *hug*
  16.  
  17. DWORD patchedBytes = 0;
  18. char newFilename[256] = "";
  19.  
  20. int _tmain(int argc, _TCHAR* argv[])
  21. {
  22. {
  23. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  24. SetConsoleTextAttribute(hConsole, (FOREGROUND_GREEN));
  25.  
  26. }
  27.  
  28. cout << "##########################################" << endl;
  29. cout << "" << endl;
  30. cout << "" << endl;
  31.  
  32.  
  33. ZeroMemory(&buffer, 200);
  34. cout << "Enter connection URL: ";
  35. cin >> buffer;
  36.  
  37. if (strlen(buffer) > 100)
  38. {
  39. MessageBoxA(NULL, LPCSTR("File has not been patched. URL is too long!"), LPCSTR("Error!"), MB_ICONERROR);
  40. cin.get();
  41. exit(0);
  42. }
  43.  
  44. {
  45.  
  46.  
  47. string s = buffer;
  48.  
  49. string encoded = base64_encode(reinterpret_cast<const unsigned char*>(s.c_str()), s.length());
  50. string decoded = base64_decode(encoded);
  51.  
  52. cout << "encoded: " << encoded << std::endl;
  53. cout << "decoded: " << decoded << std::endl;
  54.  
  55.  
  56.  
  57. }
  58.  
  59. HANDLE resultCreateFile = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
  60. //cout << resultCreateFile << " GetLastError :" << GetLastError << endl;
  61.  
  62. DWORD resultFilePointer = SetFilePointer(resultCreateFile, (LONG)0x9BD0, nullptr, FILE_BEGIN);
  63. //cout << resultFilePointer << " GetLastError :" << GetLastError << endl;
  64.  
  65. BOOL resultWriteFile = WriteFile(resultCreateFile, buffer, 200, &patchedBytes, NULL);
  66. //cout << resultWriteFile << " GetLastError: " << GetLastError << endl;
  67. if (resultWriteFile > 0)
  68. {
  69. cout << "Save file as(don't forget file extension):";
  70. cin >> newFilename;
  71. BOOL copyFileresult = CopyFile(filename, newFilename, false);
  72.  
  73. MessageBoxA(NULL, LPCSTR("File has been successfully patched!"), LPCSTR("Success!"), MB_OK);
  74. }
  75.  
  76. else if (resultWriteFile == 0)
  77. {
  78. MessageBoxA(NULL, LPCSTR("File has not been patched, make sure Stub is available and not in use!"), LPCSTR("Error!"), MB_ICONERROR);
  79. return (0);
  80. }
  81. BOOL resultCloseHandle = CloseHandle(nullptr);
  82.  
  83. int f;
  84. cin >> f;
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement