IndieDeveloper

SPRX C++ AUTH

Jun 4th, 2016
1,997
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/sys_time.h>
  2. #include <sys/types.h>
  3. #include <sys/socket.h>
  4. #include <sys/syscall.h>
  5. #include <sys/timer.h>
  6. #include <netinet/in.h>
  7. #include <arpa/inet.h>
  8. #include <netdb.h>
  9. #include <netex/net.h>
  10. #include <netex/errno.h>
  11. #include <string.h>
  12. #pragma region Declarations
  13. #include <sys/ppu_thread.h>
  14. #include <string.h>
  15. #include <sys/sys_time.h>
  16. #include <sys/time_util.h>
  17. #include <stdarg.h>
  18. #include <assert.h>
  19. #include <sys/process.h>
  20. #include <sys/memory.h>
  21. #include <sys/timer.h>
  22. #include <sys/return_code.h>
  23. #include <sys/prx.h>
  24. #include <stddef.h>
  25. #include <math.h>
  26. #include <stdarg.h>
  27. #include <cellstatus.h>
  28. #include <typeinfo>
  29. #include <vector>
  30. #include <pthread.h>
  31. #include <locale.h>
  32. #include <cell/error.h>
  33. #include <sys/paths.h>
  34. #include <time.h>
  35. #include <net\if_dl.h>
  36. #include <sys/socket.h>
  37. #include <netinet/in.h>
  38. #include <arpa/inet.h>
  39. #include <cell/cell_fs.h>
  40. #include <cell/sysmodule.h>
  41. #include <stdio.h>
  42. #include <string.h>
  43. #include <cell/fs/cell_fs_errno.h>
  44. #include <cell/fs/cell_fs_file_api.h>
  45. #include <ppu_intrinsics.h>
  46. #include <cstdlib>
  47. #include "Dialog.h"
  48. #pragma comment(lib, "net_stub")
  49. #pragma comment(lib, "netctl_stub")
  50.  
  51. #define SERVER_PORT htons(80)
  52.  
  53. int Socket;
  54. struct hostent *Host;
  55. struct sockaddr_in SocketAddress;
  56. char bufferReturn[10000];
  57. char RequestBuffer[2000];
  58.  
  59. char *HookName;
  60.  
  61. int WriteinConsole(const char * s)
  62. {
  63.     uint32_t len;
  64.     system_call_4(403, 0, (uint64_t)s, std::strlen(s), (uint64_t)&len);
  65.     return_to_user_prog(int);
  66. }
  67.  
  68. void SleepMM(usecond_t time)
  69. {
  70.     sys_timer_usleep(time * 1000);
  71. }
  72.  
  73. char* SocketRequest(char* URL, char* Key, char* Path = "")
  74. {
  75.     Host = gethostbyname(URL);
  76.     SocketAddress.sin_addr.s_addr = *((unsigned long*)Host->h_addr);
  77.     SocketAddress.sin_family = AF_INET;
  78.     SocketAddress.sin_port = SERVER_PORT;
  79.     Socket = socket(AF_INET, SOCK_STREAM, 0);
  80.     if (connect(Socket, (struct sockaddr *)&SocketAddress, sizeof(SocketAddress)) != 0) {
  81.         return "CONNECTION ERROR";
  82.     }
  83.     strcpy(RequestBuffer, "GET /");
  84.     if (strlen(Path) > 0){
  85.         strcat(RequestBuffer, Path);
  86.     }
  87.     strcat(RequestBuffer, Key);
  88.     strcat(RequestBuffer, " HTTP/1.0\r\nHOST: ");
  89.     strcat(RequestBuffer, URL);
  90.     strcat(RequestBuffer, "\r\n\r\n");
  91.  
  92.     send(Socket, RequestBuffer, strlen(RequestBuffer), 0);
  93.  
  94.     while (recv(Socket, bufferReturn, 10000, 0) > 0)
  95.     {
  96.         return bufferReturn;
  97.         SleepMM(1);
  98.     }
  99.     socketclose(Socket);
  100. }
  101.  
  102. void WriteByte(int Address, unsigned char Input)
  103. {
  104.     *(unsigned char*)Address = Input;
  105. }
  106.  
  107. void encryptDecrypt(char *input, char *output) {
  108.     char key[] = { 'K', 'C', 'Q' }; //Can be any chars, and any size array
  109.  
  110.  
  111.     for (int i = 0; i < strlen(input); i++) {
  112.         output[i] = input[i] ^ key[i % (sizeof(key) / sizeof(char))];
  113.     }
  114. }
  115.  
  116. bool IsRequest(char* Key)
  117. {
  118.  
  119.     char* check = SocketRequest("www.mysite.com", Key, "KeyReturnDir");
  120.     char* s = strstr(check, "Key is valid");
  121.     if (s != NULL)
  122.     {
  123.        
  124.         return true;
  125.     }
  126.     else
  127.     {
  128.         return false;
  129.     }
  130. }
  131.  
  132. int ExitThisShit()
  133. {
  134.     system_call_1(41, 0);
  135.     return_to_user_prog(int);
  136. }
  137. char Key[]; // Key Amount . Change it if you need
  138. char* GetKey()
  139. {
  140.     int fd;
  141.     int ret;
  142.     uint64_t pos;
  143.     uint64_t nread;
  144.  
  145.     cellMsgDialogProgressBarInc(0, 1);
  146.     cellMsgDialogProgressBarSetMsg(0, "Loading Key...");
  147.     ret = cellFsOpen("/dev_hdd0/tmp/key.txt", 0, &fd, NULL, 0);
  148.     if (!ret)
  149.     {
  150.         cellFsLseek(fd, 0, CELL_FS_SEEK_SET, &pos);
  151.         ret = cellFsRead(fd, Key, sizeof(Key), &nread);
  152.         if (!ret)
  153.         {
  154.             cellFsClose(fd);
  155.         }
  156.         else
  157.         {
  158.             cellMsgDialogClose(5.0);
  159.             SleepMM(500);
  160.             Dialog::msgdialog_mode = 2;
  161.             Dialog::Show("Key failed to Read!");
  162.             ExitThisShit();
  163.         }
  164.     }
  165.     else
  166.     {
  167.         cellMsgDialogClose(5.0);
  168.         SleepMM(500);
  169.         Dialog::msgdialog_mode = 2;
  170.         Dialog::Show("Key failed to load!");
  171.         ExitThisShit();
  172.     }
  173.     return;
  174. }
RAW Paste Data