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